06-23-2023 06:29 PM
We have a program where we are trying to use two menu controls to allow a user to select from a list (test 1, test 2, test 3, etc.) and then another drop down menu with the unit under test (unit 1, unit 2, unit 3, etc.). Based on the combination of these two menus we want to then send out various digital outputs for ports 0-7 in varying low or high states. These will only be set once at the beginning before the test starts to trigger another controller. The digital output section I have working, but I am stuck on how to convert these two menu controls to an array that will set for example: The user selects "test 1" & "unit 1" from the menus, this will turn port 0 thru port 7 - low. If the user selects "test 1" & "unit 2" from the menus, port 0 - high & port 1-7 - low. If the user selects "test 1" & "unit 3" from the menus then port 1 will be high & port 0, 2-7 would be low. There is a total of 36 combinations between all the tests and number of units, so being able to do this programmatically would be ideal. Any ideas of how to go about this? Any help is greatly appreciated, and thanks in advance.
06-24-2023 07:00 AM
@TMDATA wrote:
The user selects "test 1" & "unit 1" from the menus, this will turn port 0 thru port 7 - low. If the user selects "test 1" & "unit 2" from the menus, port 0 - high & port 1-7 - low. If the user selects "test 1" & "unit 3" from the menus then port 1 will be high & port 0, 2-7 would be low.
Based on your explanation, seems like the pattern is that for unit [x], port [x+2] will be high.
06-24-2023 11:31 AM - edited 06-24-2023 11:38 AM
Can we assume that the number of available test is constant, same for the number of units? Can these numbers change in the future as needs change? Can the available options for the "units" vary as a function of "test"?
You have only listed a few combinations. can you give us the full truth table?
I would just turn the two integers of the selection into a single integer and use that to index into a lookup table row (2D array of booleans or U8).
Another option would be to use a map where the input is a cluster of the two controls and the value is a 1D array of booleans or U8. Make sure all possible cases are mapped.
Typically we can give more specific advice of you would attach a simplified VI, at least containing the two controls.