Go Down

Topic: Equivalent of Pulsout command? (Read 3261 times) previous topic - next topic


I am trying to port some code from PBASIC to the Arduino language. One of the commands that I need is called Pulsout.http://www.dontronics.com/psbpix/pulsout.html
What command would I use to receive the same effect as Pulsout? Is it shiftin?
Any help would be greatly appreciated.


If you set a digital pin to be an output, then digitalWrite() it to 1 and digitalWrite() it back to 0 you will have made a pulse just under 10 microseconds long. That is pretty close to Pulsout.  You could put a delayMicroseconds() call in between to make it longer.


If it is possible, is there another way that takes less time? Specifically, I need something that takes less then 8 microseconds.


You can do this, but you need to use the IO registers directly.
Figure out which port and pin number you are needing to alter and then you can do something like...
Code: [Select]
PORTD |= _BV(3);  // turn on pin 3 of port d
PORTD &= ~_BV(3); // turn off pin 3 of port d

_BV(3) is just a macro that makes the bit mask for bit 3, PORTD is the IO register. That will get you a fraction of a microsecond of on time for your pin. You can use the high level functions like pinMode() to set up the pin and then use these for the timing critical part. Don't use a variable in the _BV() if you can help it, it makes dramatically slower code.

The hardware page has a link to the pinout picture for Arduinos. You can see which port and pin a given digital pin is on.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131