Shop OBEX P1 Docs P2 Docs Learn Events
Little HELP (IF,THEN)?????? — Parallax Forums

Little HELP (IF,THEN)??????

Radridz3Radridz3 Posts: 49
edited 2010-01-20 07:14 in BASIC Stamp
I have a cnc mill machine that uses air slides and for me to get the z axis slide to work I used the 5v signal from the z axis direction pin (pin7) on my breakout board. Know that solved the down. But the ups a little tricky. I cant just have a swapping relay circuit that keeps the up relay on....because the air silenoid valves have poor duty cycles. So I cant leave the relay on. So I figured I would use the active low signal from the same z axis pin7 direction. To pulse a 74hc123 and it worked ..BUT circuit fails quickly because of my lack of datasheet and electronics knowledge. So I figured I'd get out my trusty homework bs2 and write a really simple code. Easier said than done I'm getting all kinds of false triggers for some reason. My setup was this. Pin7 z axis from my parellel port to pin1 of my bs-2 know this pin when drilling going down will be active high 5v . When z is done moving the signal goes low...To no voltage so I wrote the code accordingly. When theres·NO power i need the bs-2 to read pin1 low and then send pin 2 high for maybe a couple seconds...The air cylinders set up not to exhaust the up air it holds it. So I dont have to constantly hit the relay·...Sounds simple enough what am I missing. I haven't been playing with microcontrollers lately so Im really rusty on code. Here's the code very basic but maybe Im just up to late. HAHa Another thought maybe Im just missing something in the circuit from the signal wire.

·DO
· DEBUG ?· IN1
· IF (IN1 = 0) THEN
··· HIGH· 2
··· PAUSE 2500
··· LOW 2
··· PAUSE 2500
· ELSE
··· PAUSE 50
· ENDIF
LOOP


getting rid of the else didn't solve the triggering problem either....The idea works perfect when the signal pins high(1) but if its low and supposed to just be (0)'ssss I get a 1 in there every few cycles. Any help would be thankful........

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2010-01-18 13:19
    A schematic would really help here.

    Your code segment is very simple so if its doing funny things, its likely some interaction between the input and the electrical noise caused by the valves.
    Just as a comment, the IF loop is 5 seconds long during which time the Stamp can't check anything else. That also may be affecting performance.

    Is your input properly pulled down?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • Radridz3Radridz3 Posts: 49
    edited 2010-01-18 22:01
    I only have a 10k before the bs-2 and the hmwrk board already has 220 ohm arrays also. I dont think im pulling down proper. The input circuit is very bare. Any circuit help would be appreciated. And its defintly noise causing the false triggers. the way its hooked up right now it work its just not consistant. Thanks for the help once again.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-01-19 01:25
    Try this and see if this dose not work for you

    'cntr = cntr + 1 * (1 - Chg)··· ·' this is for Pin1 = 0
    'IF (cntr = 5)
    THEN EXIT········ ' this line ADJ how many time it run this loop as long as it stay 0 for 5 loops then this statement become true if·goes ' to 1 then the counter rest to (cntr = 0)

    'cntr = cntr + 1 * Chg·········· ·' this is for Pin1 = 1
    'IF (cntr = 5
    ) THEN EXIT········ ' this line ADJ how many time it run this loop as long as it stay·1 for 5 loops then this statement become true·......... ' if·goes·to 0 then ·the counter rest to (cntr = 0)



    I use this· Routine a lot for input or switch when· I want a debounced input

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    chg········· PIN···· 1
    cntr········ VAR···· Byte

    DO
    cntr = cntr + 1 * Chg
    IF (cntr = 5) THEN
    ·DEBUG ?· IN1

    · HIGH· 2
    ··· PAUSE 2500
    ··· LOW 2
    ··· PAUSE 2500
    · ELSE
    ··· PAUSE 50
    · ENDIF
    LOOP


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 1/19/2010 1:31:21 AM GMT
  • stamptrolstamptrol Posts: 1,731
    edited 2010-01-19 15:17
    No question, 10K is making the Stamp pin almost think its just waving in the breeze.

    Change the 10K to 1K or 470 ohms. Then use the 10K to pull-up the Stamp input pin to +5v.

    ················································ | +5v
    ·················································\
    ················································ / 10K
    ················································ \
    ······························· 470··········· |
    zaxis pin
    /\/\/\/\
    |--stamp input pin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • Radridz3Radridz3 Posts: 49
    edited 2010-01-20 07:14
    That circuit works perfect with the old code. Counter code is a good idea so im writing some code to use that method instead of the plain jane code. I ended up taking the down relay from pin7 and running both of them threw the stamp that way I can write a clean code and not have a relays hang or false triggers. Also thought about using meas switch ......And then the wind would really trigger it hahahahha...Thanks for the help and when its all wired maybe I'll throw a couple pics in projects someday. Thanks again Guys..>>..
Sign In or Register to comment.