Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

PID PWM MYDAQ PROJECT

HI All

 

I am fairly new to Labview. I am trying to control the speed and position of a 12V motor which draws 4 amps. I want PID to control a PWM signal which will drive the motor. Thus far, I have PID directly controlling the motor through a transistor. The PID signal voltage goes to the base of the transistor,  allowing a large or small voltage to travel from the battery to the motor (using transistor as an amplifier). I am receiving feedback from a hall sensor which indicates motor position. The MYDAQ only has one counter function, but both counting the hall sensor cycles and outputting a PWM signal require counters (I think). To resolve this, I am using using software to count the hall cycles, so I have a counter free for the PWM signal.

I was hoping to simply wire my PID output to a DAQ assistant and configure the DAQ assistant for a Pulse Output

It doesn't seem to be as simple as this

Can anyone help me out as to the simplest way to get the PID output to control a PWM signal???

 

I have attached a document with images of the front panel and block diagram. I have also attached the vi.....as it stands at the minute

 

All help greatly appreciated

 

Regards

G

Download All
0 Kudos
Message 1 of 4
(7,992 Views)

Hi G,

 

Thanks for your post. What I think you need to do is turn the output from the PID into a percentage. So depending on your parameters you can change the PID into duty cycle. For example if the output from the PID was 0.15, you could times that by 100 to have a 15% duty cycle. This is better done by setting up your own DAQ counter output task rather than using the DAQ assistant.

 

I have found some other resources that I think you might find helpful:

 

- Introduction to PWM using DAQmx: http://zone.ni.com/devzone/cda/tut/p/id/2991

- An Example of PWM output with dynamic duty cycle updates: https://decibel.ni.com/content/docs/DOC-13798

- Similar Forum Post: http://forums.ni.com/t5/LabVIEW/PWM-and-Pid-control-with-MyDaq/m-p/1510576/highlight/true#M565577

 

Please let me know how you get on, if you have any other questions please post back.

 

Best Regards,

Ben B.

Applications Engineer
National Instruments UK & Ireland

"I've looked into the reset button, the science is impossible!"
0 Kudos
Message 2 of 4
(7,979 Views)

Hi Benjamin

 

I have written a  PWM VI. I have the VI attached, and the updated PID PWM Vi. It is not working for me do. I set my PID gains between 0 and 5 (I assume the counter function outputs 0 or 5). I multiplied the PID output by 2 to give a maximum of 10 ( I read somewhere that the Daq MX reads duty cycle between 0 and 10 and not 0 and 100??) I have a waveform chart connected to the PID output and when I run the program, it reads 10, so I believe the problem is with the PWM code. I selected myDAQ/ctr0 on the counter dropdown box on the front panel and wired accordingly. I used my multimeter to read the output from ctr 0 when running the program but I read nothing (I can read a voltage when using PID to directly control the motor)

 

 

Any help greatly appreciated?

 

Regards

G

Download All
0 Kudos
Message 3 of 4
(7,956 Views)

Did you get this working?  I ran across this thread in a related search, and noticed that it's a few weeks old but maybe not so old as to be irrelevant.  There are some problems with your understanding.  I'm not sure where you got the idea that duty cycle is 0-10, but it's 0-1 (fraction, not percentage).  Don't mix units.  The PID outputs duty cycle, not voltage, so setting the range to 0-5V won't work, and multiplying that by 2 definitely doesn't help.  The PID output should be 0-1 because that's the duty cycle range you want to control.  You're probably getting an error when you set a duty cycle outside the 0-1 range, and that's why you get no response.

0 Kudos
Message 4 of 4
(7,858 Views)