04-27-2009 04:18 PM
Hi,
I am using a stepper motor to control a valve in order to actively regulate the pressure of my system to acheive a specific setpoint. I have been using the PCI 6229 card to control the stepper motor with a digital output for the direction and a TTL (also generated via a digital output) to drive the motor. I have developed a variation of Write Digital Chan -Ext Clk.vi to send the pulse train to my device through a digital output because I have no spare counters to use for this application. I would like to use the output of my pressure monitor (an analog voltage) as the input to labVIEW for a feedback loop where the output is a pulse train with a varying number of pulses depending on how close I am to the desired pressure.
This seems like a common application, but I couldn't find an previous posts that suggest how you can use labVIEW to develop a PID or other feedback loop with an analog input and a pulse-train of varying length for the output. I would appreciate any suggestions, even links to previous posts that may be relevant.
If there is an obvious solution, I might be able to free up a counter for this purpose, but I didn't see any PID examples that included counter outputs either ....
Thanks!
04-28-2009 02:00 AM
The reason why you can't find PID examples with pulse train outputs is the fact, that this is everything else but a typical usecase. Unlike servo motors, the discrete positions of a stepper motor are not well suited for closed loop control. In fact most motion control systems that offer closed loop stepper modes don't run PID loops. Instead they compare the motor's position with the commanded position at the end of the move and compensate the difference by pull-in moves. Stable PID control of a stepper motor is hard to obtain and it's not recommended.
With this said here are some tips that might help you:
Kind regards,
Jochen Klier
National Instruments
05-11-2009 04:50 AM
For some reasons we sometimes use a stepper instead of a servo motor and we have successfully developped several applications using a PID. Our setup is quite different to yours and the value to control is the torque :
There are some important limitations with this solution (software PID, override percentage is "only" 0 to 150 of the programmed velocity...) but it works quite well in our applications.
05-11-2009 08:16 AM
05-11-2009 08:39 AM - edited 05-11-2009 08:41 AM
Here's a screenshot from the PID loop. I add some comments that should help you to understand the code :
05-12-2009 04:10 AM
JB,
I really like the idea of using the velocity overide function for a closed loop control of a stepper motor. Thus you don't have to take care of the step generation and there is not such a risk of a step loss compared to direct step generation from a software control loop.
It's always great to learn something new!
Kind regards,
Jochen
05-12-2009 04:50 AM - edited 05-12-2009 04:52 AM
Jochen,
It's really a great honor for me if you, the uncontested Motion specialist (I don't like the word Guru), could learn something from me !
Kind regards
05-13-2009 06:00 AM
05-20-2009 03:00 PM
Hi,
I am trying out something similar, but with a servomotor and need torque feedback. I have an existing piece of code written using event generation logic which works well (Toggling motor direction between upper and lower limits for a fixed # of cycles), but need to improvise the same functionality using state machine architecture, This is giving me the problem. I believe my transition of states is messed up. I am attaching both my codes, can anyone take a look at them and let me know where I am going wrong?
Thanks
Sasi.
05-21-2009 03:57 PM
Hi Sasidhar,
You should try running your code using Highlight Execution. You can select the light bulb at the top of the block diagram to do this. You can watch your code execute with Highlight Execution and see where the transition mistake is happening. I use it all the time to figure out how my code flows. Don't forget to turn it off once you fix the problem though! Thanks.