|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
||||
|
||||
|
Re: Yaw Sensor
Quote:
Quote:
-Kevin |
|
#17
|
|||||
|
|||||
|
Re: Yaw Sensor
Quote:
For development, we used the BEI unit from last year. Except for a different scale factor, the software should be the same, except also that the AD units saturate at much higher rates (that's goodness) and have corresponding less resolution (badness but not significant to me). So even though I won't have the AD unit before competition, we'll change the wiring and socketing for it today, and hopefully I can just plug it in at the competition, change a constant, and be up and running. Bill |
|
#18
|
|||||
|
|||||
|
Re: Get_Analog_Value in an ISR
Quote:
Your code suffers in a way I was trying to avoid, but may well be insignificant. But here's my issue with it anyway: the "fast" process executes really often, as you say, probably well in excess of 100 kHz, but clearly depending on what you do in it, EXCEPT when data is ready from the master processor. Then the "slow" process is called, and the "fast" process doesn't get called at all while that is happening. In my case that's about 10ms, so I miss a couple of the 4ms interrupts. You code partly deals with this problem, since it counts up 1ms interrupts and later uses them all up, even if more than 10 of them happened without any "slow" process service. So what will happen in your code, if the "slow" process is longer than 10ms, is that sometimes the 10ms code will get called at different than 10ms intervals, causing some jitter in your sampling rate. You'll get the right number of calls, just not at precise intervals. If your slow process does not exceed 10ms, your code is perfect. In my case the desired sample rate was 4ms, and I couldn't get the "slow" code to run that fast, so I miss samples. I should at least switch to your interrupt counting method so as not to miss samples, only have some delayed. Hope this long post was not too incoherent. Thanks for the code snippet. Even though it's not what I wanted, it's an improvement over how I'm doing it and I'll use it if I can't solve the problem another way. Bill |
|
#19
|
|||
|
|||
|
Re: Get_Analog_Value in an ISR
Quote:
|
|
#20
|
|||
|
|||
|
Re: Yaw Sensor
Quote:
Also, pay attention to the spec sheet for those devices. You can extend the 150's range up to 4x - that is 600 deg/sec. My team has found the 150/sec adequate for even vigorous spins (i.e. bouncing off things). |
|
#21
|
|||
|
|||
|
Re: Get_Analog_Value in an ISR
Quote:
I essentially re-wrote all the IFI analog stuff to make it smaller (and to understand the PIC): From "sensor.h" Code:
enum AdcValues
{
Gyro,
ArmPositionFeedback,
szAdcVal
};
Code:
//*************************** ADC Task ****************************************
// Note: OpenADC configures all the input port bits appropriately.
// Individual conversions, however, just reset the ADC hardware
// as the ADC turns off periodically for some unknown reason.
void Init_ADC_Task(void)
{
OpenADC( ADC_FOSC_RC & ADC_RIGHT_JUST & (~szAdcVal),
ADC_CH0 & ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS );
}
int GetADC(enum AdcValues chan)
{
ADCON1 = ~szAdcVal & 0x0F; // Configure # channels and vref
ADCON2 = 0x80 | 0x03; // Right Justify & internal RC clock
ADCON0 = (chan<<2) | 0x01; // Set channel and turn on.
Delay10TCYx(10); // Let things settle
ConvertADC(); // Start conversion
while (BusyADC()); // Wait conversion done
return ReadADC(); // Return word
}
|
|
#22
|
|||||
|
|||||
|
Re: Get_Analog_Value in an ISR
Thanks Larry. I've changed my code to process an interrupt count outside of the ISR, following the method in your earlier post of counting up interrupts in the ISR and counting them down in the main thread. Even with the jitter this introduces, the gyro is now performing very nicely.
We have been doing much in haste lately, and I multiplex across all the tasks on the build team. So I have not yet taken time to do much optimization of code, or to understand how we're managing to use 10ms. We do table lookup and interpolation for a couple of math functions (arctan and sqrt), but these are 64 entry tables and using a binary search (6 compares per lookup) so I don't think they're consuming a lot of time. The other thing is I do some arithmetic in 32 bits where I know with more careful planning, I could use smaller variables. This is clearly eating up some time too. Maybe after we ship tomorrow I'll have time to scrub the code good. Bill |
|
#23
|
|||
|
|||
|
Re: Yaw Sensor
32 bit math will chew up time. With the AVR processors (my fav) 32 bit floating point is marginally slower than long, so I tend to use float for stuff that might need several scaling operations with integer math. I suspect something similar might be going on with the PIC. The nice thing about float is that scaling comes for free (with caveats, of course).
You must be doing wheel encoder odometry. I skipped the trig stuff and just use the Gyro for heading and the wheel encoders for velocity control and overall distance traveled. We do odometry (using the heading and distance) off line (via the dashport) and, apparently, the PC tracks the actual robot position pretty well. Good luck! I ship in the next hour - and I am GLAD to have it gone! |
|
#24
|
|||
|
|||
|
Re: Yaw Sensor
Quote:
Also I found the 300 deg/sec gyro (evaluation board model) on the Digikey site for $75.00 (300 deg/sec gyro - click here and then on "Search again"), so it is legal to order it from Analog Devices for $50.00. See http://www.analog.com and enter "ADXSR300EB" or "ADXSR150EB" in the search field, depending on which version you want. Either way, make sure you get the EB (Evaluation Board) version. Otherwise, you wind up with a tiny (7 mm square) surface-mount chip with no leads. I have several of them to return to Digikey. |
|
#25
|
||||
|
||||
|
Re: Yaw Sensor
Quote:
or you could have your bot read the zero value at some point when you know the bot is not running, like when its disabled by the comp port at the start of the match. |
|
#26
|
|||||
|
|||||
|
dynamic zero point determination
Quote:
Since you mentioned it, I wonder how stable you other guys are finding the zero point to be. The 100ms correction computed as above varies by about +/- 10% (100 to 120). I haven't tried to determine if this is because of routing the cable near noise sources or is just the nature of the gyro. Would like to know others' experiences. In your case Ken, since you're immediately dividing by 4, a +/- 10% variation would only be +/- 1 or 2 I guess. Bill |
|
#27
|
||||
|
||||
|
Re: Yaw Sensor
keep in mind - where is your power switch on your bot?
if the operator bumps the bot while/after turning it on, the gyro will read the motion as the zero point I am thinking of using the 'disable' variable to know when the bot is not yet running, and taking the zero point then, assuming this is before the match starts and auton is not yet running. |
|
#28
|
|||||
|
|||||
|
Re: Yaw Sensor
or you could get a continously running avrage from when its turned on to when its enabled and take that as the zero point. thats pretty much error free unless your in california
![]() |
|
#29
|
|||
|
|||
|
Re: Yaw Sensor
Any of you who are using the ADXRS150EB should keep in mind that sampling faster than 40 Hz is useless. According to the ADXRS150EB datasheet, the evaluation board contains components that set the bandwidth to 40 Hz. Sampling more frequently won't do you any good and increases the likelihood that you'll sample and integrate random electromagnetic interference.
|
|
#30
|
|||
|
|||
|
Re: Yaw Sensor
Quote:
Last edited by seanwitte : 29-02-2004 at 21:53. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Anyone know where to buy a spare yaw rate sensor? | Jim Meyer | Technical Discussion | 11 | 30-03-2003 21:18 |
| Yaw rate sensor pin-out | GregT | Electrical | 8 | 18-02-2003 00:07 |
| Yaw Rate Sensor to 90 degrees? | Bruce C. | Programming | 4 | 11-02-2003 00:36 |
| yaw sensor | CHSguard72 | Electrical | 1 | 06-02-2003 01:44 |
| Yaw Rate Sensor | ImmacGirl_03 | Technical Discussion | 2 | 10-12-2001 15:15 |