In this article I'll shown how to realize a tank loading sequence function.

Defining a range of 16 tank (water tank), an automation system has to load them by a random adjustable sequence. Something like:

Loading                 -->--->--->--->--->---->---->-----

Loading Sequence  --1---3---6---2---10---11---9----  (1= tank n°1 ; 3=tank n°3 ;....)

Following picture show the sample application (for screen resolution reasons I take a 8 tank system in stand of 16, half function capability)

 Main

 

The system fill a tank until:

  1. tank is full (OR)
  2. tank still enabled to be load (OR)

then move to load NEXT tank. NEXT (next loading tank referred to previous picture) is the value I'll get from the described function:

IDE: Codesys v.3.5 SP5 patch 3

 

This is the function called by PLC_PRG main cycle:

 SortingFC

These are the in/out function parameters:

InOutParam

This is the source code:

Code

This is the debug function:

Please note that each time next available silo is force to "full" or not "enabled", the function jumps to the 2nd next and so on: