Você está na página 1de 5

Embedded Control Exercises

Ball on inclined Plane (BoiP)


Figure 1 below shows the real model with a red ball, the inclined plane in form of two stainless steel rods, the servo motor as actuator to manipulate the angle of the inclined plane, the sensor retaining fixture for the measurement of the ball position and the printed circuit board (PCB) with the micro controller. Inclined Plane Ball Sensors Angle Angle Black rod Micro controller PCB with 4x20-LCD and five push-buttons Servo Motor

Figure 1: Ball on inclined plane with sensors, actuator (servo motor) and microcontroller PCB

The goal of the exercises are the modeling, simulation and programming for controlling the position of the ball on the inclined plane. There are three exercises: 1. Calculation of position and acceleration as a function of the inclined plane angle Study and understand the formulas of ball acceleration and position on the next pages Do the mathematical calculation of the function . Angle is given by the servo motor arm and manipulates with the coupled black rod angle of the inclined plane. Build a MATLAB script which will plot the function Tool chain is only MATLAB 2. Modeling and Simulation of a closed loop control with BoiP and PID controller Modeling the mechanical model (BoiP), where position x depends on angle Construct a closed loop with PID control, BoiP and the reference value Tool chain is MATLAB, Simulink and the dedicated libraries 3. Programming the PID controller in embedded C Self-study: ATmega128, AVR studio, FreeRTOS (Books or Internet)

Controlling task: Coding, build and download to the microcontroller Test your code on the real model Tool chain is AVR Studio, FreeRTOS with applicable tasks and queues and LogView for comparing the position over time graph of the simulation and the real model

Exercise #1 - Calculation of Position, Acceleration and Angle


Figure 2 shows the forces acting on the red ball: 1. Gravitational force due to gravity

2. Rotational forces due to the torque produced by the rotational acceleration of the red ball

with a balls moment of inertia With Newtons 2nd law of motion the sum of all forces is equal to red balls mass multiplied by its acceleration.

All other real forces for example friction are not considered. x

D Fh mg
Figure 2: Acting forces on ball

Fmt

After rearrangement of the last equation the acceleration of the red ball is now a function of angle

With integration of acceleration we get the speed and with another integration we get the position of the red ball. Result is the function . For a constant angle the formula for the position is

Limits of integration (necessary for Simulink - limited integrator) are defined by the maximum of the angle (here estimated to 10 degrees) and the mechanically predetermined lengths of the inclined plane (0.23 m). The maximum roll time of the ball is given by next formula with angle at maximum value. Acceleration and speed at start time are both zero, so the integration constant C is zero.

and after formula reorganization

Speed is first deduction of position

With insertion of tmax in the speed formula we get the maximum speed of the ball on the inclined plane

Control of angle is reached by the actuator, see servo motor arm a1 in Figure 3. The angle of the actuator has a value range of . Figure 3 in conjunction with the equations of a triangle (law of cosines) will help by the mathematical calculation of the function .

2 hk b2 2 a1 1 1 c1=c2 c1 c1 triangle2 triangle1 c1 lk

a2 1 h b1 2

d
Figure 3: Model for calculation of

The next table show some values of the real.

Name d h l = a2 r = a1 c = b2 hk lk

Formula and Value 105 mm 19 mm 118.72mm 18 mm 36.22 mm 17 mm 117.5 mm

MATLAB value 105e-3 19e-3 118.72e-3 18e-3 36.22e-3 17e-3 117.5e-3

The following equation will be helpful for building the MATLAB script for the model. Constants: , and Sum of angles at the center point of the big circle (inclined plane): Two laws of cosines for triangle1: Law of cosines for triangle2:

Sum of angles at the center point of the small circle: Angle is a function of angle 1 and 2. Both angles are a functions of triangle side c1 and the rest in the formula are constants. Triangle side c1 on the other hand is a function of angle 1 and this angle is a function of angle . This will lead to the wanted function A first linear approximation for the function is

All equations will be simulated with MATLAB and the result should be compared with the first linear approximation. A possible result is shown in Figure 4.

Figure 4: Example of exact and approximate equation of

The thick blue line is the exact value of the function and the red line is the approximation of the function. ToDo list for exercise #1: Build a MATLAB script with two vector constructs for angle first for angle is greater than angle - second for angle is less than angle - the right equations for both vectors and the plot commands for drawing the functions. Get from the plot the value limits for angle , when the angle is limited to 5 degree ! Questions: What is special about multiplication with vector values in MATLAB ? Why is the approximation not so good if angle is greater than 40 degree ?

Você também pode gostar