is it possible...
avitus
Posts: 23
Hi, I was wondering if it was possible to assign a HIGH LOW sequence like the one below to an output pin? and what kind of commands would be used.
thank you.
HIGH 3
PAUSE 70
LOW 3
PAUSE 100
HIGH 3
PAUSE 70
LOW 3
PAUSE 100
HIGH 4
PAUSE 50
LOW 4
PAUSE 100
HIGH 6
PAUSE 35
LOW 6
PAUSE 50
HIGH 6
PAUSE 35
LOW 6
PAUSE 50
HIGH 6
PAUSE 35
LOW 6
PAUSE 50
thank you.
HIGH 3
PAUSE 70
LOW 3
PAUSE 100
HIGH 3
PAUSE 70
LOW 3
PAUSE 100
HIGH 4
PAUSE 50
LOW 4
PAUSE 100
HIGH 6
PAUSE 35
LOW 6
PAUSE 50
HIGH 6
PAUSE 35
LOW 6
PAUSE 50
HIGH 6
PAUSE 35
LOW 6
PAUSE 50
Comments
You have a sequence of "High P, Pause N, Low P, Pause X" commands which, along with some other commands to set the values of P, N and X, could be put into a loop or subroutine call, to essentially do the same thing that your series of explicit commands do. Depending on just how long the series of High/Low is, and how much the P/N/X values must change over that series, it may just be clearer and easier to write the series out the way you did.
What exactly did you mean, or want to do?
PAR
is it possible?
Like an "auto-fire" or something?
Is that right?
If so, it's pretty easy to use an IF...THEN.· You could also use BUTTON, instead.· Check PBASIC Help.
Post Edit -- Or do you want all of those HIGH/LOWs to be on one pin?···
This is a·re-hash of a Subject that you started recently -- http://forums.parallax.com/showthread.php?p=612250
If you want them on one pin, then put them on one pin.· I just don't get it.· What·is·the problem?
Post Edited (PJ Allen) : 11/26/2006 3:00:23 AM GMT
thank you for your responce. Im not sure if its something totally simple that im not understanding, or if i'm not realying my goal properly. I am fairly new to programing, and am spending a lot of time with my nose in a "what is a microcontroller" book. So thank you for your patience.
Just to get it out there. I have 4 input pins with the high/low sequences on them. I am wanting to assign the combined pin sequences to trigger when i press a single output button attached to a OutPin.
Is it the difference between an INPUT and an OUTPUT you're not grasping?· A button or switch gets attached to an INPUT (pin assigned as an INPUT.)
As I asked/wrote·previously, it seems you want a sequence [noparse][[/noparse]a series of HIGHs and LOWs on Pins 3, 4, 6] to·execute as the result of a button-push.·
Is that correct?· Yes / No
I have written a program (above) which will do just that, and had done as much in my previous Reply.
yes that is what i was looking for.
Thank you
However, I am stuck once again. The problem consists when the stamp sequence is loaded. It wont allow me to access the HIGH/LOW inputs individually. Plus the stamp wont stop running. it continues to repeat itself.
How to i get the sequence with the button press to only run once, and without disabling the individual pins involved?
Im using basically the exact script you suggested above. Thanks again
Posting partial sections of code leaves out too much detail to tell what might be wrong.
A button is an input device. A properly configured button will change the signal going TO the Stamp from high to low (or low to high depending on the wiring) and the stamp will see this change and respond (in the PJ Allen example the pin sees low (Vss) until the button is pressed--so it loops waiting; when the button is pressed the Stamp sees +5V (Vdd) and skips the THEN to continue with the code).
Output may be high or low, but it is still OUTPUT. HIGH 6 sets the pin at +5V, LOW 6 makes the pin 0 volts, but it is still output and meant to exert work. As an example-- an led is connected from ground (Vss), through a resistor, to an output pin; when the pin is HIGH current flows from the +5V pin through the led and resister to ground*, when the pin is LOW, no current flows because both the pin and ground are 0 volts.
Hooking the led and resistor from the pin to +5 (Vdd) works the same, but the led is on when the pin is LOW, because voltage can flow from +5 to the low pin--it is the difference between voltages that makes the led light. AND, either way, the pin is OUTPUTing a voltage (0 or 5, LOW or HIGH).
--Then again, maybe I misread and this isn't the problem. In that case... keep posting, we'll figure it out!
HTH,
Mark
The code below weaves the pauses to enable all three sequences to execute at the same time.
Another way to do it would be a loop with on off timer settings where your loop compares time passed with the on off trigger values, a clock would be necessary to pull that off or some really good code structure to allow the number of cycles of code to be known for each pass through the logic.
Picture shows time going from top to bottom, all three pins are high at time 0 at time 35 pin 6 goes low at time 50 pin4 goes low and at time 70 pin3 goes low, at time 85 pin 6 goes high (35+50 =85)
So you see different pauses between the high low commands because the pause command halts all the code. Like I said, a polling loop with a program clock is the best way to do something like this. If indeed this is what you are trying to do but maybe it's not and I misread your goal as well.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
As of now its not allowing me to execute the individual input buttons or end the original sequence. it seems to continue even when its finished the line of script. maybe my timing is off. i am pretty much running the script PJ Allen suggested
this is what it looks like..
DO
INPUT 1 'P1 assigned as INPUT
IF (IN1 = 0) THEN'check P1 status, waiting for button
HIGH 3
HIGH 4
HIGH 6
PAUSE 35
LOW 6
PAUSE 15
LOW 4
PAUSE 20
LOW 3
PAUSE 15
HIGH 6
PAUSE 35
LOW 6
PAUSE 50
HIGH 6
HIGH 3
PAUSE 35
LOW 6
PAUSE 35
LOW 3
PAUSE 100
ELSE
ENDIF
LOOP
I don't know what your full code looks like but I would do it like this
Mainloop:
check all 4 buttons put logic 1 or 0 for status in a nibble check if 1 0r 0 in the if then logic below and gosub the routine for that button and return.
if button1 pushed then gosub button1 led pattern
if button2 pushed then gosub button2 led pattern
if button3 pushed then gosub button3 led pattern
if button4 pushed then gosub button4 led pattern
goto loop
ledpattern1:
high
low
...
return
next 3 button subroutines here
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!