Pneumatic Coding Problem

Hello All FIRST Teams who read this.

My question goes out to the programmers. I was wondering if anyone knew a line of code that we could use to shut our compressor off once the pressure on the pressure guage reached 115psi and turned it back on if it dropped to around 30psi. our mapping is as follows:

digital_io_out17 /Compressor/
digital_io_out18 /Pressure Guage/

If someoue could help us that would be great!

Thanks alot guys

//~!AaRoN!~

]

I presume you mean the digital pressure switch? If you are, this code is really obvious and I’m sure you’ll figure it out if you just think about it. I’ll give you a hint: if

if…:slight_smile: yesh, that’s what it is, lol… ok so…uhm, tell me if this is right?
if digital_io_out18 = 115;
then…uhm…? lol sorry i’m not THE greatest with C…
hmm…see i was looking through trying to find a list of acceptable codes in C for robotics but i coudn’t seem to find a list so I’m tryin’ to figure it out…but you can use then statements…correct…?

Thanks

30psi? You wont be able to do much of anything with 30psi but if you really want it to kick in at 30psi you are going to have to use the pressure transducer and a few if statements. If you want to use the pressure switch it switches off at about 115 and back on down around 80-90 (I think). The code for it is in the default user_routines.c

The line of code that you need is already in the default code. Connect the switch to digital I/O 18, and the compressor to relay 8. You CANNOT power the compressor with a digital I/O pin.

The pressure switch is connected to a digital input/output. So it can not have a value of 115, or even 30. It can only have a value of 1 or 0. So when the pressure reaches 115 psi is sends a signal (either 1 or 0, i don’t know) and when it drops down to 95 psi it sends the opposite signal. The only way for you to read the exact pressure value is to add an additional analog sensor to measure the pressure. But why would you want to turn the compressor on at only 30 psi? That’s the minimum pressure needed to run a solenoid! Wouldn’t you want to keep your pressure at least half the maximum allowed value?

if digital_io_out18 = 115;
then…uhm…? lol sorry i’m not THE greatest with C…
hmm…see i was looking through trying to find a list of acceptable codes in C for robotics but i coudn’t seem to find a list so I’m tryin’ to figure it out…but you can use then statements…correct…?

I think that you are just learning c are you not? you have experience with VB or Qbasic do you? that will help you but C isn’t the same…
when you make an if statement you don’t use a then statement like in BASIC.

Take a couple hours and read some documentation. On this site is the official Programming reference PDFs they have code that is specific to the FIRST controller. the 2004 version is what you want there is no 2005 edition. look on page 19 in the gray code box it shows an if statement for an input and a pwm.

http://www.ifirobotics.com/rc.shtml#Programming

A genecic c programming book would be a worthwhile buy.

Have fun you about to become a professional C programmer!

lasoaaro,

There are a few quick things you need to be aware of:

Your compressor should be hooked up to a “Relay” output, not a digital output. On your robot controller, you will see plugs labelled “Relay Outputs.” These should be wired to a SPIKE Relay module, which in turn should be wired to your compressor.

The SPIKE driving the compressor should NOT be wiring to a Digital Output as you have mentioned.

Additionally, the Nason Pressure Switch should be wired directly to a Digital Input (not output as you stated - they are the same plugs, but you can configure them to be inputs OR outputs in software). Again you will see plugs marked “Digital In/Out” on the robot controller. Once everything is wired correctly, the correct code to use should be:



relayX_fwd = rc_dig_inYY;


Where X is the Relay Output for the compressor, and Y is the Digital Input for the Nason Pressure Gauge.

I noticed you are located in Peterborough. I don’t know if it’s feasible to visit Toronto, however if you are having programming difficulties, contact the director for the Regional(s) that you are attending, and they will be able to hook you up with a veteran programmer to assist you, or to arrange a time to visit a nearby team for help.

-SlimBoJones…

Why in the pneumatics manuel does it state

No specific Digital Input Port is designated for the pressure switch. The Robot Controller must be programmed to react to the Input Port that is connected to the pressure switch

While in the standard progamming 2.2 and 2.4 it says

digital_io_18 = INPUT; /* Used for pneumatic pressure switch. */

And

relay8_fwd = !rc_dig_in18; /* Power pump only if pressure switch is off. */

???
This is the code that comes pre-programmed into the bot… so why in the manual does it deny it?

this doesnt work for us any suggestions

Doesnt work??

Check List:

  1. Pump hooked up to a spike relay, hooked up to relay header 8
  2. Pressure switch wired between ground and signal on a pwm cable hooked to dig_in 18
  3. no rogue programming activitys
  4. bot turned on

This should work fine, when the pneumatics get up to 115psi then it shuts off and resumes at 95psi, cant think of any reason why that wouldnt work…

What the manual means is you can move those around to any digital input and relay combination you choose. The default code is only providing a suggested location, not a required location.
For instance, our team needed digital input 18 for a multi-bit binary switch, the default pressure switch input was in the way (for deeper programming reasons), so we moved the pressure sensor to a different digital input.