Go Down

Topic: PWM at Low Frequencies (.12 Hz-10 Hz) (Read 5 times) previous topic - next topic

cyclegadget


Quote
Are there any suggestions on how to produce a clean square waveform at these lower frequencies?


I have a sneaky suspicion that the problem has nothing to do with your code or the Uno.



I wonder what would have the capacity to change a waveform... What in the world could perhaps induce resistance to voltage change....

Udo Klein

You might try my code http://blog.blinkenlight.net/experiments/measurements/flexible-sweep/ here. It is completely tested down to 0.0001 Hz. If your issue persists with my code then your issue is caused by your circuit and not by the code.
Check out my experiments http://blog.blinkenlight.net

retrolefty

Assuming you want a 50%/50% square wave output I would just load up the MStimer2 library and have it's ISR just flip the output pin each time it's called. So I would just set the timer to interrupt at the millisecond value that corresponds to one half the period time of the desired frequency you wish to use. To change the frequency just
stop the timer interrupt, issue a new set timer interrupt with the new time value then do another start timer interrupts. Simple and low overhead I would think?

http://www.pjrc.com/teensy/td_libs_MsTimer2.html

Lefty

Coding Badly


Zapro

I cannot see why a lower frequency would alter the logic level on the output - try looking at the probe on the scope, it sounds like it's set to AC coupling!!

// Per.

Go Up