|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Interfacing a digital compass with the RC
As an off-season project, my team wants to add a digital compass to this year's robot. We are currently interested in the one featured here: http://www.robot-electronics.co.uk/s...CMPS032004.htm
I was wondering if anyone has experience with this or other digital compasses or if anyone has specific advice for getting data from it with the robot controller. The documentation says it can use PWM and I2C outputs (outputs on the compass, meaning inputs on the RC). Which of these would I want to use? Which pins would I connect it to on the controller? Also, we're looking for something that can handle spinning around pretty quickly without getting out of whack. How quickly does this compass update? |
|
#2
|
||||
|
||||
|
Re: Interfacing a digital compass with the RC
We planed on using on this season but we were unable to include it due to a lack of time. Ill see if i can get any notes from the programmer about it, and if you want i think we have a program that sends the orientation of the to the controller. It's somewhat of a drivercentric prototype.
|
|
#3
|
|||||
|
|||||
|
Re: Interfacing a digital compass with the RC
Kelli,
We had looked into using a compass on a few occassions. The ones we were looking at (and I am guessing this one as well) reguire a rather large current pulse or pulses to help calibrate and restore operation. The I2C reference is a car serial control protocol as I remember. Perhaps someone from the auto makers could elaborate on this. We had trouble working with our prototype depending on the building structure. Although we were able to get usable data in most locations, we didn't want to depend on arena variables to prevent us from doing a good auto mode. FYI so you don't get too discouraged, we spent some long hours trying to debug the compass while working on a stainless steel conference room table. Rack that up to late hours at the end of the build. It took us a while to realize where the error was coming from. See http://www.robot-electronics.co.uk/h...he_i2c_bus.htm Last edited by Al Skierkiewicz : 23-05-2007 at 08:06. |
|
#4
|
|||||
|
|||||
|
Re: Interfacing a digital compass with the RC
Please forgive a uninformed question but,
How would you use a digital compress in a robot? And wouldn't the electronics and metal of the robot throw it off a few dozen degrees? Especially when inside a building. |
|
#5
|
||||
|
||||
|
Re: Interfacing a digital compass with the RC
Your only issue with the Inter-Integrated Circuit (I2C) communications is... none of the lines from the processor that do I2C are routed outside the board!
If your working on an non-FIRST project, then definintely you can use I2C, however, on the FIRST RC you'll need to use PWM. According to the website that you ordered this from, the PWM signal updates at anywhere from 66ms - 102ms (or 9.8 - 15.2Hz, slower the closer you get to 359.9degrees). If you need help doing PWM pulse timing, just give me a yell, didnt know if you just wanted advice with which way to go or what. You can check this post to see if it will help you any, but can't remember if i said much on pwm timing here. Again, if not, just give me a yell back on this thread and i'll be happy to help. By the way just for my curiosity, what's this compass for exactly? Why do you want to know which way your robot's going? Arent you worried about flux fields from motors and such in your robot throwing it off? -q |
|
#6
|
|||||
|
|||||
|
Re: Interfacing a digital compass with the RC
That is part of the high current pulse for cal, etc. Car compass modules use this type of device. It requires some thought and planning as to placement but it is done all the time. Cars don't really need to depend on direction when inside a building or structure so it is usually not a problem. I have had a car compass go a little whacky inside big garages or undergound though.
|
|
#7
|
|||
|
|||
|
Re: Interfacing a digital compass with the RC
We have a holonomic drive train, and we want to use the compass to determine which way our robot is pointing so we can make a field-centric drive system. We aren't worried about it being off relative to the Earth, we just need it to be consistently off.
We're trying to use the 2007 RC for this project. Can it receive PWM input? |
|
#8
|
||||
|
||||
|
Re: Interfacing a digital compass with the RC
Quote:
Absolutely it can recieve PWM input, thats the great thing about embedded processors, you can do about anything you want! If you need help with how to program up a pulse timer using a hardware timer and a PORTB external interrupt, i can definitely help, just get me in touch with your programmer and i'll see what i can do. -q |
|
#9
|
||||
|
||||
|
Re: Interfacing a digital compass with the RC
Quote:
Quote:
The year this took place was 2003. We explored a bunch of options and ended up going with a gyro and integrating to get rotational position. This worked perfectly for the 15 seconds of autonomous, but unfortunately it would not be stable enough for Kelly's needs (where it would need to maintain correct orientation for basically the whole match). As for reading the PWM input, sometimes you can take the PWM output and run it through a simple RC circuit to convert it to an analog value that you could read directly with the RC. |
|
#10
|
||||
|
||||
|
Re: Interfacing a digital compass with the RC
Quote:
Have had to do this this year and in the past for getting distance data out of an ultrasonic sensor... -q Last edited by Qbranch : 23-05-2007 at 17:56. Reason: Yeah... commas separate list items in coloquial english... :o |
|
#11
|
|||
|
|||
|
Re: Interfacing a digital compass with the RC
How hard is that?
|
|
#12
|
||||
|
||||
|
Re: Interfacing a digital compass with the RC
Algorithm wise its easy peasy. Hardware wise, you'll need to know how to use interrupts, and how to use a hardware timer... nothing too bad.
If you'd like to try, i'll write up how you do it, just don't want to take the time to write it till i'm sure somebody needs it. (call me lazy )-q |
|
#13
|
||||
|
||||
|
Re: Interfacing a digital compass with the RC
Yes, that's not hard to do at all. I was simply offering a potential alternative solution in case the original poster isn't comfortable using timer interrupts and such. Occasionally things which seem most obvious to one person can be very daunting to another.
|
|
#14
|
||||
|
||||
|
Re: Interfacing a digital compass with the RC
We have a Devantech CMPS03 Digital Compass I would apresiate if someone could give me some step by step instructs on hw to do this, please.
|
|
#15
|
||||
|
||||
|
Re: Interfacing a digital compass with the RC
Quote:
Step one: Get a copy of Kevin Watson's interrupt code here. Step two: Enable timer 1, set the prescaler to 1:8, change register operations to 8-bit accesses, and disable the timer 1 interrupt. These are all documented in Initialize_Timer_1(). Also, enable interrupt 1 in Initialize_Interrupts(). Step three: Add these declarations to the top of interrupts.c. Increasing the value of SAMPLES should decrease the noise in your readings, to an extent: Code:
#define SAMPLES 1 unsigned char Temp_Buf; unsigned int Timer_Snapshot; unsigned int Readings[SAMPLES]; unsigned char p=0; Code:
void Int_1_Handler(void)
{
Temp_Buf = TMR1L;
Timer_Snapshot = TMR1H;
if(Temp_Buf == 0xFF)
Timer_Snapshot--;
Timer_Snapshot <<= 8;
Timer_Snapshot += Temp_Buf;
TMR1L = 0;
TMR1H = 0;
Readings[p++] = ((Timer_Snapshot - 0x4000) / 125) % 360;
p %= SAMPLES;
}
Code:
unsigned int Get_Compass(void)
{
int i,x=0;
for(i=0;i<SAMPLES;i++)
x+=Readings[i];
return x/SAMPLES;
}
Step seven: Call Get_Compass() to get the current reading from the compass... I can't remember right now if the value is in degrees or tenths of degrees, but you should be able to figure it out pretty quickly. Best of luck! Last edited by jgannon : 27-09-2007 at 19:04. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Where can I get a digital compass sensor? | EHaskins | Technical Discussion | 6 | 26-09-2007 18:33 |
| Interfacing with Allen-Bradley Sensors | doubleslash | Electrical | 9 | 31-01-2006 14:11 |
| I2C Digital Compass Programming | CyberWolf_22 | Programming | 7 | 03-01-2005 00:20 |
| Interfacing a PC with last year's Robot Controller | punarhero | Technical Discussion | 2 | 21-04-2004 00:05 |
| Interfacing a second Micro to the RC | Matt Reiland | Programming | 3 | 08-06-2003 00:11 |