Logo

Forums » Segbot » IMU models

johndavid400
Avatar

Hi John,

thanks for joining and glad you got your Lawnbot finished. I have not been able to find the exact sensors I used in the book for some time now, but I am in the process of writing code for a more reliable replacement. If you cannot find the new one I am going to use, I would be happy to help you get one.

I will let you know as soon as I get the new sensor working.

JohnNguyen
Avatar

Hi JohnDavid,

Thanks for reply to me. Yes, I would like to get the new one as you're going to use. Let me know how to get it.

Thanks

gerrymoore
Avatar

Thanks John...I look forward to any info/sketches for the 6050 or similar...not sure where the link to your code snippet went though!!  cheers Gerry

johndavid400
Avatar

Hey Gerry,

sorry, forgot to paste it in there, here it is:

http://bildr.org/2011/06/l3g4200d-arduino/

gerrymoore
Avatar

Hi John..thanks for the link....also found your instructable code for the balancing skateboard!  Can I ask whether either of these codes can be adapted for the MPU6050 I have...I realise the I2C address is different but not sure if all of the other register addresses would have to be worked out and changed?  Must say, I'm a bit impatient to get something working with this MPU...I have managed to get some serial output to my PC but it's a bit meaningless and too fast to be of any use.  I am right in assuming my Duemilanova Arduino is OK for the MPU6050 and I don't need a more up to date Arduino??  I realise you must be a very busy guy but any help gratefully taken...cheers  Gerry

johndavid400
Avatar

Hi Gerry,

I don't have an instructable for a skateboard, but you must be talking about my friend XenonJohn... he has a bit more experience with balancing bots than I do (he has built several and I have built only one), and he has some really good code examples but his are slightly different than mine.

Is this what you saw?:

http://www.instructables.com/id/Easy-build-self-balancing-skateboardrobotsegway-/

If so, he almost wrote the chapter for the Seg-bot in my book.. but the timing didn't work out and I ended up doing it myself and somewhat differently than him... but he is a cool guy.

You are correct that any Arduino will work with I2c, it does not need to be the newest.

gerrymoore
Avatar

Hi John.....Thanks for the info re the Arduino...and sorry for mixing you up with your friend!!

I think I'm just gonna have to be patient and wait for someone wth a mind "Immeasurably superior to mine" to come up with some usable code for my unicycle!!  cheers and Happy Easter, Gerry.

ArduinoJack
Avatar


Hi John,
Thanks again for your explanation on how the serial interphase works on the Sabertooth motor controller. I have now understood how the Arduino is communicating with the Sabertooth.
I do have an inquiry into the IMU for the Segbot. The readings on my accelerometer(ADXL335) and gyroscope(LPY503) are 0.05 and 0.12 respectively on equilibrium(flat surface).  I was able to measure the offset value on the accelerometer  which is 503 using the code on the Arduino Robotics Book.  Entering the 503 offset value into the V3autocalibrate code yielded an accelerometer reading of 0.01 on equilibrium. I would like to measure the offset value of the gyroscope(LPY503) but the code I created using the book as a guide was unable to measure offset value. Gyroscope: 0 is all I got from the serial monitor. I will attach the code I created here:

int Angle_Rate = 0;
int Angle = 0;
int gyro_Pin = A2; // read gyroscope from Analog pin 2
int last_update;
int cycle_time;
long last_cycle = 0;

void setup(){
  Serial.begin(9600);
  analogReference(EXTERNAL);
}

void time_stamp(){
  last_cycle = millis();
  while((millis() - last_cycle) 

Would you mind modifying the code so it can measure gyroscope offset value?
Am I right in thinking it’s the gyroscope offset value that will make the gyroscope readings to 0.00 on equilibrium?

 

By the way, what's the proper way of formatting the code when posting on this forum so it won't take so much space?

Thanks again for your support.

johndavid400
Avatar

Hey ArduinoJack,

Awesome that you are testing this out... I just got my LPY503's in the mail. I am in the process of adding the v3 autocalibrating code which gets the offsets and sets them for you at startup, so you don't have to mess with that stuff. I have added a new folder next to the rest of the iterations for the LPY503 so you can check it in a few days and I should have some progress:

https://github.com/johndavid400/Segbot/blob/master/LPY503AL/LPY503AL.ino

 

I see why you are getting a 0 value for gyro in your code... you declared the analog pin like this:

int gyro_Pin = A2; // read gyroscope from Analog pin 2

but the A2 is messing it up, you only need to put the number here, so 2 in this case. make it look like this and it should work:

int gyro_Pin = 2; // read gyroscope from Analog pin 2

 

As for the proper formatting, unfortunately I don't yet have an easy way to change code to a block.. sometimes pasting it in from another source (ie. arduino ide), it will automatically change to to preformatted text block, but I will check on adding a way to do this.

Cheers,

jd

ArduinoJack
Avatar

Thank you for looking into the code John. I will try it out. Okay, I'm looking forward for the new code for the LPY503AL gyro.

Best Regards,

Jack

JohnNguyen
Avatar

Hi John David,

After found 6DOF IMU ( https://www.sparkfun.com/products/10010 ). Wiring as in book. I can not make it work. Some one correct me if I do sonething wrong with Segbot.

TESTING:

1/ Razor 6 DOF IMU analog is tested Gyros and Acce, Arduino Uno R3 tested , Sabertooth 2X25 ( Serial switch ) tested, Arduino Protoshield all working good.

2/ Wiring as in book:

Wiring:                                         Arduino:                          Sabertooth:

Soflware Serial                              D3                                   S1

Gain Potential ( 3.3V and GND)      A2                                    X

Steering          (3.3V and GND)       A3                                    X

Engage ( 2nd lead to GND)             D4                                    X

12V    ( GND between 2 abttery)      Input Jack                         X

24V                                               X                                      B+  , Gnd B-

Motors                                          X                                      The rest is motors

3/ Using solfware Version 1 or same as in book. Using Arduino Sketch 1.0.4 , I change

mySerial.write(m1_speed); //mySerial.print(m1_speed, BYTE); THIS FIX BYTE NO LONGER SUPPOERTED
mySerial.write(m2_speed); //mySerial.print(m2_speed, BYTE);

If I use Sketch 0023 I dont need to change BYTE no longer supported.

After upload, This is what I start up procedure: Lean back Segbot about 10 degree, turn on power from battery ( to power Sabertooth and Arduino same time ) then wait about 5 seconds, turn on DeadMan switch, put Segbot to level. But I can not see or feel anything from Segbot.

QUESTION:

1/ What is Startup Procedure ?

2/ The solfware Version 1 for 6 DOF I'm using is correct ? or what version do I use ?

3/ What else do I need to correct ?

Hope U understand what I just explain, Thanks,

 

 

almajed
Avatar

Hi John

I recently manage to get 2 seprate sensors

ADXL335

IDG500

i connected evrything togther. and try it with the V3 code and it looks like its working in the serial monitor but i cant get any reading for the gyro in the calebrating code and i dont know why. i have check all the pins in the code and in arduino but still doent give any reading for the gyro.

the v3 code is working fine. i can see the both readings for the acc and the gyro.

what do you think the problem is ?

Kstuck
Avatar

I have been tinkering around off and on with an Arduino balancing bot for the past year or so.

I am using this IMU: http://www.starlino.com/store/acc-gyro

No problems getting the IMU from the fine folks over at Starlino. I chose this IMU because it is analog.

It's probably overkill for a balancing bot.

 

ArduinoJack
Avatar

Hi John,

I got sidetracked with some other projects (I've been flying R/C quadcopters) but I'm wondering if there is a new code for the LPY503AL gyro. I'm ready to continue working on the Segbot.

Thank you.

All the best,

Jack

erikhedb
Avatar

Have an ebay clone of the sparkfun 6DOF I2C board.

https://www.sparkfun.com/products/10121

http://bildr.org/2012/03/stable-orientation-digital-imu-6dof-arduino/

Have it running the same way as in the bildr article.

My concern is drift. 

1. Does my inexpensive board give more drift and less quality then the original board? The circuits should be the same and the quality of the board is good.

2. How do we actually compensate for drift in the segbot code? (The short descriptin in the book is ... short)

Gerry
Avatar

Hello to all,
I have just provided a code for IMU Sabertooth 2x25 MPU 6050 and that seems to work well.
It needs a good cleaning and a tune-up.
Someone capable is willing to work a little?
Regards, GerryM

Gerry
Avatar

Hello to all,
I have just provided a code for IMU Sabertooth 2x25 MPU 6050 and that seems to work well.
It needs a good cleaning and a tune-up.
Someone capable is willing to work a little?
Regards, GerryM

erikhedb
Avatar

Have my project on the way with a alumimium box frame and just about to setup all the electronics. Arduino uno, Sabertooth 2x25 and a IMU Digital Combo Board - 6 Degrees of Freedom with ITG3200 and ADXL345.

Where can I find your code?

I have tested my MPU and it works well. Next step is to mount all electronics and bring the software parts togther as a whole.

Where can I find your sourcecode?

/Erik

andersk44
Avatar

Hi,

I am working with Sparkfun's Triple Axis Accelerometer and Gyro Breakout - MPU-6050,  SEN-11028.

Is there someone here that has some experience of this chip in controlling the Segbot?

I try to document my progress on Fb-group: https://www.facebook.com/groups/1415442618700681/

The Facebook group is labeled: "STUV- the KillerMobile".

andersk44
Avatar

Hello to all,
I have just provided a code for IMU Sabertooth 2x25 MPU 6050 and that seems to work well.
It needs a good cleaning and a tune-up.
Someone capable is willing to work a little?
Regards, GerryM

Hi,

I'm trying to get the MPU 6050 (Sparkfun BoB) and the Sabertooth 2x25 to work. I'm intrested to dig in to this.
Regards Anders