Practical - 1 DAC CODE
Practical - 1 DAC CODE
Practical - 1 DAC CODE
Experiment -
Aim –
Assembly language Programming using 8051.
Apparatus –
8051 microcontroller kit by Dyna.
Theory –
DYNA-51 is designed to be an ideal introduction to rapidly expanding field of
Microcontrollers. It is an excellent tool for learning 8051 Micro controller and also for
development of 8051 based systems. The kit has LCD module interface and ASCII
keyboard interface. DYNA-51 has two modes of operation
1. Local mode
2. Remote Mode
POWER SUPPLY
The kit is used with the Dyna log's SMPS 03A Model Power Supply. The 6 pin
female connector can be plugged in 6 pin male connector soldered on-board.
The power requirement of Dyna-51 board is:
+5 V 3 Amps
+12 V 1 A
-12 V 0.5 A
Installation procedure -
1. First connect Power Supply (SMPS-03A) cable (6-pin female connector) to the
system supply connector (CN3) with proper orientation.
2. For Serial mode connect the serial cable to 9-pin DTM connector.
3. Switch on the Power Supply. LCD display will show
4. Press ‘S’ key for Remote (Serial) Mode or ‘CR’ for Local Mode.
Memory map -
The memory map of DYNA-51 is shown in the following table:
203149 - FMM
MCOEP
D Display Memory
Syntax: D start end <CR>
D start Selected area of addressable memory may be accessed and displayed by the D
command. The D command produces a formatted listing of the memory contents
between start (starting address) and end (end address) inclusive on the display. Each
line of the listing begins with the address of the first memory location displayed on
that line, represented as 4 hexadecimal digits followed by contents of 8 memory
locations, each one represented by 2hexadecimal digits.
E Edit Memory
Syntax: E strt<CR>
The E command allows you to examine and modify memory locations individually.
A Assemble Command
Syntax: A strt address <CR>
The A command accepts assembly language statements and assembles each statement
into executable machine code. These assembled machine codes are stored in a
specified memory on line-by-line basis at the time of entry.
203149 - FMM
MCOEP
Disassemble Command
Syntax: U start end <CR>
The U command followed by the address disassembles the program from the specified
location. The U command translates machine instruction into assembly language
mnemonics.
GO Run Program
Syntax: GO Addr<CR>
The GO command is used to execute user program from the address stated in this
command. To illustrate the operation of [GO] command the sample program is given
below.
R REGISTER DISPLAY
Syntax: R<CR>
This command is used to examine the contents of ACC, PSW, SP, DPTR, PC and
registers R0 to R7.
EX. R <CR>
R0- R7 : 02 04 05 06 07 09 01 00
Dyna-51 Local Mode
Dyna log 4-16
203149 - FMM
MCOEP
Program –
1) Addition of two 8bit numbers
Two numbers at D200h and D201h
Result is at D400h
203149 - FMM
MCOEP
203149 - FMM
MCOEP
203149 - FMM
MCOEP
Experiment -
Aim –
Control of stepper motor using 8051.
Apparatus –
8051 microcontroller kit by Dyna, PIO stepper motor card, CN4 cable, DB-9
connector, stepper motor.
Theory –
The stepper motor controller card has 12 pins connector out of which 1, 2, 3 are
connected to power supply (+12, +5, GND) respectively which is obtained from the
serial port connector which is at back of microcontroller kit. The pins 4,5,6,7 and 8
are PA1, PA2, PA3, PA4 and GND are connected to 8255 using CN4 connector.
While pins 9, 10, 11 and 12 are connected to motor windings B1, A1, B2, A2.
The connection block diagram is shown in figure
203149 - FMM
MCOEP
The address of different ports of 8255 on CN4 connector are given in following
diagram
T
h
e
s
t
e
p
p
e
r motor is a 12V D.C motor with a current rating of 5A per phase. The step angle is
1.8 degree. The stepper motor has a winding which is shown below
Each phase winding is split into two equal section A1, A2 and B1, B2. The two
windings are differentially wound as shown in figure by polarity dots. The
significance of this is that a +ve current flowing through A1. This type of winding is
called bifilar winding. Thus with bifilar winding a unipolar supply with 4 on-off
switches as is sufficient.
203149 - FMM
MCOEP
The below switching sequence/logic will move the staff in one direction. To change
the direction the direction of sequence, execute the sequence form upwards. The
stepping action is caused by sequential switching supply to the two phases of the
motor as explained in the switching sequence table.
Position SW1 SW2 PH-1 PH-2 CODE
P3 P2 P1 P0
A 2 4 0 1 0 1 05H
B 1 4 1 0 0 1 09H
C 1 3 1 0 1 0 0AH
D 2 3 0 1 1 0 06H
Program –
Write program to rotate motor continuously in clockwise direction
203149 - FMM
MCOEP
203149 - FMM
MCOEP
Experiment -
Aim –
Interfacing of 8 bit A/D converter with 8051.
Apparatus –
8051 microcontroller kit by Dyna, PIO ADC card, CN4 cable, DB-9 connector.
Theory –
The DMS-ADC-01 Analog to Digital Converter card interfaces with the DYNA-51 or
any other DMS Microprocessor kits. It is used to develop digital signal processing and
real time process control applications.
DMS-ADC-01 card incorporates monolithic CMOS 8 bit successive approximation
analog to digital converter ADC-0809. This converter features a high impedance
chopper stabilized comparator, its resolution is 8 bits and conversion time is
100microseconds. It has a programmable clock oscillator that generates 100 KHz
clock signal. The reference voltage for the ADC is 5.12 V and is generated by
dividing 6.8 V Zener voltage .The instructions are written considering DYNA-51
Microcontroller kit. In case this card is interfaced to any kit, then care has to be taken
regarding the port an RAM addresses of the kit.
V REF +
CLOCK
START
GND
EOC
VCC
IN 7
IN 6
IN 5
IN 4
IN 3
OE
D3
D1
14 13 12 11 10 9 8 7 6 5 4 3 2 1
15 16 17 18 19 20 21 22 23 24 25 26 27 28
IN 0
IN 1
IN 2
V REF -
ALE
D2
D0
D4
D5
D6
D7
A
B
C
General Procedure -
1: Before switching ON the power supply, check the direction of the 26 pin flat
connector cable connector at both ends. All the supply connections+5 V, +12 V and -
12V must be applied simultaneously the ADC -01A card. ADC 0809 chip will get
damaged if +5V is absent +/ -12V supply is applied.
2: Defined 8255 PIO in mode00, Port A as input port, Port B as output port and Port
C as input port. Do not define the 8255 in any other mode except as mentioned above,
to avoid damage to the 8255 IC.
3: The maximum positive analog input voltage to be applied to the ADC-01A is less
than or equal to 5.120V dc (+ or -) or 3.5 V RMS ac (frequency less than 60 hertz).
203149 - FMM
MCOEP
4: The reference voltage on the ADC -01A is factory calibrated at 5.12V and do not
change this setting, because if excessive voltage is applied, ADC-0809 may get
damaged.
203149 - FMM
MCOEP
Program –
PC OPCODE LABEL INSTRUCTIONS REMARK
C100 900103 MOV DPTR,#0103H
C103 7489 MOV A,#89H
C105 F0 MOVX @DPTR,A
C106 900101 MOV DPTR,#0101H
C109 7401 MOV A,#01H
C10B F0 MOVX @DPTR,A
C10C 900100 L3 MOV DPTR,#0100H
C10F 7400 MOV A,#00H
C111 F0 L1 MOVX @DPTR,A
C112 04 INC A
C113 B4FFFB CJNE A,#FFH,L1
C116 900100 L2 MOV DPTR,#0100H
C119 14 DEC A
C11A F0 MOVX @DPTR,A
C11B B400F8 CJNE A,#00H,L2
C11E 80EC SJMP L3
203149 - FMM
MCOEP
Experiment -
Aim –
Interfacing of 8 bit D/A converter with 8051.
Apparatus –
8051 microcontroller kit by Dyna, PIO DAC card, CN4 cable, DB-9 connector.
Theory –
The DMS-DAC -01A Digital to Analog Convertor interfaces with the DYNA -51
Microcontroller kit or any other Microcontroller and Microprocessor kits. It is used to
implement analog and digital signal processing and real time process control
application on DAC-01A interface card.
DAC-01A is designed around DAC-0800 monolithic 8bit high speed current output
digital converter featuring 100 n seconds settling time (typical). DAC-01A has
adjustable voltage reference which permits full scale voltage. The Vref to full scale
current matching of better than +/- 1 LSB gives +/- full scale error.
Precision OP-AMP based current to voltage converter has 20 mA output load driving
capacity. Analog input is polarity protected and buffered and has 10 ohms input
impedance. Analog comparator has medium switching speeds (in milliseconds)and
its outputs converted to TTL level and latched to avoid oscillating comparator status
reading which occurs when 2 analog inputs of the comparator are nearly equal .
The PCB track design is shielded to keep low noise level in the analog paths and this
card gives stable readings of the analog input. The DAC-01 card is also protected for
reverse supply polarity. The instructions are written considering DYNA-51 kit. If this
card is interfaced to any other kit, then care has to be taken regarding the port and
RAM addresses of the kit.
General Procedure -
1: Before switching ON the power supply, check the direction of the 26 pin flat cable
connector at both ends. All supply connections +5V, +12V and -12Vmust be applied
simultaneously to the DAC -01A cart. DAC 0800 and 8255 chips will get damaged if
only +5Vis applied to the cart.
2: Defined Port A of 8255 in the output mode (as a data output port).Port B is also in
the output mode for applying control signals to the DAC and define Port C as input
mode to read the status of DAC. Do not define the 8255 in other mode except as
mentioned above, to avoid damage to the 8255 IC
3: The DAC analog voltage at output socket supplies for 20 mA load (maximum), no
attempt should be made to draw more current from this output.
4: The maximum + analog input voltage to be applied to the analog voltage input
socket are less than or equal to +6V.
203149 - FMM
MCOEP
Description -
DMS-DAC-01A Interface card is designed around the DAC 0800 monolithic 8 bit
high speed current output digital to analog convertor and it is plugged into 8255 chip
through a 26 pin flat cable connector on the DYNA-51 kit. Ports A and B of the 8255
are defined in the output mode and Port C in the input mode. The 8 bit data input for
DAC 0800 is written into the Port A output register by the CPU. This data is latched
into LS373 by applying a software generated positive going latching pulse through bit
PBO of Port B (used to control port) of 8255. A logic high state at bit PBO keeps the
latch in LS373 in flow through condition. When the RESET key of DYNA-51 is
pressed, the address and data buses of the system as well as the 8255 ports go into
tristate condition, and logic 1's by LS373 remains in flow through condition and DAC
gets FF Hex as input data and gives fullscale output.
Port C of the 8255 is used as an input status port and it must not be defined in the
output mode when the DAC-01A card is connected to DYNA51. The DAC 0800
gives complementary sinking current outputs IO and IO* proportional to the digital
data input and reference voltage. The full scale output currents IFS for all logic states
is given by:
IFS = IO + IO* = (VRFF/RREF) x (255/256)
DAC0800 will give full scale output current.
NOTE: *indicated active low signal.
IFS = IO = = (VRFF/RREF) x (255/256)
Precision metal film resistors with high temperature stability are provided for positive
and negative references and the reference voltage is variable (adjusted by pot)
between 0 to +VCC and are buffered. The output current IO of DAC 0800 is converted
into voltage Vo by precision OPAMP based current to voltage converter as shown
below
The current drawn by the inverting and non-inverting terminal of Op-amp is very
small and the current IO sink by DAC 0800 develops a voltage Vo = -IO -RF at the
output of the Op-amp.
203149 - FMM
MCOEP
203149 - FMM
MCOEP
Experiment -
Aim –
Interfacing of LCD with 8051.
Apparatus –
8051 microcontroller kit by Dyna, 16by2 LCD display.
Theory –
LCD display is used to display the messages for more interactive way to operate the
system or displaying error messages etc. interfacing LCD to microcontroller is very
easy if you understanding the working of LCD. In recent years, the LCD is finding
widespread use replacing LED’s this is due to following reasons:-
1. The declining prices of LED’s.
2. The ability to display numbers, characters and graphics. This is in contrast to
LED’s which are limited to no. Of few characters.
3. Incorporation of a refreshing controller into the LCD thereby relieving the CPU of
the task of refreshing the LCD. In contrast the led must be refreshed by the CPU
to keep displaying the data.
4. Ease of programming for characters and graphics.
16×2 Liquid Crystal Display which will display the 32 characters at a time in two
rows (16 characters in one row). Each character in the display of size 5×7 pixel
matrix, although this matrix differs for different 16×2 LCD modules if you take
JHD162A this matrix goes to 5×8. This matrix will not be same for all the 16×2 LCD
modules. There are 16 pins in the LCD module, the pin configuration us given below
PIN
NAME FUNCTION
NO
203149 - FMM
MCOEP
PIN
NAME FUNCTION
NO
1 VSS Ground pin
2 VCC Power supply pin of 5V
3 VEE Used for adjusting the contrast commonly attached to the potentiometer.
RS is the register select pin used to write display data to the LCD
(characters), this pin has to be high when writing the data to the LCD.
4 RS
During the initializing sequence and other commands this pin should
low.
Reading and writing data to the LCD for reading the data R/W pin
5 R/W should be high (R/W=1) to write the data to LCD R/W pin should be
low (R/W=0)
Enable pin is for starting or enabling the module. A high to low pulse of
6 E
about 450ns pulse is given to this pin.
7 DB0
8 DB1
9 DB2
10 DB3
8 bit Data bus
11 DB4
12 DB5
13 DB6
14 DB7
15 LED+ Back light of the LCD which should be connected to Vcc
16 LED- Back light of LCD which should be connected to ground.
VCC, VSS AND VEE – Vcc, vss provide +5v & ground resp. VEE used for controlling
LCD contrast.
RS (Register select) – There are two very important registers inside the LCD. The RS
pin is used for their selection as follows. If RS =0 the instruction command code
register is selected, allowing the user to send a command such as clear display cursor,
at home, etc. If RS =1 the data register is selected allowing the user to send data to be
displayed on the LCD.
R/W (Read - write) - R/w input allows the user to write information to the LCD or
read information. From it R/w=1 when reading
R/w=0 when writing
E (Enable) - The enable pin is used by LCD to latch information presented to its data
pins, when data is supplied to data pins a high to low pulse must be applied to this pin
in order for the LCD to latch in the data present at the data pins. This pulse must be
minimum of 450ns wide.
203149 - FMM
MCOEP
D0-D7 (8 bit data bus) - The 8-bit data pins d0-d7are used to send information to the
LCD or read the contents of LCD’s internal registers. To display letters and no’s we
send ASCII codes a-z, a-z and 0-9 to these pins while making RS=1. There are also
instruction command codes that can be sent to the LCD to clear the display to force
the cursor to the home position or blink the cursor. We also uses RS=0 to check flag
bit to see if the LCD is ready to receive information. The busy flag is d7 and can be
read when R/W=1 and RS=0 as follows if R/W=1 and RS=0 when d7=1(busy flag=1)
the LCD is busy taking care of internal operations and will not accept any new
information when d7=0 the LCD is ready to receive the new information. It is
recommended to check the busy flag before writing any data to LCD.
Command Function
0F LCD ON, Cursor ON, Cursor blinking
ON
01 Clear screen
2 Return home
4 Decrement cursor
06 Increment cursor
E Display ON ,Cursor ON
80 Force cursor to the beginning of 1st line
C0 Force cursor to the beginning of 2nd line
38 Use 2 lines and 5×7 matrix
83 Cursor line 1 position 3
3C Activate second line
0C3 Jump to second line, position3
OC1 Jump to second line, position1
LCD initialization.
The steps that has to be done for initializing the LCD display is given below and these
steps are common for almost all applications.
The steps for sending data to the LCD module is given below. I have already said that
the LCD module has pins namely RS, R/W and E. It is the logic state of these pins
203149 - FMM
MCOEP
that make the module to determine whether a given data input is a command or data to
be displayed.
The circuit diagram shows how to interface a 16×2 LCD module with
microcontroller. Capacitor C3, resistor R3 and push button switch S1 forms the reset
circuitry. Ceramic capacitors C1, C2 and crystal X1 is related to the clock circuitry
which produces the system clock frequency. P1.0 to P1.7 pins of the microcontroller
is connected to the DB0 to DB7 pins of the module respectively and through this
route the data goes to the LCD module. P3.3, P3.4 and P3.5 are connected to the E,
R/W, RS pins of the microcontroller and through this route the control signals are
transferred to the LCD module. Resistor R1 limits the current through the back light
LED and so do the back light intensity. POT R2 is used for adjusting the contrast of
the display.
203149 - FMM
MCOEP
203149 - FMM