Thread: RELAY!!
View Single Post
  #7   Spotlight this post!  
Unread 03-11-2010, 15:54
Jared Russell's Avatar
Jared Russell Jared Russell is online now
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,077
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: RELAY!!

The joystick axes output a double between -1 and 1. Victors and Jaguars conveniently accept a double value between -1 and 1 as an input.

Relays can be set to kForward, kReverse, or kOff (or kOn, but that doesn't seem to matter here).

So you need to write some code that translates from [-1, 1] to [kForward, kReverse, kOff].

All you need to do is write an if...else statement that checks if the joystick axis is pushed forward, backwards, or is in the center. In other words, is the axis <0, >0, or ==0 (note that you might not want to check if it is exactly zero, since the tiniest bit of movement would make your motor move - you probably want a threshold so that if the stick is within, say, .1 of 0, just call it zero).

EDIT: Aww, Dave - he was getting so close!

Last edited by Jared Russell : 03-11-2010 at 15:56.
Reply With Quote