How can we program the pneumatics to toggle between in and out? Right now we can only leave the piston out by holding the button down. How can we set it up to toggle?
Thanks
How can we program the pneumatics to toggle between in and out? Right now we can only leave the piston out by holding the button down. How can we set it up to toggle?
Thanks
are you using a single or double solenoid. What type of switch are you using (spst, dpdt, momentary, locking, etc). That’s the bare minimum information, because each combination would have a different line (or lines) of code to work.
i believe we are using a double solenoid
You probably have something like this:
relayX_fwd = pX_sw_trig
You need something like this:
if (pX_sw_trig) then relayX_fwd = 1
if (pX_sw_top) then relayX_fwd = 0
If using two buttons is out of the question, you’ll have to get a bit more creative:
if ((pX_sw_trig ~= LastState) & (pX_sw_trig = 1)) then
relayX_fwd = OpenClose
OpenClose = OpenClose - 1
endif
LastState = pX_sw_trig
*Originally posted by Coach C *
**
if ((pX_sw_trig ~= LastState) & (pX_sw_trig = 1)) then
relayX_fwd = OpenClose
OpenClose = OpenClose - 1
endif
LastState = pX_sw_trig **
The PBASIC operator for not equal is <>. Also, use the keyword AND instead of &. Finally, can get rid of the variable OpenClose and just use relayX_fwd=1-relayX_fwd if you are running low on variable space. Either way, make sure to set relayX_rev=1-relayX_fwd.
umm… im using &, and ~= and their working just fine in my code…
and they are used in the default code from I.F.
*Originally posted by Justin Stiltner *
**umm… im using &, and ~= and their working just fine in my code…
and they are used in the default code from I.F. **
~= is not valid syntax. The editor complains about it and won’t even tokenize. It also is not any of the four default codes, so I’m not sure where you saw it. As for &, it is not the correct operator to use here. Here’s a quote straight from the Stamp Manual (page 153):
The easiest way to avoid the kinds of problems this might cause is to always use a conditional operator with IF…THEN. Change the example above to read IF Flag = 1 THEN IsTrue. The result of the comparison will follow IF…THEN rules. Also, the logical operators will work as they should; IF NOT Flag = 1 THEN IsTrue will correctly evaluate to false when Flag contains 1.
This also means that you should only use the “named” conditional logic operators NOT, AND, OR, and XOR with IF…THEN. The conditional logic operators format their results correctly for IF…THEN instructions. The other logical operators, represented by symbols ~ & | and ^ do not; they are binary logic operators.
Finally, see any of the below threads for more info:
http://www.chiefdelphi.com/forums/showthread.php?s=&threadid=18007
http://www.chiefdelphi.com/forums/showthread.php?s=&threadid=17730&highlight=bitwise
http://www.chiefdelphi.com/forums/showthread.php?s=&threadid=15287&highlight=bitwise
yea my bad on the first one… that one doesent workbops self in head