Pages: [1]   Go Down
Author Topic: It is possible to create less than 1ms on and off  (Read 581 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Connecticut, US
Offline Offline
Edison Member
*
Karma: 2
Posts: 1036
Whatduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: April 03, 2009, 10:44:39 am by Oracle » Logged

Pages: [1]   Go Up
Jump to: