Go to Post Don't let Dean's homework assignment enter into the equation; his homework is about spreading his organization and has nothing to do with you doing what you want to do. - jonathan lall [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 25-02-2016, 02:38
FRC3220 FRC3220 is offline
Registered User
no team
 
Join Date: Feb 2016
Location: Spangle
Posts: 11
FRC3220 is an unknown quantity at this point
Controlling motors with spike relays

I need help mapping a spike relay to the x axis of a joystick to control the rotation of a window motor. I've tried modifying the samples they give you, but to no avail. I haven't been doing this very long. Is there anything I might be overlooking? I'm not getting any errors, just no response from the motors. Is there some way to debug or diagnose my problem?

Thanks in advance!
Reply With Quote
  #2   Spotlight this post!  
Unread 25-02-2016, 06:19
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,495
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Controlling motors with spike relays

A spike relay just has four states (kOff, kOn, kForward, and kReverse IIRC) while a joystick is usually a continuous value from -1 to 1. An easy way if you're trying to do this would be an if-then-elseif-then-else block similar to this:
Code:
if (joystick_input > 0.25)
then relay.set(kFORWARD);
else if (joystick_input < -0.25)
then relay.set(kReverse);
else relay.set(kOff);
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #3   Spotlight this post!  
Unread 25-02-2016, 12:52
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: Controlling motors with spike relays

I tried that, and it still didn't work. I have a solenoid mapped to the y-axis of the same joystick. Our builders built an excavator-like arm, and they want to be able to pick it up with the y-axis of the joystick, and rotate it with the x. The solenoid works, but the relay still doesn't. Is there any way that one is interfering with the other? Here's my TeleOp Periodic Code for the rotation motor:
Code:
 
     double joystick2X;
     joystick2X = stick2.GetX();
     if (joystick2X > 0.1)
        {arm_rotator.Set(Relay::kForward); }
     else if (joystick2X < -0.1)
        {arm_rotator.Set(Relay::kReverse); }
Reply With Quote
  #4   Spotlight this post!  
Unread 25-02-2016, 13:08
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,495
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Controlling motors with spike relays

Your current code doesn't have any way to stop the motor; it needs a final else clause.

Other than that, I don't see the issue in this snippet of code.

The next few things to check:
  • Did you verify that you're getting the values you expect from the GetX()?
  • Is the spike control wire plugged into a relay port (not a PWM or DIO or analog port)?
  • Is relay of the Relay class and initialized to use the same port as the wiring is connected to?
  • Are the wires in the right orientation (both power and control), and are you getting a good connection?
  • Is the fuse on the spike blown?
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #5   Spotlight this post!  
Unread 25-02-2016, 13:50
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: Controlling motors with spike relays

How can I verify the values? Nest a print statement somewhere, maybe?
Reply With Quote
  #6   Spotlight this post!  
Unread 25-02-2016, 14:46
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: Controlling motors with spike relays

cout << joystick2X << endl;

You can look at the console using rioLog in Eclipse or the console log viewer on the driver' station. (click the gear above the log window on the right and select "View Console")

You could also put the value on the smart dashboard:
SmartDashboard:utNumber(joystick2x)
Then switch the driver station to smart dashboard.
__________________
Brian K
Team 1225 Robotics Mentor
Reply With Quote
  #7   Spotlight this post!  
Unread 25-02-2016, 22:33
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: Controlling motors with spike relays

Is there any way I can test my code without connecting to the robot? We had to tag and bag Tuesday, but we still have some work to do.
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 10:01.

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