Funny, I thought this to be a rather routine PID application. Granted it would have to be fast, the proportional band width will be the key, and I think it can certainly be done with one loop. We do fast PID for temp control that has a cycle time of about 50mS (not really so fast, when you think about it, only fast compared to off-the-shelf process controllers) and the proportional band width needs to be narrow enough for the system to respond quickly, but wide enough to not overshoot wildly. That would equate to being narrow enough to keep the ball from dropping out of range, but fast enough to recover quickly. I never did get this process to run smoothly with anything but a zero derivative, so maybe what's needed here also is PI control.... By the time you figure out how you can actualize the on/off cycling in a wide enough range to keep the ball afloat, you might as well have stayed with the analog ouput and a fast PI algorithm. If someone had some spare time, this could probably be accomplished with a 100 or 50mS packaged process controller with an analog output....then the PID data extracted and used in your PIC program... > The inner loop that adjusts current as a function of position > and desired > force will probably need to be much faster than the outer PID control > loop. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu