Go to Post I decided I would keep coming and it just kept getting more and more fun. By the time build season started going I couldn't have quit if I wanted to ^_^ - Mr. Pockets [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 02-03-2016, 22:24
FRC3220 FRC3220 is offline
Registered User
no team
 
Join Date: Feb 2016
Location: Spangle
Posts: 11
FRC3220 is an unknown quantity at this point
Relay question

So, we've been having problems with some of our relays not working. I'm using the code that they give you for an example, because if it ain't broke, then don't fix it, right? Anyway, It seems like our relay is on (solid orange light all the time), and when I push the button to activate it in TeleOp, we hear it click, but nothing happens. Just to make sure that I'm not going insane, setting a relay to go forward, such as " example_relay.Set(Relay::kForward) " will also turn it on, right? I don't have to have an " example_relay.Set(Relay::kOn) " block nested with it, right? And for the record, it's quite possible that the issue is wiring. I just want to make sure everything is okay on my end. Here's the code, for those of you who need to see it:

Code:
bool forward = stick.GetRawButton(button2);
bool reverse = stick.GetRawButton(button3);
if (forward && reverse) {
	arm_rotator.Set(Relay::kOn); }
else if (forward == true) {         //Do I have to set it on in here, as well?
	arm_rotator.Set(Relay::kForward); } 
else if (reverse == true) {                         //And here?
        arm_rotator.Set(Relay::kReverse); }
else {
	arm_rotator.Set(Relay::kOff); }
Reply With Quote
  #2   Spotlight this post!  
Unread 03-03-2016, 00:03
ghead ghead is offline
Registered User
FRC #3103
 
Join Date: Aug 2013
Location: US
Posts: 13
ghead is an unknown quantity at this point
Re: Relay question

The orange light indicates the relay has power but is 'off', no output. It will turn green when forward and red when reverse. 'kOn' is only used when you initialize a relay with a defined direction, Relay::kForwardOnly for example, instead of kBothDirections.

So you would either use kOn, or you would use kForward and kReverse, depending on how you initialized the relay. kOff is used in both cases to turn off the relay.

So assuming you initialized the relay with kBothDirections, your code would look something like:

Code:
bool forward = stick.GetRawButton(button2);
bool reverse = stick.GetRawButton(button3);

if (forward == true) {
	arm_rotator.Set(Relay::kForward); } 
else if (reverse == true) {
        arm_rotator.Set(Relay::kReverse); }
else {
	arm_rotator.Set(Relay::kOff); }
Reply With Quote
  #3   Spotlight this post!  
Unread 03-03-2016, 00:09
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 357
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
Re: Relay question

How did you initialize the Relay? Did you use just Relay(x) where x is the number staring at 0? That should initialize a relay that can turn on in both forward and reverse.
__________________
Brian K
Team 1225 Robotics Mentor
Reply With Quote
  #4   Spotlight this post!  
Unread 03-03-2016, 00:35
FRC3220 FRC3220 is offline
Registered User
no team
 
Join Date: Feb 2016
Location: Spangle
Posts: 11
FRC3220 is an unknown quantity at this point
Re: Relay question

I only included the relay port on the roboRIO when I initialized it. Should I add kBothDirections? Could that be my problem? Or perhaps it's that first "if" statement. Would skipping the "on" block, and starting with the kForward block like ghead make a difference? Ugh. I wish I could drive to my school, unbag our robot, and run some tests, right now!!!

Last edited by FRC3220 : 03-03-2016 at 00:40.
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


All times are GMT -5. The time now is 13:28.

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