FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

programming the compressor

I have set up the default FRC arcade program and have set up a solenoid to actuate a cylinder in teleop and in autonomous.  I have also deployed the solenoid with compressor example in labview and it works fine, so i know that the compressor and associated spike and wiring work good.  I would like to incorporate that vi into my current robot main vi as described above.  Can anyone give the steps to do that?  I am a neophyte so need some pretty good directions,  Thanks much

John

0 Kudos
Message 1 of 10
(9,440 Views)

Have you given this a try and run into specific problems?  Have you looked through the LabVIEW tutorials available here?  There's a lot of information available.

The basic steps you need to take are:

1) Open the references in Begin

2) Put the code to trigger the solenoid in TeleOp (and Autonomous, if necessary)

3) Close the references in Finish

If you take a look at Begin, you'll see that it already opens a bunch of references (the "Open" functions), then assigns them names and stores them in a registry (the "Registry Set" functions).  You can do the same for all the references in the compressor example.  You can even copy-paste most of it from the Compressor example, except that you'll need to put in the Registry Set functions yourself.  The name of the reference assigned in the registry doesn't matter, so long as you're consistent.  Inside TeleOp, you use the Registry Get functions to get the reference to the solenoid, and the compressor if necessary.  To trigger the solenoid, you'll probably want to use a joystick button instead of a front-panel button.  Finally, in Finish, again use the Registry Get functions to get the references and close them, following the same pattern as the code already in Finish.

0 Kudos
Message 2 of 10
(4,059 Views)

so have opened a registry in the begin vi and the compressor started up fine,  but did not shut

off when it reached the 100 Psi.  how might i wire the compressor to shut off? can i attach my begin vi

and teleop vi to show you?

thanks john

0 Kudos
Message 3 of 10
(4,059 Views)

Yes, you can attach your VI.

The compressor shut-off is determined by the pressure switch, which must be wired into a digital input channel.  The limit is around 150psi, not 100psi.  In your LabVIEW code, this should be set up the same way it is in the compressor example, although you should use a constant rather than a front-panel control to select the digital input channel.  To make a front panel control into a constant, right-click on the control's block diagram terminal and choose "Change to Constant."  If the compressor shut off properly when running the compressor example, copy the working code.  If the compressor did not shut off properly when you ran the example, then there's probably a problem with the way you wired the switch.

0 Kudos
Message 4 of 10
(4,059 Views)

Thanks for the quick reply> My pressure switch actually cuts out at about 120 psi. I have tested it with the example and that is when it cuts out.

I think i did change the constant values, but being a real newby at this i may have left something off.

I have attached my begin vi, the teleop vi and the independent vi.

thanks much

Download All
0 Kudos
Message 5 of 10
(4,059 Views)

Hi John,

If you are using slot 4, channel 1 for the pressure switch and relay 1 for the spike, then it looks like you've wired the constants correctly. Looking the rest of the code, you probably don't need to have the Compressor Start VI in the teleopVI. Since the teleop VI is called repeatedly (once during each iteration through the Robot Main loop), and you only need to call the Compressor Start VI once at the beginning.

Are you noticing that the compressor doesn't shut off while you're in the autonomous mode or in the teleop mode or both?

Also, just to clarify, are you expecting the compressor to shut off at 100 or 120psi? Doesn't it ever shut off while you're running the code?

~Olivia

NI FIRST Support

0 Kudos
Message 6 of 10
(4,059 Views)

HI Olivia,   well after getting rid of the compressor vi in the execute and finish

it worked fine,  i only have the compressor in the begin vi.  Well it works fine in

teleop. In autonomous the compressor and motors run for the short time and then

they both stop,  i guess i might have to set up the compressor to run in autonomous

first and then the motors,   would you want to help me with that??

thanks john

0 Kudos
Message 7 of 10
(4,059 Views)

In Finish, you should be still be closing the compressor - and that should not have any effect on anything else, other than properly cleaning up resources when you stop the robot code.  I'm not sure there's actually a problem if you don't do it, but it's a good habit to close references that you open.

When you say that the motors and compressor run for a short time, does it make it through your entire autonomous sequence once?  At the moment, as soon as your sequence finishes, the autonomous loop will stop running (in the Fire Sol case, you wire true to the while loop stop condition).  Once autonomous finishes, the watchdog will no longer be fed, and the motors and compressor will stop.

0 Kudos
Message 8 of 10
(4,059 Views)

yes it make is through the entire autonomous sequence one time,  and yes the sequence stops when

it reaches the stop,  I believe i just need to maybe put a delay loop at the beginning to allow the compressor

fully air up until the nason switch stops the compressor,and then allow the motors to move.  right?

thanks John

0 Kudos
Message 9 of 10
(4,059 Views)

A delay at the beginning of the autonomous will do it.  Alternatively you could wait until the pressure switch trips, which would indicate that the compressor has reached full pressure.  I think there's a "Compressor Running" VI that provides that information; if not, you could try reading the digital input directly (I suspect you can unbundle the digital input reference from the compressor reference, but I can't confirm that at the moment).  If you want to keep the compressor running after your autonomous completes, but before TeleOp starts, then you'll need to keep the autonomous loop running so that the watchdog will continue to be fed.  You don't ever need to stop the autonomous independent loop because it will terminate automatically when the autonomous period ends.

0 Kudos
Message 10 of 10
(4,059 Views)