OCCRA
Go to Post When you start thinking of FIRST as a robotic building contest you have left the pavement and you are in deep weeds. - KenWittlief [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 01-21-2010, 04:46 PM
Jason F Jason F is offline
Registered User
FRC #2198
 
Join Date: Jan 2010
Location: Canada
Posts: 2
Jason F is an unknown quantity at this point
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
Reply With Quote
  #2   Spotlight this post!  
Unread 01-21-2010, 09:56 PM
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
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?
Reply With Quote
  #3   Spotlight this post!  
Unread 01-22-2010, 09:51 AM
Jason F Jason F is offline
Registered User
FRC #2198
 
Join Date: Jan 2010
Location: Canada
Posts: 2
Jason F is an unknown quantity at this point
Re: How to program solenoid and compressor?

I am not sure howto get started
Reply With Quote
  #4   Spotlight this post!  
Unread 01-22-2010, 11:40 AM
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-30-2010, 12:51 AM
Derschatten Derschatten is offline
Registered User
FRC #1203 (Pandemonium)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2003
Location: West Babylon
Posts: 31
Derschatten is an unknown quantity at this point
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);
            }
    }
    }
Reply With Quote
  #6   Spotlight this post!  
Unread 01-30-2010, 04:37 PM
bamse bamse is offline
UFO Designer
AKA: Fredrik
FRC #2745 (Some Assembly Required)
Team Role: Mentor
 
Join Date: Nov 2009
Rookie Year: 2009
Location: San Antonio
Posts: 1
bamse is an unknown quantity at this point
Thumbs down Re: How to program solenoid and compressor?

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);
Reply With Quote
  #7   Spotlight this post!  
Unread 02-07-2010, 01:00 AM
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: How to program solenoid and compressor?

Quote:
Originally Posted by bamse View Post
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);
This is not correct, call the Compressor class tell it the digital input and the spike port and it will take care for you.

ex: Compressor myComp = new Compressor(1,1); //That's all you need
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
Reply With Quote
  #8   Spotlight this post!  
Unread 02-07-2010, 01:22 AM
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: How to program solenoid and compressor?

Quote:
Originally Posted by Kingofl337 View Post
This is not correct, call the Compressor class tell it the digital input and the spike port and it will take care for you.

ex: Compressor myComp = new Compressor(1,1); //That's all you need
By default, the compressor is not enabled until you call the start() method on it. This is needed in addition to the creation of a Compressor object.

Quote:
Originally Posted by bamse View Post
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);
Make sure to call start() on the compressor object, and also make sure that it is a class member so it does not go out of scope. Since the example code in post #5 shows no declaration for airCompressor, my best guess is that you're creating a new one each loop.

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);
     }
     ...
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote
  #9   Spotlight this post!  
Unread 02-08-2010, 03:15 PM
synth3tk's Avatar
synth3tk synth3tk is offline
Lead Mentor / Volunteer / TBA
AKA: David Thomas
FRC #7486
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Ohio
Posts: 2,021
synth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond repute
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.
__________________
Quote:
The difference between theory and application is that in theory, theory and application are the same; In application, they are not.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Solenoid Wiring and Compressor Help BurtGummer Electrical 16 02-17-2010 02:25 PM
How do you download a program and have it saved to the c-rio 2560DawgDM NI LabVIEW 12 02-03-2010 08:58 PM
How to download and keep a program on crio zackcool123 Programming 2 02-16-2009 06:22 PM
How to conect solenoids to the circuit board. and how to program it...??? arpitshah Pneumatics 6 01-13-2008 03:06 PM
Teach Genia How to Program and Win a Prize Eugenia Gabrielov Chit-Chat 25 02-25-2005 01:31 PM


All times are GMT -5. The time now is 09:30 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi