Hey! Our team is in need of code that will run a tank drive and a compressor for pneumatics. Any help and code would be appreciated, since we are new at pneumatics stuff. Thanks in advance.
The suggested code is simply to read a digital input from a pressure switch and copy its value out to a Spike wired up to the compressor. The pressure switch supplied in last year’s kit of parts has two set points, turning on at about 95 PSI and off at about 115, so you don’t have to worry about fancy programming unless you really want to.
I believe the default code wants the compressor on relay 8 and the switch on digital input 18, but don’t take my word for it without checking first.
The default code is also already set up for tank drive. I don’t remember which joystick inputs or pwm outputs it wants. Read the comments in the code; they are very helpful.
if you dont want to just use the default code and would rather write it yourself to fully learn how it works, you can do something like this…
Put a line in the default routine that will call a function that will check the compressors pressure (whether the pressure switch is on or off).
If the switch’s input goes high, turn on the compressor. Then when there is enough pressure the switch will change states and you can turn the compressor off.
In our program, we made “Compressor” an alias for a relay output (Relay 3 in our case), and “CompSwitch” an alias for the digital input the pressure switch was on. You can code these lines in the “user_routines.h” file with the syntax
#alias NewName OldName
Our Compressor checking function looked like this.
void CheckComp(void)
{
if(CompSwitch == 1)
{
Compressor = 1;
}
else
{
Compressor = 0;
}
}
I didn’t know #alias was a valid preprocessor directive. I thought it would be
#define NewName OldName
I tried checking the default code and I couldn’t find the compressor code. Where is it exactly? I’m new at this.
Line 353 of the newest version of user_routines.c. Its only one line so its easy to miss. Requires the compressor to be connected to relay output 8 and the pressure switch to digital input 18.
relay8_fwd = !rc_dig_in18; /* Power pump only if pressure switch is off. */
I hate to be the search NAZI but please attempt to read through the search results. I started a thread almost identical to this one last week.
Sorry for ranting, but i see the mod’s point
Marcus