need Solenoid help

If anyone knows how to write a solenoid program correctly or any where i can get info on it, I would be very Grateful

Have you looked at the documentation? It should give you a good start.

Yea i looked at it and wrote from it and it didn’t work

Are you doing pneumatics? If so, there are a number of ways to wire pneumatics. Assuming you hook the pneumatic valve to two Solenoid channels (DO channels). Here is the code to operate it.

Disclaimer: I am new to pneumatics, so this may not be the right way to do it, but it works for us. Another way to do it is to use a relay instead of two solenoid channels but it requires a relay.


#define SOLENOID_EXTEND_CHANNEL  1
#define SOLENOID_RETRACT_CHANNEL 2
private:
    Solenoid *m_solenoidExtend;
    Solenoid *m_solenoidRetract;
...

// In some constructor
    m_solenoidExtend = new Solenoid(SOLENOID_EXTEND_CHANNEL);
    m_solenoidRetract = new Solenoid(SOLENOID_RETRACT_CHANNEL);

...

// To extend the pneumatics
    m_solenoidRetract->Set(false);
    m_solenoidExtend->Set(true);

// To retract the pneumatics
    m_solenoidExtend->Set(false);
    m_solenoidRetract->Set(true);

Forgot to mention a few more things: make sure your DO module is in the default slot 8 (or you have to specify the slot in the code). Also make sure the soloenoid bumper is powered with appropriate voltage. FIRST provided 24V valves this year, so you need to feed 24V to the bumper (not 12V).

BTW, forgot to mention one more thing: you need to create a compressor object too. The compressor power should be hooked to a Spike relay and the pressure switch should be hooked to a digital input channel.


#define PRESSURE_SWITCH_CHANNEL  1
#define RELAY_COMPRESSOR_POWER  1
private:
Compression *m_compressor;
...

// In some constructor
    m_compressor = new Compressor(PRESSURE_SWITCH_CHANNEL, RELAY_COMPRESSOR_POWER);
    m_compressor->Start();

thanks that should be egood enough