Difference between revisions of "PIC32MX: Sinusoidal Analog Output"
LawrenceChen (talk | contribs) |
LawrenceChen (talk | contribs) |
||
Line 22: | Line 22: | ||
Selecting the number of points to use to generate the sine wave is important because choosing too few will result in a very rough sine wave. When the number of points is too low, you can actually see multiple RC charging graphs between each point. However, if we choose too many points, a peak appears at what should be 0V on the sine wave. To prevent this peek from occurring, one could insert an “if” statement in the lookup table generation loop that replaces all of the occurring 0’s into 1’s. Inclusion of the if statement would result in no true 0V output for that particular output. The ideal number of points for 25Hz is around 200 points. |
Selecting the number of points to use to generate the sine wave is important because choosing too few will result in a very rough sine wave. When the number of points is too low, you can actually see multiple RC charging graphs between each point. However, if we choose too many points, a peak appears at what should be 0V on the sine wave. To prevent this peek from occurring, one could insert an “if” statement in the lookup table generation loop that replaces all of the occurring 0’s into 1’s. Inclusion of the if statement would result in no true 0V output for that particular output. The ideal number of points for 25Hz is around 200 points. |
||
[[Image: |
[[Image:500pts10Hz.jpg|frame|This demonstrates what happens when you pick too many points. The output signal has a peak occurring at the 0V area. This output signal used 500 points at 10Hz.]] |
||
[[Image: |
[[Image:100pts25Hz.jpg|left|frame|This demonstrates what an ideal analog output should look like. This output was generated using 100 points at 25Hz.]] |
||
[[Image: |
[[Image:10pts25Hz.jpg|center|frame|This demonstrates what happens when you select too few points. The output signal shows the capacitor charging. In this case, 10 points at 25Hz are used in generating the analog output.]] |
||
==RC Time Constant== |
==RC Time Constant== |
Revision as of 14:23, 2 May 2010
Overview:
How do we obtain analog output? ie PWM (brief description)
How do we get sinusoidal output? ie divide up sinusoid into N points, scale duty cycle accordingly
General discussion about how cutoff frequency, number of points period (N) and the RC time constant matter.
State that the examples here have PWM at 20kHz.
Cutoff Frequency
How to choose cut-off frequency -- what is the equation?
Show picture if you choose your frequency to high and if you choose your frequency to low.
Say something about how the amplitude decreases with high frequency
Number of Points Per Period
Selecting the number of points to use to generate the sine wave is important because choosing too few will result in a very rough sine wave. When the number of points is too low, you can actually see multiple RC charging graphs between each point. However, if we choose too many points, a peak appears at what should be 0V on the sine wave. To prevent this peek from occurring, one could insert an “if” statement in the lookup table generation loop that replaces all of the occurring 0’s into 1’s. Inclusion of the if statement would result in no true 0V output for that particular output. The ideal number of points for 25Hz is around 200 points.
RC Time Constant
The RC time constant plays a big role in creating the sine wave. By increasing the RC constant, the quality of the output signal is increased, where "quality" refers to the width of the output signals. Despite having such advantages, a larger RC constant will result in a phase lag which causes a delay between the output of the PIC and the output from the whole circuit.
Sample Code
Include your sample code (this may need cleaned up a bit).
To make a box around the code, put a 'space' in front of each line.