Logic to control a multi-head weigher like machine

120 views Asked by At

I need help to create an algorithm to control a machine which will do something very similar of what a multi-head weigher does. I will have a array of 192 available "heads" to make combinations.

I don't need to find all availabe combinations. The machine will take some time to process the combinations so if I find, let's say, 30 combinations every time it will be enought.

I want to optimize it and use first the combinations thar need to use 1 head only, then the combinations of 2 heads only and then 3 heads and so on so the machine output will be higher as possible.

This will be implemented on a PLC so I don't have "unlimited" resourses like a PC. Recursion for example is a problem.

I will be using codesys to program

I'd like to see a suggestion on how to implement this

For example the machine need to outup 3KG to 3.2KG loads. And I have up to 192 weights ranging from 0.5 to 4KG (yes, it can have overloads). I need to find the 30 best combos every time.

EX

Combo 1 = HEAD1 = 3.1Kg Combo 2 = HEAD5 (1.5) + Head8 (1.6) = 3.1Kg

1

There are 1 answers

3
Guiorgy On

The problem you are describing sounds similar to the Knapsack problem with some modifications.

GeeksforGeeks has a few implementations in different languages with different complexity and memory footprint. I'd try choosing one of those and modifying it according to your problem and porting the code to CODESYS.

If the exact solution comes out to be too slow for your system, you may try an Approximation algorithms for Knapsack instead.

If that also doesn't cut it, perhaps consider using a faster PLC.