Go to Post The toughest regional is always the one you are competing in! - AcesPease [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-01-2009, 11:35
Kage's Avatar
Kage Kage is offline
1st year junior mentor :)
AKA: Kage
FRC #0238 (Cruisin' Crusaders)
Team Role: Mechanical
 
Join Date: Dec 2008
Rookie Year: 2006
Location: Manchester
Posts: 125
Kage is just really niceKage is just really niceKage is just really niceKage is just really nice
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 10-01-2009, 15:10
Eric Finn's Avatar
Eric Finn Eric Finn is offline
Registered User
FRC #0166 (Chop Shop)
Team Role: College Student
 
Join Date: May 2006
Rookie Year: 2005
Location: Merrimack, NH
Posts: 101
Eric Finn has a spectacular aura aboutEric Finn has a spectacular aura about
Send a message via AIM to Eric Finn
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.
__________________
It always takes longer than you expect, even when you take into account Hofstadter's Law.
--Hofstadter's Law

Reply With Quote
  #3   Spotlight this post!  
Unread 10-01-2009, 17:51
jee7s jee7s is offline
Texan FIRSTer, ex-frc2789, ex-frc41
AKA: Jeffrey Erickson
FRC #6357
 
Join Date: Nov 2007
Rookie Year: 1997
Location: Dripping Springs, TX
Posts: 297
jee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond repute
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
Reply With Quote
Reply


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
Programming a single relay to two buttons in easyC Pro? Gizmo2417 Programming 1 17-02-2008 17:10
Easy C Relay Programming Team_486 Programming 1 26-03-2007 15:01
Pneumatics (Spike Relay, Solenoid etc.) Programming oceansidehs Programming 8 10-02-2007 13:58
Relay Programming Questions... comwiz7 Programming 11 21-02-2006 13:04
Relay Assignments MulletFish Programming 9 27-01-2005 14:15


All times are GMT -5. The time now is 09:58.

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