Well, something doesn't match up. First, you can't seem to decide if you're controlling speed or position -- first you say that you're controlling position, then speed, then you're quoting your unknown colleague as saying you're controlling speed.
So back off a pace or two: what do you want the motor to do? If the answer is "go to the position that I command, and I absolutely don't care how it gets there", then you're controlling position. If the answer is "go a certain speed, and I don't care where it is", then you're controlling speed. If it's something like "go to the position I command, but never exceed V", then you're controlling both position and velocity, and boy are you going to be smarter coming out the other end of this problem than you are now (assuming that you succeed).
Now, assuming that you are controlling the motor drive (either voltage or current), and that you want the motor to go to a certain position, your system does, indeed, need to take the derivative of the motor position. But the 'D' in PID is derivative, so you don't necessarily have to take the derivative _before_ you apply the problem to your PID controller -- you may well be able to let the controller do that.
For the rest -- read this, and get back to us with questions:
formatting link
--
My liberal friends think I'm a conservative kook.
My conservative friends think I'm a liberal kook.
Then -- depending on a whole bunch of other things -- you probably don't need to explicitly take the derivative of position before you run the PID controller.
(Note that if you're trying to do really precise control, and you're running through a gear box, flexible mechanism, or other physical process that divorces the motor somewhat from the positioner, then it is often a Really Good Idea to have independent feedback of the motor speed, either through a tachometer, an encoder, or as a poor second choice, back EMF calculations).
--
My liberal friends think I'm a conservative kook.
My conservative friends think I'm a liberal kook.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.