Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Programming a relay in C++ (http://www.chiefdelphi.com/forums/showthread.php?t=71768)

Kage 01-10-2009 11:35 AM

Programming a relay in C++
 
How do you do it? this is probably too general a question, but we just started using C++ for this build season, and we're pretty inexperienced. So we need to know how to properly initialize it, and just basically how to do it. sorry if that's not a good explanation, or if the subject is too broad.

Eric Finn 01-10-2009 03:10 PM

Re: Programming a relay in C++
 
In this season's code, you would do the following:

Code:

Relay myRelay([slot],[chanel],kBothDirections); //initialize the relay in slot [slot], channel [channel], and allow it to move both directions
myRelay.Set(kForward); //turn the relay on in the forward direction
myRelay.Set(kOff); //turn the relay off

Value and Direction are enumerated in Relay.h in WPILib. Be aware that you cannot Set the Relay as kOn if you use kBothDirections as the third parameter to the Relay constructor.

If this isn't enough detail, just say so.

jee7s 01-10-2009 05:51 PM

Re: Programming a relay in C++
 
Since the enumerated members are in the Relay class, you need

Code:

myRelay.Set(Relay::kForward)
in order to set the proper scope for kForward.

Also, since the constuctor defaults to kBothDirections, you don't need to include that parameter.

So, to initialize a relay object called "r41" on DSC 4 relay channel 1 using the default mode (kBothDirections) and set it forward you'd use:

Code:

Relay r41(4,1);
r41.Set(Relay::kForward);

-Jeff


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

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