Log in

View Full Version : Double solenoid code


Zach S.
10-02-2014, 18:09
I've been trying to wrap my head around this code for two days now and I can't figure it out. I've got the declaration (DoubleSolenoid festo) and the port set ( festo(1, 2)) what is the code for teleop that gives me control of the solenoid, this is the only thing I can't get

Alan Anderson
10-02-2014, 21:43
http://wpilib.screenstepslive.com/s/3120/m/7912/l/132407-operating-pneumatic-cylinders-solenoids should tell you what you need to know. Briefly, use the Set() method of the DoubleSolenoid class, passing it one of the constant values kOff, kForward, and kReverse.

Zach S.
11-02-2014, 12:36
My line of code for Set() looks like this
festo.Set(kForward);
festo is the call for our DoubleSolenoid. When i try to build the code I get the following errors:
C:/windriver/workspace/SimpleTemplate/MyRobot.cpp: In member function `virtual void RobotDemo::OperatorControl()':
C:/windriver/workspace/SimpleTemplate/MyRobot.cpp:58: error: `kForward' undeclared (first use this function)
C:/windriver/workspace/SimpleTemplate/MyRobot.cpp:58: error: (Each undeclared identifier is reported only once for each function it appears in.)

Any idea why the Set() I am using is not working?

RufflesRidge
11-02-2014, 12:42
Any idea why the Set() I am using is not working?

Because kForward is a member of the DoubleSolenoid class. Use DoubleSolenoid::kForward

Zach S.
11-02-2014, 13:30
Because kForward is a member of the DoubleSolenoid class. Use DoubleSolenoid::kForward

Sorry, I am a bit new to C++ (recently switched from labview) where is it that I make the ::kForward, is it in the Teleop, or init?

RufflesRidge
11-02-2014, 13:47
Sorry, I am a bit new to C++ (recently switched from labview) where is it that I make the ::kForward, is it in the Teleop, or init?

In the set line that you posted, replace kForward with the text I posted above.

Zach S.
11-02-2014, 13:48
In the set line that you posted, replace kForward with the text I posted above.

Thanks, the code built correctly I will try this out on the bot today!

Zach S.
17-02-2014, 14:07
Okay, tested the program but I still have an issue.

The code seems to be working, I can see the lights on the FESTO changing as I hit the button on the joystick, however, it seems that the solenoid will not fire. Is this a wiring or more code problem? And how can we get this fixed?

Alan Anderson
17-02-2014, 14:25
Is it a 12 volt or a 24 volt solenoid? Are you providing it with the voltage it requires?

Do you have enough pneumatic pressure supplied to it for the pilot valve to activate?

Zach S.
17-02-2014, 16:41
Is it a 12 volt or a 24 volt solenoid? Are you providing it with the voltage it requires?

Do you have enough pneumatic pressure supplied to it for the pilot valve to activate?

24 Volt, I have the wires running from the solenoid breakout board into the FESTO. And as for pressure we are building it up to 60 for testing, and nothing is firing.

Alan Anderson
17-02-2014, 21:52
24 Volt, I have the wires running from the solenoid breakout board into the FESTO.

Just to be certain: Are you feeding the Solenoid Breakout's power input with 24 volts?

Zach S.
18-02-2014, 09:48
Just to be certain: Are you feeding the Solenoid Breakout's power input with 24 volts?

Yes, we have a 20 amp fuse on it, should we be using a 30 amp?

cgmv123
18-02-2014, 09:59
Yes, we have a 20 amp fuse on it, should we be using a 30 amp?

Running it through a breaker would only give it 12 volts. 24 volts has to come from the power supply at the bottom of the PDB.

Alan Anderson
18-02-2014, 10:30
24 volts has to come from the power supply at the bottom of the PDB.

Right.

The cRIO only uses the first two terminals of the four on the 24v output of the Power Distribution Board. Use the second two to feed the Solenoid Breakout.

(The black connectors show a NC on the third terminal, but the PDB itself provides 24v there.)