Let's Make Robots!

Picaxe 40X1 Pulsin and Pulsout

Hello.  Anyone know how to use a pin on port C, say...c7 (leg 26) in order to get a pulsin or pulsout for the 40X1 picaxe?  I know the syntax just to turn the pin high or low, but I don't know how to reference the pin when I use the pulsin command, for example what would go in the "pin" part of the PULSIN command:


PULSIN pin,  state, wordvariable


Thanks in advance for any help you can give =)



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Yeah, I found the syntax for the pulsin command in the second manual, but I did not find that piece of information in it =\  I did find it in the "Picaxe 18X/28X/40X Extended Features" document though.  I guess I can't use my parallax ultrasonic sensor with the 40X1 then, because it requires the use of a pulsin and a pulsout command on the same pin.  Haha, I thought that the 40X1 could do everything better than the 08M, but that seems to be something that the 08M can do that the 40X1 can't.  

I think you can get the ultrasonic sensor to work. It requires a pulse with a minimum of 10 microseconds, but I think it will work with a 1 millisecond pulse as well. Try the code below.

low portc 7

pause 1 'keep pin 7 low for 1 mS

high portc 7 ' start the pulse

pause 1 'keep it high for 1mS

low portc 7 'end the pulse

pause 10 'wait for the recharge period

pulsin 7,1, w0 

Ah, I see.  Yeah, I'm still a little confused as to what the numbers refer to on the 40X.  (The 08M seemed much easier to understand.)  In the command:


pulsin 7, 1, w0


Is the "7" referring to Input portC 7 (or leg 26) of the microcontroller?   I would have thought that it was referring to Input 7 (leg 30 of the microcontroller.)

Sorry. I was looking at the picaxe 28x1. On that chip input 7 = output c7

if you use one of the regular digital inputs (legs 19-22 and 27-30) you might be able to use

low portd 7 'leg 30 high

I'm not sure if it will work. In the pin configurations only the 40x2 refers to portd. If it doesn't work: I guess the regular digital inputs cannot be used as outputs (shame!) 


Sure is.  Thanks for your help!

You should check the manuals, specifically manual 2, from picaxe. picaxe_manual2.pdf

You cannot use pulsout on any of the digital inputs (= portc outputs). This means you're stuck with the low and high commands with a short pause in between. I think the problem with that is the length of the pause. The shortest pause = 1 millisecond. The pulsout command can give you a 10 microsecod pulse.

To use pulsin with input pin 7 (or portc 7 or c7); use the following syntax

pulsin 7, 1, w0

the second argument has to be 1 to start measuring when the pin goes from low to high. Of the second arg is 0, the measurement starts when the pin goes from high to low.

You should really check out the picaxe manuals. There very easy to comprehend.You can find them at http://www.rev-ed.co.uk/picaxe/