From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID for flow rate control

Hello,

Greetings. I have attached one PID control code here. I need to control pump flow rate based on sensor value through PID controller. I am using LS inverter for controlling pump(rpm) and this is connected with the computer (LabVIEW) through RS232 to 485 converter cable. Problem is:

1. during running, it shows the "scan failed" error (picture attached_PID code error-1) 

2. If I remove the "scan from string" option, then another error is showed (picture attached_PID code error-2)

any suggestion to overcome this problem????? 

0 Kudos
Message 1 of 8
(3,010 Views)

Hi Milon,

 

1. during running, it shows the "scan failed" error (picture attached_PID code error-1) 

2. If I remove the "scan from string" option, then another error is showed (picture attached_PID code error-2)

any suggestion to overcome this problem?

1. Open the COM port only ONCE before the loop, close it ONCE after the loop!

2. Why do you use multiple channel PID when you want to control just one pump? Use the single channel polymorphic instance and get rid of all those arrays and the inner FOR loop!

3. You need to handle errors in your inner loop as well! Is there a timeout error after the VISARead? If so: why? Do you receive a string from your converter? If yes: why does ScanFromString fail? Do you receive a string in the expected format? (Debug!)

4. With serial communication I would NOT use DAQmx with a samplerate of 1kS/s as you set in your VI! How fast does your converter communicate?

5. You didn't set any PID gains, there are still the default values. Did you even characterize your control system? (Ziegler-Nichols or other algorithms?)

6. Why did you hide the label of "error2"? How should we tell from your 2nd image where the error occurs? Btw. here point 3 applies too: you need to handle errors programmatically!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(2,988 Views)

Hello Mr. GerdW,

Thanks for your reply. A lot of questions... Actually, I don't have a deep idea about LabVIEW. I didn't understand some of your questions also. 

1. You said, "Open the COM port only ONCE before the loop, close it ONCE after the loop!" which loop for loop or while loop?

2. Actually, I have control 3 pumps (or more if needed). Do I need to modify this cope for this criteria?

3. I didn't found any timeout error yet. I am confused about the connection of the converter with LabVIEW... I don't know how to control the inverter frequency through LabVIEW... I need your help.

4. Sample rate will be changed. Maybe it would be 1S/s.....

5. I got some PID gain through simulation. I will apply that.

6. Confused about this error....

Hope, your support will be continued. TIA

0 Kudos
Message 3 of 8
(2,969 Views)

Hi Milon,

 

1.

check.png

Open once before the loop and close once after the loop.

You still need to implement some error handling!

 

2. For several pumps you can use the array instance of the PID control.

 

3. I am confused about the connection of the converter with LabVIEW... I don't know how to control the inverter frequency through LabVIEW... I need your help.

You will find all the help you need in the manual of your converter. There it's described how you can control the output frequency.

 

6. Do some debugging.

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 8
(2,962 Views)

hi Mr. GerdW,

I have modified the code as you suggested. but the same error occurred. I think it is the communication problem between the inverter and LabVIEW. Here I have attached the pics of communication. If you have any idea/experience, please suggest me what to do or what's wrong...

0 Kudos
Message 5 of 8
(2,957 Views)

Hi Milon,

 

error 85 is as is explained in the error message: ScanFromString got an input string which is not as expected by the format string…

 

On your manual image: all you show is the hardware description of the connection.

You need to read the "software" part too: which kind of communication is used over those RS485 hardware?

Which commands does the inverter expect? How are the answers encoded?

What are the settings (baudrate etc.) of the RS485 connection? Did you set them correctly in your VI?

 

AND WHY do you still open and close the serial communcation with each iteration of that inner loop???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(2,954 Views)

Hello Mr. GerdW,

I tried to set the inverter according to the RS485 communication manual. but the same error (error 85 or error1) shows again and again. I tried to search examples in LabVIEW community but didn't find suitable examples. I think the problem in LabVIEW code, as I want to control pump through the frequency of the inverter. I have attached the RS485 communication pdf and error pic here.

 

Would you take a look, please?

0 Kudos
Message 7 of 8
(2,935 Views)

Hi milon,

 

did you set all parameters, not just the frequency mode?

Which communication do you use: modbus or ls?

And where do you create messages expected by the inverter, according to your manual?

Did you debug your VI? Which answer did you receive? Did it conform to your format string used for ScanFromString?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 8
(2,922 Views)