Kevin Watson's Kick-off Demo Code!

Just out of curiosity,

One of our big mentors is an aviation company. They have a bunch of parts from autopilot systems sitting around. Do you think it is worth trying to make this stuff work, or should we just shell out a couple of hundred for something which works.

Also, has anyone taken a look at RC helicopter gyros? I was searching and found some on a hobby shop site, the even had PWM cables attached. Thoughts?

The gyros used in helicopters are integrated PID controllers. It takes an input from the receiver as the set point, compares it to the internal sensor value, and outputs the PWM signal required to match the rates. There are potentiometers to adjust the gain. As such, they aren’t suitable for integrating the heading because you don’t have access to the raw sensor output. I don’t think they are high precision parts but I don’t know for sure.

Thanks

Thanks a lot Kevin!

Sorry to hear about your home :frowning:

My team didn’t receive the Kit yet but we decided now that we’re going to use a testing plataform and last year’s kit so that we can start our programming tests.

And since we programers were just helping out with other stuff we decided to do a very simple GUI for your code, We’ll be finishing it today and I’ll post here.

Thanks.

I assume this is for the gyro code? If so, the conversions I gave you were in units of degrees, which is too course to use. Rich Petras wanted milliradians (pi radians = 180 degrees), so that’s what the new gyro code will return. I’ve also built in the option of returning tenths of a degree by uncommenting some #defines in gyro.h:



[size=2]/*******************************************************************************
*
* TITLE  gyro.h 
*
* VERSION: 0.2 (Beta)						   
*
* DATE:  12-Jan-2005
*
* AUTHOR:  R. Kevin Watson
*	[email="[email protected]"][email protected][/email]
*
* COMMENTS:
*
********************************************************************************
*
* CHANGE LOG:
*
* DATE		 REV  DESCRIPTION
* -----------  ---  ----------------------------------------------------------
* 21-Nov-2004  0.1  RKW - Original
* 12-Jan-2005  0.2  RKW - Altered Get_Gyro_Rate() and Get_Gyro_Angle() to use
*				   long integers for internal calculations, allowing larger
*				   numerators and denominators in the GYRO_RATE_SCALE_FACTOR
*				   and GYRO_ANGLE_SCALE_FACTOR #defines.
* 12-Jan-2005  0.2  RKW - GYRO_RATE_SCALE_FACTOR and GYRO_ANGLE_SCALE_FACTOR
*				   #defines added for Analog Devices' ADXRS401, ADXRS150 and
*				   ADXRS300 gyros.
*
*******************************************************************************/[/size]
[size=2][/size] 
[size=2]#ifndef _gyro_h
#define _gyro_h[/size]
[size=2]#define TRUE 1
#define FALSE 0[/size]
[size=2]// MILLIRADIANS_PER_TENTH_DEGREE = 349/200
// ADC_BITS_PER_VOLT = 1024/5
// GYRO_RATE_SCALE_FACTOR = ANGULAR_RATE_PER_VOLT / ADC_BITS_PER_VOLT
// GYRO_ANGLE_SCALE_FACTOR = GYRO_RATE_SCALE_FACTOR / SAMPLE_RATE[/size]
[size=2]// default parameters for Silicon Sensing Systems' CRS03
// sensitivity = 20mV/deg/sec
// #define GYRO_RATE_SCALE_FACTOR 625/256 // defaults to 625/256 for tenths of a degree/sec
// #define GYRO_ANGLE_SCALE_FACTOR 25/512 // defaults to 25/512 for tenths of a degree
// #define GYRO_RATE_SCALE_FACTOR 8725/2048 // defaults to 8725/2048 for milliradians/sec
// #define GYRO_ANGLE_SCALE_FACTOR 349/4096 // defaults to 349/4096 for milliradians[/size]
[size=2]// default parameters for Analog Devices' ADXRS401
// sensitivity = 15mV/deg/sec
// #define GYRO_RATE_SCALE_FACTOR 1665/512 // defaults to 1665/512 for tenths of a degree/sec
// #define GYRO_ANGLE_SCALE_FACTOR 333/5120 // defaults to 333/5120 for tenths of a degree
// #define GYRO_RATE_SCALE_FACTOR 5811/1024 // defaults to 5811/1024 for milliradians/sec
// #define GYRO_ANGLE_SCALE_FACTOR 581/5120 // defaults to 581/5120 for milliradians[/size]
[size=2]// default parameters for Analog Devices' ADXRS150
// sensitivity = 12.5mV/deg/sec
// #define GYRO_RATE_SCALE_FACTOR 125/32 // defaults to 125/32 for tenths of a degree/sec
// #define GYRO_ANGLE_SCALE_FACTOR 5/64  // defaults to 5/64 for tenths of a degree
#define GYRO_RATE_SCALE_FACTOR 1745/256  // defaults to 1745/256 for milliradians/sec
#define GYRO_ANGLE_SCALE_FACTOR 349/2560 // defaults to 349/2560 for milliradians[/size]
[size=2]// default parameters for Analog Devices' ADXRS300
// sensitivity = 5.0mV/deg/sec
// #define GYRO_RATE_SCALE_FACTOR 625/64 // defaults to 625/64 for tenths of a degree/sec
// #define GYRO_ANGLE_SCALE_FACTOR 25/128 // defaults to 25/128 for tenths of a degree
// #define GYRO_RATE_SCALE_FACTOR 8725/512 // defaults to 8725/512 for milliradians/sec
// #define GYRO_ANGLE_SCALE_FACTOR 349/1024 // defaults to 349/1024 for milliradians[/size]
[size=2]
void Initialize_Gyro(void);  // initializes and starts the gyro software
int Get_Gyro_Rate(void);  // returns the current heading angular rate of change
int Get_Gyro_Angle(void);  // returns the current heading angle
void Calc_Gyro_Bias(void);  // calculates the current gyro bias
int Get_Gyro_Bias(void);  // returns the current calculated gyro bias
void Set_Gyro_Bias(int);  // manually sets the gyro bias
void Reset_Gyro_Angle(void); // resets the heading angle to zero
void Disable_Gyro(void);  // disables the gyro
void Initialize_Timer_2(void); // initializes and starts timer2
void Timer_2_Int_Handler(void); // interrupt service routine for timer2
#endif

[/size]

-Kevin

It’s not just for the gyro, it’s kind of a general tool

What it does is just that we’ve selected some ‘defines’ that we have seen in your code that we think that should be something that not just us but all the teams are gonna have to change a lot during tests, and also at the competition, so our tool just grab those defines as put it on text boxes so that you can easy alter it without having to go trough all the code and find the right place.

Then you must use MpLab to compile the code.

We’re translating this tool to English and comenting the code.

We’re kind of late because we were having trouble with the Wireless serial device that you’ve mentioned in your site, we can make it work but only at 9600bps so we can’t program our robot using Ifi Loader, can you give us some direction here ?

Thanks a lot

The SMiRF wireless transceivers will only go as high as 38,400 baud, so they cannot be used to program the RC. They are, however, great for sending debugging telemetry back to your computer without a long serial cable.

-Kevin

I’ve updated the PID/Scripting code to include the latest gyro code, additional documentation and data sheets for compatible encoders and gyros. It can be found here: http://kevin.org/frc.

-Kevin