LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID control for a linear motor

Hello,

 

I don't have much experience with LabVIEW so please be nice!

 

  • I have a voice coil linear motor (moving in one axis, not rotating) and I use a Source Measure Unit (PXIe-4138) and niDCPower driver, to source voltage to it.
  • With a fiber sensor I measure the displacement of the motor and I get a voltage that corresponds to it. 

I try to implement a PID controller in LabVIEW to control the output of the Source Measure Unit in order to correct for imperfections of a sinusoidal motion of the motor (inertia etc). 

 

In other words, I want to source the motor with voltage and correct it continuously based on the displacement of the motor. So, the PID controller should have as input the voltage by the SMU and the voltage from the displacement sensor, and give feedback to the SMU. 

 

Currently I have programmed the SMU to output the Voltage profile that I want (sinusoidal), but I don't know how to implement it in the PID control. 

 

Any suggestions?

 

Nikos

0 Kudos
Message 1 of 2
(839 Views)

Hi Niko,

 

Looks like you're familiar with the concept of PID control.  You probably just need some suggestions on how to implement the loop.  Usually I try to implement a simple "P" proportional controller to get started.  That's just a fancy way of saying, if the process variable is too high, decrease your output, and if too low increase your output.  Like a thermostat.  

 

So the pseudocode would look something like this:

 

1. initialize niDCPower, set SMU output voltage to 0.

2. define your "setpoint" - this refers to the sensor voltage of when you have the desired displacement from motor

3. while:

  - acquire sensor voltage

  - if sensor voltage is less than "setpoint", increase SMU output by 0.1

  - if sensor voltage is more than "setpoint", decrease SMU output by 0.1

repeat the above at 1000Hz

 

With any luck, you should start seeing the motor oscillating around your setpoint.  I'm assuming that the SMU is able to change its output voltage immediately.  If if takes over 10-100ms for update, this control loop will be bottlenecked.

 

Once this works, you can replace your P algorithm with a formal PID to get better tracking and less oscillation. 

 

BR

John

Add motion to LabVIEW in 30min or less - TENET EMotion
Finding it hard to source NI hardware? Try NI Trading Post

Message 2 of 2
(805 Views)