View Single Post
  #5   Spotlight this post!  
Unread 11-01-2012, 16:08
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: New to 2CAN and Jaguar

Quote:
Originally Posted by mikets View Post
Wait, I found the scaling code in CANJaguar. It is in packFXP16_16. It means the full range is actually +/- 65536. So like I suspected, the outputValues in jag.Set() should always be in the range of +/- 1.0 and the CANJaguar module will scale it to +/- 65536 and send it to the jags. Then why do we need to multiply 150.0? I am confused.
The actual range depends on the mode. Look at the documentation for CANJaguar::Set.

Code:
/**
 * Set the output set-point value.  
 * 
 * The scale and the units depend on the mode the Jaguar is in.
 * In PercentVbus Mode, the outputValue is from -1.0 to 1.0 (same as PWM Jaguar).
 * In Voltage Mode, the outputValue is in Volts.
 * In Current Mode, the outputValue is in Amps.
 * In Speed Mode, the outputValue is in Rotations/Minute.
 * In Position Mode, the outputValue is in Rotations.
 * 
 * @param outputValue The set-point to sent to the motor controller.
 * @param syncGroup The update group to add this Set() to, pending UpdateSyncGroup().  If 0, update immediately.
 */
Everything you see inside the CANJaguar class is to convert from the WPILib API formats (such as -1.0 to 1.0) into the binary format to send to the Jag. Since in speed mode, the units are RPM, I don't want to control my motor +/- 1 RPM... that's too slow. I set the RPM range in my example to +/- 150 RPM cause it made sense for the mechanism I was sensing with that encoder.

In the case of RobotDrive, it computes a motor output +/- 1.0 based on joystick inputs. If you are not using motors in Percent Vbus mode, then that's probably not a good range. The RobotDrive class allows you to specify a scale value by calling SetMaxOutput(); with a floating point number to multiply by the +/-1.0 values that it computes before they are passed into the Set(); call on each motor.

Hope that's clearer.

-Joe
Reply With Quote