Over the years Linux is being used as operating system in many intelligent and smart electronic devices starting from mobile phone, refrigerator to cow milking devices apart from desktops and server computers. Though Linux is open source, its often difficult for a beginner to get started. In this presentation embedded system and embedded Linux have been introduced through examples, animation and short explanation. This presentation is targeted to the absolute beginner or embedded software engineer who wants to be part of exciting world of Linux and the enthusiast or even manager who just wants to get idea about embedded Linux.
Over the years Linux is being used as operating system in many intelligent and smart electronic devices starting from mobile phone, refrigerator to cow milking devices apart from desktops and server computers. Though Linux is open source, its often difficult for a beginner to get started. In this presentation embedded system and embedded Linux have been introduced through examples, animation and short explanation. This presentation is targeted to the absolute beginner or embedded software engineer who wants to be part of exciting world of Linux and the enthusiast or even manager who just wants to get idea about embedded Linux.
Dos Manuales, uno para el Lider del Comité o Circulo de Seguridad y otro Manual para cada Participante. Ilustrados e interactivos contribuyen a motivar y a formalizar la tarea del Comité haciéndola mas productiva y creativa para generar soluciones participativas a los problemas de Seguridad del Trabajo en la empresa.
4. CH1: Introduction to Microprocessor/Microcontroller
และหลังจากนั้นไมโครคอนโทรเลอรก็มีการพัฒนาอยางตอเนื่องจนกระทั่งป 2523
บริษัทอินเทลก็ไดนําไมโครคอนโทรลเลอรตระกูล MCS-51 ออกสูทองตลาดซึ่งมี
ความสามารถมากกวาตระกูล MCS-48 และในตระกูล MCS-51 นี่เองก็ไดมีหลาย
บริษัทที่ไดนําเอาฐานของไมโครคอนโทรลเลอรตระกูลนี้ไปออกแบบเพิ่มอุปกรณ
บริการตางๆบนชิปเขาไปใหเหมาะสมกับการทํางานประเภทตางๆ เชนการเพิ่ม A/D
การเพิ่มจํานวนขาเพื่อเพิ่มจํานวนพอรต เปนตน
รูปที่1-2 รูปรางของ 8748
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
7
CH1: Introduction to Microprocessor/Microcontroller
ระบบคอมพิวเตอรเบื้องตน
Address Bus
CPU
Data Bus
Control Bus
I/O
ROM
RAM
รูปที่1-3โครงสรางระบบคอมพิวเตอร
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
8
4
5. CH1: Introduction to Microprocessor/Microcontroller
จากรูปที่1-3 เปนองคประกอบโดยทั่วไปของระบบคอมพิวเตอรโดยจากรูป
แสดงใหเห็นโครงสรางทางฮารดแวรแตสําหรับสวนที่เปนซอฟตแวรซึ่งทําหนา
ที่ควบคุมการทํางานของระบบทั้งหมดจะถูกเก็บใน ROM โดยคําสั่งใน ROM
จะถูกนําไปประมวลผลโดย CPU โดยคําสั่งใน ROM จะถูกสงผานบัสขอมูลไป
ยัง CPU สําหรับบัสในระบบคอมพิวเตอรโดยทั่วไปแลวก็แบงออกเปน 3 ชนิด
คือ
1. Data Bus
: ทางผานขอมูลระหวาง CPU และ I/O หรือ หนวยความจํา
2. Address Bus : แอดเดรสกําหนดตําแหนงของหนวยความจําหรือ I/O
3. Control Bus : สัญญาณควบคุมจาก CPU เพื่อควบคุมการติดตอกับอุปกรณ
ตางๆบนบัสไมวาจะเปน RAM / ROM หรือ I/O
และเพื่อใหเขาใจระบบมากขึ้นก็จะตองทําความเขาใจในการทํางานของ CPU ดวย
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
9
CH1: Introduction to Microprocessor/Microcontroller
Instruction Register
Instruction Decoder
and Control Unit
ALU
Accumulator
Register
Program Counter
Clock
Stack Pointer
รูปที่1-4 โครงสรางอยางงายของ CPU
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
10
5
6. CH1: Introduction to Microprocessor/Microcontroller
การทํางานของ CPU (Central Processing Unit)
ผังของตัวประมวลผลดังแสดงในรูปที่1-4 จะประกอบดวยสวนตางๆดังนี้
1. Register :
ใชในการเก็บขอมูลชั่วคราว(ไฟเลี้ยงหายขอมูลก็หาย)
2. ALU (Arithmetic and Logic Unit) :
เปนสวนคํานวณคณิตศาสตรและลอจิก
3. รีจิสเตอรคําสั่ง (Instruction Register):
เปนรีจิสเตอรเก็บรหัสคําสั่ง
4. สวนถอดรหัสคําสั่งและหนวยควบคุม(Instruction decoder and Control Unit)
ทําหนาที่แปลคําสั่งและสรางสัญญาณไปควบคุมการทํางานสวนตางๆใหไดผล
ตามคําสั่ง
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
11
CH1: Introduction to Microprocessor/Microcontroller
5. Program Counter (PC) ทําหนาที่เก็บตําแหนงของคําสั่งถัดไปที่จะถูกกระทํา
6. Accumulator เปนสวนของหนวยความจําใชในการคํานวณทางคณิตศาสตร
7. Stack Pointer (SP) เปนรีจิสเตอรเก็บตําแหนงของหนวยความจําซึ่งจะถูกใช
งานอยางอัตโนมัติเมื่อเกิดการเรียกใชโปรแกรมยอยคาของ Program Counter จะ
ถูกเก็บลงบนพื้นที่ของ Stack และ SP ก็จะเก็บตําแหนงที่เก็บคา PC เมื่อครูนี้ ซึ่ง
จะกล า วถึ ง เรื่ อ ง Stack อี ก ครั้ ง ในตอนที่ ก ล า วถึ ง รี จิ ส เตอร ต า งๆของ
ไมโครคอนโทรลเลอรที่เราจะศึกษากันตอไป
8. Clock สวนสรางสัญญาณนาฬิกาซึ่งเปนการใหจังหวะในการทํางานของสวน
ตางๆภายใน CPU
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
12
6
7. CH1: Introduction to Microprocessor/Microcontroller
สําหรับการทํางานของ CPU นั้นอาจแบงออกเปนขั้นตอนคือ
1.การ Fetch คําสั่ง (Fetch Instruction)
เปนขั้นตอนที่หนวยควบคุม (Control Unit) อานคําสั่งจากหนวยความจําแลวทําการ
ถอดรหัสคําสั่งนั้น โดยการทํางานเริ่มจาก
-ตําแหนงคําสั่งที่เก็บใน Program Counterรีจิสเตอรจะถูกสงมาที่ Address Bus
-สัญญาณควบคุมการอาน(Read) จะทํางานเพื่อทําใหเกิดการอานขอมูลในหนวยความจํา
-คําสั่งที่เปนขอมูลจากหนวยความจําถูกสงมาบน Data Bus
-คําสั่งที่ถูกสงมาบน Data bus จะถูกเก็บไวในรีจิสเตอรคําสั่ง (IR) ของ CPU
-และคาตําแหนงใน Program Counter รีจิเสอตรก็จะถูกเพิ่มขึ้นเพื่อทําการ Fetch คําสั่งถัดไป
2.การกระทําตามคําสั่ง (Execute Instruction) เปนขั้นตอนตั้งแต CPU กระทําตาม
คําสั่งที่ Fetch มาจนแลวเสร็จคําสั่งนั้นๆซึ่งในขั้นตอนนี้อาจจะมีขั้นตอนอื่นๆรวมอยูเพราะ
ขึ้นกับวาคําสั่งนั้นใหทําอะไรบาง
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
13
CH1: Introduction to Microprocessor/Microcontroller
ดังนั้นอาจเขียนขั้นตอนการทํางานของ CPU ดังรูปตอไปนี้
Fetch
1 รอบคําสั่ง
(Machine Cycle)
Execute
Fetch
คําสั่งถัดไป
รูปที่1-5 ขั้นตอนการทํางานของ CPU
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
14
7
8. CH1: Introduction to Microprocessor/Microcontroller
อยางที่กลาวมาแลววาไมโครคอนโทรลเลอรนั้นถูกออกแบบมาสําหรับงานดาน
ควบคุมโดยเฉพาะไมวาจะอยูในเครื่องใชตางๆ,ระบบควบคุมในรถยนตสวนประ
กอบของคอมพิวเตอรเชนมีใน Hard disk โมเด็ม เมาส คียบอรดดังนั้นก็ตองการให
อุปกรณอื่นๆที่มีอยูภายนอกมีนอยที่สุดดังนั้นโครงสรางของไมโครคอนโทรลเลอร
ก็จะเปนการรวมเอา Peripheral ตางๆมาอยูบนไมโครคอนโทรลเลอรและนอกจาก
นั้นยังมีสวนที่จัดการเกี่ยวกับอินเตอรรัพทอยูบนไมโครคอนโทรลเลอรอีกดวยดัง
แสดงในรูปที่1-6 ซึ่งในรูปเปนเพียงตัวอยางเทานั้นเพราะไมโครคอนโทรลเลอร
แต ล ะตั ว ก็ จ ะมี อุ ป กรณ ต า งๆบนชิ ป ที่ แ ตกต า งกั น ไปตามวั ต ถุ ป ระสงค ข องการ
ออกแบบ
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
15
CH1: Introduction to Microprocessor/Microcontroller
Timer
CPU
Interrupt
Control
Serial
Port
Internal Bus
RAM
ROM
Parallel
Port
รูปที่1-6 ตัวอยางโครงสรางของไมโครคอนโทรเลอร
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
16
8
9. CH1: Introduction to Microprocessor/Microcontroller
ตัวอยางการใชงานไมโครคอนโทรลเลอร
รูปที่1-7 ไมโครคอนโทรลเลอรในมิเตอรวัดการใชพลังงานไฟฟา
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
17
CH1: Introduction to Microprocessor/Microcontroller
รูปที่1-8 มิเตอรวัดกําลังไฟฟาที่ควบคุมดวยไมโครคอนโทรลเลอร
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
18
9
10. CH1: Introduction to Microprocessor/Microcontroller
ไมโครคอนโทรลเลอร
ไมโครคอนโทรลเลอร
รูปที่1-9 ไมโครคอนโทรลเลอรกับการเก็บขอมูลการใชไฟฟาในหางสรรพสินคา
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
19
CH1: Introduction to Microprocessor/Microcontroller
89C51RD2
รูปที่1-10 รูปรางของบอรดควบคุมสําหรับการนับการใชไฟฟา
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
20
10
11. CH1: Introduction to Microprocessor/Microcontroller
รูปที่1-11 ตนแบบ 3 เฟส Power meter ที่ควบคุมดวย 89C51RD2
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
21
CH1: Introduction to Microprocessor/Microcontroller
รูปที่1-12 ตัวอยางการใชไมโครคอนโทรเลอรในงานควบคุมอุณหภูมิ
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
22
11
12. CH1: Introduction to Microprocessor/Microcontroller
รูปที่1-13 ไดอะแกรมของบอรดไมโครคอนโทรเลอรในรูปที่1-12
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
23
CH1: Introduction to Microprocessor/Microcontroller
รูปที่1-14 ตนแบบของบอรดไมโครคอนโทรเลอรในรูปที่1-13
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
24
12
13. CH1: Introduction to Microprocessor/Microcontroller
Basic Digital Circuit
Inverter : 74LS04
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
25
CH1: Introduction to Microprocessor/Microcontroller
ในการใช Gate ขับอุปกรณภายนอกตองคํานึงถึงความสามารถในการจายกระแส
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
26
13
14. CH1: Introduction to Microprocessor/Microcontroller
AND gate : 74LS08
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
27
ดิจิตอลเกตในแบบที่เอาตพุตเปน Open Collector จะเหมาะสมกับการเชื่อมตอ
ระหวางวงจรที่แรงดันไมเทากันเชนจาด TTL ไปขับวงจรขับรีเลยเปนตน
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
28
14
15. วงจรสมมูลแบบ Open Collector และคุณสมบัติ 74LS07
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
29
CH1: Introduction to Microprocessor/Microcontroller
Decoder Circuit with 74LS138
Decoder จะใชสําหรับในการ Decode สัญญาณแอดเดรสเพื่ออางหนวยความจํา
Microprocessor by pisit wisutmetheekorn psw1999@yahoo.com
30
15