# Help needed with challenging algorithm

## Recommended Posts

• MVP 2023

I have an odd customer request that has me stumped as to how to program this efficiently - perhaps someone here can help.

I am using a v570 PLC to control 10 valves. I have 10 demand digital inputs (requests to open individual valves) and 10 digital outputs to open and close the valves. The pump that pushes chemical through these valves is not capable of handling more than a few open valves simultaneously, also some of the valves are more important than others. So, the customer would like an input on-screen to adjust the number of valves that can be open simultaneously and a priority selection for any or all of the valves. If there are more than the input value number of valves being requested to open simultaneously, then additional valves should be held off until an open valve closes. Valve opening should be in FIFO order with priority valves taking precedence.

The biggest problem I'm having is trying to deal with the FIFO (i.e. maintaining a continuous and current hierarchical list of valves waiting their turn to open) and for dealing with the conflict that allows the priority valves to move to the head of the line.

Can anyone suggest the basic framework of an algorithm that will accomplish this in VisiLogic?

##### Share on other sites

Hi Flex,

I want to give you some initial tips:

There is Functional block (FB) Events. There you define a vector of bits. In your case each bit wil represent output of a valve. One fo thhe functions of this FB will show you how many bits are active (how many valves are open). You can easilly compare this number with the limit, set from, let's say HMI and block new valves to be open.

If there is more requests during block, you can enter the pointer of the valve requested in a vector of MI.

In VisiLogic > help menu > Examples > Project examples > Ladder you can find a nice working example V570 Vector FIFO. I hope it will help you to manage the vector of waiting to open valves.

It seems now you have the basic elements to start programming. I guess few details are missing.

Let me know if these tips are useful and which further help you need.

##### Share on other sites

• MVP 2023

Thank you very much, Emil. I will spend a couple of days looking at this and get back to you.

## Create an account

Register a new account

×