Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Relays not working (http://www.chiefdelphi.com/forums/showthread.php?t=113491)

e10 14-02-2013 15:33

Relays not working
 
We are having an issue getting our relays to work. We are using a spike relay to move a motor. We believe everything is connected correctly, as the light on the relay is on. Thus we think the problem is in our code:

Code:

class RobotDemo : public SimpleRobot
{       
        RobotDrive myRobot; // robot drive syste0m
        Relay feeder;
       
public:
        RobotDemo(void):
                feeder(5, Relay::kForwardOnly)

        void OperatorControl(void)
        {
                while (IsOperatorControl()){
                       
                                    feeder.Set(Relay::kOn);       
                          feeder.Set(Relay::kForward);
                }
        }


Toa Circuit 14-02-2013 16:36

Re: Relays not working
 
Get rid of the line that says
Code:

feeder.Set(Relay::kOn);
and try that.
I've never written that line ever, and all you should need is the feeder.Set(Relay::kForward);

Jon Stratis 14-02-2013 16:51

Re: Relays not working
 
Relay.Value has 4 values: kForward, kOff, kOn, and kReverse. These each do something specific with the relay.

kForward drives it forward - in other words, it connects M+ to your +12V input, and M- to the ground input.

kReverse drives it backwards - M+ to ground, M- to +12V.

kOff turns off the connections - it connects both M+ and M- to ground.

kOn turns on both connections - it connects both M+ and M- to +12V.

In terms of FIRST use with motors, all you really need is off, forward, and reverse. Using it with the compressor, all you need is off and forward.

However, in some low voltage situations (like pneumatic solenoid valves or LED lighting) you can run the ground wire directly into the power distribution board's ground, and run the positive wire to either of the relay outputs.

In the case of a 2-position pneumatic solenoid hooked up to a single cylinder, this means you always drive the relay forward or reverse, and the cylinder will move accordingly - setting it to off or on won't do anything.

In the case of LED lighting, this can allow you to turn on different sets of LED's - for example, forward might turn on red LED's, while reverse turns on blue ones. off would turn them both off, while on would turn them both on.

ekapalka 14-02-2013 17:49

Re: Relays not working
 
It's probably just us, but we couldn't get the relays to work unless we were using a pointer...
Code:

feeder->Set(Relay::kForward);

SuperBK 14-02-2013 20:38

Re: Relays not working
 
You are missing the line
myRobot(1,2)
Under
RobotDemo(void):

and above
feeder(5, Relay::kForwardOnly)

That initializes the robot drive and the feeder

Code:

class RobotDemo : public SimpleRobot
{       
        RobotDrive myRobot; // robot drive syste0m
        Relay feeder;
       
public:
        RobotDemo(void):
                          myRobot(1,2),
                feeder(5, Relay::kForwardOnly)

        void OperatorControl(void)
        {
                while (IsOperatorControl()){
                       
       
                          feeder.Set(Relay::kForward);
                }
        }



All times are GMT -5. The time now is 18:22.

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