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?