Tutorial Microcontroller MCS-51 ATMEL ISP
 

 

Super MCS51 Trainer

Standart MCS51 Trainer

Standart AVR Trainer

Programmer USBASP

Standart ARM Trainer

 

 

6.3. Generating a Stair Step Voltage by Using Look Up Table

In this lesson we are like to design, how to generate stair step voltage from 0volt trough 5 volt, with resolution 0.5 volt each step. There is something you must to do is to calculate the konstanta K, as you have learned in previous lesson.

Step 1st
Build the circuit as shown in figure 2.16. As you seen on figure 2.16. P0.0 trough P0.7 is connected to A8 - A1.
For example, we assumes that the Vref = 5 volt, R14 = 5 k, and Rf = 5k

   K = Vref/ R14;
     = 5/5k
= 1 mA
If, we put logic high into A1 through A8 then we have:
Io = 1 mA x 0.99
= 1 mA
So,Vo = Io x Rf
= 1 mA x 5k
= 5 volt
Voltage Resolution = 5/255 = 0.0196 volt

* Voltage 0 volt
= 0/ 0.0196
= 0 decimal * Voltage 0.5 volt
= 0.5/0.0196
= 25 decimal
* Voltage 1 volt
= 1/0.0196
= 51 decimal * Voltage 1.5 volt
= 1.5/0.0196
= 76 decimal : :
* Voltage 5 volt
= 5/0.0196
= 255 decimal

Step 2nd
In this step, you must tipe the assembly program to make a voltage from your DAC, we assume that you have already known the editor, we used MIDE-51 to edit the program.

       org 0h
       mov DPTR,#DataDAC
start: clr A
movc A,@DPTR+A
mov P0,A
inc DPTR
call delay
sjmp start ; delay: mov R0,#0
delay1:mov R2,#0fh
djnz R2,$
djnz R0,delay1
ret
;
DataDAC:
DB 0,25,51,76,102,127,153,178,204,229,255
end

Step 3rd
Safe your assembly program above, and name it with dac3.asm (for example) Compile the program that you have been save by using MIDE-51, see the software instruction.

Step 4th
Download your hex file ( dac3.hex ) into the microcontroller by using Microcontroller ATMEL ISP software, see the instruction.After download this hex file you'll see the action of DAC ( of course if your cable connection and your program are corrected )

6.4. Generating a Sine Wave Voltage by Using Look Up Table

In this lesson we are like to design, how to generate sine wave voltage from 0volt trough 5 volt, with resolution 0.1 volt each step. There is something you must to do is to calculate the konstanta K, as you have learned in previous lesson. For this lesson you must to do by your self, something that gives you a clue is:

Figure 2.17. Sine wave voltage 0 - 5 volt