I2C Compass

Hitec robotics including ROBONOVA humanoid, HSR-8498HB servos, MR C-3024 Controllers and RoboBasic
56 postsPage 2 of 41, 2, 3, 4
56 postsPage 2 of 41, 2, 3, 4

Post by roboTT » Tue Jul 07, 2009 10:34 pm

Post by roboTT
Tue Jul 07, 2009 10:34 pm

This is great!!

Can you please make a shot how did you connect the compass to RN board?
This is great!!

Can you please make a shot how did you connect the compass to RN board?
roboTT offline
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by RoboJeronimo » Thu Jul 23, 2009 7:09 pm

Post by RoboJeronimo
Thu Jul 23, 2009 7:09 pm

NovaOne wrote:These are photos of my compass fitted inside my RN head:
Image
Image
Wire colours as follows:
Purple +5v
Grey SCL
White SDA
Black 0v


Where did you buy this head for the robonova?
NovaOne wrote:These are photos of my compass fitted inside my RN head:
Image
Image
Wire colours as follows:
Purple +5v
Grey SCL
White SDA
Black 0v


Where did you buy this head for the robonova?
RoboJeronimo offline
Robot Builder
Robot Builder
Posts: 19
Joined: Fri Jul 10, 2009 11:54 am

Post by NovaOne » Fri Jul 24, 2009 5:38 pm

Post by NovaOne
Fri Jul 24, 2009 5:38 pm

It is made with a standard RN-1, U Type Universal Bracket and standard RN-1 internal Shoulder Back Bracket plus a small sheet of black alloy folded see template link here:
http://robosavvy.com/Builders/NovaOne/RN%20alloy%20templates.pdf

I am currently redesigning te head and will post a picture of the finished design here
It is made with a standard RN-1, U Type Universal Bracket and standard RN-1 internal Shoulder Back Bracket plus a small sheet of black alloy folded see template link here:
http://robosavvy.com/Builders/NovaOne/RN%20alloy%20templates.pdf

I am currently redesigning te head and will post a picture of the finished design here
NovaOne offline
Savvy Roboteer
Savvy Roboteer
Posts: 405
Joined: Thu Jul 05, 2007 7:30 am

Post by RoboJeronimo » Wed Jul 29, 2009 6:46 pm

Post by RoboJeronimo
Wed Jul 29, 2009 6:46 pm

I tried with your code (the last you posted) but i'm making something wrong. I think my i2cdata variable is always at 255.

I conected the compass with the two pull-up resistors and I calibrated by switch metod. An inconvenient is I haven't the LCD for viewing the final value (I deleted this part of the code).

Can u help me?
I tried with your code (the last you posted) but i'm making something wrong. I think my i2cdata variable is always at 255.

I conected the compass with the two pull-up resistors and I calibrated by switch metod. An inconvenient is I haven't the LCD for viewing the final value (I deleted this part of the code).

Can u help me?
RoboJeronimo offline
Robot Builder
Robot Builder
Posts: 19
Joined: Fri Jul 10, 2009 11:54 am

Post by ProblemChild » Wed Jul 29, 2009 11:26 pm

Post by ProblemChild
Wed Jul 29, 2009 11:26 pm

Nova One, I'm dead impressed with your head and sensor array.
The problem that immediately came to mind was not only the initial calibration but the noise induced by all the motors/moving metal work and the electronics.

Has this proved to be an issue?

I was thinking of using the Cameras from Sparkfun as they are already digital and probably even smaller than the units you have pre installed in your head.

Out of interest wouldn't say some IR leds or 2D bar code symbols in it's environment be at least as good to direct your RN especially in a crowded home with lots of Mag field distortions ??

John
Nova One, I'm dead impressed with your head and sensor array.
The problem that immediately came to mind was not only the initial calibration but the noise induced by all the motors/moving metal work and the electronics.

Has this proved to be an issue?

I was thinking of using the Cameras from Sparkfun as they are already digital and probably even smaller than the units you have pre installed in your head.

Out of interest wouldn't say some IR leds or 2D bar code symbols in it's environment be at least as good to direct your RN especially in a crowded home with lots of Mag field distortions ??

John
ProblemChild offline
Savvy Roboteer
Savvy Roboteer
Posts: 43
Joined: Tue Jul 28, 2009 5:02 pm

Post by NovaOne » Sat Aug 01, 2009 5:49 am

Post by NovaOne
Sat Aug 01, 2009 5:49 am

roboTT wrote:
Can you please make a shot how did you connect the compass to RN board?


Sorry I missed your post roboTT:

In my previously posted I2c code I used ports 5 and 10, and later ..... ports 15 and 16 however, based on advice from i-Bot i decided to change the PWM ports 46 and 47 as they are rarely used.
Therefore:
Code: Select all
CONST SDA = 46 'Use port 15 for Data, constant SDA
CONST SCL = 47 'Use port 16 for Clock, constant SCL


Image
See port assignments here:
http://robosavvy.com/Builders/i-Bot/C3024%20ports.pdf

RoboJeronimo wrote:
I tried with your code (the last you posted) but i'm making something wrong. I think my i2cdata variable is always at 255.
...
Can u help me?


Sorry to hear this, I will try...? If you are using the old 15,16 ports have you disabled you motor outputs?
Note: Not related to the core i2c code, Ive just seen some strange code in the TurnReqHeading routine :? .....the if statements were jumbled up... maybe got mixed up with the BBCode when I originally pasted them in?
...so I have deleted the old code segments and uploaded a PDF with the "correct" code segments in , sorry if this has caused anyone problems.

John wrote:
The problem that immediately came to mind was not only the initial calibration but the noise induced by all the motors/moving metal work and the electronics.

Has this proved to be an issue?


The CMPS03 seems be far enough away from the servos to work fine in single byte mode. The main problem I had was that I wanted to mount a speaker in the head for the SP03..... the mag field did mess up the compass so I used a piezo speaker instead.....not really getting much volume from that though :?

Currently I do not have either connected, will have to see what I can fit in the new design...but don't hold your breath.... :roll:

I was thinking of using the Cameras from Sparkfun as they are already digital and probably even smaller than the units you have pre installed in your head.

Sounds great! please post the pics
Out of interest wouldn't say some IR leds or 2D bar code symbols in it's environment be at least as good to direct your RN especially in a crowded home with lots of Mag field distortions ??

Yes, or perhaps a the camera from a wiimote :wink:
roboTT wrote:
Can you please make a shot how did you connect the compass to RN board?


Sorry I missed your post roboTT:

In my previously posted I2c code I used ports 5 and 10, and later ..... ports 15 and 16 however, based on advice from i-Bot i decided to change the PWM ports 46 and 47 as they are rarely used.
Therefore:
Code: Select all
CONST SDA = 46 'Use port 15 for Data, constant SDA
CONST SCL = 47 'Use port 16 for Clock, constant SCL


Image
See port assignments here:
http://robosavvy.com/Builders/i-Bot/C3024%20ports.pdf

RoboJeronimo wrote:
I tried with your code (the last you posted) but i'm making something wrong. I think my i2cdata variable is always at 255.
...
Can u help me?


Sorry to hear this, I will try...? If you are using the old 15,16 ports have you disabled you motor outputs?
Note: Not related to the core i2c code, Ive just seen some strange code in the TurnReqHeading routine :? .....the if statements were jumbled up... maybe got mixed up with the BBCode when I originally pasted them in?
...so I have deleted the old code segments and uploaded a PDF with the "correct" code segments in , sorry if this has caused anyone problems.

John wrote:
The problem that immediately came to mind was not only the initial calibration but the noise induced by all the motors/moving metal work and the electronics.

Has this proved to be an issue?


The CMPS03 seems be far enough away from the servos to work fine in single byte mode. The main problem I had was that I wanted to mount a speaker in the head for the SP03..... the mag field did mess up the compass so I used a piezo speaker instead.....not really getting much volume from that though :?

Currently I do not have either connected, will have to see what I can fit in the new design...but don't hold your breath.... :roll:

I was thinking of using the Cameras from Sparkfun as they are already digital and probably even smaller than the units you have pre installed in your head.

Sounds great! please post the pics
Out of interest wouldn't say some IR leds or 2D bar code symbols in it's environment be at least as good to direct your RN especially in a crowded home with lots of Mag field distortions ??

Yes, or perhaps a the camera from a wiimote :wink:
NovaOne offline
Savvy Roboteer
Savvy Roboteer
Posts: 405
Joined: Thu Jul 05, 2007 7:30 am

Post by RoboJeronimo » Mon Aug 03, 2009 6:50 pm

Post by RoboJeronimo
Mon Aug 03, 2009 6:50 pm

It works! thank you!

Wrong port conection :roll:
It works! thank you!

Wrong port conection :roll:
RoboJeronimo offline
Robot Builder
Robot Builder
Posts: 19
Joined: Fri Jul 10, 2009 11:54 am

Post by RoboJeronimo » Wed Aug 05, 2009 5:52 pm

Post by RoboJeronimo
Wed Aug 05, 2009 5:52 pm

Hi again,

I use the compass with byte return value. I prove the byte values doesn't distribute around the 360 degrees proportionally. Why :?:

I need my robot turns around. Something like: bytevalue + (255/2)
Hi again,

I use the compass with byte return value. I prove the byte values doesn't distribute around the 360 degrees proportionally. Why :?:

I need my robot turns around. Something like: bytevalue + (255/2)
RoboJeronimo offline
Robot Builder
Robot Builder
Posts: 19
Joined: Fri Jul 10, 2009 11:54 am

Post by ProblemChild » Wed Aug 05, 2009 6:18 pm

Post by ProblemChild
Wed Aug 05, 2009 6:18 pm

How far off equal spaced are they? Is it just a rounding error or some big jumps due to say lumps of metal /stray field etc?

Is the relationship computable or should you just have say a 256 element matrix to be used as calibration file??

value from I2C===> Index table ====> orientation in Degrees


By the way Got Fedora11 working on the Roboard...Next thing is to get the Control libraries sorted then Yippie ;)

John
How far off equal spaced are they? Is it just a rounding error or some big jumps due to say lumps of metal /stray field etc?

Is the relationship computable or should you just have say a 256 element matrix to be used as calibration file??

value from I2C===> Index table ====> orientation in Degrees


By the way Got Fedora11 working on the Roboard...Next thing is to get the Control libraries sorted then Yippie ;)

John
ProblemChild offline
Savvy Roboteer
Savvy Roboteer
Posts: 43
Joined: Tue Jul 28, 2009 5:02 pm

Post by NovaOne » Wed Aug 05, 2009 7:59 pm

Post by NovaOne
Wed Aug 05, 2009 7:59 pm

I use the compass with byte return value. I prove the byte values doesn't distribute around the 360 degrees proportionally. Why Question
RoboJeronimo


Is it just a rounding error or some big jumps due to say lumps of metal /stray field etc?

Maybe?

But is it really a problem. I can't get my RoboNova to turn accurately through a required angle with hip rotation, nevermind the standard foot skidding method.

bytevalue + (255/2)


Compass Bearing as a byte, i.e. 0-255 for a full circle, hence there are 256 steps.
Are you trying to check 360/256 = 1.40625 :?
I use the compass with byte return value. I prove the byte values doesn't distribute around the 360 degrees proportionally. Why Question
RoboJeronimo


Is it just a rounding error or some big jumps due to say lumps of metal /stray field etc?

Maybe?

But is it really a problem. I can't get my RoboNova to turn accurately through a required angle with hip rotation, nevermind the standard foot skidding method.

bytevalue + (255/2)


Compass Bearing as a byte, i.e. 0-255 for a full circle, hence there are 256 steps.
Are you trying to check 360/256 = 1.40625 :?
NovaOne offline
Savvy Roboteer
Savvy Roboteer
Posts: 405
Joined: Thu Jul 05, 2007 7:30 am

Post by ProblemChild » Wed Aug 05, 2009 8:48 pm

Post by ProblemChild
Wed Aug 05, 2009 8:48 pm

well since this problem seems to lack data I would suggest an experiment

Stick RN on a table with a bit of paper with say 5/10 degree markings on it to give accurate rotation guidance. Then align the RN to the 0 deg mark measure the value then rotate it to say the 5 degree mark and take another value from the Mag sensor then repeat for the whole 360.

You may then want to repeat it for maybe just the sensor it's self then maybe the RN with large metal objects near or some such

from this you should be able to see if the RN or the metal objects upset the sensor and also get a table you could use to calibrate the sensor against.

Any other Ideas from you guys ?

John
well since this problem seems to lack data I would suggest an experiment

Stick RN on a table with a bit of paper with say 5/10 degree markings on it to give accurate rotation guidance. Then align the RN to the 0 deg mark measure the value then rotate it to say the 5 degree mark and take another value from the Mag sensor then repeat for the whole 360.

You may then want to repeat it for maybe just the sensor it's self then maybe the RN with large metal objects near or some such

from this you should be able to see if the RN or the metal objects upset the sensor and also get a table you could use to calibrate the sensor against.

Any other Ideas from you guys ?

John
ProblemChild offline
Savvy Roboteer
Savvy Roboteer
Posts: 43
Joined: Tue Jul 28, 2009 5:02 pm

Post by RoboJeronimo » Tue Aug 11, 2009 6:45 pm

Post by RoboJeronimo
Tue Aug 11, 2009 6:45 pm

Hi, I'm working in a function to fix the position of the robonova. The code is down. This code doesn't works if the compass is around 0 value. why???

SPEED 10
GOSUB standardposition
I2cAckBit = 0
I2cAddr = &Hc0
I2cReg = 1
GOSUB I2cByteRead
RUMBO=i2cdata 'take the position to should stay
TEMPO 230
MUSIC "EDE"
MAIN:
I2cAddr = &Hc0
I2cReg = 1
GOSUB I2cByteRead
BRUJULA=i2cdata 'current position

BRUJULA=BRUJULA-RUMBO
IF BRUJULA>250 OR BRUJULA<5 THEN GOTO SALTO
'250-5 is a margin value for the position
IF BRUJULA<127 THEN GOSUB LEFT_TURN
IF BRUJULA>127 THEN GOSUB RIGHT_TURN
'select the shortest way

SALTO:
GOTO Main
Hi, I'm working in a function to fix the position of the robonova. The code is down. This code doesn't works if the compass is around 0 value. why???

SPEED 10
GOSUB standardposition
I2cAckBit = 0
I2cAddr = &Hc0
I2cReg = 1
GOSUB I2cByteRead
RUMBO=i2cdata 'take the position to should stay
TEMPO 230
MUSIC "EDE"
MAIN:
I2cAddr = &Hc0
I2cReg = 1
GOSUB I2cByteRead
BRUJULA=i2cdata 'current position

BRUJULA=BRUJULA-RUMBO
IF BRUJULA>250 OR BRUJULA<5 THEN GOTO SALTO
'250-5 is a margin value for the position
IF BRUJULA<127 THEN GOSUB LEFT_TURN
IF BRUJULA>127 THEN GOSUB RIGHT_TURN
'select the shortest way

SALTO:
GOTO Main
RoboJeronimo offline
Robot Builder
Robot Builder
Posts: 19
Joined: Fri Jul 10, 2009 11:54 am

Post by Gort » Tue Aug 11, 2009 7:51 pm

Post by Gort
Tue Aug 11, 2009 7:51 pm

I have many questions, if RUMBO gets assigned a 0 and BRUJULA is assigned a 0 then your IF statement is true (IF BRUJULA>250 OR BRUJULA<5 THEN GOTO SALTO). If RUMBO is greater than BRUJULA then BRUJULA will always be less than 5, so you’re IF statement will always be true. What is happening in SALTO:, nothing or a walk foward? IF nothing then your program will never do anything. The others are what is happening in I2cByteRead? What are the variable types and why do you assign &Hc0 to I2cAddr twice and 1 to I2cReg twice. Once before the main and once in the main. I have both a compass and a LCD display that I can hook up to my RN. I have been very busy at work though, hopefully I can work on both this weekend. That way I could be more helpful.
I have many questions, if RUMBO gets assigned a 0 and BRUJULA is assigned a 0 then your IF statement is true (IF BRUJULA>250 OR BRUJULA<5 THEN GOTO SALTO). If RUMBO is greater than BRUJULA then BRUJULA will always be less than 5, so you’re IF statement will always be true. What is happening in SALTO:, nothing or a walk foward? IF nothing then your program will never do anything. The others are what is happening in I2cByteRead? What are the variable types and why do you assign &Hc0 to I2cAddr twice and 1 to I2cReg twice. Once before the main and once in the main. I have both a compass and a LCD display that I can hook up to my RN. I have been very busy at work though, hopefully I can work on both this weekend. That way I could be more helpful.
Gort offline
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 555
Joined: Wed May 31, 2006 1:00 am
Location: KC, MO, USA

Post by Gort » Tue Aug 11, 2009 7:56 pm

Post by Gort
Tue Aug 11, 2009 7:56 pm

My other question is do you filter the compass data in anyway? What happens if you get bad data in RUMBO or BRUJULA?
My other question is do you filter the compass data in anyway? What happens if you get bad data in RUMBO or BRUJULA?
Gort offline
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 555
Joined: Wed May 31, 2006 1:00 am
Location: KC, MO, USA

Post by RoboJeronimo » Tue Aug 11, 2009 8:17 pm

Post by RoboJeronimo
Tue Aug 11, 2009 8:17 pm

Gort wrote:I have many questions, if RUMBO gets assigned a 0 and BRUJULA is assigned a 0 then your IF statement is true (IF BRUJULA>250 OR BRUJULA<5 THEN GOTO SALTO)

Yes, it's true



Gort wrote: If RUMBO is greater than BRUJULA then BRUJULA will always be less than 5, so you’re IF statement will always be true.

It shouldn't be true, because a byte variable is circular, so the secuence of values is ...254,255,0,1,2... so 2-4=254



Gort wrote: What is happening in SALTO:, nothing or a walk foward? IF nothing then your program will never do anything.

The robot is quiet in a position and if I turn it, It must fix its position only turning left/rigth



Gort wrote:The others are what is happening in I2cByteRead? What are the variable types and why do you assign &Hc0 to I2cAddr twice and 1 to I2cReg twice. Once before the main and once in the main.

This code have been explain in this post. I2cByteRead reads the value of the compass, the others are variables which are used by this function.
Gort wrote:I have many questions, if RUMBO gets assigned a 0 and BRUJULA is assigned a 0 then your IF statement is true (IF BRUJULA>250 OR BRUJULA<5 THEN GOTO SALTO)

Yes, it's true



Gort wrote: If RUMBO is greater than BRUJULA then BRUJULA will always be less than 5, so you’re IF statement will always be true.

It shouldn't be true, because a byte variable is circular, so the secuence of values is ...254,255,0,1,2... so 2-4=254



Gort wrote: What is happening in SALTO:, nothing or a walk foward? IF nothing then your program will never do anything.

The robot is quiet in a position and if I turn it, It must fix its position only turning left/rigth



Gort wrote:The others are what is happening in I2cByteRead? What are the variable types and why do you assign &Hc0 to I2cAddr twice and 1 to I2cReg twice. Once before the main and once in the main.

This code have been explain in this post. I2cByteRead reads the value of the compass, the others are variables which are used by this function.
RoboJeronimo offline
Robot Builder
Robot Builder
Posts: 19
Joined: Fri Jul 10, 2009 11:54 am

PreviousNext
PreviousNext
56 postsPage 2 of 41, 2, 3, 4
56 postsPage 2 of 41, 2, 3, 4
cron