Jump to content

Array or a table


Roman85

Recommended Posts

Hello,
I'm using 4 Combo Box in my HMI.  Each Combo Box has 4 options and the user choice is stored in a "Select_Valve" array  (of type INT8).

I convert the value of "Select_Valve" to binary type, and I  want to open the valves one after another according to the user selection using "UID_0016 -> Outputs_0:Outputs3"

I'm thinking to use FIFO table for storing the user selection and in the end pushing the results to  "UID_0016 -> Outputs_0:Outputs3 ".

looking for advice, is it possible to implement with just array functions? there is no help, so I don't understand how to use 'Store in Array' function... 

Thank You!

Sanity Check_v1.2.jpg

Untitled picture.png

Link to comment
Share on other sites

I really don't understand what you are trying to do.

If you know c#, then a pseudo code would be nice.... for example, assuming that you array of selected values is called SelectedValuesArray  (and its size is 4)

 

for (int i = 0; i < 4; i++)

{

var value = SelectedValuesArray[0];

// then the rest of the code here

 

Few days ago, I've helped you, so I remember that the combo boxes have values of 0 to 15, and you wanted to translate the selected value into an array of bits (so 15 for example will have 4 bits set).

Are you using each of 4 bits for a different range of outputs? For example:

valves 1-4 -> outputs 0-3

valves 5-8 -> outputs 4-7

.

.

.

valves 13-16 -> outputs 12-15

 

If so, have you considered using 16 checkboxes?

Link to comment
Share on other sites

I'm not seeing the entire expression in the tags inputs, so I'm not sure, but aren't you overwriting outputs 0 to 3, so the last rung wins?

The code that I assume is running is:

If (start) then NumToBits(SelectedVaalvesAlign[0]. Valve_Selection), And Then CopyArray(ValveSelection, 0, 4, Outputs, 0)

If (start) then NumToBits(SelectedVaalvesAlign[1]. Valve_Selection), And Then CopyArray(ValveSelection, 0, 4, Outputs, 0)

If (start) then NumToBits(SelectedVaalvesAlign[2]. Valve_Selection), And Then CopyArray(ValveSelection, 0, 4, Outputs, 0)

If (start) then NumToBits(SelectedVaalvesAlign[3]. Valve_Selection), And Then CopyArray(ValveSelection, 0, 4, Outputs, 0)

 

So if I understood correctly, Outputs 0 to 3 are being overwritten by the last rung. I assume that you have 16 valves. And each combo-Box contains 16 options , which are mapped to 16 bits.

You are trying in this case to map 64 bits (16*4) into 16 bits.

Is there any chance of getting the project, so I'll be able to read it better? (You can send it to support@unitronics.com and ask them to forward it to me).

 

You can call the support by phone and explain them in words what you are trying to achieve (And I'm sure it will be easier to explain it and understand what they suggest).

Maybe the idea of 4 ComboBoxes is faulted (Maybe you need 16 checkboxes).

 

 

 

Link to comment
Share on other sites

A loop won't help, since you will still overwrite outputs 0 to 3.

Please talk with out support tomorrow, or when ever you can. I'm sure that after they understand what you're trying to accomplish, then they will find a solution.

 

If you want that on time X, the valves will be opened using Combo Box 1

In time X + 1 sec, the valves will be opened using Combo Box 2

In time X + 2 secs, the valves will be opened using Combo Box 3

In time X + 3 secs, the valves will be opened using Combo Box 4

(the same 16 valves)

 

Then maybe it is better using a Timer with 1 second (and not idle), and after each timer tick, increment an index.

You can then use "Load from Array" element, in order to load a specific value from the SelectedValveAlign (by index), and use that value (Load from Array will store the value into Valve_Selection) and the rest of the code remain as it is right now.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...