You are on page 1of 10

Queron Williams 10031755

Micromouse Control Report

03/04/2012

Robotics Group Project 2011-2012 Control Report Contributions

This page shows the percentage contribution made by the group members (Queron Williams & Adam Waterman) over the last year. Section weightings 12.5% 12.5% 25% 50% Contribution per section Queron Adam Williams Waterman 50% 100% 100% 100% 50% 0% 0% 0% Total percentage Queron Adam Williams Waterman 6.25% 12.5% 25% 50% Total Queron Williams 93.75% Adam Waterman 6.25% 6.25% 0% 0% 0%

Sections 1st term presentation 2nd term presentation Control report Final report

I agree to the figures shown in the table above:

Queron Williams:

date:

Adam Waterman:

date:

Queron Williams 10031755

Micromouse Control Report

03/04/2012

Robotics Group Project 2011-2012

Control Report

Micromouse
Queron Williams and Adam Waterman

Queron Williams 10031755

Micromouse Control Report

03/04/2012

Introduction:
This is a report documenting the modelling, simulation and testing the dc motor that we will be using in our Micromouse project. The model of the dc motor will help me understand the characteristics of the dc motor and tune my mouse for a better performance.

Aims and objectives:


Create an accurate model of the DC motor we will be using. Find a way to add friction to this model. Plot of the step response and a quantitative time domain analysis for the model we have created. Implement PID position control for the DC motor. Use what I have learnt to produce a speedometer. This will use the velocity of one motor to set a target position for the other motor.

DC motor Modelling: Building a model of the motor allows us to design appropriate controllers and test them in simulation quickly, easily and without risk of damaging anything. To allow us to easily model the motor I used Laplace Transforms. This converts differential equations into algebraic equations, making them much easier to solve. The Laplace transform converts
a function f(t) from the time domain to the frequency domain F(s). Once in the frequency domain the equations may be put into and transfer function which allows us to see how a system acts on an input. Many different Laplace transforms can be found online. The ones which we need are given below:

Constants L(R) = R, Function of Time L(I(t)) = I(s), Derivatives of Time L( dI/dt ) = sI(s),

From this we can calculate the following transfer function:

Queron Williams 10031755

Micromouse Control Report

03/04/2012

This Transfer function is then constructed in Simulink.

When running this simulation we can see that the motor accelerates initially however the graph then levels out as the motor reaches its top speed.

One problem with this is that there is no form of control so adding a disturbance such as an external force to the system changes the output dramatically

Queron Williams 10031755

Micromouse Control Report

03/04/2012

Now that I had an accurate motor model I decided to implement a PID controller to see how the motor would react under different loads. PID stands for Proportional Integral derivative. This means the system calculates 3 separate values and factors them together with a bias to produce an output. In the real world this type of control has many applications from cruise-control to thermostats however for our mouse we will be able to use this for achieving an accurate output on the wheels of our mouse. The system will use feedback from our encoders to adjust output power and make sure the motors are always under control. So what does each term do? Proportional this is calculated by working out the error of the system. Its purpose is to make the system adjust more the further it is from its target. Increasing the proportional gain will make a system more responsive however to much can cause oscillation. Integral this is calculated by adding up previous errors. A proportional system may never reach its target, by adding the integral this continuous error (steady state error) would cause an increase in the system output causing the system to reach its target. Having to much integral though can cause the system to become unstable. Derivative - this is calculated by working out the rate of change in the system. It is used to slow the rate of change in the output of the systems and smooth the system output. Derivative control is used to reduce the magnitude of the overshoot produced by the integral component and improve the combined controller-process stability. The PID is worked out as follows:

output = (Kp*error) + (Ki*integral) + (Kd*derivative)

Adding this to our model: I Implemented the PID into our simulation so that we could calculate values to be used on our mouse.

Queron Williams 10031755

Micromouse Control Report

03/04/2012

With the PID it can be seen that the system begins to recover from external forces that are applied. For this example Kp = 1 Ki=1 and Kd=1.

Increasing Kp can increase the systems responsiveness. For this example Kp = 4 Ki=1 and Kd=1.

However increasing this to high causes overshoot. For this example Kp = 20 Ki=1 and Kd=1.

Queron Williams 10031755

Micromouse Control Report

03/04/2012

Increasing Ki makes the system recover from steady state error faster however causes the system to overshoot the target. For this example Kp = 4 Ki=2 and Kd=1.

Increasing KD makes the system output far smoother. For this example Kp = 4 Ki=2 and Kd=2.

Queron Williams 10031755 Speedometer:

Micromouse Control Report

03/04/2012

I implemented a position PID loop on the mouse that would use the velocity of the right wheel (x20) as the target position for the left motor. This allowed us to use one of the motors as visual feedback to show the speed of the other wheel, much like a speedometer would in a car. The PID routine was placed inside a 10ms interrupt so runs at 100Hz. We sent the speed of the right motor, power output to the left motor and position of the left motor over UART with an FTDI cable and graphed the results in MATLAB. We sampled at 100ms as this was the fastest that the Uart allowed at a low baud rate.

The green is the speed of the right motor, red is the position of the left motor. As you can see the output motors position was able to very accurately track the input wheels velocity. The blue shows the power level to the left motor, this initially appears to be very noisy however this is actually just the PID attempting to constantly adjust the output power.

Queron Williams 10031755

Micromouse Control Report

03/04/2012

This enlarged snippet of the previous graph shows how accurately the position PID tracks the velocity. There is no point where the position is more than 1encoder click out from the velocity..

Queron Williams 10031755

Micromouse Control Report

03/04/2012

Analysis and Conclusion:


During this task I found that there are many factors that are not taken into consideration in the model of the motor. These are factors such as friction inside the gearbox and the weight of the mouse which would have to be accelerated. Although only having a small impact on the overall behaviour of the motor these inaccuracies started to add up when i tried to use the models to calculate PID values to use on my actual hardware. I could have spent a long time adding each of these to the model however this would be time consuming and may still have provided inaccurate results. I found that the model was not that useful for finding values for use on the actual mouse. I found that the best way to tune the PID on the actual hardware was to do it on the mouse and send the data back to the computer for more detailed analysis. This took a lot of the guesswork out of tuning the PID and meant that I was able to get a PID that reacted accurately and reliably, even under heavy loads. One thing that I did find the simulated PID useful for was that being able to run many quick simulations. This helped me learn what each of the three terms did within the PID and how each one changed the system response. When I was having problems with the PID values on the mouse I was easily able to replicate this in the simulation then figure out which values needed to be changed to fix the problem. Without the simulation this may have taken hours of trial and error on the hardware. I found that the ability to graph data in MATLAB was a great help and allows you get a very large amount of feedback from you mouse very easily. This is something that often causes a problem when working on embedded hardware as there usually no display or feedback other than leds. Once we had the PID tuned and working I was incredibly impressed with how responsive it was. This project was my first experience with using PID and I had not expected such good results from the output. I think that I will be using PID again in any control based projects I do in the future as it gives such good results and is relatively easy to implement.

10

You might also like