Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

I2C bus on RBC (ATMEGA128) for many sensor

Korean company maker of Robot kits and servos designed for of articulated robots. Re-incarnation of Megarobotics.
24 postsPage 2 of 21, 2
24 postsPage 2 of 21, 2

Post by Flid » Sun Aug 15, 2010 4:58 pm

Post by Flid
Sun Aug 15, 2010 4:58 pm

l3v3rz wrote:Ok great - official release out real soon now :)

Its also built into the BASIC as well so for doing rapid prototypes could be a good alternative. when you get your compass code working hope you can post and I'll add to the library

cheers


Bad News :cry:

Don't work with the Devantech CMP03 compass module

I use same routine of ACC who working (vb.net)

For ACC
Code: Select all
            Dim OutBuff(0) As Byte
            OutBuff(0) = &H2

            wmt.I2C_write(&H70, OutBuff)

            Dim InBuff(-1) As Byte
            ReDim OutBuff(-1)
            InBuff = wmt.I2C_read(&H71, OutBuff, 6)

            Me.Text = "x:" + InBuff(1).ToString + " y:" + InBuff(3).ToString + " z:" + InBuff(5).ToString


And for CMP03 compass
Code: Select all
        Dim Add_CMP03 As Byte = &HC0

        Dim OutBuff(0) As Byte
        OutBuff(0) = &H1     '''register 1 = Compass Bearing as a byte, i.e. 0-255 for a full circle

        wmt.I2C_write(Add_CMP03, OutBuff)

        Dim InBuff(-1) As Byte
        ReDim OutBuff(-1)
        InBuff = wmt.I2C_read(Add_CMP03 + 1, OutBuff, 1) 'read answer in one byte


And the answer in the buffer is always 130 :x

I tryed with bigger buffer (10) to see the result and I have:
130;4;8;16;32;64;128;0;0;0

I tryed too, with other register like 2 and 3, and same result :roll:

Any suggests ? :? Where I'm wrong :oops:
l3v3rz wrote:Ok great - official release out real soon now :)

Its also built into the BASIC as well so for doing rapid prototypes could be a good alternative. when you get your compass code working hope you can post and I'll add to the library

cheers


Bad News :cry:

Don't work with the Devantech CMP03 compass module

I use same routine of ACC who working (vb.net)

For ACC
Code: Select all
            Dim OutBuff(0) As Byte
            OutBuff(0) = &H2

            wmt.I2C_write(&H70, OutBuff)

            Dim InBuff(-1) As Byte
            ReDim OutBuff(-1)
            InBuff = wmt.I2C_read(&H71, OutBuff, 6)

            Me.Text = "x:" + InBuff(1).ToString + " y:" + InBuff(3).ToString + " z:" + InBuff(5).ToString


And for CMP03 compass
Code: Select all
        Dim Add_CMP03 As Byte = &HC0

        Dim OutBuff(0) As Byte
        OutBuff(0) = &H1     '''register 1 = Compass Bearing as a byte, i.e. 0-255 for a full circle

        wmt.I2C_write(Add_CMP03, OutBuff)

        Dim InBuff(-1) As Byte
        ReDim OutBuff(-1)
        InBuff = wmt.I2C_read(Add_CMP03 + 1, OutBuff, 1) 'read answer in one byte


And the answer in the buffer is always 130 :x

I tryed with bigger buffer (10) to see the result and I have:
130;4;8;16;32;64;128;0;0;0

I tryed too, with other register like 2 and 3, and same result :roll:

Any suggests ? :? Where I'm wrong :oops:
Flid
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Sun Jul 11, 2010 11:34 pm

Post by l3v3rz » Sun Aug 15, 2010 7:53 pm

Post by l3v3rz
Sun Aug 15, 2010 7:53 pm

I can't see any thing wrong with it. Can you try starting at register 0 and read 4 bytes and see if you get the firmware version ?

so something like:

Code: Select all
   wckMotion wmt = new wckMotion("COM5", true); 

   wmt.I2C_write(0xC0, new byte[] {0});

   byte[] ib = wmt.I2C_read (0xC1, new byte[] {}, 4);
   Console.WriteLine("ver={0}, bear={1}",ib[0], ib[1]));


Otherwise it can really be one of following:
1. my code in DCMP - although it works with Accelerometer, may be timing is off for compass.

2. hardware connection on compass to RBC ? Have you scope it up and seen any data transfer? I assume you've checked its in I2C mode and not PWM mode.

3. robobuilderlib not correctly sending data to DCMP - you could try loading BASIC and running that at least then you're cutting out the PC and the robobuilderlib out of equation

Without the hardware its hard to help, but if you do find any problems with the code do let me know so I can update the library.

good luck
I can't see any thing wrong with it. Can you try starting at register 0 and read 4 bytes and see if you get the firmware version ?

so something like:

Code: Select all
   wckMotion wmt = new wckMotion("COM5", true); 

   wmt.I2C_write(0xC0, new byte[] {0});

   byte[] ib = wmt.I2C_read (0xC1, new byte[] {}, 4);
   Console.WriteLine("ver={0}, bear={1}",ib[0], ib[1]));


Otherwise it can really be one of following:
1. my code in DCMP - although it works with Accelerometer, may be timing is off for compass.

2. hardware connection on compass to RBC ? Have you scope it up and seen any data transfer? I assume you've checked its in I2C mode and not PWM mode.

3. robobuilderlib not correctly sending data to DCMP - you could try loading BASIC and running that at least then you're cutting out the PC and the robobuilderlib out of equation

Without the hardware its hard to help, but if you do find any problems with the code do let me know so I can update the library.

good luck
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by Flid » Mon Aug 16, 2010 1:49 pm

Post by Flid
Mon Aug 16, 2010 1:49 pm

l3v3rz wrote:I can't see any thing wrong with it. Can you try starting at register 0 and read 4 bytes and see if you get the firmware version ?

so something like:

Code: Select all
   wckMotion wmt = new wckMotion("COM5", true); 

   wmt.I2C_write(0xC0, new byte[] {0});

   byte[] ib = wmt.I2C_read (0xC1, new byte[] {}, 4);
   Console.WriteLine("ver={0}, bear={1}",ib[0], ib[1]));



Same Answer 130;4 :evil:

l3v3rz wrote:1. my code in DCMP - although it works with Accelerometer, may be timing is off for compass.

2. hardware connection on compass to RBC ? Have you scope it up and seen any data transfer? I assume you've checked its in I2C mode and not PWM mode.

3. robobuilderlib not correctly sending data to DCMP - you could try loading BASIC and running that at least then you're cutting out the PC and the robobuilderlib out of equation


1) Sure but where ?
2) In I2C sure, Ok, something append (see with led, I don't have scope here, maybe next week, when I will be back at my work)
3) I can't run basic.hex :cry:
l3v3rz wrote:I can't see any thing wrong with it. Can you try starting at register 0 and read 4 bytes and see if you get the firmware version ?

so something like:

Code: Select all
   wckMotion wmt = new wckMotion("COM5", true); 

   wmt.I2C_write(0xC0, new byte[] {0});

   byte[] ib = wmt.I2C_read (0xC1, new byte[] {}, 4);
   Console.WriteLine("ver={0}, bear={1}",ib[0], ib[1]));



Same Answer 130;4 :evil:

l3v3rz wrote:1. my code in DCMP - although it works with Accelerometer, may be timing is off for compass.

2. hardware connection on compass to RBC ? Have you scope it up and seen any data transfer? I assume you've checked its in I2C mode and not PWM mode.

3. robobuilderlib not correctly sending data to DCMP - you could try loading BASIC and running that at least then you're cutting out the PC and the robobuilderlib out of equation


1) Sure but where ?
2) In I2C sure, Ok, something append (see with led, I don't have scope here, maybe next week, when I will be back at my work)
3) I can't run basic.hex :cry:
Flid
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Sun Jul 11, 2010 11:34 pm

Post by l3v3rz » Mon Aug 16, 2010 2:17 pm

Post by l3v3rz
Mon Aug 16, 2010 2:17 pm

You need to work out why Basic.hex is seeing ERR and OK from your PC.

If serial comms isn't working - then robobuilderlib won't be working. Theres no error protocol so it could just be giberish you're seeing.

I don't believe there is any problem with basic.hex - it would be good to hear if someone else has downloaded and can confirm that of course, as it all works fine on my PC/Robot.

You could try a different robobuilder function such simply reading the position of servo. ie. wck.wckReadPos(13) this should return true, then read value wck.respnse[1] for the position

cheers
You need to work out why Basic.hex is seeing ERR and OK from your PC.

If serial comms isn't working - then robobuilderlib won't be working. Theres no error protocol so it could just be giberish you're seeing.

I don't believe there is any problem with basic.hex - it would be good to hear if someone else has downloaded and can confirm that of course, as it all works fine on my PC/Robot.

You could try a different robobuilder function such simply reading the position of servo. ie. wck.wckReadPos(13) this should return true, then read value wck.respnse[1] for the position

cheers
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by Flid » Tue Aug 17, 2010 8:12 am

Post by Flid
Tue Aug 17, 2010 8:12 am

Image

I think I found the problem :D

I'm an idiot :oops: the ACC run under 3.3 volts and the CMPS03 run under 5 volts :roll:

So or I must use one Level-Converter like this one... Or I must use one compass under 3.3 V

See this : http://www.nxp.com/documents/applicatio ... N10441.pdf

Thanks l3v3rz for listening my problems :wink:

I will be back in this topic when my problem will be solve :D
Image

I think I found the problem :D

I'm an idiot :oops: the ACC run under 3.3 volts and the CMPS03 run under 5 volts :roll:

So or I must use one Level-Converter like this one... Or I must use one compass under 3.3 V

See this : http://www.nxp.com/documents/applicatio ... N10441.pdf

Thanks l3v3rz for listening my problems :wink:

I will be back in this topic when my problem will be solve :D
Flid
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Sun Jul 11, 2010 11:34 pm

Post by l3v3rz » Tue Aug 17, 2010 10:29 am

Post by l3v3rz
Tue Aug 17, 2010 10:29 am

might be easier to get a different compass chip - robosavvy sell one that works from 2.7-5.2v

http://robosavvy.com/store/product_info ... cts_id/394
might be easier to get a different compass chip - robosavvy sell one that works from 2.7-5.2v

http://robosavvy.com/store/product_info ... cts_id/394
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by Flid » Thu Aug 19, 2010 11:20 am

Post by Flid
Thu Aug 19, 2010 11:20 am

Crazy, I will be :twisted:

I put one HMC5843 Image
(this one...)

But this time NO ANSWER from HMC5843 :x

I performed like the HMC5843 Datasheet:
Init:
-write to the HMC5843 (0x3C), Mode register, 0x00

Read
-write to the HMC5843, Register 3
-read byte from HMC5843 (0x3D)
-nothing :cry:

@Everybody: Any ideas ?

@i-Bot: Can you send me the wiring and souce code (for robobuilder, the part where you acces to the camera) of your hack with the wiimote camera, pleeeease :P
Crazy, I will be :twisted:

I put one HMC5843 Image
(this one...)

But this time NO ANSWER from HMC5843 :x

I performed like the HMC5843 Datasheet:
Init:
-write to the HMC5843 (0x3C), Mode register, 0x00

Read
-write to the HMC5843, Register 3
-read byte from HMC5843 (0x3D)
-nothing :cry:

@Everybody: Any ideas ?

@i-Bot: Can you send me the wiring and souce code (for robobuilder, the part where you acces to the camera) of your hack with the wiimote camera, pleeeease :P
Flid
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Sun Jul 11, 2010 11:34 pm

Post by Flid » Mon Aug 23, 2010 6:42 pm

Post by Flid
Mon Aug 23, 2010 6:42 pm

@i-Bot: Can you send me the wiring and souce code (for robobuilder, the part where you acces to the camera) of your hack with the wiimote camera, pleeeease
@i-Bot: Can you send me the wiring and souce code (for robobuilder, the part where you acces to the camera) of your hack with the wiimote camera, pleeeease
Flid
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Sun Jul 11, 2010 11:34 pm

Post by Flid » Fri Sep 03, 2010 3:11 pm

Post by Flid
Fri Sep 03, 2010 3:11 pm

Well, Working now with HMC5843 and an adaptator 3.3 to 5 Volts and modifications in accelerometer.c :D

Modif in accelerometer.c
Code: Select all
//==============================================================//
// Delay_I2C
//==============================================================//
void Delay_I2C(void)
{
   NOP;
   NOP;
   NOP;
   NOP;   
   NOP;
   NOP;
}


and I remplaced all double NOP; by Delay_I2C(); in primitives I2C functions.

So now I'm sure we have one problem with timing in I2C functions :roll:

And in I2C_AckRead() We do not read the Acknowledge.
We are waiting for assuming it has been sent :?

To be continuous... :wink:
Well, Working now with HMC5843 and an adaptator 3.3 to 5 Volts and modifications in accelerometer.c :D

Modif in accelerometer.c
Code: Select all
//==============================================================//
// Delay_I2C
//==============================================================//
void Delay_I2C(void)
{
   NOP;
   NOP;
   NOP;
   NOP;   
   NOP;
   NOP;
}


and I remplaced all double NOP; by Delay_I2C(); in primitives I2C functions.

So now I'm sure we have one problem with timing in I2C functions :roll:

And in I2C_AckRead() We do not read the Acknowledge.
We are waiting for assuming it has been sent :?

To be continuous... :wink:
Flid
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Sun Jul 11, 2010 11:34 pm

Previous
24 postsPage 2 of 21, 2
24 postsPage 2 of 21, 2