View Single Post
  #1   Spotlight this post!  
Unread 07-02-2009, 16:16
NewKid NewKid is offline
Registered User
AKA: Greg
FRC #1622 (Spyder)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: San Diego
Posts: 2
NewKid is an unknown quantity at this point
Clicking spike relay while on

My team and I have been trying to get the compressor programmed, but it usually clicks when the light is green switching to red for a split second before going back to normal. It does it almost randomly, and does seem to be linked to our code. We have been using a simple on/off trigger so that we can turn the relay on and off, but the clicking happens when the spike should be on. our code is:
Quote:
void compressorTest(Compressor *compr, Relay *rel)
{
static bool isOn = false;

UINT32 psvalve = compr->GetPressureSwitchValue();

if (0 == psvalve)
{
if (false == isOn)
{
isOn = true;
rel->Set(Relay::kOn);
}
}
else
{
if (true == isOn)
{
isOn = false;
rel->Set(Relay::kOff);
}
}
}
When all of the isOn {...} code is commented out, then the clicking does not happen, and it behaves correctly.

Can anyone help?