Wednesday, 19 April 2017

VFD control lines and servo tuning

VFD control lines:

I've never used a CNC machine (yet) so even some simple stuff can be a bit confusing. So typically you have M03 (spindle CW), M04 (spindle CCW) and M05 (spindle stop) commands in your g code to define the direction of the spindle and actually turn it on and off. There's also the S command to set the spindle speed (eg S1000 demands 1000rpm). You can set the speed by setting the S command and then come along later and actually enable the spindle - or vice versa apparently. But VFDs don't usually have a 3 line control like that, so I was confused. The simplest scheme is the "2-wire" arrangement where you have an enable for FWD and another enable for REV, plus a 0-10V analog signal for the speed. That's also the default mode for the Yaskawa VFD. In fact, issuing M05 overrides M03 and M04, so there is no need to run the M05 line to the VFD and a 2-wire scheme should be fine. That way, once the M05 is issued, the VFD should stop.

As ever, the Yaskawa gear is simple to connect up. The terminal blocks are "screwless" ie spring loaded, so quick and easy to use. I used boot ferrules to avoid strands of wire straying. I've got the following connections:
  • AC - Analog ground 
  • A1 - Analog 0-10V (spindle speed)
  • SC - Digital ground
  • S1 - FWD / M03
  • S2 - REV / M04
  • MA - ALARM relay (NO terminal)
  • MC - ALARM relay (COM)
Note that I have commoned the screen and ground connections.



This allows the "2-wire" scheme to be implemented, along with VFD alarm status which can be wired into the e-stop circuit and/or the controller's VFD alarm input.

Bottom line - works nicely with the VFD default settings. I rescaled the analog input so that 10V gives 6000rpm (the default is 3000rpm) and everything is good. With the remote operator, it is possible to display the (motor) spindle speed, although on this machine I believe the driving and driven pulleys are the same size and the VFD has some form of clever compensation for slip frequency, so the display should be close to the actual machine spindle speed - or good enough for my purposes.

Servo tuning:

I thought it was probably time to man up and run the servos from the full 120Vdc, rather than the girly setting of 48-50V. One direct consequence of the change is to reduce the gain margin by something like 5dB or so. I don't pretend to have done any sort of optimisation of the PID controllers yet but this seems to be the time to do it.

I got off to a good start at least - the increased voltage didn't cause any of the drives to pop as such. However, they were certainly on the margin of instability and it's quite possible that they would worsen once warmed up.

You can connect up the CNCdrives USB diagnostics tool when the servos are still connected up to the controller. It's a bit noddy but seems to work fairly reliably. You connect up to the chosen drive using the USB interface (you have to get one of these when you buy your servo drives), then download the parameters from the drive. You can then fiddle about with the various parameters and test the response to step demands. The response of each tests is shown graphically a second or 2 after the event.

These are the values that were in the drives. I suspect they may be what was shipped. The Z axis had different values, as I had already messed with them. Interestingly, the shipped values didn't seem to be a million miles off.

One criticism would be the lack of a timescale on the graphical display, although I could connect a scope up if I were really bothered. Of course, the aim is to bugger about with the Ap, Ad, Ai etc values until you appear to have achieved the best looking response, so perhaps the actual timescale is beside the point. However, I can say that the speed of response is pretty damned fast, judging by the way the whole machine judders in response.

Anyway, I spent an hour or so "optimising"(?) the parameters for the 3 drives. Not surprisingly perhaps, the final values I arrived at seem to work for all 3 axes, or close enough that there doesn't seem any point having slightly differing values between them. The proportional gain (Ap) is the key value to get roughly right to start with, then some derivative (Ad) to minimise overshoot, then some integral (Ai) to eliminate offset. As you dial in more of one term, it affects the optimal value of the others, so a fair bit of trial and error is needed. In the past I've done all sorts of Bode plots, Nyquist diagrams, plant models etc but that's water under the bridge now and would take me longer to get it wrong than to simply bugger about for an hour or so.

Even after optimisation(?) the Z axis grumbles a bit but that seems to be the result of either the much reduced moment of inertia of that axis or possibly some issue with the encoder or possibly some backlash (must check the belt tension and the encoder coupling). But if it were just the result of crap optimisation of the Z axis controller, I would have been able to make it stable by messing with the various gains. In fact it wasn't possible to eliminate the problem, no matter what. Grabbing hold of the graduated wheel on the ballscrew helped a bit, so it's possible that some additional moment of inertia (a large metal disk?) could help. These are the final values:

As you can see, the shape of the response doesn't look too bad - minimal overshoot and rapid settling. And nudging the gain terms up and down from there doesn't seem to offer any improvement.

NB: The "Li" term seems to be some form of clamp on the integrator. Lowering it from the default value of 40,000 to the final value of 5,000 helped the response without any obvious degradation elsewhere.

After dialing those values into all 3 controllers, I have a stable, quiet (apart from the grumbling Z axis) machine. It seems to be rather quick to position, which I shouldn't complain about. I suppose I could probably turn the rapids up from ~4500mm/min to around 11000mm/in if I felt my willy size needed increasing. That would be over 400IPM in Mercan units. But I'll leave it where it is for now, unless there is a problem later.

No comments:

Post a Comment

TIG welder up and running - after some fault diagnostics and repair

Finally got some time to connect up the flow meter and argon hose. Plugged in the torch and ground cables and the torch hose etc. Powered it...