Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Compressor works in teleop but not autonomous? (http://www.chiefdelphi.com/forums/showthread.php?t=85746)

cybiko123 10-05-2010 19:07

Compressor works in teleop but not autonomous?
 
Hi,

We're having some issues with our compressor in autonomous. compressor.start(); doesn't seem to do anything, but all other code in autonomous works fine, and compressor.start(); works in teleop.

Are we doing something wrong?

buildmaster5000 10-05-2010 20:40

Re: Compressor works in teleop but not autonomous?
 
what we did was put the compressor.start(); line in robotInit() and it worked all the time

biojae 11-05-2010 00:15

Re: Compressor works in teleop but not autonomous?
 
compressor.start() won't start the compressor every time you call it.

It is designed to be called once for every time you stop it.
(it defaults to off)

When you call start, a semaphore is set to true.
This flag is checked twice a second by another thread, and if enabled (from the semaphore) and enabled (from the driver station) and the pressure switch pulls the IO pin to ground it sets the compressor's spike to turn on forward.

The line
Code:

c->Enabled()
is the semaphore that is set by calling start (and stop)

This is the thread that turns on and off the compressor (In C++, the Java version is very similar):
Code:

static void compressorChecker(Compressor *c)
{
        while (1)
        {
                if (c->Enabled())
                {
                        c->SetRelayValue( c->GetPressureSwitchValue() == 0 ? Relay::kOn : Relay::kOff );
                }
                else
                {
                        c->SetRelayValue(Relay::kOff);
                }
                Wait(0.5);
        }
}

This starts right after creating the compressor object.

You only need to call start once in the program.

cybiko123 11-05-2010 13:55

Re: Compressor works in teleop but not autonomous?
 
Hi,

@biojae: We know that compressor.start(); is meant to be called once. The problem is, it doesn't do anything (even with pressure at zero).

In other words, it's not starting even when it should (and again, the compressor works in teleop without an issue).

@buildmaster5000: We're using SimpleRobotTemplate, so we don't have robotInit(). We'll try robotMain() and see what it does.


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

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi