07-26-2019 10:05 AM
dear Mr. GerdW,
Greetings. I have modified my code according to my description. Would you please check it is ok or not?
TIA
07-29-2019 11:31 AM
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.
07-29-2019 01:52 PM - edited 07-29-2019 01:55 PM
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…
07-29-2019 09:14 PM - edited 07-29-2019 09:45 PM
Respected Mr. GerdW,
Greetings. You asked a lot of question. I think you forgot my problem which I posted before (attached a picture).
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.
07-30-2019 12:46 AM - edited 07-30-2019 12:47 AM
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…)
07-30-2019 04:40 AM
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?
07-30-2019 05:32 AM
Hi Milon,
why do you write analog values to your Arduino digital output pins?
I usually use two different options:
(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:
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…
08-01-2019 03:36 AM
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?
08-01-2019 03:49 AM
Do you really control both pumps with the same serial port?
/Y
08-01-2019 03:57 AM
Dear Yamaeda,
Sorry, its a mistake. The serial ports would be different.