Sunday, 18 January 2009

Calculating platform angle

I have written arduino code to calculate the platform angle and it works perfectly!

This is a graph made in Processing which is taking the angle calculated by the arduino from the serial port. I am oscillating the board quickly.

I am using the complementary filter approach documented by alot of balancing robots. The actual code is something like:

val = ((((analogRead(xPin)-xZero)/148.48)* 180/3.1415926535897932384626433832795))*-1); //accelerometer angle calculation

valG = valG + ((analogRead(gyroPin) - gZero)*4.8099347014925373134328358208962)/200; //integration of gyro and gyro angle calculation

angle = (val * 0.005) + (valG * 0.995); //complementary filter

valG = angle; //drift correction of gyro integration

I can tell it works as intended, because if i rotate the board flat on the table, the gyro senses it, whilst the accelerometer is still flat, so you see it increase and then decay slowly back to zero, rather like a capacitor discharge curve. This shows the accelerometer correcting the gyro's 'drift'.

1. looks good mark! integrate gps and some sort of autonavigation intelligence so it can drive you home from the pub by itself!

2. can you comment on the specific floats you used in your Val and ValG calculations? what is the dt used in the integration. thanks for the clarification!

3. What sensors are you using? Can you post your pde?

4. look at this, for similar code and sensor

5. Nice looking project. I was wondering if you had an idea of the overall cost and the expected speed when its done?

panikos

6. Thanking you for sharing the suberp project,

I wonder you could post the arduino and processing code to calculate the platform angle. It looks like that you used the processing to graph the output.

Regards,
Ozhan

7. Excellent project.

Why do you multiply by 4.8099347014925373134328358208962 and divide by 200?

Where does 4.809 and 200 come from?

Thank you,

Joaquin

8. Excellent

but what are 4.8099... and 200 for the gyro and 148.48 for the acc?

Lot of money invested

10. hi,
how you have connected the XV3500CB?
have you a wiring diagram?

11. Do you have the eletric circuit draw?....and the components positions too?...

12. great thanks for share

I thing kalman filer is good for segway

13. I would like to say thanks for sharing this valuable information.
2 Wheel Self Balancing Scooter

14. Nice looking project. I was wondering if you had an idea of the overall cost and the expected speed when its done?

15. thanks for sharing information i like your blog i read it but im searching for a Toronto Limousine