I don't know if this is an appropriate post for this section, but I just wanted to share some joy.
My project is to control the speed of a DC PM motor for a classic car project. The car will have a non-standard gearbox which has no mechanical speedometer drive. Since I want to keep the original (mechanical) speedometer then this has to be driven by a motor, from electrical pick up pulses related to road speed.
As a newbie to the Arduino, I have been on a steep learning curve this year. Starting in April 2015, I decided to learn 'C' as this is the basis of the Arduino sketch language. Then having bought an Uno, and built up an interface board, I began to put some code together. I decided not to use the PID library as I wanted to learn the hard way - and assumed that my own code would be easier to understand (in hindsight I am not sure that it was!).
When first connected up, after a bit of debugging the motor did run, and follow the demand signal to a fashion, but there were all sorts of problems. The speed was unstable, erratic, and sometimes the motor either jumped to full speed, or just stopped and sulked.
Many weeks passed by as I tried to tune the P and I constants to get it under control, but I seemed to swap one problem for another and felt like I wasn't getting there. But whilst doing this, I did make a lot of changes to the way I was declaring variable types in order to eliminate errors and overcome limitations of the code.
Last week I posted that I still had instability problems, especially at low speed start up, and I was thinking of going back to the drawing board, and trying a brush-less motor drive instead.
But after some further changes to variable types, and more tweaking of the P and I constants, today I finally cracked it! The motor now tracks road speed (from a pulse generator) closely from 5 mph right up to max speed quite closely, and any overshoot is short lived.
The moral of my story? Well I guess patience and perseverance, and watch out for data typing problems.
Whilst I am far from expert, I hope that now I will be able to help someone else at least in some small way on a similar project.