pulsout help

drjeseuss

Member
Is it possible to use pulsout with a variable? Specifically:

Code:
for b0 = 0 to 7
  pulseout b0,1
next b0
How about using pulsout with a mask? For example:

Code:
pulseout %00001101,1
If not, does anyone know an effective way to get the same result as either/both of the above?
 

hippy

Ex-Staff (retired)
"PULSOUT <variable>, <length>" will work as expected, the pin number held in the variable will pulse.

As to "with a mask"; there is no such thing as a mask for PULSOUT, so that %00001101 is simply treated as a pin number; %1101, $D, 13. There's no such pin 13 so such commands will either be ignored or treated as 'number // 8', or 'number & 7', in this case pin 5.
 

BeanieBots

Moderator
Only guessing, but I think what is desired by using a 'mask' is to have multiple simultaneous pulsouts on 'specified' pins.
eg pulseout %00001101,1 to pulsout on pins 0,1,2 & 3 all at the same time.

To the best of my knowledge, such a task is not possible.
 

drjeseuss

Member
"PULSOUT <variable>, <length>" will work as expected, the pin number held in the variable will pulse.

As to "with a mask"; there is no such thing as a mask for PULSOUT, so that %00001101 is simply treated as a pin number; %1101, $D, 13. There's no such pin 13 so such commands will either be ignored or treated as 'number // 8', or 'number & 7', in this case pin 5.
I'm glad to know this will work! I am curious though, is it possible to use pulse (or pulse w/ variable) on other ports? How would this be done? For example:

Code:
pulsout portc 1,1
I've read and read about use of pulsout, pins, dirs etc. From my understanding of the manual, portB portC and portD would not be able to recieve the pulsout command as there isn't a variant similar to high command HIGH PORTC 1,1. Am I correct?

Only guessing, but I think what is desired by using a 'mask' is to have multiple simultaneous pulsouts on 'specified' pins.
eg pulseout %00001101,1 to pulsout on pins 0,1,2 & 3 all at the same time.

To the best of my knowledge, such a task is not possible.
You nailed it. That's exactly what I was hoping to achieve. Sad to hear it's not an option. Guess I can just HIGH/LOW to get roughly the desired effect. Thanks!
 

hippy

Ex-Staff (retired)
PULSOUT cannot be applied to PORTC pins, although on the X2's it can be applied to any pin which can be an output, eg on the 20X2, "PULSOUT C.0, 100", will work.

PULSOUT only applies to one pin at a time; giving a sequence of PULSOUT commands will pulse each in turn. It is possible to use HIGH-PAUSE-LOW but to pulse simulataneous pins something like the following is best -

pins = %00101101
Pause <time>
pins = %00000000

Note that on some PICAXE this may not be absolutely simultaneous on all pins. It is best to never design for absolutely simultaneous response as in reality that's not possible. Look down at the smallest timescale and there will usually be some discrepency.
 

drjeseuss

Member
PULSOUT cannot be applied to PORTC pins, although on the X2's it can be applied to any pin which can be an output, eg on the 20X2, "PULSOUT C.0, 100", will work.
I think I'm about due for an upgrade to 20x2. If only I can find where my wife's put my paycheck... :)

Related to my prior question, would "PULSOUT C.0,100" be able to use a variable pin number? For example, "PULSOUT C.b0,100". I know the example likely isn't correct, though can't think of another way to do this.

btw: Sorry for so many simple questions and less actual hands on learning lately. My wife's due with our first any day now so it's been very chaotic around the house. I get time here and there to distract myself with writing code for (hopefully) upcoming projects, but as soon as she sees the hardware come out I must be getting too comfortable and it becomes chore time.
 

BeanieBots

Moderator
It should also be possible to do this:-

For b0 = C.0 to C.7
pulsout b0,100
Next b0

but careful when doing things like that!
 

hippy

Ex-Staff (retired)
Yes, that will work ( except C.6 on 20X2 is input only ).

What will not necessarily work as hoped for is ...

For b0 = A.0 To C.7
PulsOut b0, 100
Next

Such FOR loops should deal only with a single port at a time ...

For b0 = A.0 To A.7
PulsOut b0, 100
Next
For b0 = B.0 To B.7
PulsOut b0, 100
Next
etc
 

drjeseuss

Member
I really appreciate the feedback! My ultimate goal is to use this on my LCD controller. There will be up to 3 LCDs possible, so I will need 3 E lines. If I can set them up in variables I can easily have a single Init routine and set of SendByte routines, then simply adjust the variable (b0) to determine which LCD is getting the commands. So:

Code:
b0 = 3  ' LCD 1 on "standard" pin
gosub init
b0 = 1  ' LCD 2
gosub init
b0 = 0  ' LCD 3
gosub init

init:
PULSOUT b0,1
I've obviously left out a lot, but the above is just for example. This should work out quite nicely!!

Would I still be able to use pin variables? Such as:

Code:
symbol E1 = 3
symbol E2 = 1
symbol E3 = 0

b0 = E2  ' Set to LCD 2 E pin
PULSOUT b0,1
 
Last edited:

BeanieBots

Moderator
Yes, you can do that but be aware of the different convention depending on which PICAXE you use and don't forget you can symbols for variables too.

eg
Symbol Enable = b0
symbol E1 = B.3
symbol E2 = B.1
symbol E3 = B.0

Enable = E2 ' Set to LCD 2 E pin
PULSOUT Enable,1
 
Top