06-07-2012 03:16 AM - edited 06-07-2012 03:25 AM
I'm trying to control a test instrument using LabVIEW and a series of RS232 interfaced stepper motors. One of the stepper motors is used to compress a spring which in turn applies a point load in the 'z' direction on a flat plane. I am monitoring this normal load using a load cell. The flat plane is moved in the 'y' direction by another stepper motor.
I am trying to program the stepper motor to exert a linear ramped load (e.g., start at 10N and end at 100N). The gradient of the load 'curve' is defined by the movement of the plane in the y direction. For example at the initial 'y' position the force must be at the initial force (10N). At the final 'y' position the force must be at the final force (100N). The flat plane moves at a constant speed. See attached jpeg
Currently, I am using a PID function to set the initial load - this is relatively easy since I have a static set point (the flat plane is initially not moving). I then have a vi which generates the force set point from the y position during the load ramp. Another PID function reads this constantly changing set point and outputs a velocity to the stepper motor to control the force. Unfortunately, I have been unable to tune the PID correctly. The force output does not achieve the desired force quickly enough, produces a wavy shape to my load ramp. I need this to be as linear as possible.
For info, I am using a PID loop to control the slew rate (velocity) of the stepper motor. In mechanical terms, the applied force is simply a function of the number of rotations of the motor, the lead screw pitch, some frictrional losses and the combined spring rate of the system. I can control the stepper motor using position control mode (encoder counts) but since I do not know (accurately) the spring rate of the whole mechanical system, this is not easy to use. I could use the stepper motor in an incremental (relative) position control mode - i.e. during the ramp I could program the PID loop to incrementally control the rotational position of the stepper motor.
I have also used a system with no feedback. I have tried setting the velocity of the z stepper motor to a fixed value which is calculated from the difference between the two desired forces, the ‘y’ distance and the ‘y’ speed. This gives better results but there is an empirical ‘fudge factor’ which needs to be tuned to give a fine control of the gradient of the load curve. Otherwise the load overshoots or undershoots the final set point. With this approach, the load curve is slightly controlled by the surface texture of the moving flat plane which is not desirable.
Does anyone have any experience with PID (or PI) feedback with a constantly changing set point?
I think my problem is that the set point is a function of the 'y' distance which is always changing except from at the start and end of the ramp. This results in inaccuracies as the setpoint is never actually achieved.
Any help/ideas would be great as I am a little bit stuck on this problem.
I can post sections of my code this evening if this will help.
06-07-2012 03:37 AM
It may be that the reponse time of my system means that I cannot use PID control. I using a NI-USB-6211 card to monitor the load cell and there are 51200 counts per rev for the stepper motor. With this resolution on the stepper motor controlling the y axis, the setpoint might change every few iterations of the code...
Can anyone suggest a different control method?
06-08-2012 08:08 AM - edited 06-08-2012 08:08 AM
It sounds like the code and the hardware seem to be behaving correctly, so we really are just focusing on the implementation of the PID Control parameters. Since we're seeing an oscillatory response about the changing setpoint, based on the attached image, this is usually due to the magnitude of the differential term in the PID loop. By reducing the size of the differential component, we should be able to quench the oscillations in the system; however this will make the response slower, so we could also try boosting the Proportial gain.
How have you currently tuned the PID parameters? Have you adopted a method such as Zeigler-Nicholls tuning? This is a relatively basic method used to optimise PID plant response characteristics, which will probably be fine for this application.
In terms of the speed of the generated feedback signals, we could also try looking at your code to check whether we're able to increase the frequency at which the analogue output channels are updated, as well as how quickly our feedback signal is acquired and processed.
At this point, I wouldn't be concerned with the fact that the setpoint is constantly changing; PID being a closed loop implementation of control should work fine in this instance.
06-08-2012 09:18 AM
I've previously attempted the tune the PID controller using the NI autotune and by manual adjustment (trial and error). I did not know about the Z-N method. I'll have a go at this and report back. At the moment im using the instrument with a proportional feedback controller that I have written. This seems to give the best performance so far. Hopefully I can tune the PID controller to yield better results.
06-08-2012 09:24 AM
BTW, the process variable is acquired as an analogue signal from the load cell. The manipulated variable output by the PID controller is currently a DBL which is converted to a string, passed to VISA write and sent to the stepper to vary its speed. I can rewrite the code and make some hardware modifications to control the velocity of the stepper motor using an analog voltage from my DAQ card. I think this would probably have less lag than sending commands via RS232. This will probably help in tuning the PID controller.
06-08-2012 11:05 AM
Going to analog mode for tuning sounds useful. With either mode, I'd suggest you put some type of rate limiter
on your velocity control signal - steppers can be touchy about step changes in velocity.
Also, as I recall the math from doing LaPlace stuff once upon a while ago, a tuned PID controller will guarantee
zero error when the input is a step function. However, it leaves you with a calculate-able "tracking error" when
the input is a ramp function. To drive the dynamic tracking error to zero requires another poll in the controller
Try to tune to a step function first, then observe the tracking error you get with a ramp input. Your PID might
still be plenty good enough to track as well as you need.
06-12-2012 02:48 AM
Update. I've finally programmed the z axis stepper motor driver to accept a 0-10V analog input to control the slew rate. I've tuned the PID function (using the built in NI tuner) and got good results with a static y axis.
The next job is to integrate the new code into my application and test the setup with a moving y axis. I'm hopeful as the force output seems to track the setpoint well even with large setpoint oscillations. I think the lag caused by sending the stepper motor commands over rs232 was increasing the response time of the system, leading to overshooting the set point.
Thanks for the help! I'll report back once I've done some more testing.