I want to program a 2 coil solenoid so that when I push a button, the bimba extends and then when I push the same button again it retracts. I cannot figure this out. If someone could provide some code it would be greatly appreciated, or talk me through it in simple text.
Normally I wouldn’t post complete code (I’d rather give suggestions and help guide you) but since we are almost a week away from ship here you go.
Attached .vi works by toggling a state whenever button 1 is pressed and actuating the appropriate cylinders. We aren’t using pneumatics this year so I just noticed that the solenoid vi’s use enumerated constants (like the relay’s) compared to boolean values like last year, but this should still work fine. We used this last year for a periscope on our robot that one of our drive team would toggle up and down with the joystick trigger. Good luck!
SolenoidTrigger.vi (12.8 KB)
SolenoidTrigger.vi (12.8 KB)
I changed your code to satisfy our double coil solenoid, but the problem with my code is that when the bimba is in its retracted state the solenoid clicks nonstop. I think that it is because my code is trying to make it do something but since it is already there it can’t and just keeps trying. I’ve attached a copy of my solenoid code so any suggestions would be appreciated.
Teleop.vi (31.2 KB)
Teleop.vi (31.2 KB)
Couple problems:
-It is clicking because you have the same reference and are issuing 2 different commands at the same time. With a double acting solenoid this means that it should be operating on 2 channels. If you are using the solenoid module on the cRIO this means that you should use Channels 1 and 2 (or whatever you are using). The code that I originally posted should satisfy this exactly.
-Also you definitely want to avoid having while loops in your Teleop, this is a bad practice and will more than likely make your drive sluggish at best. With your code the while loop only executes once, so why even have it?
There is a valid reason to use a “run-once” loop (though Dyson’s code doesn’t do it). It lets you use a shift register to remember a value between runs of the surrounding vi. If you have a bunch of such values you need to keep around, a single loop surrounding the relevant functions can be a little cleaner than a bunch of feedback nodes.
Alan - That is a good point. I tend to avoid using shift registers if at all possible, as I think it can be detrimental in troubleshooting effectively, but that’s just me. And I would still be vary wary about implementing them in the FRC Teleop.vi as a poor implementation could lead to other (and possibly unforeseen) problems in the future. A better idea to me would be to use a For Loop, at least then you can definitively control how many times a loop will run before exiting, compared to a While Loop where you are more likely to be checking on an external (from the Teleop.vi) input.
But the application that you stated, using shift registers in place of multiple feedback nodes is great!