![]() |
Pneumatics system code
From all of us here at Team 4939, hopefully everybody had a good time. As a rookie team I know we did.
During the off-season we decided to incorporate a very basic pneumatics system into our robot, so that we would be more experienced for next. We were able to figure out where to connect everything (or so we think) according to the instructions, but when it comes to the code, we are just feeling very lost. As a rookie team most of out programmers including myself, have no clue where to go from here. We found a couple resources online, but are just feeling very confused. We believe we have all the parts we just have to get them to work. The system works manually, but when doing it automatically with the joystick we have no clue where to go. Here is our current code Code:
package edu.wpi.first.wpilibj.templates;I will try and upload a picture of how we have the system set up tomorrow. Thanks in Advance |
Re: Pneumatics system code
The compressor is controlled automatically through the Compressor class. Simply pass the Pressure Switch and Relay channels to the constructor and call Compressor#start() in robotInit() and you should be good to go. If desired, it can be disabled with Compressor#stop().
Solenoids come in two varieties: Solenoids and DoubleSolenoids. Single solenoids can be set true or false, while double solenoids are typically set to DoubleSolenoid.Value.kForward, DoubleSolenoid.Value.kReverse, or DoubleSolenoid.Value.kOff. A simple example incorporating your code: Code:
package edu.wpi.first.wpilibj.templates;Also, you might want to check out these articles from the WPILib docs at ScreenSteps Live: http://wpilib.screenstepslive.com/s/...for-pneumatics http://wpilib.screenstepslive.com/s/...ders-solenoids |
Re: Pneumatics system code
I would start by making a list of what all the connected pneumatic components are and what joystick inputs they're supposed to be controlled by. This will make it easier to help you.
By the way, the following two code snipets are identical: Code:
int x;Code:
int x=4; |
Re: Pneumatics system code
Since you are just starting out, I want to point out a tiny error in Domenic Rodriguez ' s code. He named a variable "double" since it represents a double solenoid. However, you can't name a variable "double" in Java as it is a reserved word. Change the name to doubleSol or something else and you will be fine. Be sure to only change the name of the variable and not other occurrences of "double".
Sorry...on mobile or I would repost the code with the fixes in place. |
Re: Pneumatics system code
Quote:
|
Re: Pneumatics system code
Sorry for not replying earlier, but I just haven't been able to test the code that you all helped out with yet, due to exams and such. I should be able to test the system out tomorrow and I will post a reply letting you know how it worked out. I was able to get a picture: http://postimg.org/image/wvu8lykol/ . If that makes a difference to the code.
Also I was wondering something about where to plug the spike in, I pluged one end to the solenoid, and the other end into port 5 on my Digital side car. I noticed in the code that Domenic Rodriguez posted : Code:
// PneumaticsPorts 1, 2, and 3 are labeled. Where should I plug my Spike into? Thank You to all that helped me get this far, just a little more help is needed. |
Re: Pneumatics system code
Quote:
The Solenoid and DoubleSolenoid classes only work for controlling solenoids through the solenoid module. If you are controlling your solenoid through a relay, you will need to use the Relay class instead. Judging by your picture, it looks like you are using a double solenoid. I've never controlled a solenoid through Spikes before, Updated code: Code:
package edu.wpi.first.wpilibj.templates; |
Re: Pneumatics system code
Quote:
The code for a double would use kForward for one direction and kReverse for the other direction. Don't use kOff for this purpose. Wiring a spike to control a 12v-only solenoid via a Relay output on the Digital Sidecar looks like this: ![]() 24v solenoids are usable only through the cRIO Solenoid Module/Breakout, not a 12v Spike relay. |
Re: Pneumatics system code
Quote:
|
Re: Pneumatics system code
I suspect from your photo that it is a 24v solenoid just because that's what has been offered in the KOP, but that style can be either voltage rating. The black end caps will have a voltage printed on them.
If it is a 24v solenoid, then it gets wired to two sets of pins on the Solenoid Breakout and the Solenoid Breakout must get 24v power from the empty connectors of the Power Distribution's special 24v output. |
Re: Pneumatics system code
Quote:
I should be able to use the code above posted by Domenic Rodriguez correct? |
Re: Pneumatics system code
Quote:
|
Re: Pneumatics system code
I tried out the code but it did not work out.
If I am right the spike has a light that is supposed to flash when I pressed the assigned button on my joystick. Also on my driver station when a activate any of the other functions such as (movement, or intake motors) the voltage spikes, is that not supposed to happen when a press the button assigned to the pneumatics spike. None of the things is happening, so I don't know what to exactly do. I am sitting here with my team so any immediate help would be greatly appreciated. |
Re: Pneumatics system code
Please provide a copy of your code for this.
Also, what is the LED on the spike doing? (Blink Status & Color) |
Re: Pneumatics system code
I am using the code that Domenic Rodriguez posted:
Quote:
Here are some pics of the wiring at the moment: http://tinypic.com/view.php?pic=11qp...8#.U6m8OyWmfIU http://i61.tinypic.com/2qkjmuh.jpg Any solutions would be appreciated |
Re: Pneumatics system code
Ok, to do some quick troubleshooting:
First, for my sanity, please add brackets Code:
// SolenoidCode:
spike.set(Relay.Value.kForward); |
Re: Pneumatics system code
"If the spike LED is not solid Green, you have a wiring issue. Either your wire is bad or the spike is on the wrong port. If that does work, it becomes a code issue."
We tried switching all the wires, but not change in the light. Here is the updated code: Code:
package edu.wpi.first.wpilibj.templates; |
Re: Pneumatics system code
Did you try it without any case statements around the relay set? I'm trying to remove the controller from this as well.
Code:
package edu.wpi.first.wpilibj.templates; |
Re: Pneumatics system code
I tried it with the new code that you posted but that did not work out either. No change in light on the spike or change in the system
|
Re: Pneumatics system code
In this pic it looks an awful lot like the PWM cable into the Spike is backwards. Make sure the black wire is near the "B" on the casing. Also check the Digital Sidecar end of this wire, to make sure Black lines up with (-) (Red with + and White with SIG).
Edit: According to your code, it should be in Relay output 4. Also note: the socket in Spikes and Victors can be a little funny - make sure the connector is properly and snuggly seated all the way down into the socket. The solid orange light on the spike means it's being commanded to do nothing, which is certainly the case if there is no proper signal coming in. |
Re: Pneumatics system code
No I'm becoming puzzled. Can you check your digital Side Car to ensure all lights are operating correctly
http://wpilib.screenstepslive.com/s/...tem-components Are you able to control the drive motors? |
Re: Pneumatics system code
Quote:
1. Your double solenoid valve is wired incorrectly. Each end of the valve is one solenoid, each of which has a red wire (+, positive) and a black wire (-, negative). Make sure these wires are connected to the spike exactly as shown in this diagram. Right now you are doing something totally different with those wires, which wouldn't work even if the Spike were working properly (it's not, due to 2 below). You should have a red wire on each of the M+ and M- terminals on the spike, and then both black wires should connect to the GND terminal on the Spike. 2. As I posted above, ensure all PWM cables (for lack of a better name - the grouped black, red, and white wires) are inserted in the right direction. In general: B means black; (-) means GND which is always black (or maybe brown or blue ... ) + means hot which is always red, and SIG is signal which is usually white. |
Re: Pneumatics system code
Ya all the motors are working.
Here is a pic of the sidecar at the moment: http://i58.tinypic.com/ohrara.jpg The relay lights don't seem to be steady or blinking, but everything else seems to be fine. I also changed the port to 7 for the spike on request of my team. Code:
package edu.wpi.first.wpilibj.templates; |
Re: Pneumatics system code
If I'm seeing that right, I think I found the issue. The Spike must be plugged into the Relay Ports on the Side Car. You have it plugged into the PWM ports.
|
Re: Pneumatics system code
I rewired the solenoid and spike to the way that was suggested, and we checked the PWM cables and still no fix, the light is still red.
Could it maybe be the code? Can someone check that and reply back. |
Re: Pneumatics system code
Red or Orange? If Red, that means it's working (and the colors in the guide I consulted were backwards).
|
Re: Pneumatics system code
We plugged the spike into the Relay ports. But the light is still orange in the spike. Any suggestions
|
Re: Pneumatics system code
When we connect the spike to the Digital I/O the solenoid lights up, but the spike's lights turn off.
|
Re: Pneumatics system code
When we put it into the Digital I/O and we move the wire around the light on the spike changes from green, to orange, to red for 2 seconds, and when we push the wire in all the way the spike has no color. And all this is without me turning on the driver station. The spike does not work when we plug in to the PWM section, or the relay section of the sidecar. We don't know where to go from here. Any help would be appreciated.
|
Re: Pneumatics system code
It needs to be plugged into the Rleay section. Lets go from there. By plugging it into the DIO, you're setting it to reverse, as the reverse pin in the Spike is getting the 5V from the DIO. Lets try setting it to reverse in code while it's on the relay panel.
Code:
public void operatorControl() { |
Re: Pneumatics system code
Nothing different happened even though I changed the code, also the lights on the solenoid turned off.
|
Re: Pneumatics system code
Off? Ok, it sounds like you have a bad spike relay. Replace the spike with a different one and we'll see what happens. Also, what are teh LEDs on the digital side car above the relay section showing?
|
Re: Pneumatics system code
Changed spike, no change. No LEDs lit on sidecar.
|
Re: Pneumatics system code
We changed the spike but nothing different happened.
Here is how our sidecar looks right now: http://postimg.org/image/xbjxvkuln/ |
Re: Pneumatics system code
Out of curiosity, have you tried hooking up your compressor yet? If the relay for your compressor is also not working, you may have an issue with your Digital Sidecar.
|
Re: Pneumatics system code
Is that side car picture with or without your code in Teleop?
|
Re: Pneumatics system code
Quote:
|
Re: Pneumatics system code
Quote:
The picture is with the robot on and the code loaded, but not with teleop activated. We could turn on teleop and take another picture if you would like. |
Re: Pneumatics system code
Quote:
All relay outputs (and all other outputs, for that matter) are disabled when the robot is not enabled from the driver station. All of these tests of whether the spike and solenoids are receiving a non-neutral signal won't do any good unless the driver station has enabled Teleop mode. |
Re: Pneumatics system code
Quote:
http://postimg.org/image/nltuevm3n/ |
Re: Pneumatics system code
The image isn't loading for me. Can you confirm the link is working for you?
|
Re: Pneumatics system code
Quote:
It was working for me, but I tried using a different website. Here is the new link: http://s13.postimg.org/xvw9e4bzb/photo2.jpg |
Re: Pneumatics system code
I'll run down the whole chain here to try to locate the issue. If any these fails, don't go any further, you'll need to fix that problem before moving on.
1. Are other outputs working? For example, can you drive with Teleop enabled. If so, keep the robot in this mode (Teleop Enabled) for all other tests. In any disabled mode, all outputs are disabled. Additionally, your code only runs in Teleop Enabled. 2. What is the latest code you have compiled and deployed? This code should be declaring a Relay object on port 7, and then in OperatorControl() it should set the value to something other than kOff (kReverse or kForward). 3. If the above is true, do the LEDs on the Relay bumper show anything, while in Teleop Enabled? According to the link given previously, a relay output's LEDs will be red for reverse, green for forward, off for off. 4. Now with the relay output working properly, make sure the Spike is wired correctly to the relay output and to the PD board. Does the Spike's LED match the Digital Sidecar's relay LED (again, in Teleop Enabled)? 5. Are the solenoid wires connected appropriately to the Spike? If so, does one of the solenoids light up (again, in Teleop Enabled)? 6. ... there will be more but let's get through those first |
Re: Pneumatics system code
Quote:
|
Re: Pneumatics system code
Quote:
Another thing to check: Are there any errors appearing on the diagnostics tab of the driver station? You can click Clear Errors to see if any new ones are being reported at the moment. Do this in Teleop Enabled as well. It might be that one of your safety loops is timing out, locking up your outputs. However, you report the other outputs working, so I'm not sure how this could be... Do you have a multimeter on hand? It might also be worthwhile to unplug the cable from the spike and probe its ends, to see if the digital sidecar is sending an output despite its LED state. |
Re: Pneumatics system code
Quote:
These are the errors that show up on driver station after I click clear : Code:
WARNING <Code> 44008 occurred at FRC_NetworkCommunications <radioLostEvents> 3178.632 <radioSeenEvents>We are getting 3 V on PWM section, 0 V on the relay section, and 0 V on DIO. Correction: We are getting 4 V on DIO |
Re: Pneumatics system code
Any help with this issue would be greatly appreciated.
Also my team is pressuring me to re-check the code, because they think that is the case. Here is the current code that I am running: Code:
package edu.wpi.first.wpilibj.templates; |
Re: Pneumatics system code
This line...
Code:
compressor.start(); // Relay port 1Code:
spike.set(Relay.Value.kReverse); // Relay port 7 |
Re: Pneumatics system code
Quote:
Quote:
On the relay output, is this measured between one of the signal wires (A or B) and ground (-) while Teleop is enabled? Make sure to measure both A and B relative to ground since which one is active depends on whether you are commanding forward or reverse. If you are not enabled, both will of course be off. |
Re: Pneumatics system code
We tried switching the ribbon cable that connects to the CRIO, and still no reply. The voltage is still dead. We really doubt that the relay section of the sidecar is the only thing disabled, because everything else is working. We measured voltage with teleop enabled as well. We don't know where to go from here.
We don't have a spare sidecar, so any other solutions would be greatly appreciated. |
Re: Pneumatics system code
Quote:
|
Re: Pneumatics system code
A and neg, B and neg on relay and no voltage.
Red and black, white and black, red and white on wire coming from relay, zero voltage. All other parts of the SC work perfectly. No Color on LEDs for relay, never seen them on, but never used the relay either. |
Re: Pneumatics system code
Quote:
|
Re: Pneumatics system code
Yes we did test all of our outputs, and it is very odd indeed that only the relay section is not working on the sidecar. By the way we are able to drive the robot.
Unfortunately we are about done for the season, and won't be looking into replacing this sidecar, for the rest of the Summer. When we come back in September a new sidecar will be a priority, and hopefully that fixes the problem. For now I would like to thank all the people who took out the time to help us try and solve this issue. Before we end this thread I just wanted to ask, if a pneumatics module would be more reliable in this type of situation? Thank you once again and have a great summer break everybody. |
Re: Pneumatics system code
Quote:
Both the solenoid breakout and the sidecar are honestly pretty reliable, but the solenoid breakout on the cRio will only power the solenoids. You still need a relay output and a spike to power any onboard compressor. If you're referring to the new PCM for next year, it's hard to say before we get our hands on the details, but I'm sure it will be more than capable as well. Perhaps you could remove the casing and do some more inspection of the circuit board with your DMM, referencing the schematic. The behavior does seem a bit curious, and I feel like we're missing something... |
| All times are GMT -5. The time now is 17:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi