LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID instrumentation and application

Solved!
Go to solution

dear Mr. GerdW,

Greetings. I have modified my code according to my description. Would you please check it is ok or not? 

TIAP controller.JPG

0 Kudos
Message 11 of 35
(1,467 Views)

Hello Mr. GerdW,

 

Greetings. I have attached a proportional control code here.

Problem 1: The codes work well but the cycling time is 80 sec for -100~100 output range, and 50 sec for -5~5 sec. How can I minimize/decrease this cycling time?

Problem 2: The setpoint was 2 but in the waveform chart, it oscillated around 0.7. I can't understand the reason.

 

Would you please consider my problems? Thanks in advance. 

P controller_2.JPG

0 Kudos
Message 12 of 35
(1,440 Views)

Hi Milon,

 

why are there two wait functions in your code?

Remove them: you already set a sample rate for your DAQmx task, so the loop will not run faster than 1Hz!

What is that Arduino code doing? Which "trigger pin" are you reading? Why do you output twice? What do you output to your Arduino?

 

Problem 1: The codes work well but the cycling time is 80 sec for -100~100 output range, and 50 sec for -5~5 sec. How can I minimize/decrease this cycling time?

Which "cycling time" are you talking about?

(To increase changes of the PID output you should also use the I and D gain…)

 

Problem 2: The setpoint was 2 but in the waveform chart, it oscillated around 0.7. I can't understand the reason.

It's a P controller: you will always have an error…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 13 of 35
(1,430 Views)

Respected Mr. GerdW,

Greetings. You asked a lot of question. I think you forgot my problem which I posted before (attached a picture). 

Problem.JPG

Maybe you didn't check the attached VIs also. 

1. "Wait functions" for keeping the pump running (like 5 or 10 seconds and the time will be calculated by mixing algorithm)

2. "Cycling time"- I wanted to mean sensing interval. As I said the code waits 80 sec during -100~100 output range, and 50 sec during -5~5 output range and runs again. 

3.  "It's a P controller: you will always have an error…" Yes, I know but the difference between the set value and present value is very very big. its not acceptable. I am searching for the error reason.  

P controller_2.JPG

 

 

0 Kudos
Message 14 of 35
(1,412 Views)

Hi Milon,

 

Maybe you didn't check the attached VIs also.

I did. But that didn't answer my questions…

 

1. "Wait functions" for keeping the pump running (like 5 or 10 seconds and the time will be calculated by mixing algorithm)

This design is completely wrong!

A PID control loop should run at a know interval. Right now you have your pumps run for "5 to 10s" - and then you wonder about those slow control loop times???

Place DAQ, Arduino communication and PID control into their own (parallel) loops to allow "fast" (DAQ, PID) loops to run without interfering with this "slow" Arduino comm loop…

Or remove those wait functions from your loop. The PID will decide wether to switch on or off those pumps!

You also should NOT wait for the whole "5 to 10s" at once, but check for new PID output values atleast each second!

 

2. "Cycling time"- I wanted to mean sensing interval. As I said the code waits 80 sec during -100~100 output range, and 50 sec during -5~5 output range and runs again.

That's because of your programming. Just like you created your VI…

 

3. "It's a P controller: you will always have an error…" Yes, I know but the difference between the set value and present value is very very big. its not acceptable. I am searching for the error reason.

Use I gain to minimize the error. (PID basics…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 15 of 35
(1,394 Views)

Respected Mr. GerdW,

 

Greetings. I have modified the code as you suggested. But it didn't show the desired result. The setpoint was 2.0 but the pump kept running. In the graph, you could see the pH level reached 2.5... Would you please make some modification of my code?

P controller_4.JPG

 

 

0 Kudos
Message 16 of 35
(1,403 Views)

Hi Milon,

 

why do you write analog values to your Arduino digital output pins?

 

I usually use two different options:

  1. Create my own slow PWM signal from the analog PID output, with a cycle time of 10-20s. The pump will be on according to the percentage value from PID. (And I don't use any additional wait function to create that PWM…)
  2. Switch on/off at ~50% PID output, maybe with a small hysteresis…

(Don't you have a book on control loops you could read?)

 

This is how I implemented option 1 for a heater with 2 heating coils:

check.png

The PID outputs a percentage between 0 and 95%. This is scaled to a value between 0 and 39 to generate an ON/OFF boolean signal by comparing with a counter. The PWM cycle is 40*250ms=10s…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 17 of 35
(1,393 Views)

Respected Mr. GerdW,

I beg pardon to you. Last 2 days, I tried to understand your code but couldn't understand completely. I also don't have any book. I tried to use analog to digital converter but couldn't succeed. I am sorry. Would you please modify my code at a specific point? 

P controller_5.JPG

0 Kudos
Message 18 of 35
(1,372 Views)

Do you really control both pumps with the same serial port?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 19 of 35
(1,366 Views)

Dear Yamaeda,

 

Sorry, its a mistake. The serial ports would be different.

0 Kudos
Message 20 of 35
(1,364 Views)