The Segway is a two-wheeled, self-balancing, battery powered electric vehicle invented by Dean Kamen. It is produced by Segway Inc of New Hampshire, USA. The name Segway is a homophone of the word segue, meaning smooth transition. PT is an abbreviation for personal transporter. Computers and motors in the base of the device keep the Segway PT upright when powered on with balancing enabled. A user commands the Segway to go forward by shifting their weight forward on the platform, and backward by shifting their weight backward. The Segway detects, as it balances, the change in its center of mass, and first establishes and then maintains a corresponding speed, forward or backward. Gyroscopic sensors and fluid-based leveling sensors detect the weight shift. To turn, the user presses the handlebar to the left or the right.
Balancing a small platform
Working Principal . 0 X -X Motor pushes the other way based on the angle.
Angle measurement based off the accelerometer reading. Gain is a constant based on your setup. Hardware Arduino Uno (8-bit Atmel AVR microcontroller) L298 H-bridge ( motor control) Actuators (Gear Dc Motors ) 6 V: 440 RPM and 250 mA free-ru Tyres (Rc car tyres ) IMU (MPU-6000/6050 Six-Axis (Gyro + Accelerometer) MEMS MotionTracking Devices) IMU-GY521 The MPU-6000/6050 devices combine a 3-axis gyroscope and a 3-axis accelerometer on the same silicon die together with an onboard Digital Motion Processor (DMP) capable of processing complex 9-axis MotionFusion algorithms. user-programmable gyro full-scale range of 250, 500, 1000, and 2000/sec (dps) and a user-programmable accelerometer full-scale range of 2g, 4g, 8g, and 16g. IMU
Block Diagram of the System
Filters Why do we need filters. The raw data from the IMU has very much noise. With the time the gyro drifts and that will lead the robot to fail.
Accelerometer and Gyro The problem with accelerometers As an accelerometer measures all forces that are working on the object, it will also see a lot more than just the gravity vector. Every small force working on the object will disturb our measurement completely. If we are working on an actuated system (like the Segway), then the forces that drive the system will be visible on the sensor as well. The accelerometer data is reliable only on the long term
Kalman Filter
The Kalman filter estimates a process by using a form of feedback control. The states of the process is estimated by the filter at a certain point and then obtains a feedback of noisy measurements. Therefore, the equations for the Kalman filter fall into two groups, the time update equations and measurement update equations Kalman Pros and Cons Theoretically ideal filter for combining noisy sensors to get clean, accurate estimates. Cons Complex algorithm Hard to implement Would kill processor time.
The complementary filter
Complementary Filter Angle = 90%*(Angle + Angular Velocity*dt) + 10%*(Non Filtered Angle) Clean Angle High Pass Constant Previous Clean Angle Angular Velocity Reading from Gyro Time Rate of sampling Low Pass Constant Raw Angle Reading from Accelerometer This integration converts angular velocity to angle. Low Pass High Pass Pros and cons of complementary filter Can help fix noise drift and horizontal acceleration dependency. Fast estimates of angle. Not very processor- intensive.
Cons Not very accurate estimate like Kalman filter.
Results Comparison of Kalman and Complementary filter(rest) Results Comparison of Kalman and Complementary filter(moving) Results Comparison of Kalman Complementary filter and simple ..gyro(moving) PID After implementing the filters the PID is applied to make the robot balance.
PID is The proportional term Kp * e(t) is an output value based the difference between the set point and actual point.
The integral term is the sum of all errors over time, this term allows the controller to advance the output such that all the errors are eventually cancelled out.
The derivate term, is based on the first derivative of the proportional error, it checks if the error is getting smaller as time goes by.
Tuning Kalman tuning The filters performance could vary greatly if the parameters are not properly adjusted.
1. The initial covariance matrix.
2. The state estimate vector.
3. The Q matrix and its corresponding random noise vector w.
4. The R matrix and its corresponding random noise vector v.
Kalman Values of Q_accelerometer and Q_gyroscope are set depending on how much confidence one puts on the particular sensor. A higher value indicates that the particular sensor is trusted less as compared to the other sensor. The value of the R_measurement matrix indicates the amount of noise expected from the measurement, a low value indicates that the measurement is less corrupted with noise The filter tuning method used on this project was done by trial and error. Once the tuning covariance matrices Qw and measurement matrix Rv constant parameters provided the desire output response, the constant values were kept The measurement noise and the process noise covariance matrix values used are Q_angle = 0.001; Q_bias = 0.003; R_measure = 0.03; PID tuning The PID controller use da set of tuning rules which is based on the Ziegler Nichols method. Select typical operating setting for desired speed, turnoff integral and derivative part and then increase Kp to max or until oscillation occurs. If system oscillates, divide Kp by 2.
Increase Kd and observe behavior when changing desired
speed by about5% and choose value of Kd that gives a fast
damped response.
Slowly increase Ki until oscillations tarts.ThendivideKi by2or3.