|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||
|
|||
|
How to program solenoid and compressor?
Hi, this is team 2198 and we are having trouble programming for the solenoids and compressors for java. We would appreciate any help we can receive whether it is a program or a simple guide.
Thanks for reading ![]() |
|
#2
|
||||
|
||||
|
Re: How to program solenoid and compressor?
If someone has real sample code, jump in. In the mean time, there is some test code in edu.wpi.first.wpilibj.CompressorTest which is used to test WPILibJ on a special test rig.
Also, if you could give some details about the problems your seeing? - not sure how to get started? - code doesn't compile? - code runs with exceptions? - code runs, but doesn't do what you want? |
|
#3
|
|||
|
|||
|
Re: How to program solenoid and compressor?
I am not sure howto get started
![]() |
|
#4
|
||||
|
||||
|
Re: How to program solenoid and compressor?
OK, there's some solenoid example code in the DefaultCodeProject.
From NetBeans, select "File/New Project...". In the window, open the "Samples" folder, select "FRC Java", then "DefaultCodeProject.zip" and continue making the project from there. Also, as I mentioned before there is some test code in WPILibJ. To see that code, select "File/Open Project...". Navigate to your "sunspotfrcsdk" directory, then the "lib" directory under that. From there select WPILibJ. |
|
#5
|
|||
|
|||
|
Re: How to program solenoid and compressor?
This should give you a good idea.
Code:
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Solenoid;
public class Airsystem extends SimpleRobot {
private Joystick DriverStick;
private AxisCamera camera; //defines Axis Camera
private Solenoid s1,s2; //defines solenoids
public Airsystem() {
DriverStick = new Joystick(1); // USB port
airCompressor = new Compressor(1,1); //Digtial I/O,Relay
airCompressor.start(); // Start the air compressor
s1 = new Solenoid(1); // Solenoid port
s2 = new Solenoid(2);
public void autonomous() {
}
public void operatorControl() {
if(DriverStick.getRawButton(1) == true)
{
s1.set(true);
s2.set(false);
}
if(DriverStick.getRawButton(2) == true)
{
s1.set(false);
s2.set(true);
}
}
}
|
|
#6
|
|||
|
|||
|
Howdy...
We had to insert this piece of code in the operatorControl() as well, // New compressor code... if (airCompressor.getPressureSwitchValue()) { airCompressor.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOff); } else { airCompressor.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOn); } And don't forget to turn the compressor off when exiting your operatorControl loop... airCompressor.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOff); |
|
#7
|
||||
|
||||
|
Re: How to program solenoid and compressor?
Quote:
ex: Compressor myComp = new Compressor(1,1); //That's all you need |
|
#8
|
||||
|
||||
|
Re: How to program solenoid and compressor?
Quote:
Quote:
The example should look more like this: Code:
....
public class Airsystem extends SimpleRobot {
private Joystick DriverStick;
private AxisCamera camera; //defines Axis Camera
private Solenoid s1,s2; //defines solenoids
private Compressor airCompressor;
public Airsystem() {
DriverStick = new Joystick(1); // USB port
airCompressor = new Compressor(1,1); //Digtial I/O,Relay
airCompressor.start(); // Start the air compressor
s1 = new Solenoid(1); // Solenoid port
s2 = new Solenoid(2);
}
...
|
|
#9
|
|||||
|
|||||
|
Re: How to program solenoid and compressor?
Instead of deleting your post with "Problem is now solved", can you please tell us in case we have the same issue? We also don't know how to program the compressor using Java.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Solenoid Wiring and Compressor Help | BurtGummer | Electrical | 16 | 17-02-2010 14:25 |
| How do you download a program and have it saved to the c-rio | 2560DawgDM | NI LabVIEW | 12 | 03-02-2010 20:58 |
| How to download and keep a program on crio | zackcool123 | Programming | 2 | 16-02-2009 18:22 |
| How to conect solenoids to the circuit board. and how to program it...??? | arpitshah | Pneumatics | 6 | 13-01-2008 15:06 |
| Teach Genia How to Program and Win a Prize | Eugenia Gabrielov | Chit-Chat | 25 | 25-02-2005 13:31 |