LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID controlled PWM output

Solved!
Go to solution

Hello,

 

I am trying to develop a PWM output which controls a SSR which controls a DC motor. This DC motor drives a pump for coolant flow. The idea is to control the coolant temp of a combustion engine. Once the temperature setpoint is entered, the PID control system can control the dutycycle. A thermocouple feeds the actual temperature back to the PID system.

By combining 2 pieces of VI, which I found on the net, I already made it work. I attached it below.

However, I have a disturbing problem, that it will stop and start the code (and thus, also the PWM output) every looptime the VI will pass the "DAQmxStopTask.vi" .

This causes some disturbance in the temperature stability.

Does anyone have a suggestion for me how to improve this code?

 

Thanks in advance!!

 

Sincere Regards, Theo

0 Kudos
Message 1 of 6
(5,939 Views)

1. Consider not using the Assistant functions, they only complicate things for you in the end.

2. What is the purpose of the inner loop? Get rid of it!

3. If you have the Full dev system, consider the built-in PID functions.

4. The structure of your vi is not correct. You want to start you PWM channel, THEN enter a loop where you regulate and change the pulse width of your running PWM output. Then, when your vi is finished, stop your task. Now your are starting and stopping every second, that is (one thing) that is causing you problems.

 

0 Kudos
Message 2 of 6
(5,901 Views)

Dear Sir Per Hult,

 

 

Thank you for your reply. Regarding comment 4: I would love to change it to a form as you suggest. I also see this problem. However, the program does not allow me to move the "start DAQmx" in front of the "Initialize DAQmx". The problem is, we need to initialize first, but we want to be able to change the PWM dutycycle realtime when the program is running (nescessary for the PID regulation) . Appearantly, the "start DAQmx" always needs to come after the initializing. But I need the initializing first to change the PWM. I like to have everything in only 1 while loop, preferably the "start DAQmx" in front of this, and the "stop DAQmx" and "reset DAQmx" on the other end outside the wile loop. But every variant on this attempts failed. Can you give me some hints on this?

 

 

Sincere Regards, Theo

0 Kudos
Message 3 of 6
(5,864 Views)

Hi Theode,

 

program does not allow me to move the "start DAQmx" in front of the "Initialize DAQmx".

Sure!

You need to initialize first before you can start your task!

 

I like to have everything in only 1 while loop, preferably the "start DAQmx" in front of this, and the "stop DAQmx" and "reset DAQmx" on the other end outside the wile loop. But every variant on this attempts failed.

Really? Every different variant?

First init, then start - before the loop.

In the loop you change the PWM value.

After the loop you stop the task and clear it.

 

Can you give me some hints on this?

Yes: did you look at those example VIs coming with LabVIEW?

They explain a lot of different things - and DAQmx comes with a huge library of examples!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(5,859 Views)

Gerd is right in that you should look at the supplied examples, it will save you time.

 

But let me just add that what you is missing is DAQmx Write! (Counter, Single Channel, Single Sample, Frequency). Just perform DAQmx Write each you want to change the pulse width, your signal will change instantly. That is what i meant by "change the pulse width of your running PWM output"

0 Kudos
Message 5 of 6
(5,837 Views)
Solution
Accepted by topic author TheodeGroot

Hi,

 

I found a solution

 

Regards, Theo

0 Kudos
Message 6 of 6
(5,803 Views)