Shop OBEX P1 Docs P2 Docs Learn Events
is it possible... — Parallax Forums

is it possible...

avitusavitus Posts: 23
edited 2006-11-28 21:38 in BASIC Stamp
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

Comments

  • PARPAR Posts: 285
    edited 2006-11-26 01:51
    What's the question behind your question? Each HIGH and LOW command specifies which pin to set (high or low, for output). So, it's not possible to assign the sequence you show to "an output pin" (i.e., one pin); you output to three different pins: 3, 4 and 6.

    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
    avitus said...
    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
  • avitusavitus Posts: 23
    edited 2006-11-26 02:20
    My HIGH LOW pin sequence are set on input buttons, that trigger a command on a controller. what i am wanting to do is combine the the 3 pin's sequence i have into the press of one of my other buttons/pins set to the controller.

    is it possible?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-11-26 02:31
    You want to make one of the Stamp pins an input, and have the program check/test that input, once that test is satisfied then you want to execute your series of output sequences?

    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.
    Input_Check:
      IF input = 0 THEN Input_Check  'waits for input = 1
     
    HIGH 3 
    PAUSE 70
    LOW 3 
    PAUSE 100
    HIGH 3 
    PAUSE 70
    LOW 3 
    PAUSE 100
    HIGH 4 ... etc
    
     
    

    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?
    HIGH 14 
    PAUSE 70
    LOW 14
    PAUSE 100
    HIGH 14 
    PAUSE 50 
    LOW 14 
    PAUSE 100
    HIGH 14 
    PAUSE 35
    LOW 14
    PAUSE 50
    HIGH 14
    PAUSE 35
    LOW 14
    PAUSE 50
    HIGH 14 
    PAUSE 35
    LOW 14
    PAUSE 50
    




    Post Edited (PJ Allen) : 11/26/2006 3:00:23 AM GMT
  • avitusavitus Posts: 23
    edited 2006-11-26 07:43
    Pj Allen.

    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.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-11-26 14:36
    INPUT 1           'P1 assigned as INPUT
     
    Button_Check:
      IF (IN1 = 0) THEN Button_Check  'check P1 status, waiting for button
     
    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
     
    GOTO Button_Check   'starts over again, waiting for a button-push
     
     
    

    avitus said...
    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.
    462 x 334 - 36K
  • avitusavitus Posts: 23
    edited 2006-11-26 15:18
    pj allen.

    yes that is what i was looking for.

    Thank you
  • avitusavitus Posts: 23
    edited 2006-11-27 05:52
    thank you again PJ.
    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
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-11-27 06:16
    Avitus, post your entire program as an attachment.

    Posting partial sections of code leaves out too much detail to tell what might be wrong.
  • LSBLSB Posts: 175
    edited 2006-11-27 13:15
    Just a guess here, but maybe there is some confusion between input / output and high / low? Rereading, I get the impression that avitus is looking for input on low pins, thus the reference to not 'having access' to individual pins and his comment that he's(?) looking for something when 'press a single output button'. IFF that is the case, then it is a basic misunderstanding...
    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
  • metron9metron9 Posts: 1,100
    edited 2006-11-27 15:24
    I read you want to execute all three pins at the same time when you push one button, and only execute one of the three sequences when pressing one of three other buttons. (you have 4 buttons?)

    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.


    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
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
    333 x 282 - 8K
  • avitusavitus Posts: 23
    edited 2006-11-28 19:35
    If executing the 3 high low pins off of one seperate input. and also be able to execute the individual 3 pins off of there own individual input button is what you are reffering to above.. then yes.. that is my goal.

    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
  • avitusavitus Posts: 23
    edited 2006-11-28 19:47
    Thank you for your reply mark. I do believe your on to something. Like you said because the voltage is still flowing 0 or 5, LOW or HIGH the THEN is being skipped. and thats why i believe its still continuing to run. atleast thats what i am leading to believe at this point, correct me if im wrong.
  • avitusavitus Posts: 23
    edited 2006-11-28 20:57
    Right now i am using an IF THEN ELSE, and a DO LOOP. And like i said the sequence is running as it sould off of the 4th input button. however its not allowing me to use the individual inputs after the 4th input button has been pressed.

    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
  • metron9metron9 Posts: 1,100
    edited 2006-11-28 21:21
    Hmmm i am confused, I thought you were using PJ's code but you list the code I put up for button 4

    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!
  • avitusavitus Posts: 23
    edited 2006-11-28 21:38
    yes i was using PJ Allens script first. then i switched over to the one i last posted. But they seem to give me the exact same results. Anyway metron9, i will try yours out. thank you for the reply
Sign In or Register to comment.