Go Down

### Topic: Self Balancing Robot Woes (Read 591 times)previous topic - next topic

#### Abhishek_M

##### Jan 29, 2016, 07:30 pm
Hi, I'm making a self balancing robot like many of you guys.
My hardware: adafruit 10dof IMU, UNO r3, generic 6v geared hobby motors, adafruit motorshield v2.3.

I can't seem to get the complimentary filter and the PID loop to work.

I'm also posting the code alongwith.

Any and all help is highly appreciated.

#### MarkT

#1
##### Jan 29, 2016, 10:03 pm
Quote
I can't seem to get the complimentary filter and the PID loop to work.
Can you provide more useful information than this - what doesn't work, what have you
tried, how you've tested indivual parts before integrating them together etc...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### jremington

#2
##### Jan 30, 2016, 02:51 amLast Edit: Jan 30, 2016, 03:01 am by jremington
The following code doesn't make much sense and seems very unlikely to work. Can you explain what you think it is doing?
Why do you declare Ax to be an integer?
The low pass filter does not appear to be properly coded. Why is the X-axis acceleration used together with "Angle"?
What is Ay used for?
Code: [Select]
`unsigned long Ax;...         Ax = event.acceleration.x; // Assign X-axis value to var[Ax]      accel.getEvent(&accel_event);       /* Calculate pitch and roll from the raw accelerometer data */      Ay = dof.accelGetOrientation(&accel_event, &orientation);    Angle = A * (Ax + orientation.pitch * DT) + (1-A) * Ax;    OutPut = Kp * Ax + Ki * (Ax + Angle) + Kd * Ax/DT;`

#### briantee

#3
##### Jan 31, 2016, 07:18 pm
Code: [Select]
`/* Get a new sensor event */   CurTime1 = millis();  CurTime2 = millis();    if (CurTime2 - CurTime1 >= 10) //if time is more than 10 ms    {      DT = CurTime1 - millis();      sensors_event_t event;       accel.getEvent(&event);      Ax = event.acceleration.x; // Assign X-axis value to var[Ax]      accel.getEvent(&accel_event);       /* Calculate pitch and roll from the raw accelerometer data */      Ay = dof.accelGetOrientation(&accel_event, &orientation);      CurTime1 = millis();`

CurTime2 will always be the same as Curtime1 minus a couple microseconds of course. The "if" statement will never run.

Go Up