![]() |
Yaw Sensor
Can someone tell me how to operate a Yaw Sensor?
Where is it hooked up on the robot controller. Digital or Analog. We did printf's to see what settings were occurring as we rotated it around, but the code only ever showed 135..... Help. Thanks, Phil |
Re: Yaw Sensor
the yaw sensor is an analog device - and you have to supply it with power on its +5V pin - you should see it sitting at 127 or 128 when the bot is not turning, and go up to 254 and down to 0 if you turn the robot fast enough
also, make sure you know the axis of rotation for the sensor - it only senses rotation on one axis. |
Re: Yaw Sensor
Quote:
Also, the Yaw Rate Sensor supplied for the 2003 season has a higher angular rate capacity than the sensors provided in previous years. The 2003 sensors had a theoretical (according to the datasheet) maximum of 75deg/sec, while previous years' had a theoretical maximum of 64deg/sec. |
Re: Yaw Sensor
But even with the sensor reading 137, when we move the sensor in ANY direction, tilting up/down, or rotating left/right, no change in the 137 value.....
Thanks, Phil |
Re: Yaw Sensor
If you're patient enough, you can take the sensor off the control system and supply it with 5V, connect GND, and use either a multimeter or an oscilloscope to watch the output to see if it changes at all, or even if the normal output is around 2.66V ((5/254)135).
On the other side of things, you can try to determine whether the analog input to the control system is working properly. You can connect a regular potentiometer to the analog input, and see if the read value changes respectively. If that fails, I would check to make sure that the potentometer works properly, etc. Hope this helps. |
Re: Yaw Sensor
Quote:
|
Re: Yaw Sensor
the yaw rate sensors are analog, and you need to call Get_Analog_Value() on the variable in order to get the actual value. reading it directly won't work (and it looks like that's what you're doing).
also, remember that the analog inputs on the rc are now 10-bit, so without moving the sensor, you should get a reading around 512. hope that helps. |
Re: Yaw Sensor
Quote:
Hold the gyro level and twist it quickly 90 degrees or more in the horizontal plane. Code:
// this assumes in User_Initialization() at least... |
Re: Yaw Sensor
Quote:
Boy am I new to this stuff. Coding no problem, but a Robot isn't a Database. :) Thanks, Phil |
Re: Yaw Sensor
Here is the code from team 492's current robot. It uses the ADXRS150 evaluation board. They are available from Future, but I got ours as samples directly from Analog. The basic code works for any gyro, you just need to adjust the various #defines.
Wiring is simple too. The evaluation board is a 20pin dip. You need to connect two pins to ground and two to +5v and one pin is the output. A standard three conductor servo cable is all you need. I put ours on a bit of breadboard + a socket along with some other stuff. Note, our code is called at 100hz. The Gyro has a bandwidth > 40hz so you want to sample it much faster. It wouldn't hurt to sample at 200-400hz, but 100 seems good enough. 38hz (the 26.2ms loop rate for IFI) is too slow. Also note, below, that our observed scale was more like 200deg/sec range vs the specified 150. The scale changes with temperature, so if you want really accurate results you need to use the built in temperature sensor to compensate. I am going to just calibrate at the competition and trust that the temperature will be reasonably constant over the day. Code:
/********************** Gyro Task *************************************** |
Re: Yaw Sensor
only thing I disagree with on your post is the sensor has a bandwith of 40Hz or so, but your bot is heavy enough that IT wont have a bandwith anywheres near the 26mS sample loop
your motors will not be able to spin the bot around so quick that you need to worry about the bandwidth of the sensor if your bot is jittering and twitching at 38Hz, you've got more problems to worry about than using a gyro :c) |
Get_Analog_Value in an ISR
I want to sample some analog inputs at 4ms.
The first way I tried this was to set up a timer interrupt at 4ms and in the ISR, set a tic4ms flag. Then in the polling loop, whenever the tic4ms flag was set, I'd clear it and run the sampling code. The problem with this is that my main processing, which runs every 26ms, uses about 9ms and I miss some of the 4ms tics. Next try was to read the analog inputs in the ISR itself. I hoped that doing #pragma interruptlow InterruptHandlerLow save=PROD, section(".tmpdata") would save enough context, but it evidently does not - I am getting a smattering of wild data now in the main polling process. First I thought this was because I was calling Get_Analog_Value in the ISR as well as in the main process. Get_Analog_Value uses some SFRs, and they are not saved across the interrupt, so this would be expected to at least give some bad samples if not worse data mangling. But I moved all the analog sampling to the ISR so Get_Analog_Value would be called from only one thread. This did not eliminate the problem. Anybody have suggestions? Also, my assumption is that Get_Analog_Value only runs a few tens of microseconds (15-30 or so) so I can do many of them in a 4ms ISR w/o an overrun problem. This is what it looks like in the pic datasheet. Can anyone confirm this? Thanks for any help. Bill |
Re: Get_Analog_Value in an ISR
Quote:
Team 492 samples the ADXSR150 at 100hz (10ms). Our basic logic is a 1khz timer that increments a byte counter (atomic operation). In the fast loop of the IFI code we check that counter and do stuff when it increments. The fast loop is called often enough to sample the timer directly (e.g. no interrupts) but we used them anyway in case some code in the Autonomous routines took longer than a milli-second to run. Code:
void Process_Tasks(void)Code:
|
Re: Yaw Sensor
Just a heads up... You cant use the gyro from last years kit (very clear... see the QA id's #341, 346, 190). Therefore, you have to use a different one under the custom electronics pricing. The only real viable option is the ADXRS series from Analog Devices, and if you need more then 150 deg/sec, then it will get much harder (the Evaluation Board version of the 300 deg/sec model is just barely over the price limit... you will need to mount 300 deg/sec yourself). Nobody made it very clear in the previous posts, and I didnt know what gyro you were using to begin with.
|
Re: Yaw Sensor
We were going to use last years gyro at "custom electronics cost" but it is a none issue now as we have gone another route.
Dead rec with timing loop on the turn. Thanks, Phil |
| All times are GMT -5. The time now is 14:59. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi