-
Notifications
You must be signed in to change notification settings - Fork 5
Arduino PID Cotroller Ball Balance
PID Controller - A proportional–integral–derivative controller (PID controller or three-term controller) is a control loop mechanism employing feedback that is widely used in industrial control systems and a variety of other applications requiring continuously modulated control.
Objective - To balance a ping-pong ball in the center of a beam using an arduino & communicating the results to a raspberry pi via a Bluetooth connection
- P [Process] - The Ping-Pong Ball position
- Sp [Setpoint position] - Arduino programmed desired middle position
- Fp [Feedback position] - Ultrasonic Distance Sensor real position based on distance reading
- E [Error]- E = Sp - Fp
NOTE : Error is the difference between the desired ping-pong ball position (Sp) and the actual ping-pong ball position measured by the sensor (Fp).
- PID_p = Kp * E
- PID_i = PID_i + Ki * E
NOTE : The integral is based on the sum of error over time. So at t0 the will be the integral constanct * the error, but this will grow and decrease gradually over time as the error changes.
- PID_d = Kd * (Ec - Ep /Δt)
NOTE : For the derivitave calculation we consider the ping-pong ball velocity. Which is the change in position (displacement) divided by the change in time.
Δx/Δt
, where Δx is the current Error (Ec) - the previous error (Ep).
- Arduino Uno
- HC-05 Bluetooth Module
- Sg90 Micro Servo
- Ultrasonic Distance Sensor
- The Arduino should be able to provide the position of the ping-pong ball by reading the ultrasonic distance sensor.
- The Arduino should be able to actuate the servo to pivot a balance beam left and right quickly.
- The Arduino should be able to both receive commands from a raspberry pi & return results over a bluetooth connection using the hc-05 bluetooth module.
NOTE: The main result would be the time needed to balance the ping-pong ball.
- The Control System should be able to balance the ping-pong ball from any starting point of the ping-pong ball along the balance beam and from any starting position of the balance beam (i.e. starting at an angle that is not 0 degrees; parallel to the base).
- The Control System should be able to accept PID parameter values (Kp, Ki, Kd) sent to it from the Raspberry Pi.
- Upon power up, the balance beam should have a default start position.
- The Arduino should be able to set specific balance beam position/angles to start at (i.e. -20 degrees or 30 degrees).
- The Arduino should have a general response message for verifying bluetooth communication with the Raspberry Pi. (i.e. Pi sends: "?", Arduino response: "!")