Go to Post Note to self for next year, apply physics rather than "well, this SEEMS like it would work." - Karibou [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #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?
  #2   Spotlight this post!  
Unread 07-02-2009, 17:46
Urban Hawk Urban Hawk is offline
Head of R&D and Head of Scouting
FRC #1886
Team Role: Scout
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Urbana, maryland
Posts: 118
Urban Hawk is infamous around these partsUrban Hawk is infamous around these partsUrban Hawk is infamous around these parts
Re: Clicking spike relay while on

the lighting for a spike is as follows:
for a motor:
Orange - OFF / Brake Condition (default)
Green - Motor rotates in one direction
Red - Motor rotates in opposite direction
Off - OFF / Brake Condition

for a solenoid:
Orange - Both Solenoids OFF (default)
Green - Solenoid connected to M+ is ON
Red - Solenoid connected to M- is ON
Off - Both Solenoids ON

Basicly when it switches from green to red the spike is reversing the direction.

from the code what appears to be happening is that it starts off as isOn = false. Then it enters the first part of the code and isOn changes so now isOn = true. then it looks like the program then goes into the next part of the code and then changes it back to false. Are you sure that you are not looping it because the first time it would go through it would do the first half of the code and the next time through it would switchback.
__________________
FEAR THE HAWK!!!
  #3   Spotlight this post!  
Unread 07-02-2009, 18:29
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
Re: Clicking spike relay while on

no, it is programmed right, and it goes orange not red (my mistake), but it clicks back and forth, almost too fast too see, just a split second switch when it is only programmed to be on
  #4   Spotlight this post!  
Unread 07-02-2009, 18:35
BrentJ BrentJ is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Sep 2008
Rookie Year: 2009
Location: Auckland, New Zealand
Posts: 64
BrentJ has a spectacular aura aboutBrentJ has a spectacular aura about
Re: Clicking spike relay while on

Quote:
Originally Posted by NewKid View Post
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:


When all of the isOn {...} code is commented out, then the clicking does not happen, and it behaves correctly.

Can anyone help?
First thing please indent and comment your code.
Indenting code makes it a lot easier to read and look for mistakes especially in next if's , while etc statements.

Also by commenting your code you make it easier for people to see what you mean.

By reading a comment of what you want to do, another person can look at the syntax of your code and see if what you want to do is the same as the code you have written will do.

Off the top of my head I don't know exactly what the mistake is but I would try a few things.


Did you set up a compressor object elsewhere in your code?
Because if you have then this runs in the background and automaticaly turns the compressor on /off.

I think your rel->Set(Relay::kOn); rel->Set(Relay::kOff);
maybe trying to take control from the compressor object.

I would be looking for instances of where the the compressor relay is set on/off. It may be other examples rel-Set() but I think it more likely to be a compressor object.

Hope this helps.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
spike relay problem? Maxpower57 Electrical 15 09-04-2012 19:18
Spike relay question Zack Briggs Electrical 17 19-02-2008 14:48
Spike Relay Wire Gauge sparrowkc Electrical 7 12-02-2008 14:26
Spike Relay Input nwagers Electrical 3 16-07-2002 22:23


All times are GMT -5. The time now is 10:14.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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