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 |
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.
- Refer your manual of microprocessor trainer kit to find out address of CWR and port A
R-2R ladder DAC |
Comments
Post a Comment