Roman85 Posted November 1, 2017 Report Share Posted November 1, 2017 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! Link to comment Share on other sites More sharing options...
Saragani Posted November 1, 2017 Report Share Posted November 1, 2017 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 More sharing options...
Roman85 Posted November 5, 2017 Author Report Share Posted November 5, 2017 Saragani thank you for your help. I'll try to explain... I have array 'Select_Valve[0..3]' (type INT8) and I want to convert each Select_Valve to Bit type in a little time shift. My problem is that it's doing it only to the last Select_Valve. Link to comment Share on other sites More sharing options...
Saragani Posted November 5, 2017 Report Share Posted November 5, 2017 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 More sharing options...
Roman85 Posted November 5, 2017 Author Report Share Posted November 5, 2017 Yes, you are right, I'm overwriting the data in outputs 0 to 3. I need to implement a loop for 'Num to Bits' for sending all the user selections to output. Link to comment Share on other sites More sharing options...
Saragani Posted November 5, 2017 Report Share Posted November 5, 2017 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 More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now