MicroLabPDF
MicroLabPDF
MicroProcessor Lab
What is required is: to write an assembly code to read the state of switches (K1 -
K8) of the MML8086K3 trainer board. Then, display the read pattern to the LEDs
(L1 - L8) by using 8255A adapter.
. ثم نضوي الضو اللي مقابل إلها، بدنا نشوف مين الكبسة المكبوسة
PORT A can be set for Modes 0, 1, 2. PORT B for 0, 1 and PORT C for mode 0 and
BSR (Bit Set/Reset).
Port C was divided into two parts: PC upper (PCU) ⇒ PC7 - PC4 and PC lower
(PCL) ⇒ PC3 - PC0.
In addition to these three ports, there is a control word register CWR, and all the
registers each have an address, as in the following image:
1
Port Address
Register Address
PORT A 0FF28H
PORT B 0FF29H
PORT C 0FF2AH
To write the code, you must first write to the control word register using the Out
instructions: CWRالزم نفعل ال
Reminder :
Out DX,AL (write)
DX contain the port address
and AL contain what you need to write to this port
In Al,Dx (Read)
D7 D6 D5 D4 D3 D2 D1 D0
2
Steps to write code:
1. write to CWR
2. read buttons from PB
3. write to PA (Leds)
================================================================
3
Gate0 == Enable ⇒ +5V
Clk0 ⇒ 1MZ
Key Features:
2. 16-bit Counters: Each counter is 16 bits wide, allowing for timing delays from
microseconds to seconds, depending on the clock input frequency, frequency
range of 0 - 2 MHz.
4
5. Clock Input & Gate Control: Each counter has a clock input and a gate
input, allowing external signals to control the counting process.
Selects Address
Counter 0 0040H
Counter 1 0041H
Counter 2 0042H
The idea is : to write to CWR, then write to a specific counter using the address.
mode بدنا نكتب عليه ونختار الcounter عشان نحدد أيCWR أول اشي رح نكتب على
Ok, What should we write on CWR?
Let's see this picture!
5
Let's start with the first part:
What is required is: Initialize counter 0 in mode 3 (square wave) with a frequency of
10kHz. Assume input frequency is 1MHz.
Before that, we must show the value that we write on the counter 0. . .
input frequency is 1MHz and the frequency for square wave 10kHz
1*10^6 / 10*10^3 = 100 , so the value on counter0 must be 100
mov dx,40h ;the address of counter0
mov al,100 ;Quotient
out dx,al
6
And The output ⇒
Part 2:
Initialize counter 0 in mode 2 (Rate generator) with a period of 100µs. Assume input
frequency is 1MHz
period = 100 * 10^(-6) ⇒ frequency = 1/ period ⇒ frequency=10 kHz
same as part 1 ⇒ 1 MHz / 10 kHz = 100
but mode 2 (Rate generator) ⇒ D3=0 , D2=1 and D1=0
7
⇒ And The output
================================================================
لِيمسح الدمع من عينيك إن نزال ️♥ ُيؤتي َك من لُطفه ما لست تعرف ُه
إ ّياك يا صاحبي أن تق ُتل األمال ️♥ هللاُ أكر ُم من ُيعطي على ٍ
قدر
8
Exp 3:A musical electronic Organ
In this experiment, we will read the push buttons (connected on port A in the 8255) to
determine which one is pressed, then based on the pressed push button, there is a
different frequency value for each push button, then based on the frequency value
we write on the counter 1 in the 8253.
بناء،) لتحديد أي الكبسات مضغوط عليها8255 فيport A في هذه التجربة سنقوم بقراءة الكبسات (مشبوكات على
.8253 في1 ثم بناء على قيمة التردد نكتب على العداد،على الكبسة المضغوطة يوجد قيمة تردد مختلفة لكل كبسة
NOTE:
يعني فعلنا الكاونتر وبس نكتب1 لما نكتب عليهenable (gate( َكport B رح نستخدم البت األول في
. يعني ألغينا تفعيله0
Audio Amplifier: An audio amplifier is an electronic device that increases the strength
(amplitude) of audio signals that pass through it. An audio amplifier amplifies
low-power audio signals to a level which is suitable for driving loudspeakers.
9
push 1 2 3 4 5 6 7
button
10
أول اشي بنكون ملغيين تفعيل الكاونتر يعني معطيين االينيبل ( 0بورت ، )Bثم بس نقرأ الكبسة بنروح بنفعل الكاونتر
من خالل البروسيجر turnOnOrgan
NOTE: There is a slight difference in the way the procedure is written in the lab, as
follows:
11
Exp 4: 8279 Keyboard / Display Interface
Objectives:
1. To know the basic principle of 8279 and microcomputer interface.
2. Use 8279 to interface the six 7-segment display array.
3. Use 8279 to interface the 4x4 matrix keyboard.
It can handle both 7-segment displays and matrix keyboards, which makes it ideal for
systems where both input and output are essential, like calculators or user interface systems
in embedded hardware.
12
● CN/ST: Control/strobe, connected to the control key on the keyboard.
● CS (Chip Select): Used to activate the chip. When low, the chip is enabled to
communicate with the processor.
● DB7-DB0: Consists of bidirectional pins that connect to the data bus on micro.
● IRQ: Interrupt request, becomes 1 when a key is pressed, data is available.
● OUT A3-A0/B3-B0: Outputs that send data to the most significant/least significant
nibble of display.
● RD (Read): Used to read data from the chip.
● WR (Write): Used to write data to the chip.
● RESET: Used to reset the chip, returning it to its initial state.
● RL7-RL0: Return lines are inputs used to sense key depression in the keyboard
matrix.
● Shift: Shift connects to Shift key on keyboard.
● SL3-SL0: Scan line outputs scan both the keyboard and displays.
.ً معاkeyboard وseg display-7 بنستخدمها عشان نتحكم في8279 باختصار هاي القطعة
بينما في البارت الثاني رح نقرأ أي كبسة، seg-7 في البارت األول رح نستخدمها حتى نظهر رمز معين على
. seg-7 ثم بنا ًء على هاي الكبسة رح نظهر الرمز تبعها على، مكبوسة من الكيبورد
، address => FF81 كيف هذول رح نعملهم ؟ الزم نبعث داتا معينة على ال، اوك
اوك ايش هي الداتا اللي رح نبعثها؟، ) FF81 => control / FF80 => Data (
: بنا ًء على ايش من هذول األوامر رح أعملMost significant bits 3 في البداية الزم نحدد آخر
D7 D6 D5 D4 D3 D2 D1 D0
The command word format is 8 bit, the three most significant bits selects the various
operations which are given as:
13
010 Read FIFO / Sensor RAM
110 Clear
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 D D K K K
DD represents the display mode and KKK represents the keyboard mode.
سيستجيب فقط ألول مفتاح تم الضغط عليه ويهمل8279 فإن،يعني أنه إذا تم الضغط على مفتاحين في نفس الوقت
.الثاني
Code =>
Program Clock:
The different keys of the keyboard are scanned one by one in a sequence to detect a key
press by the 8279; and also key de-bouncing is implemented by this device. All these
functions require the timing signal. The 8279, therefore, needs an internal clock. The
frequency of this clock should be around 100 KHz.
D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 P P P P P
14
زي بالتجربة اللي قبل بنقسم، ً تقريبا55KH ألنه بدنا الفريكونسي تكون18 لي، P => 18 رح نحط في ال
.18 ً بيطلع الجواب تقريبا1MHz / 55 KHz
Code =>
Clear:
D7 D6 D5 D4 D3 D2 D1 D0
1 1 0 CD CD CD CF CA
The bits D7 D6 D5 represent command word 6 (1 1 0). CA Clears All (it clears both display
RAM and FIFO). CF Clears FIFO Status and resets the IRQ line. CDCDCD Clears all rows
of the display RAM to a selectable blanking code.
Code =>
>>>>>>>>>>>>>>>>>>>> إيش النيكست سيب؟ هسا هيك بتكون القطعة هاي جاهزة لحتى نستخدمها
15
seg-7 أول مطلوب في هذا البارت أنه نطبع رمز معين على
: رح نفعلها من خالل األمر التالي، seg-7 )6( اللي بدي أظهر عليها ألنه عناseg-7 أول اشي الزم نفعل الـ
To display information, the seven segment data is to be written in the internal display buffer.
To enable writing seven segment data into the display buffer, the write display RAM
command has to be written into the command word register. The command word for the
same is as shown:
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 A1 A A A A
: التاليformat ؟ حسب الـseg-7 ضايل شغلة وحدة وهي كيف رح نمثل هذا الرمز المعين على
D7 D6 D5 D4 D3 D2 D1 D0
d c b a dp g f e
.1 واللي بدي أطفيه بعطيه0 يعني الضو اللي بدي أضويه بعطيه، common anode مع االنتباه أنهم
FF80 وكل رمز بنبعثه على عنوانGP. 2 الرمز اللي رح نظهره
d c b a dp g f e
0 0 1 0 1 0 0 0 G
1 1 0 0 0 0 0 0 P.
0 1 0 0 1 0 1 0 2
16
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
0 0 0 0 0 1 1 0 0 0C
1 1 0 0 1 1 1 1 1 9F
2 0 1 0 0 1 0 1 0 4A
17
3 0 0 0 0 1 0 1 1 0B
4 1 0 0 1 1 0 0 1 99
5 0 0 1 0 1 0 0 1 29
6 0 0 1 0 1 0 0 0 28
7 1 0 0 0 1 1 1 1 8F
8 0 0 0 0 1 0 0 0 08
9 0 0 0 0 1 0 0 1 09
18
PART TWO: Display Section
في هذا البارت بدل ما أنا أعطى 8279رمز معين تظهره على ، seg-7رح أقرأ من الكيبورد كبسة معينة ثم بنا ًء
عليها بظهر الرمز تبعها.
كل كبسة إلها رقم عمود ورقم صف ،مرتبين في هذا الجدول:
بنقرأ من عنوان FF80قيمة ،هاي القيمة بتكون بتحتوي على رقم الصف ورقم العمود لهاي الكبسة ،فإذا كان رقم
الصف 5ورقم العمود 1يعني الكبسة Eمكبوسة وهكذا.
19
CNTL SHIFT D5 D4 D3 D2 D1 D0
________ ROW _________ _______ COLUMN _______
CNTL SHIFT D5 D4 D3 D2 D1 D0
0 0 0 0 0 1 0 0 1 09H
1 0 0 0 0 0 0 0 1 01H
2 0 0 0 1 0 0 0 1 11H
3 0 0 1 0 0 0 0 1 21H
4 0 0 0 0 1 0 0 0 08H
5 0 0 0 1 1 0 0 0 18H
6 0 0 1 0 1 0 0 0 28H
7 0 0 0 0 0 0 0 0 00H
8 0 0 0 1 0 0 0 0 10H
9 0 0 1 0 0 0 0 0 20H
A 0 0 1 1 0 0 0 0 30H
B 0 0 1 1 1 0 0 0 38H
C 0 0 1 1 0 0 0 1 31H
D 0 0 1 1 1 0 0 1 39H
E 0 0 1 0 1 0 0 1 29H
F 0 0 0 1 1 0 0 1 19H
. seg-7 الثانية رح نخزن فيها القيمة تبعتها اللي رح أظهرها بالarray و ال
d c b a dp g f e
0 0 0 0 0 1 1 0 0 0C
1 1 0 0 1 1 1 1 1 9F
20
2 0 1 0 0 1 0 1 0 4A
3 0 0 0 0 1 0 1 1 0B
4 1 0 0 1 1 0 0 1 99
5 0 0 1 0 1 0 0 1 29
6 0 0 1 0 1 0 0 0 28
7 1 0 0 0 1 1 1 1 8F
8 0 0 0 0 1 0 0 0 08
9 0 0 0 0 1 0 0 1 09
A 1 0 0 0 1 0 0 0 88
B 0 0 0 0 1 0 0 0 08
C 0 1 1 0 1 1 0 0 6C
D 0 0 0 0 1 1 0 0 0C
E 0 1 1 0 1 0 0 0 68
F 1 1 1 0 1 0 0 0 E8
نوخذ مثال عشان نفهم ؟ مثالً أنا كبست على الكبسة Aكيف حيتنفذ الكود ؟
أول اشي بحط مؤشر على بداية ال arrayاألولى diومؤشر آخر على بداية ال arrayالثانية si
بقرأ قيمة من FF80هاي القيمة حتكون 30Hألني كابسة على A
بقارنها مع اللي بأشر عليه diبكون على بداية ال arrayبالتالي مش نفس الكبسة اللي كابسة عليها
بروح بزيد قيمة diوكمان بزيد قيمة siألني بدي كل كبسة مع الرمز تبعها اللي بقابلها ،ثم برد بقارن القيمة اللي
بأشر عليها diمع القيمة اللي قرأتها
وهكذا بضل أزيد في المؤشرين لحتى تتساوى القيمة اللي بأشر عليها diمع القيمة اللي قرأتها
وقتها إيش بعمل ؟ بظهر القيمة اللي بأشر عليها siعلى ال ،seg-7وانتهى !
21
================================================================
22
Exp 5: ADC0809 analog-to-digital conversion
1. Analog Inputs (IN0-IN7): The ADC0809 has 8 analog input channels (IN0 to IN7),
which allow it to select one of the 8 analog input signals for conversion. In our circuit,
the channels are connected to potential analog sources.
2. Multiplexer: The built-in 8-channel multiplexer allows selecting one of the 8 input
channels (IN0 to IN7) for analog-to-digital conversion. This selection is done using
the address lines ADD-A, ADD-B, and ADD-C.
3. Reference Voltage (ref(-), ref(+)): The reference voltage pins (ref(-) and ref(+))
are used to define the range of the input voltage for conversion. The input voltage
should be within the range of these reference voltages to get accurate digital
conversion.
4. Digital Output (D0-D7): The output of the conversion is an 8-bit digital value. The
least significant bit (LSB) is D0, and the most significant bit (MSB) is D7. These bits
represent the digital equivalent of the analog input signal.
23
5. Control Signals:
○ START: Starts the analog-to-digital conversion process.
○ ALE (Address Latch Enable): Used to latch the input address into the
multiplexer.
○ EOC (End of Conversion): This signal goes high to indicate the end of
conversion.
○ OE (Output Enable): Controls when the digital output is placed on the output
bus.
○ CLOCK: A clock signal is required to control the timing of the conversion.
6. Logic Gates (74LS02): The 74LS02 chip in the circuit contains NOR gates, which
are used here to control the enabling of the ADC and its operations based on the
clock and other control signals (such as read (RD) and write (WR)).
What is required is: Use the ADC to convert an analog value (potentiometer) to
digital value, then re-convert it into analog value in order to display it on the
seven-segment displays.
𝑛
𝐷𝑖𝑔𝑖𝑡𝑎𝑙 = (𝑎𝑛𝑎𝑙𝑜𝑔 * 2 )/𝑉𝑐𝑐
8
𝐷𝑖𝑔𝑖𝑡𝑎𝑙 = (𝑎𝑛𝑎𝑙𝑜𝑔 * 2 )/5 ==> 𝐷𝑖𝑔𝑖𝑡𝑎𝑙 = 𝑎𝑛𝑎𝑙𝑜𝑔 * 51
How to convert the digital output of the ADC to analog, in order to display it on
the seven-segment displays?
𝑛
𝑎𝑛𝑎𝑙𝑜𝑔 = (𝐷𝑖𝑔𝑖𝑡𝑎𝑙 * 𝑉𝑐𝑐)/2
8
𝑎𝑛𝑎𝑙𝑜𝑔 = (𝐷𝑖𝑔𝑖𝑡𝑎𝑙 * 5)/2 ==> 𝑎𝑛𝑎𝑙𝑜𝑔 = 𝐷𝑖𝑔𝑖𝑡𝑎𝑙 / 51
24
How to get the ones digit and the fraction digits?
Use one port for the data, and another port to select the seven-segment display, in
our experiment we used port A for the data and port B for the selection process.
We will create 2 arrays, one for the ones digit -dp is ON, the other is for the fraction
-dp is OFF.
ones :
num dp g f e d c b a Hex
0 0 1 0 0 0 0 0 0 40H
1 0 1 1 1 1 0 0 1 79H
2 0 0 1 0 0 1 0 0 24H
3 0 0 1 1 0 0 0 0 30H
4 0 0 0 1 1 0 0 1 19H
5 0 0 0 1 0 0 1 0 12H
6 0 0 0 0 0 0 1 0 02H
7 0 1 1 1 1 0 0 0 78H
8 0 0 0 0 0 0 0 0 00H
9 0 0 0 1 1 0 0 0 18H
25
fractions:
num dp g f e d c b a Hex
0 1 1 0 0 0 0 0 0 C0H
1 1 1 1 1 1 0 0 1 F9H
2 1 0 1 0 0 1 0 0 A4H
3 1 0 1 1 0 0 0 0 B0H
4 1 0 0 1 1 0 0 1 99H
5 1 0 0 1 0 0 1 0 92H
6 1 0 0 0 0 0 1 0 82H
7 1 1 1 1 1 0 0 0 F8H
8 1 0 0 0 0 0 0 0 80H
9 1 0 0 1 1 0 0 0 98H
اللي رح نعمله بالكود نقرأ قيمة من ال ، ADCالقيمة هاي حتكون ، digitalألنه زي ما حكينا ال
ADCبوخد Analog inputوبط ّلع .digital output
ثم بعد ما قرأنا قيمة من ال ADCالمطلوب مننا نحول هاي القيمة ل analogحسب المعادالت السابقة ،
ثم نظهر هاي القيمة ( ) analogعلى .seg-7
ال adcمشبوك مع ، address FF80 Hأول خطوة نكتب على هذا العنوان 0عشان ن ّفعل ال ،adcثم
بنعمل delayوبنقرأ قيمة من هذا العنوان هاي القيمة Digital
26
على فرض أنا مدخلة لل Adcقيمة ، analog = 2.5بالتالي القيمة اللي حنقرأها من ال adc = 128
بتكون مخزنة في ، Alمهمتي هسا أحول هاي القيمة ل analogيعني أرد أرجعها ل 2.5من خالل
المعادالت.
بنقسم القيمة اللي قرأتها ( )128على >= 51ناتج القسمة بتخزن في ، al = 2وباقي القسمة بتخزن في
ah = 26
رح نظهر أول اشي على seg-7ناتج القسمة وهو ( 2بنبعث هاي القيمة للعداد cx = 2وبنمشي في
loopوبنضل نزيد في مؤشر ال arrayحتى يوصل عند كود ) 2
ثم بنفعل ال seg-7اللي بدي اياها من خالل الكتابة على address ff29الخاص في بورت B
ثم بنكتب على address ff28الخاص في بورت : Aالقيمة الي بأشر عليها المؤشر حاليا ً وهي كود 2
وهيك بكون أظهرت العدد الصحيح على ال ،Seg-7ضل اللي بعد الفاصلة >>>>>>>>>>>>>>>>>>>
بنضرب باقي القسمة في >= 10بصير ، 260ثم بنقسمه على ، 51بنشوف ناتج القسمة إيش هو ألنه هو
اللي بهمني حاليا ً ألنه أنا بدي بس أول عدد بعد الفاصلة العشرية ،بتخزن ناتج القسمة في al = 5
ثم عشان نظهره على seg-2نفس الفكرة ( بنبعث هاي القيمة للعداد cx = 5وبنمشي في loopوبنضل
نزيد في مؤشر ال arrayحتى يوصل عند كود ) 5
ثم بنفعل ال seg-7اللي بدي اياها من خالل الكتابة على address ff29الخاص في بورت B
ثم بنكتب على address ff28الخاص في بورت : Aالقيمة الي بأشر عليها المؤشر حاليا ً وهي كود 5
وهيك بكون أظهرت العدد العشري على ال Seg-7
27
NOTE: we added delay after each display; to display different values on different
seven-segment displays at the same time.
================================================================
28
Exp 6: DAC0832 digital-to-analog conversion
Objectives:
1. Understanding of the basic principles of digital/analog conversion, and master
the use of DAC0832 chips.
2. To know the application of DAC0832.
In this lab, we will use the DAC0832 to create a simple function generator
(square, and sine waves).
29
PART ONE: SQUARE WAVE
30
PART TWO: SINE WAVE
بنعوض ابتدا ًء من الصفر وبنصير نزيد، بنا ًء على هاي المعادلةdigital قيمDAC يعني رح ندخل على
قيمة36 واحد واحد لحتى نوصل
31
Exp 7: LED 16x16 Dot Matrix Display
The LED 16x16 dot matrix display is made up of 256 LEDs arranged in 16 rows and
16 columns. It operates using a common-cathode configuration, meaning all LED
cathodes are connected in columns and all anodes in rows. By controlling the rows
and columns, each LED can be turned on or off individually, allowing for the display
of text, images, and animations.
To control the display, you activate specific rows and columns to light up certain
LEDs. For example, pulling a row high and a column low will turn on the LED at the
intersection. This setup minimizes the number of pins required to control all LEDs
(32 pins in total).
Rows are active-high, but columns are active-low.
The display is refreshed quickly by scanning through rows and columns, creating an
illusion of continuous images or animations.
The image shows an example of the circuit where different rows and columns are
connected to a microprocessor to control the display.
Our experiment uses two 8x8 dot matrix displays as 16x8 displays, which means
they have eight rows and sixteen columns. The matrix is connected to the 8255 IC.
Columns have two ports and rows have one port.
32
PART ONE: Display a one number from:
R D
0 0 0 1 1 0 0 0 1 )(7
0 0 1 0 0 0 0 0 2 )(6
0 1 0 0 0 0 0 0 3 )(5
0 1 1 1 1 0 0 0 4 )(4
0 1 0 0 0 1 0 0 5 )(3
0 1 0 0 0 1 0 0 6 )(2
0 0 1 1 1 0 0 0 7 )(1
0 0 0 0 0 0 0 0 8 )(0
اعملنا Arrays 2وحدة للصفوف ووحدة لألعمدة ،بنمشي على مصفوفة األعمدة وبنفعل عمود عمود بكل
لفة ،وبنمشي على مصفوفة الصفوف حسب الضو اللي بدنا نضويه بنبعث القيمة.
يعني مثالً بأول لفة بفعل العمود األول كله بس الضواو اللي رح يضووا حسب شو فعلت من الصفوف فما رح
يضوي اشي ،ثاني لفة رح يضوي من العمود الثاني الصف الثالث والرابع والخامس والسادس وهكذا.
احنا بنمشي عمود عمود بس بسبب السرعة رح يبين كأنه ضووا كلهم بنفس الوقت.
33
PART TWO: Basic animation on 8x16 LED matrix
المطلوب في هذا البارت هو كتابة برنامج يقوم بعرض حركة بسيطة على شاشة LED 8x16
العملية المطلوبة هي تشغيل عمود واحد فقط من األعمدة الـ 16بشكل متتابع بدءاً من العمود األول ( )C1حتى العمود
األخير ( ،)C16ثم العودة بالعكس إلى العمود األول مرة أخرى.
الكود ممكن ينكتب بطريقتين :األول عمل مصفوفة لألعمدة (تفعيل عمود عمود) والثانية استخدام أمر ROL
34
Exp 8: Controlling a DC Motor
The purpose of this experiment is to examine the operation of a DC motor to learn its
basic wiring connections and how to control its speed by using DAC.
توضح الصورة التالية دائرة تشغيل محرك DCعلى لوحة .MML8086K3يتم تضخيم اإلشارة الناتجة من
ال DACللتحكم في المحرك .يستقبل ال DACرقما ً بين 0و 255من المعالج الدقيق للتحكم في سرعة المحرك.
DC MOTOR:
هو جهاز يحول الطاقة الكهربائية إلى طاقة حركية ،يعمل المحرك عن طريق توليد مجال مغناطيسي يتفاعل مع الملفات
الداخلية ،مما يؤدي إلى دوران العمود المتصل بالمحرك .يمكن التحكم في سرعة المحرك بسهولة عن طريق تغيير
الجهد أو التيار الذي يتم تزويده به.
ُتستخدم محركات الـ DCفي العديد من التطبيقات مثل األجهزة المنزلية ،الروبوتات ،والمركبات الكهربائية ،نظراً
لقدرتها على توفير عزم دوران ثابت وسهولة التحكم في سرعتها.
35
We are using a DAC0832 to drive the motor and contour; its speed. The push
buttons will increase and decrease the speed of the motor by 10 each time
Values below 0 or above 255 will be ignored
36
Exp 9: Controller a Stepper Motor
Stepper motors are DC motors that move in discrete steps. They have multiple coils
that are organized in groups called "phases". By energizing each phase in sequence,
the motor will rotate, one step at a time. By controlling the stepping of the motor, you
can achieve very precise positioning and/or motor speed. For this reason, stepper
motors are the motor of choice for many precision moon control applications.
Unipolar Bipolar
37
Operating Modes:
1. full step (on one-phase): the motor is operated with only one phase energized at
a me. This mode requires the least amount of power from the driver of any of the
other modes. ()بفعل ملف وبعطل الباقي
:بالكود
D7 D6 D5 D4 D3 D2 D1 D0
first step ⇒ 0 0 0 1 0 0 0 1
second step ⇒ 0 0 1 0 0 0 1 0
وماRotate بس عشان تزبط عملية الbits 4 اللي بلزمونا بس، rotate وهكذا بنضل نعمل
.bits 4 ألصفار كررنا قيمة الـrotate يصير يعمل
2. Half step: it is a combination of one phase on and two phase on full step modes.
This results in half the basic step angle. This smaller step angle provides smoother
operation due to the increased resolution of the angle.
:بالكود
D7 D6 D5 D4 D3 D2 D1 D0
first step ⇒ 0 0 0 0 0 0 0 1
second step ⇒ 0 0 0 0 0 0 1 1
third step ⇒ 0 0 0 0 0 0 1 0
and so on ….
38
Stepper motor FF28H (port A)
39
PART TWO: Use two push buttons to control the rotation of the stepper
motor.
When btn1 is pressed, the motor rotates in a clockwise direction continuously,
and btn2 rotates the motor in a counterclockwise direction.
40
PART THREE: Update Task 2 by rotating left the stepper motor a single
rotation (360°) whenever a first button is pressed and rotating right the
stepper motor a half rotation (180°) whenever a second button is
pressed.
41
Exp 10: Graphical 128x64 Dot Matrix LCD
The Graphical LCDs are thus used to display customized characters and images.
The LCD used in this lab has 128×64 dots and has a yellow-green color backlight.
The 128x64 LCD is divided into two equal halves with each half being controlled by a
separate controller, and the whole LCD is divided equally into 8 pages. Each page
consists of 8 rows and 64 columns. So two horizontal pages make 128 (64×2)
columns and 8 vertical pages make 64 rows (8×8). The paging scheme of the
graphical LCD can be easily understood from the following table:
42
يتم توصيل الـ LCDمع ، 8255يتم استخدام ports 2
port A (FF28H) ⇒ DATA
port C (FF2AH) ⇒ CONTROL
:)RW) Read/Write
:)E) Enable
CS1و : CS2
Chip Select 2).و (Chip Select 1
:)RST) Reset
43
ِ الخاصGroup byte B رح نستخدم في هاي التجربة
:8255 ب
port C معين فيbit لreset أوset بمكننا نعمل
D7 D6 D5 D4 D3 D2 D1 D0
0 X X X
BSR DON’T CARE PORT C BIT SELECT 1 = SET
MODE 0 = RESET
EXAMPLES:
1. To set bit PC0, you write the following value to the control register (not Port
C): 0000 0001B
Mov dx,0ff2bh ; address of cwr
Mov al,00000001b
Out dx,al
2. To reset bit PC7, you write the following value to the control register (not Port
C): 0000 1110B
Mov dx,0ff2bh ; address of cwr
Mov al,00001110b
Out dx,al
44
The basic operation with a graphical LCD requires the following steps:
1. LCD Initialization (send the command “Display ON”)
Refer to the Instruction List, data appears when DB0 is set to 1 and
disappears when DB0 is 0. When the display is off, there is no effect on the
data which is stored in DDRAM.
a. Activate both halves of the display (CS1 = 1, CS2 = 1)
b. Specify the value of the Display ON/OFF command.
c. Use the SendCommand procedure to write the command to the
instruction register of the LCD.
D0 = 0 => OFF / D0 = 1 => ON بنفعله كيف؟ حسب الجدول إذا كان، left half بنختار
Instruction RS R/W D7 D6 D5 D4 D3 D2 D1 D0
ON / OFF L L L L H H H H H L/H
45
أوSET عشان نعمل لهم، PC2 مشبوك معE وPC1 مشبوك معR/W وPC0 مشبوك معRS بنالحظ أنه
.PORT C 8255 ب ِ الخاصBRS MODE حسب الخطوات السابقة بنستخدمRESET
PCTL is The address of CWR 8255
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
46
>> SetCursor Procedure (select page and column numbers):
Use the (sendCommand) procedure to send the following values:
1. Select the column address (Y address). You can choose any value from
column 0 to 63. The address starts at 0x40 to address 0x7F (from the list
below).
Instruction RS R/W D7 D6 D5 D4 D3 D2 D1 D0
2. Select the page address (X address) You can choose any value from page 0
to 7. The address starts at 0xB8 to address 0xBF (from the list below).
Instruction RS R/W D7 D6 D5 D4 D3 D2 D1 D0
3. Select the row address (Z address). Usually, this address is kept in the first
row. The address is 0xC0 (from the list below)
Instruction RS R/W D7 D6 D5 D4 D3 D2 D1 D0
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
3. Data Display.
Instruction RS R/W D7 D6 D5 D4 D3 D2 D1 D0
47
● The block of data to be displayed should be prepared in a form of array. You
can find a proposed encoding of characters in an attached file. Each block is
designed as 7x8 pixels (7 columns by 8 rows).
● To print a block to the display, you have to loop through all the bytes of the
block and send them to display via the SendData procedure. Note that it is not
necessary to increment the Y address (column address) after displaying each
byte since it is done automatically.
48
================================================================
PART 1:
Print a single character (A) at the left-top side of the LCD (left half, first column, first
page).
49
50
51
PART 2:
Print (Hello) starting at the same previous position (refer to charMapping file to
retrieve character code.
لكل حرفarray نفس الكود السابق بس الفرق أنه رح نعمل
52
PART 3: Clear the GLCD
53
Exp 11: Memory Read/Write
Objectives:
● To know the application of static RAM
● To master the R/W data programming method of static RAM
NOTES:
◄ SIZE OF RAM : 64 K
◄ ADDRESS RANGE : 00000H - 0FFFFH
◄ Static RAM (or SRAM) is a type of random-access memory (RAM) that uses
latching circuitry (flip-flop) to store each bit.
◄ SRAM is volatile memory; data is lost when power is removed.
The difference between SRAM and DRAM: ()فيهم زيادة عن المانيوال ما بعرف إذا كلهم مطلوبين
Experiment Procedure:
1. Memory Write:
54
Reminder 3:
No immediate to segment moves, so mov DS,0 X
Solution: mov AX,0
mov DS,AX
Reminder 4:
starting address (DS, CS, ES, SS( )1 : عشان أوصل ِإلشي بالميموري بلزمني أحدد
offset (2
Reminder 5:
To calculate the physical address : (Starting * 10H) + offset
2. Memory Read:
★ Control the speed of the DC motor by using the byte values from the
SRAM (stored in step 1), where the byte at address 100h represents
the first speed and so on.
★ Use 4 push buttons to control the speed of the DC motor (BTN0 for the
first speed, and so on).
★ Assume that the push buttons are connected to Port A from 8255 IC.
55
================================================================
<< بالتوفيق >>
56