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:


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);
		}
	}

Get rid of the line that says


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);

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.

It’s probably just us, but we couldn’t get the relays to work unless we were using a pointer…

feeder->Set(Relay::kForward);

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

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);
		}
	}