I have spent all day on the PID aspect and trying to tune it correctly.
I have had to alter the algorith slightly. I kept getting overshoot to the left when tuning the pTerm part so I inverted this particular term on the output which seems to have cured it. I also divided the output by 2 as I was adding the value to one motor and subtracting from the other and in effect multiplying the output so dividing seemed to stop the frantic oscillations which were occuring as soon as the PID made any small adjustments.
The other problem was that the PID was simply not getting enough data. The encoder wheel in the chassis is quite slow and had one hole in it so I decided to take the chassis to pieces once again and drill extra holes in the cog so now each has 4 holes giving 4 pulses per rotation meaning errors are detected earlier before the robot veers off course and starts to oscillate due to insufficient data.
With the software and hardware problems sorted out it was quite a simple task to tune the PID to make k9 go in a reasonably straight line. According to the hardware the robot is going straight but in reality it is skewing slightly sideways but I am pretty sure this is down to the weave of my carpet.
I found the maximum number of samples I can reliably make is 4 per second. I am hoping object scanning will not drag this down otherwise the PID will need tuning all over again.
Next step is getting the scanning side working but I have a horrible feeling i may have put the sensors in the wrong place.
Foundation Degree in computing - main project. Project to convert K-9 toy into an autonomous robot. By Kristian Dunn
Thursday, 11 March 2010
PID Controller
I have been working on the PID controller element of the software as I now have an object oriented program layed out.
To test various elements of the PID controller I have had to first use a disk dump to dump all of the figures produced to file for examination then as I narrowed down the PID settings I used the InputBox method so i could enter figures manually without having to recompile the program every time.
At the moment I am only using Proportional control with a gain of 2 which gives me an almost straight line and any other setting result in massive overshoot. The robot is only sampling PID 3 times per second so I may need to optimize the code a little further. Also the wheels do not seem to send enough data so I might have to drill a few extra holes to get more pulses per rotation.
To test various elements of the PID controller I have had to first use a disk dump to dump all of the figures produced to file for examination then as I narrowed down the PID settings I used the InputBox method so i could enter figures manually without having to recompile the program every time.
At the moment I am only using Proportional control with a gain of 2 which gives me an almost straight line and any other setting result in massive overshoot. The robot is only sampling PID 3 times per second so I may need to optimize the code a little further. Also the wheels do not seem to send enough data so I might have to drill a few extra holes to get more pulses per rotation.
Thursday, 4 March 2010
Software is taking a new direction
After writing the software for a while now it has become more and more complex so I have taken the decision to break it down into chunks.
The best way I could see to do this was to use the object oriented approach.
I have gone through the grammatical analysis process of Object Oriented Analysis and implemented the classes in VB.
The robot itself is now a class of its own along with the main form and PID controller.
Today I took the PID code from 'PID without a PhD' which is written in C and re-coded it in VB whilst adding some new bits and pieces to calculate the position and error.
This project is becoming an all-consuming monster and is taking up the majority of my time.
I hope I can still meet my final goal while still concentrating on all the other work I currently have on other parts of the course.
The best way I could see to do this was to use the object oriented approach.
I have gone through the grammatical analysis process of Object Oriented Analysis and implemented the classes in VB.
The robot itself is now a class of its own along with the main form and PID controller.
Today I took the PID code from 'PID without a PhD' which is written in C and re-coded it in VB whilst adding some new bits and pieces to calculate the position and error.
This project is becoming an all-consuming monster and is taking up the majority of my time.
I hope I can still meet my final goal while still concentrating on all the other work I currently have on other parts of the course.
Subscribe to:
Posts (Atom)