Skip to main content

Generating Sine Wave Using 8085 and DAC

Strategy

Is it possible to create a beautiful sine wave using our microprocessor or microcontroller. What strategy we want to use. According to us it is possible. To generate sine wave we have to output digital equivalent values which will represent sine wave as shown in figure. Digital data 00H represents -2.5V. The 7FH represents 0V6 and FFH represents +2.5V.

The digital equivalent for sine wave can be calculated as follows. We know that sin 0°=0 and sin 90°=1. The range in 0° to 90° is distributed over digital range of 7FH to FFH i.e.,(FFH to 7FH) 128 decimal steps. Therefore taking 128 as a offset we can write digital equivalent value for sin θ =(128+128×sin É‘). Where É‘  is an angle in degrees which varies from -90° to +90° with a period of 5°. By changing the value of É‘ to less than 5°, you can get more accurate sine wave. Now you have to enter DATA(approximate hex code) in corresponding memory location as shown in the table below:


Address Algle(θ) Degree(ɑ) Hex code Data
(hex code
approximate)
2500 -90 0.0 00 00
2501 -85 0.48 00 01
2502 -80 1.94 01 02
2503 -75 4.36 04 04
2504 -70 7.71 08 08
2505 -65 11.99 0B 11
2506 -60 17.14 11 17
2507 -55 23.14 17 1E
2508 -50 29.94 1D 25
2509 -45 37.49 25 2D
250A -40 45.72 2E 36
250B -35 54.58 37 40
250C -30 64.00 40 49
250D -25 73.90 4A 54
250E -20 84.22 54 5E
250F -15 94.87 5F 69
2510 -10 105.77 6A 74
2511 -05 116.84 74 7F
2512 00 128.00 80 84
2513 05 139.15 8B 95
2514 10 150.20 96 9F
2515 15 161.12 A1 AF
2516 20 171.77 A6 B4
2517 25 182.09 B6 C0
2518 30 192.00 C0 C8
2519 35 201.42 C9 D0
251A 40 210.27 D2 D8
251B 45 218.50 DA E0
251C 50 226.05 E2 EA
251D 55 232.85 E8 ED
251E 60 238.85 EE EF
251F 65 244.00 F4 F2
2520 70 248.28 F8 F9
2521 75 251.63 FB FC
2522 80 254.05 FE FD
2523 85 255.51 FF FF
2524 90 256.00 100 00
Now the program can be written as below;
Address Label Mnemonic Machine code Comments
2000 MVI A,80H 3E, 80 Initializing the ports of the PPI 8255 as O/P ports by writing the control word as 80H.
2002 0UT CWR D3, Address of CWR Control word specify the I/O function for each ports of 8255.
2004 START MVI C,24H 0E, 24
2006 LXI H,2500H 21, 00, 25
2009 POS MOV A,M 7E
200A OUT PORT A D3, address of PORT A [[H-L]] is outputted through portA
200C INX H 23
200D DCR C 0D
200E JNZ POS C2, 09, 20
2011 MVI A,24H 0E, 24
2013 NEG DCX H 2B
2014 MOV A,M 7E
2015 OUT 00H D3, Address of PORT A [[H-L]] is outputted through portA.
2017 DCR C 0D
2018 JNZ NEG C2, 13, 20
201B JMP START C3, 04, 20

Note:

  • I will suggest you to use R-2R DAC(Digital to Analog Converter) for this purpose. If you are using this R-2R DAC for this purpose it is not preferred to breadboard it. You have to solder it to avoid erroneous values.

  • R-2R ladder DAC

  • Refer your manual of microprocessor trainer kit to find out address of CWR and port A

Comments

Popular posts from this blog

8051 Simple Programs

Sum of 8-bit Numbers Stored in Memory Here  we will discuss about 8051 programs but we can't discuss about all of the 8051 instructions. For programming 8051 we should know about assembler directives as well as instruction set. Click  here to download Atmel c51 user guide that will discuss about 8051(c51 family microcontroller) instruction set, assembler directives, c51 cross assembler from Atmel.  Program ORG 00H MOV R0,#50H   ; get memory location in memory pointer R0 MOV R1,#51H   ; get memory location on memory pointer register R1 MOV A,@R0       ; get content of memory location 50H to accumulator ADD A,@R1        ; add content of A with content of memory location 51H and store result in A MOV R0,#52H    ; get 52H to memory pointer R0 MOV@R0,A         ; copy content of A to memory location 52H END Add 16-bit Numbers ...

Introduction to 8051 embedded C

For 8051 we need to include the file reg51.h. This file contains the all the definitions of 8051 registers. With this information C compiler produces hex file that can be downloaded into the ROM of the microcontroller. It is important to note that the size of the hex file produced by the assembly language is much larger than the hex file produced by C compiler. Apart from this fact, there is many reasons for writing programs in C instead of assembly: ●It is much easier and less time consuming to write programs in C assembly. ●C is more flexible; it is easier to modify and update. ●Programming in C allows to use code available in function libraries. ●Program written inC for one microcontroller is portable to other microcontrollers with little or no modifications. Data Types in 8051 Embedded C The table shown below lists the data types that are available in typical C51 compiler. The gives information about the size of the data variable and it's value range. Data type ...

Frequency of Oscillation of RC Phase Shift Oscillator

Derivation of Frequency of Oscillation We have to find out the transfer function of RC feedback network. Feedback Circuit of RC Phase Shift Oscillator Applying KVL to various loops on the figure, we get, $$I_1 \left(R+\frac{1}{j \omega C }\right) -I_2R=V_i \text{ ....(1)}$$ $$-I_1R+I_2\left (2R+\frac {1}{j\omega C}\right)-I_3R=0\text{ ... (2)}$$ $$0-I_2R+I_3\left(2R+ \frac{1}{j\omega C}\right)=0\text{ ...(3)}$$ Replacing \(j\omega\) with \(s\) and writing equations in the matrix form, $$\begin{bmatrix}R+\frac{1}{sC} & -R & 0 \\-R & 2R+\frac{1}{sC} & -R \\0 & -R & 2R+\frac{1}{2sC} \end{bmatrix}\begin{bmatrix}I_1\\I_2\\I_3\end{bmatrix}=\begin{bmatrix}V_i\\0\\0\end{bmatrix}$$ Using Cramer's rule to find out \(I_3\), $$\text{Let, }D=\begin{bmatrix}R+\frac{1}{sC} & -R & 0 \\-R & 2R+\frac{1}{sC} & -R \\0 & -R & 2R+\frac{1}{2sC} \end{bmatrix}$$ \(|D|=\begin{vmatrix}R+\frac{1}{sC} & -R & 0 \\-R & 2R+\frac{1}{...