Go to Post I'm about to brain myself on a wall in frustration! - pfreivald [more]
Home
Go Back   Chief Delphi > Technical > Motors
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-02-2004, 21:02
Phil_Lutz's Avatar
Phil_Lutz Phil_Lutz is offline
Phil Lutz
#0851 (Froggers)
Team Role: Mentor
 
Join Date: Jan 2004
Location: El Segundo, CA
Posts: 67
Phil_Lutz is on a distinguished road
Send a message via Yahoo to Phil_Lutz
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
  #2   Spotlight this post!  
Unread 11-02-2004, 21:13
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
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.
  #3   Spotlight this post!  
Unread 11-02-2004, 21:27
FotoPlasma FotoPlasma is offline
\: |
no team
 
Join Date: Jul 2001
Rookie Year: 2001
Location: San Jose
Posts: 1,900
FotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond repute
Send a message via AIM to FotoPlasma
Re: Yaw Sensor

Quote:
Originally Posted by KenWittlief
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.
None of the FIRST-supplied Yaw Rate Sensors I have had the privilege to play around with have had different neutral outputs. Some have been upwards of 140, while others have been below 110. If you want to effectively utilize any of these Yaw Rate sensors, you'll have to find out what the neutral output is, and use that as your static state. This will limit the sensing ability of the sensor in one direction, while increasing the sensor's ability in the opposite direction (however slightly, in either case, depending on the deviation from "normal").

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.
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos
  #4   Spotlight this post!  
Unread 11-02-2004, 21:31
Phil_Lutz's Avatar
Phil_Lutz Phil_Lutz is offline
Phil Lutz
#0851 (Froggers)
Team Role: Mentor
 
Join Date: Jan 2004
Location: El Segundo, CA
Posts: 67
Phil_Lutz is on a distinguished road
Send a message via Yahoo to Phil_Lutz
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
  #5   Spotlight this post!  
Unread 11-02-2004, 21:39
FotoPlasma FotoPlasma is offline
\: |
no team
 
Join Date: Jul 2001
Rookie Year: 2001
Location: San Jose
Posts: 1,900
FotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond repute
Send a message via AIM to FotoPlasma
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.
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos
  #6   Spotlight this post!  
Unread 11-02-2004, 21:50
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: Yaw Sensor

Quote:
Originally Posted by Phil_Lutz
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.....l
What part are you using?
  #7   Spotlight this post!  
Unread 11-02-2004, 22:34
mattf mattf is offline
Registered User
#0168 (The Flashbacks)
Team Role: Programmer
 
Join Date: Apr 2003
Location: Miami
Posts: 27
mattf is on a distinguished road
Send a message via AIM to mattf
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.
__________________
2004 UCF Quarterfinalists! (168, 79, 710)
2003 UCF Regional Champions! (212, 168, 108)
  #8   Spotlight this post!  
Unread 12-02-2004, 12:07
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,847
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Yaw Sensor

Quote:
Originally Posted by Phil_Lutz
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
As a double check here is the test code we used on the EDU controller.
Hold the gyro level and twist it quickly 90 degrees or more in the horizontal plane.

Code:
// this assumes in User_Initialization() at least...
IO1 = INPUT;
Set_Number_of_Analog_Channels(ONE_ANALOG);
 
 
 
// in Process_Data_From_Master_uP():
 
unsigned int gyro;
static unsigned long gyroSum=0;
static unsigned int counter=0;
 
/* This sample assumes a 26.2ms loop */
gyro = Get_Analog_Value(rc_dig_in01);
gyroSum += gyro;
counter++;
 
if (counter > 40)
{
	gyroSum = gyroSum/counter;
	printf(" gyro = %d \n", (int)gyroSum); /* values are in the range 0-1023 */
	counter = 0;
	gyroSum = 0;
}
[edit] Fixed small bug in printf. We use different print functions, Sorry.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 13-02-2004 at 10:13.
  #9   Spotlight this post!  
Unread 12-02-2004, 17:32
Phil_Lutz's Avatar
Phil_Lutz Phil_Lutz is offline
Phil Lutz
#0851 (Froggers)
Team Role: Mentor
 
Join Date: Jan 2004
Location: El Segundo, CA
Posts: 67
Phil_Lutz is on a distinguished road
Send a message via Yahoo to Phil_Lutz
Re: Yaw Sensor

Quote:
Originally Posted by Mark McLeod
As a double check here is the test code we used on the EDU controller.
Hold the gyro level and twist it quickly 90 degrees or more in the horizontal plane.
I will test this code out tonight.
Boy am I new to this stuff.
Coding no problem, but a Robot isn't a Database.

Thanks,

Phil
  #10   Spotlight this post!  
Unread 14-02-2004, 10:16
Larry Barello Larry Barello is offline
http://www.barello.net
#0492 (Titan Robotics Club)
Team Role: Mentor
 
Join Date: Jan 2002
Location: Bellevue, WA
Posts: 85
Larry Barello has a spectacular aura aboutLarry Barello has a spectacular aura about
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 ***************************************
    Gyro output is from .25 to 4.25 volts/5v range.  ADC is 10 bits.
    Full scale output is +/- 150 deg/sec.  Sampling rate is SYSCLOCK hz.

    Adjust FULLSCALEINPUT & OUTPUT to match the observed values
    so that when the robot is turned 360 deg the reported angle is
    360.  Double check by returning robot to starting position and
    verifying angle is 0.            
    
    Note: The gyro reading is 10bits, but I shift it over 4 to get a 16 bit value.
    This allows a fractional "offset" value which, when integrated over time
    will give a more accurate "zero" value.
*/

#define FULLSCALEINPUT (203.0 * 2.0)
#define FULLSCALEOUTPUT (1023.0 * 16.0)
#define PERIOD (1.0/GYROCLOCK)

#define GYROSCALE (FULLSCALEINPUT * PERIOD / FULLSCALEOUTPUT)

// GyroTask called at the primary loop rate of 100hz.  Delay 1.28 seconds before
// setting the basic gyro offset.  Gyro seems stable enough to last the 2 minute
// match without drifting significantly. Only high speed turns will mess it up.

#define GYRODELAY 128

int InitGyro = GYRODELAY;
int GyroOffset;
int iGyroTheta, iGyroRate;		// These are Zero at boot time
long temp;

float fTheta = GYROSCALE;

void Gyro_Task(void)
{
    int GyroVal = GetADC(Gyro) << 4;

    switch(InitGyro)
    {
        default:            // Delay until stable reading
            InitGyro--;
            temp += GyroVal;// Get average ADC value over 1 second
            break;
        case 0:             
            InitGyro = -1;
            GyroOffset = temp / GYRODELAY;
            break;
        case -1:
            iGyroRate = GyroVal - GyroOffset;
            fTheta += (float)iGyroRate * GYROSCALE;
            iGyroTheta = fTheta;    // Make integer version available.
            break;
    }
}
  #11   Spotlight this post!  
Unread 14-02-2004, 17:34
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
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)
  #12   Spotlight this post!  
Unread 25-02-2004, 10:41
WizardOfAz's Avatar
WizardOfAz WizardOfAz is offline
Lead Mentor
AKA: Bill Bennett
FRC #1011 (CRUSH)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Tucson, AZ
Posts: 101
WizardOfAz will become famous soon enough
Send a message via AIM to WizardOfAz
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
  #13   Spotlight this post!  
Unread 25-02-2004, 11:27
Larry Barello Larry Barello is offline
http://www.barello.net
#0492 (Titan Robotics Club)
Team Role: Mentor
 
Join Date: Jan 2002
Location: Bellevue, WA
Posts: 85
Larry Barello has a spectacular aura aboutLarry Barello has a spectacular aura about
Re: Get_Analog_Value in an ISR

Quote:
Originally Posted by WizardOfAz
...
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
According to the C compiler manual you need to save additional context when calling functions that return values. Specifically, for 8 & 16 bit return values you need to save 'PROD'. I believe it is page 28...

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)
{
    static char GyroTimer = 0, PrintTimer = 0;

    Poll_Rx1();				// The fast loop runs > 100khz
    Poll_Tx1();				// Poll rather than interrupts
    Poll_Rx2();
    Poll_Tx2();

    while (MsTimer)				// Incremented by TimerInterrupt.
    {
	MsTimer--;			// Section.

	if (++GyroTimer == 10)		// 100hz
	{
	    GyroTimer = 0;
	    Gyro_Task();
	} // END GyroTimer

	if (++PrintTimer == 100)		// 10hz
	{
	    SysTimer++;			// General timer for system
	    PrintTimer = 0;
	    TetherTask(STDIO);
	} // END Print task
    }// END Tasking
}
Here is a snipped of our interrupt code

Code:
/*******************************************************************************
* FUNCTION NAME: InterruptHandlerLow
*
* If you want to use these external low priority interrupts or any of the
* peripheral interrupts then you must enable them in your initialization
* routine.  Read p. 28 of the "MPLAB(R) C18 C Compiler User's Guide" for
* information on context saving.
*
* Because this handler calls something, it must save ".tmpdata".  If the called
* routine returned a 16 bit variable, "PROD" would need to be saved as well.
*******************************************************************************/
#pragma code
#pragma interruptlow InterruptHandlerLow  save=section(".tmpdata")/* You may want to save additional symbols. */

void InterruptHandlerLow ()
{
    If (INTCONbits.RBIF)       		/* INTERRUPTS 3-4 (RB4, RB5, RB6, or RB7) changed. */
    {
        DecodeQuadrature(PORTB); 	// Read PORTB and clear IF to
        INTCONbits.RBIF = 0;        	// clear interrupt
    }
    if (PIR1bits.TMR2IF) 		// timer 2 interrupt?
    {
	PIR1bits.TMR2IF = 0; 	// clear the timer 2 interrupt flag [92]
	MsTimer++;		// Increment millisecond timer
    }
}

Last edited by Larry Barello : 25-02-2004 at 11:33. Reason: fixed code formatting.
  #14   Spotlight this post!  
Unread 25-02-2004, 12:02
scottm87 scottm87 is offline
Registered User
AKA: Scott McClure
#0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Nov 2002
Rookie Year: 2000
Location: Bloomfield Hills, MI
Posts: 24
scottm87 is on a distinguished road
Post 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.
  #15   Spotlight this post!  
Unread 25-02-2004, 13:27
Phil_Lutz's Avatar
Phil_Lutz Phil_Lutz is offline
Phil Lutz
#0851 (Froggers)
Team Role: Mentor
 
Join Date: Jan 2004
Location: El Segundo, CA
Posts: 67
Phil_Lutz is on a distinguished road
Send a message via Yahoo to Phil_Lutz
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
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 21:48.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi