View Single Post
  #2   Spotlight this post!  
Unread 02-25-2016, 06:19 AM
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,539
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