View Full Version : Help with Programming Pnuematics
Hi,
Our team recently lost the majority of its programmers and where switching over to Java, i understand java a little and where using robot builder to make it a bit easier. My question is how do you code pneumatic's in general and even then how would you use that in robot builder? I lurked a little to try and find out but my adventure didn't give me anything. So any help would be Greatly appreciated!!
notmattlythgoe
27-01-2014, 07:42
Hi,
Our team recently lost the majority of its programmers and where switching over to Java, i understand java a little and where using robot builder to make it a bit easier. My question is how do you code pneumatic's in general and even then how would you use that in robot builder? I lurked a little to try and find out but my adventure didn't give me anything. So any help would be Greatly appreciated!!
You'll want to create a Solenoid first.
Solenoid solenoid1 = new Solenoid(1);
Then you'll want to tell the solenoid to activate.
solenoid1.set(true);
Or deactivate.
solenoid1.set(false);
If you have a double acting cylinder you'll need teo solenoids and active and deactivate them opposite of each other, or use a DoubleSolenoid.
thanks for the reply,
Our team is using a double solenoid would the code still be the same or would their be any minor changes?
notmattlythgoe
27-01-2014, 14:42
thanks for the reply,
Our team is using a double solenoid would the code still be the same or would their be any minor changes?
DoubleSolenoid solenoid = new Solenoid(1, 2);
solenoid.set(DoubleSolenoid.Value.kForward);
kReverse would fire it the opposite direction.
Give that a try. You can also do something like:
Solenoid solenoid1 = new Solenoid(1);
Solenoid solenoid2 = new Solenoid(2);
solenoid1.set(true);
solenoid2.set(false);
Domenic Rodriguez
27-01-2014, 14:46
thanks for the reply,
Our team is using a double solenoid would the code still be the same or would their be any minor changes?
You would use the DoubleSolenoid class instead of the Solenoid class:
// Create a new DoubleSolenoid with the forward channel in port 1,
// and the reverse channel in port 2
DoubleSolenoid doubleSolenoid = new DoubleSolenoid(1, 2);
In addition, the call to DoubleSolenoid#set() is a bit different than Solenoid#set(). Instead of taking a boolean value, it takes a DoubleSolenoid.Value object:
// Set the solenoid to the 'forward' position
doubleSolenoid.set(DoubleSolenoid.Value.kForward);
// Set the solenoid to the 'reverse' position
doubleSolenoid.set(DoubleSolenoid.Value.kReverse);
// Set the solenoid to the 'off' position
doubleSolenoid.set(DoubleSolenoid.Value.kOff);
You can find more details in the FRC javadocs, located at "C:\Users\user\sunspotfrcsdk\doc\javadoc\index.html" on any computer that has the FRC Java plugins installed.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.