NI Home > Community > NI Discussion Forums
Reply
Member
Choong
Posts: 9
0 Kudos

How to use PID function to control a DC motor?

Hi everyone,

 

I wanna control a 6v DC motor using PID control toolkit 8.2.

- a close loop control system with an encoder sensor

- using a DAQ card model: NI USB-6008

- the DAQ card will be able to output pwm signal to the transistor then to my motor

 

Im stuck at getting pwm signal from the pid.vi and i wanted to know what is the process variable (PV)

pls help me on my problem, if can pls make an example VI for me

 

Thanks !

Member
Chongnang
Posts: 7

Re: How to use PID function to control a DC motor?

 Hi,

 

The process variable is the variable that you want to control. For you application, I guess it should be the duty cycle of the PWM signal.

 

I do not think that the pid.vi function can generate pwm signal. You can use the PID to create the duty cycle output, and use the output from the pid.vi function to created desired PWM.

 

To create PWM signal, please refer to the following link.

http://zone.ni.com/devzone/cda/tut/p/id/2991

 

I think you would not have any problem with creating the PWM with your 6008, since it is a multifunction DAQ.

 

Sincerely,

Gunyapart Deephanphongs

Application Engineer

NI ASEAN

 

 

Member
Choong
Posts: 9
0 Kudos

Re: How to use PID function to control a DC motor?

Hi Chongnang,

 

Thanks for replying. The link that you post is a bit hard to understand for me because of all those DAQmx VIs.
1) Do you have an easier way on how to connect output of the PID.VI to the DAQ assist VI ?
2) This is a closed- loop control system, the question is the signal from my encoder sensor it's a digital or analog ?

3) Do you know how to input transfer function without the control design toolkit ?

 

Thanks.

Member
Ymahardh
Posts: 17
0 Kudos

Re: How to use PID function to control a DC motor?

Hi,

 

1) Do you have an easier way on how to connect output of the PID.VI to the DAQ assist VI ?

Basically, above solution is easy, you just take it step by step then you will catch the fundamental. For your information, NI 6008 is not the best choice for creating PWM but for application when timing is not important. Beside above link, you may refer to below link (PWM by software timed):

 http://digital.ni.com/public.nsf/allkb/1561D31534F07D608625727900391114

 

2) This is a closed- loop control system, the question is the signal from my encoder sensor it's a digital or analog ?

Your encoder output should be the input of 6008 counter. However, 6008 only has 1 counter only supports simple event counting. This would mean that you could count only rotation in one direction - so either channel A or B. If you are interested in using a quadrature encoder, you might want to look at one of our M-Series DAQ cards. It will give you 3 terminal to connect your A, B and Z terminal from your encoder. For info regarding encoder, you may refer to this link:

http://zone.ni.com/devzone/cda/tut/p/id/7109#toc1

 

3) Do you know how to input transfer function without the control design toolkit ?

Basically, it is very possible, but you just need to do more effort. You may be interested to see this thread on how simulate transfer function without control design toolkit.

http://forums.ni.com/ni/board/message?board.id=170&message.id=367012&requireLogin=False

 

Regards

Yasrof

 

 

 

Member
qatar
Posts: 1
0 Kudos

Re: How to use PID function to control a DC motor?

hello

 

actually i noticed the conversion, actually its important to my project and need some help if someone can help me, my project is an inverted pendulum and i already designed its interfaces by using PWM drive to drive the motor and optical encoder interface as a sensor but my problem now how i can control the the signal that come from the optical encoder to send it to the pwm and as well to the DC motor

 

 

Thanks

 

ahmad