Pages: [1]   Go Down
Author Topic: Equivalent of Pulsout command?  (Read 1577 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: