Go to Post You should never, EVER bully, manipulate, or slander another team for the sake of winning. - Libby K [more]
Home
Go Back   Chief Delphi > Technical > Electrical
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 26-09-2007, 18:55
kE7JLM's Avatar
kE7JLM kE7JLM is offline
KE7JLM `
AKA: John Harris
FRC #0842 (Falcon Robotics)
Team Role: Driver
 
Join Date: May 2007
Rookie Year: 2006
Location: Phoenix, AZ`
Posts: 136
kE7JLM is a name known to allkE7JLM is a name known to allkE7JLM is a name known to allkE7JLM is a name known to allkE7JLM is a name known to allkE7JLM is a name known to all
Send a message via MSN to kE7JLM
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.
__________________
Team 842 Programmer

Pictures at:
http://picasaweb.google.com/KE7JLM
&
http://picasaweb.google.com/john.h.842

Videos -
http://www.youtube.com/user/KE7JLM

When your not busy with FIRST try NURC

  #2   Spotlight this post!  
Unread 27-09-2007, 19:01
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: Interfacing a digital compass with the RC

Quote:
Originally Posted by kE7JLM View Post
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.
I've been wanting to publish the code for this, as well as some other code, for quite some time, but I can't get a hold of Kevin Watson to allow me to reprint parts of his code. So here's the best I can do.

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;
Step four: Replace the blank Int_1_Handler() with:
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;
}
Step five: Add this to the end of interrupts.c (and add the appropriate prototype to interrupts.h):
Code:
unsigned int Get_Compass(void)
{
  int i,x=0;
  for(i=0;i<SAMPLES;i++)
    x+=Readings[i];
  return x/SAMPLES;
}
Step six: Wire pin 1 on the compass to +5V on digital I/O 1 on the RC, pin 4 to signal, and pin 9 to ground.
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!
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_

Last edited by jgannon : 27-09-2007 at 19:04.
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
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


All times are GMT -5. The time now is 11:51.

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