# Dual PID loops with motor encoder + scale encoder per axis

19 Apr 2024 23:25 #298683 by Tinine
It's very straightforward; You tell a velocity-loop ZERO and it's end of story. There are no yeah-buts, ah-buts about it. A velocity loop obeys a command and if that command is ZERO...the drive doesn't decide "oh but this dude is turning my rotor by hand so let it happen"

Will set up a demo tomorrow and video it.

Craig
The following user(s) said Thank You: PCW

19 Apr 2024 23:33 #298685 by PCW
False

The velocity loop has finite gain (or it will not be stable)
The force applied to resist motion will be proportional to this
gain * velocity. As long as you move slowly, you can rotate
the motor shaft.

19 Apr 2024 23:47 #298689 by Tinine
So how do you calibrate the BEMF gain? Why would our PID filter require a D-term if the motor takes care of it's own velocity damping without a coefficient?

Craig

19 Apr 2024 23:56 #298690 by PCW
The D term is required for bare H bridges because you typically want
much higher velocity loop gain than BEMF/motor resistance supplies.

20 Apr 2024 00:10 #298691 by Tinine
Can you show me a transfer function that demonstrates relying on BEMF for velocity damping?

Craig

20 Apr 2024 00:32 #298692 by Tinine
It's only in the realm of FOC/Vector control which requires a DSP.

Craig

20 Apr 2024 00:36 #298693 by PCW
Not sure what you mean by transfer function in this context,
but the motor torque  due to this built in feedback will be  the
motors torque_constant * (Applied_voltage - BEMF)/Motor_resistance
(the motor torque constant being torque per amp)

Note that this is similar to loudspeaker damping (where the reverse
impedance of the drive amplifier affects the damping factor)

01 May 2024 12:59 #299456
Unfortunately I haven't had a lot of time to get back to the servo drive configuration conundrum on my conversion project, but I did make a prototype of some X axis limit/home prox switches.  Just 3D prints for now - I may end up changing my mind about having them in the front T-slot.  But it should make tuning on the machine a bit less nerve-wracking in the meantime.

I've also stumbled into a 750W DMM Tech AC servo and driver.  Unfortunately just one, not a pair of them.  That just might put a bug in my ear about replacing the original huge brushed DC motors, though...
##### Attachments:

01 May 2024 15:50 #299470 by akb1212
Craig,
I'm also one of those guys who did learn control technique about 30 years ago, so I don't remember all the details.But I do know what the confusion here is: You are used to seeing encoder feedback as a constant and linear representation of the movement, like an encoder. What we have here is that the feedback isn't coming from a close to ideal device. And it is also very non-linear. So much so that it's not providing any useful feedback at all at standstill. It's only at higher speeds that this kind of feedback is usable (and available as a physical signal).Take a look at most standard VFDs, they use this back EMF as an "encoder" to control the speed of an inductance motor. They actually read out this value and use that as encoder feedback. The downside of this is that it's only available in a certain range of speeds this is reliable and useful. As a result, they have a very big limitation, they can't control the speed at low speeds. And have next to no control at standstill. This is due to the fact that the back EMF is highly dependent on speed. And is not available at low speeds.Think of it as an encoder that stops giving reliable feedback at low speeds. If there was such a product available, it would be about what we are talking about here.To get a transfer function for this kind of feedback you could get that from the software in a VFD, as they use it. But since they have so many limitations, there is no point.So..... as you might know, to get an induction motor to behave well at all speeds, you have to replace the very limited and unreliable feedback you can get from back-EMF with any kind of proper encoder.
And since all forms of available encoders are of a type that works at all speeds, we can take advantage of that and use any of them to make the servo system stable at all speeds, including standstill. Like most spindles are built today.Anyway, I do understand the tangent of trying to figure out if the system is velocity- or torque-controlled. But I think the answer to this is that it is velocity. The best way to get this confirmed would be to use a signal generator (or test with the output of a Mesa card) to see if it behaves like a speed controlled system or not. And the tests already done seem to confirm that the mode of operation isn't torque, as the system seems to be able to keep the speed constant to a degree.
And then the system closes the outer loop with encoder feedbac in order to achieve accurate positioning.I want to use dual encoder feedback on my mill, a Maho MH600E from 1990. This had an old Philips 432 controller with Rexroth servos. I did what you wanted to do and kept the servos and linear scales. So I have a system with tacos for speed control and linear scales for position control.
But I have found that the Philips controller does something that LinuxCNC isn't able to do. As is, it's impossible to get the speed and precision of feeding only the linear scales to LinuxCNC. My system has full speed control with the tacometers connected to the servo-drives. But still, the bandwidth is kind of low due to mechanical sloppiness. It's an old machine, and has run for 30 000 hours or something, so a mechanical rework is planned. I have even bought a Biax scraper lately....
Anyway, the Philips controller was able to control the mill better than I'm able to with only linear scales attached to LinuxCNC. So I attached normal encoders directly to the shaft of my servo motors and used those as feedback to LinuxCNC instead.... and now we are talking! Much better response, and way better bandwith! But.... now I lost the high accuracy of the linear scales, which have a resolution of 1um!
So.... dual encoder is what I want.
I'm not a programmer, so I'm not 100% sure how to set up HAL to make this happen. Hence, I lurke about here to find others who want the same thing..... to see if there are any configs posted with parts I can use to get my machine working.
It has been years since I started with this conversion..... way too many years.... but I hope to proceed soon,
I also need spindle orient, and have a complicated ATC I want to get running.Anders
The following user(s) said Thank You: TangentAudio

01 May 2024 16:45 #299475
Anders,
Thanks for your "back-EMF as imperfect feedback" observation, it makes a lot of sense to me. I agree that it might be the source of the misunderstandings earlier in the thread. I am also pretty convinced it mostly acts like a velocity drive, at least when it's moving.

Sounds like we have similar goals with dual loop control. I'm happy to share anything that I learn. My machine also needs some mechanical rework (backlash in ballscrews and some moderate wear in the ways) but I'd like to see how well it can be made to work with things as they are. So far, the best I've been able to achieve with a split PD / I dual loop is decent final positioning (eventually, it's still slow to settle) but still not great follow error while moving. It would be adequate for semi-manual stuff like positioning for bolt hole drilling, but not good for cuts.

Those old Maho machines look very nice, you should have a great machine when you're done with your conversion.

cheers,
Steve