self balancing unicycle

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Guys,

 

 

Here's some details of what I have and what I'm trying to achieve

 

I made a self balancing unicycle a while back, it consists of a 3-axis gyro accelerometer sensor to compute the rate and angle, kalman filter is used to compute the gyro bias and angle error

all that works fine

 

i compute torque as follows using PID

torque = d*rate + p*angle

 

and motor PWM output

PWM += torque

 

 

my question is how to limit the PWM, I want to set some threshold, ie: 50% so if commanded PWM is greater than 50% I want the motor to give boost and slow me down, basically output something larger than 50% momentarily 

 

would this be a second PID?

or what other methods could be used?

I can just add a buzzer too.

 

 

Thanks!

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

to compute the rate and angle, kalman filter is used to compute the gyro bias a

....

I can just add a buzzer too.

This seems rather strange ...you are programming Kalman filters which can be very complex mathematical beasts to understand & implement...but want to know how to limit the PWM?   PID seems reasonable, since you can play with the parameters.  If you are doing Kalman filters, programming to limit a value should be comparative cake.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

are you suggesting to do the following?

if (pwm > 50) then pwm = 50

 

that obviously you cannot do or you will tip over

 

I need to boost the output to tilt back

so my pwm = balance_pwm + tiltback_pwm

 

but if there is a boost from tiltback_pwm then balance_pwm will automatically drop due to balance PID calc

 

I hope that makes sense

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

daniel123123123 wrote:
or what other methods could be used?
Offset the command to control, as your thought, or temporarily reduce the gain.

Variable gain must be limited and analyzed (frequency response analysis to determine if there's adequate gain and phase margins)

daniel123123123 wrote:
I can just add a buzzer too.
Temporarily reduced responsiveness may be enough for the operator.

An example of audible feedback :

FlySight GPS

via https://www.avrfreaks.net/forum/advice-needed-low-power-application#comment-717353

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sounds like maybe gain scheduling needed ... if you are pretty stable, use PID to control the angle or whatever; if near falling over, use time-optimal control to get back to balanced.

 

and the KF to provide gyro bias and angle is not hard if you are designing constant gain (or stationary process)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, I think that will work

 

 

currently target angle is zero (up), and once I'm over speeding then I can alter this target angle to make it tilt back or opposite to direction of travel