Pneumatic double solenoid valve position

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…

using Java, command based…

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.

EDIT: Just found it. See the screenshot Screenshot - 34cc692fcce8534d4a2afb760f45940a - Gyazo

See Solenoid and the get() method.

snip.png


snip.png

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.

There are some pistons that have a magnetic sensor that tells you the position of the piston.

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.

The get() method probes the PCM over can, so if you do it too often it will cause communication problems (we’ve noticed at least).

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().

Would you have a java example of something like this?

Something like this:


public class Pickup
{
    Solenoid pickupExtend;
    Solenoid pickupRetract;
    boolean pickupExtended;
    public Pickup(int module, int extendChannel, int retractChannel)
    {
        pickupExtend = new Solenoid(module, extendChannel);
        pickupRetract = new Solenoid(module, retractChannel);
        set(false);  //initial state
    }
    public void set(boolean extended)
    {
        pickupExtend.set(extended);
        pickupRetract.set(!extended);
        pickupExtended = extended;
    }
    public boolean isPickupExtended()
    {
        return pickupExtended;
    }
}