Little HELP (IF,THEN)??????
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........
·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
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
·
'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·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 1/19/2010 1:31:21 AM GMT
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
·