Hello LabVIEW community,
I'm trying to control a servo motor using a discrete transfer function controller and I'm having trouble getting the controller to output values that make sense. I've successfully designed and simulated the transfer function in MATLAB but when I implement the same model in LV, I'm getting values outputted from the controller that are on a scale much larger than expected.
I'm using a USB-6211 to read data from a force sensor and then send a PWM signal to the servo based on the desired setpoint function for the force. The servo PWM signal can range from 5% to 5.8%. Unfortunately, I'm unable to specify bounds on the discrete tf controller (I'm able to with PID control) and the output ranges from 0 to 10^30, well outside the 5 to 5.8 range that I desire. Is there any way to specify the output range for the discrete controller?
I've attached a zip of the project I'm working on (main VI is TestMain.vi) and pictures of the creation of the tf model and the discrete tf controller. Please let me know if more information is needed, thanks in advance for the help!
Have you checked the ordering of the discrete polynomial - the a and b terms - if you are taking the polynomials from Matlab and trying to use in LabVIEW I think they are different - one is in ascending powers of z and the other in descending powers of z (can't rememeber which way around - but documentation will explain)
Also, check if you are working with powers of z or powers of z^-1 correctly in both.
Also, check that that the sample time is consistent between both.
Thanks for the response Andy, I did check to make sure that the a and b terms were correctly ordered in LabVIEW. I also have used the same sampling time and the powers should be consistent.
OK. Since you are trying to use the discrete transfer function within a feedback controller it can be hard to isolate the problem if you keep it in closed loop. After the initial checks you have done, I would then check that the TF itself is appropriate as a controller.There are plenty of reasons why a controller could go to exponentially large values - even if everything programmed correct:
Break the control loop (i.e. open loop), and apply a small step error to the input of the Controller - do you get what you expect on the output of the Transfer Function.in terms of magnitude, direction and speed of response. If you controller is integrating then it may just keep ramping up - so you need to see how fast it ramps up. Then if that is ok. Look at how the step error translates to a change in your PWM and motor motion again does it change correctly in terms of magnitude, direction and speed.
You might find there is a scaling factor needed to be inserted to get the error propapagting around the loop in a sensible fashion.
The Key with debugging control loops is to break the loop and understand responses, and start with a sluggishly tuned controller - ideally without integrating or derivative action which can give their own problems.