OCCRA
Go to Post *sigh* Anything else we can do to get this thing to work? - domoarigato [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Events   CD-Media   CD-Spy   FRC-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 09-27-2007, 09:17 AM
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
Programming a Devantech Magnetic Compass - CMPS03

I am using a 2004 FIRST Robot Controller, I need help getting the 0-5 read show up on the the IFI Dashboard (I know it will will show as 0-255). So far I have plug it into an analog port and made an aliases-

#define Compass ADC_CH3

I also call it from user_routine_fast-

{
pwm13 = Get_Analog_Value(Compass)/4.023;
printf("%d", pwm13);
}


Can someone show me what is wrong? I can send you the code if you would like.
__________________
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 09-27-2007, 10:36 AM
Qbranch's Avatar
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex Suchko
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: Programming a Devantech Magnetic Compass - CMPS03

You have datatyping issues. The result of Get_Analog_Value() (if its like the one in the '06 controller) returns an unsigned integer... and your dividing by a floating point... and assiging to an unsigned character!

You might try:

{
unsigned int temp;
temp = Get_Analog_Value(Compass);
temp *= 4023; //fraction version of
temp /= 1000; //your conversion factor - avoid floating point
pwm13 = (unsigned char)temp;
printf("%d", pwm13);
}
__________________



2008 Championship Rockwell Automation Innovation in Control Award Winners
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
  #3   Spotlight this post!  
Unread 09-27-2007, 05:31 PM
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: Programming a Devantech Magnetic Compass - CMPS03

did not work. Any Ideas why?
__________________
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

  #4   Spotlight this post!  
Unread 09-27-2007, 08:50 PM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 7,846
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Send a message via AIM to Alan Anderson
Re: Programming a Devantech Magnetic Compass - CMPS03

(One bit of general advice: avoid using printf() in the "fast" section. It's too easy to get characters trying to go out faster than the serial port can handle them.)

You say it doesn't work, but we don't really know what "it" or "work" mean to you. What do you expect to happen, and what is happening instead?
  #5   Spotlight this post!  
Unread 09-27-2007, 10:22 PM
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,193
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Programming a Devantech Magnetic Compass - CMPS03

Interfacing a digital compass is a good project. However, after you master the compass you may not find it meets your needs. These devices measure the earths magnetic field in 2 axis and can give orientation. The problem is a FRC robot usually has some ferrous metal in it and our motors have some big powerful magnets in them. Even if you mounted the compass far away from these fields, they will affect them. You can calibrate for hard iron effects but the margin of error is going to be less than desirable. I played with a PNI VX2e and the best I could get with a FRC robot environment was +- 5 degrees. That was with out the motors running. If another robot is near you and it has allot of ferrous metal, The compass is going to get real bad. I have given up on digital compasses for FRC uses. For the tele-operated part of the match the organic analog computer- sensor network between the drivers ears may be your best bet for detecting the robots orientation. Don't give up though. The skills you learn for the compass have other applications for our robots.
  #6   Spotlight this post!  
Unread 09-27-2007, 11:31 PM
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: Programming a Devantech Magnetic Compass - CMPS03

Ok I was vague on the problems with the compass, so here is the problem-
I am using the IFI Dashboard to read the PWM output (0-255) but when I turn on the robot the value shots up to 60 (not exactly) then quickly goes back to 0 then repeats the process at a slower rate. Then about a minute in to the process it eventually stops at 28. Nothing affect the process, if I turn the compass or put it by the motors it stays the same.
This is the Aliases-
* Below are aliases for reading an analog voltage on the ANALOG INPUTS
* using the Get_Analog_Value() function.
*/
#define Temp_Guage ADC_CH0
#define Pressure_Guage ADC_CH1
#define rc_ana_in03 ADC_CH2

#define Compass ADC_CH3
#define rc_ana_in05 ADC_CH4
#define rc_ana_in06 ADC_CH5
#define rc_ana_in07 ADC_CH6
#define rc_ana_in08 ADC_CH7
#define rc_ana_in09 ADC_CH8
#define rc_ana_in10 ADC_CH9
#define rc_ana_in11 ADC_CH10
#define rc_ana_in12 ADC_CH11
#define rc_ana_in13 ADC_CH12
#define rc_ana_in14 ADC_CH13
#define rc_ana_in15 ADC_CH14
#define rc_ana_in16 ADC_CH15

#define SIXTEEN_ANALOG ADC_16ANA /* All analog */


This is how I call it-
pwm11 = Get_Analog_Value(Pressure_Guage)/4;
pwm12 = Get_Analog_Value(Temp_Guage)/4.023;

pwm13 = Get_Analog_Value(Compass)/4.023;
{
unsigned int temp;
temp = Get_Analog_Value(Compass);
temp *= 4023; //fraction version of
temp /= 1000; //your conversion factor - avoid floating point
pwm13 = (unsigned char)temp;
printf("%d", pwm13);
}


Thank you!
By the way, I am using the Devantech Magnetic Compass - CMPS03 on a ROV so there no other robots around and also the motors we are using are about a 1.5 feet away and are small. (Nothing like the big CIMs) The only things that could interfere is the Aluminum water proof housing, or the electronics beside the compass.


Heres a link to some Pictures if that could help you- (The compass is not in these pictures but is inside the Aluminum water proof housing)
http://picasaweb.google.com/KE7JLM/RobotAllan
__________________
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


Last edited by kE7JLM : 09-27-2007 at 11:34 PM.
  #7   Spotlight this post!  
Unread 09-27-2007, 11:39 PM
Phil Mack Phil Mack is offline
Registered User
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: May 2007
Rookie Year: 2007
Location: Maryland
Posts: 30
Phil Mack is a splendid one to beholdPhil Mack is a splendid one to beholdPhil Mack is a splendid one to beholdPhil Mack is a splendid one to beholdPhil Mack is a splendid one to beholdPhil Mack is a splendid one to beholdPhil Mack is a splendid one to behold
Re: Programming a Devantech Magnetic Compass - CMPS03

Quote:
Originally Posted by kE7JLM View Post
Can someone show me what is wrong?
This compass does not output an analog voltage. It outputs a pulse with a specific time, or byte values can be read over an I2C bus.

The timing pulse is high for 1mS to 37mS in 0.1mS increments and then low for 65mS. The rise and fall time is much faster (a few nanoseconds if i recall, but i cant find the datasheet right now). The ADC in the robot controller works fast enough that whenever it measures the voltage, the voltage will be either high or low... not in between.

You essentially have three options... use an additional micro controller, design a circuit, or write interrupt driven software.

The first option is the easiest (in my oppinion) and will give you the most accurate results. You can purchase or build an I2C master with an RS232 interface that the robot controller can communicate with. One elegant implementation of this is available at http://www.emicros.com/i2c232.htm for about $90, but one could be built for much less than that (I built a less elegant one in college using an AVR Butterfly that cost $20 and that was processing overkill.)

The second option would require a series of filters and amplifiers that would translate the pulse into a voltage. This one is a bit outside of my field of expertise, so I'll leave an explanation to someone else, because it would be a relatively complex circuit.

The third option to interface with this compass you have to measure the length of the pulse width using on board timers triggered by interrupts. You would want to scale one of the timers to use increments fairly close to but not over .1ms. The pulse out on the compass would trigger an interrupt, at which point the timer's count would be noted. The (count_at_fall - count_at_rise)/clock_scale_factor would be the width of the pulse and also your heading.

I hope this helps.
~Phil
  #8   Spotlight this post!  
Unread 09-28-2007, 07:23 AM
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,193
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Programming a Devantech Magnetic Compass - CMPS03

Is this an underwater ROV? If so you have another problem. The compass you're using is a 2 axis one. If there is any tilt the reading will be way off. For apps that tilt there are 3 axis compasses with accelerometers that can compensate and give good accuracy. There are models that are ready to go with an easier RS232 interface that would work better for this app. However, they are hundreds of dollars.
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
Interfacing a digital compass with the RC Kelly Electrical 14 09-27-2007 06:01 PM
Where can I get a digital compass sensor? EHaskins Technical Discussion 6 09-26-2007 05:33 PM
I2C Digital Compass Programming CyberWolf_22 Programming 7 01-02-2005 11:20 PM
Political Compass Joshua May Chit-Chat 11 10-01-2004 09:32 PM
Compass/direction sensor Frank(Aflak) Technical Discussion 10 04-06-2003 08:18 AM


All times are GMT -5. The time now is 01:23 AM.

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


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