Is there a method that i could use to determine which solenoid is currently energized?
I guess for lack of better terms, understanding that this is not best practices, could i use that value to determine my cylinder position, extend or retract?
I understand that i should use some sensors to mechnanically detect the position… just trying ot see if there is a way to do this temporary…
I know in Labview, there are specific VIs that you can use to get the current solenoid position (it doesn’t “get” it, but rather remembers the last “set” you did). I’m assuming there’s something akin to this in Java.
We just have a solenoid object that remembers which state it’s in. It’s pretty good, you only run in to issues if it somehow misfires or you run out of air. We have positions it expects to be in when the robot starts. Otherwise you could instantiate a NULL or “undefined” state value and handle that when checking if the solenoid has not yet been fired.
Absent feedback, the only way to know the position of a 2 position solenoid is to keep one solenoid energized. They don’t consume a lot of power so there is generally not a reason to do this.
If I understand you correctly, can’t you just call the get() method to get the solenoid state? It may not reflect the real physical state (if the actual mechanism is stuck) but certainly the electrical state that the valve is energized or not.
Since it is the code who is setting the state of the pneumatics valve, it could be as simple as having a variable tracking the valve state so you can avoid calling get().