Fastest Sinus????
Posted: Thu Jul 21, 2011 9:21 pm
I still have a Textronix TM5003 function generator/counter. Is about 40 years old and makes a lot of noise. Time to get updated. Looking at internet I found function generator and counters but rather expensive.
But as PIC microcontroller user, I thought that can be done easily!
First some literature learned me that a Digital-Analog Convertor DAC, which I need, can be realised by means of:
1) PWM by changing the pulse width duty and with a RC-circuit. (Easy setup)
2) Setting the digital output on a ladder of resistances (2R-R)
I first tried the PWM, without success. The fastest 'sinus' was about 400 Hz. That can be realised also by setting my wife on a bike and use the dynamo output.
Second I tried the 2R-R ladder. I thought the PIC output should be buffered, but I figured out in the meanwhile that this can be deleted. But in the picture you will see two hex buffers (4010). And what was the fastest sinus I got? You see the answer on the scope picture. With the sinus generated in 256 steps, the frequency is just 0.1 msec, or 10 kHz.
Is that what can be expected? in the assembler program it can be seen that about 485 steps are necessary for 1 period of 100 usec. That means about 206 nsec per step. This is close to the official 203 nsec for an instruction cycle time with a 19.6608 MHz crystal.
Conclusion:
It took much more time, but was very interesting. The sinus is not ideal. The reason can be easily found in the assembler translation of the flowcode.
Question:
Is this the fastest sinus in 256 steps accuracy?
Jan Lichtenbelt
ref: http://en.wikipedia.org/wiki/Resistor_ladder
But as PIC microcontroller user, I thought that can be done easily!
First some literature learned me that a Digital-Analog Convertor DAC, which I need, can be realised by means of:
1) PWM by changing the pulse width duty and with a RC-circuit. (Easy setup)
2) Setting the digital output on a ladder of resistances (2R-R)
I first tried the PWM, without success. The fastest 'sinus' was about 400 Hz. That can be realised also by setting my wife on a bike and use the dynamo output.
Second I tried the 2R-R ladder. I thought the PIC output should be buffered, but I figured out in the meanwhile that this can be deleted. But in the picture you will see two hex buffers (4010). And what was the fastest sinus I got? You see the answer on the scope picture. With the sinus generated in 256 steps, the frequency is just 0.1 msec, or 10 kHz.
Is that what can be expected? in the assembler program it can be seen that about 485 steps are necessary for 1 period of 100 usec. That means about 206 nsec per step. This is close to the official 203 nsec for an instruction cycle time with a 19.6608 MHz crystal.
Conclusion:
It took much more time, but was very interesting. The sinus is not ideal. The reason can be easily found in the assembler translation of the flowcode.
Question:
Is this the fastest sinus in 256 steps accuracy?
Jan Lichtenbelt
ref: http://en.wikipedia.org/wiki/Resistor_ladder