Michael Rigby-Jones wrote: > To be honest, this won't be a particularly difficult control problem, This only proves you've never tried it before. > and would be possible even with a very basic PIC such as a 12C508. Maybe that is possible, but that would be a considerable challenge in my opinion. If you're not too fussy about response time and overshoot, then it will be a lot simpler. If you want to get reasonably close to what the mechanical system is capable of (like the way it was driven by the parts that got ripped out), then you will need something more powerful than a 12C508. The '508 doesn't even have an A/D. > Using a PIC with a CPP module to provide PWM makes it that much more > simple. I think essential since a PID controller requires considerable computation. > // get setpoint from the RF link > setpoint = GetSetpointFromUart(); > > // digitise the servos potentiometer value > positon = ReadAdcValue(); > > // calulate error term > error = setpoint - position; > > // integrate error > integral = integral + error; > > // apply PI control > pwm = (error * PROPORTIONAL_GAIN) + (integral * INTEGRAL_GAIN); > > // set the output to the servo motor > SetCPP( pwm ); Now it's time to put theory to practise, and learn the difference between the two. There are a lot of details you glossed over here, but it will be these details that will require 95% of your time. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist