Go Down

Topic: It is possible to create less than 1ms on and off (Read 608 times) previous topic - next topic

xyliu

It would like to create a PWM signal with less than 1ms period. Even if I gave it a 0 ms or 0.1 ms delay time, the board automatically pause for 1 ms. I am using the duemilanove.

Thank you in advance!

halley

There is hardware PWM on six output pins, but if you meant to make a square wave in software, the delay(int milliseconds) won't delay for less than one millisecond.  (Any fraction like 0.1 is rounded down to fit in an int value.)  See the delayMicroseconds(int microseconds) for much shorter delays.

xyliu

Thank you very much. It works with delayMicroseconds.

Yes, I would like to generate a PWM only for 20ms, then turn on for high later. So the function above works great.

Oracle

#3
Apr 03, 2009, 05:44 pm Last Edit: Apr 03, 2009, 05:44 pm by Oracle Reason: 1
I'm doing this in the 50uS range and precisely controlled intervals between flashes with the FrequencyTimer2 library.  For slower delays between flashes (I go up to 1 second), I use a postscaler.

Go Up