I worked again at the spindle.
I have a “theory” on how to handle the two gearings of the machine.
First, I try to get the motor RPM into LCNC. With the analog out from the VFD, I am now able to get this with an accuracy of about ±25 RPM, which is less than 5% off. I measured the real RPM with a cheap optical tachometer and the RPM that the VFD “thinks” it is at. These two were consistently very close. The VFD was consistently 3 to 5 RPM higher than the tachometer, in an RPM range from 880 RPM (at 30 Hz) to 2080 (at 70 Hz). 3 to 5 RPM seems close enough to ignore that error and believe the VFD.
Now, having the motor RPM, I set the variator by hand so the overall reduction ratio was 1:1 (or close to it)
My plan is to tune the PID at this point and later multiply the error term (pid.s.error) by the overall reduction ratio. If I am not thinking about this totally wrong, this should give the system a hopefully somewhat stable spindle PID over the very large reduction that the backgear and variator provide.
Now I do have 3 problems:
1: There is something wrong with my pid.s setup. As soon as the error gets significantly negative, the output shoots up and the system runs away. I found that pid.s.output can be between 3000 and -3000, but I use 0–10 V, not ±10 V, so as soon as pid.s.output goes negative enough, it runs awaythe sign seems to be ignored. I think this has to be a somewhat common problem with 0–10 V. I was able to remove the runaway by using a limit component to cut away the negative part of pid.s.output, but that led to strange behavior as well. With this, I can increase P to large values without it starting to oscillate much.
2: I was able to get the motor RPM, and I have the spindle RPM, but putting both into a div2 component gives 0 at all times. And not a close-to-zero float (e.g. 5.459834658e-7), but actually just 0. I thought it had to do with the deadband, but no value of that seemed to resolve this. The spindle RPM is obviously 0 when the spindle is still, so I do have a limit component to keep the spindle RPM at ≥ 1, resolving divide-by-zero issues. And as soon as the spindle spins, the numbers seem fine.
3: I already foresee a future problem: given that I have the gear ratio and a solid PID at a ratio of 1:1, I would need to scale pid.s.error (reduction_ratio * pid.s.error), but I could not find where this variable is set, so I would not know how to set my scaling factor.
Sorry for this long rambling message, I hope I was able to explain what is going on on my side.