Discussion:
Help with getting labview to use logic.
(too old to reply)
nab014
2008-08-12 14:10:09 UTC
Permalink
I am a beginner working on a research project at Louisiana Tech University.  I inherited a labview file from a previous researcher and need to edit it to include a little logic. The program basically looks at four inputs for either a low or high reading, and then based on those readings displays a value.  Such as if inputs 1,2, & 4 were reading high, it would display 0.  The new program I am trying to write is similar but instead needs to reference a list.  The values it will read will have repeats in the cycle.  The current programming would read the following based off the inputs: 0, 30, 60, 90, 120, 150, 180, 90, 240, 270, 300, 90.  I need the program to look a list and see that instead of displaying 90 after 180 and 300, it should display 210 and 330 respectively.Is there a way to do this?
MikeS81
2008-08-12 14:40:18 UTC
Permalink
Hi nab014,
if you know the array you need, then create it using a for loop. If you have the array you want and the array you need you can compare them using the equal function. You will get an boolean array. If the values are equal then, it shows true otherwise false. Then you can use another for loop in which you change the incorrect values. But if you already know the array you need why do you want to change the values?
Mike
smercurio_fc
2008-08-12 14:40:19 UTC
Permalink
Probably. But you will need to better explain what you're doing since it made no sense to me. For instance: - Why is the output 0 if 1, 2, and 4 are high? Is it those specific inputs? Or, is it any 3 inputs?
- Is the output 1 in all other cases?
- What is the format of the file?
- What is that series supposed to mean? Is the first number the first input, the second number the second input, and so on? Or, is it something else?
- Why 210 and 330? What's so special about these numbers, and how do they relate to 90 and 180 (other than seeming to be angular measurement)?
nab014
2008-08-12 14:40:22 UTC
Permalink
I am tracking the position of a rotary device.  During the rotation,
there are 12 positions, the four inputs display a 1 or 0 and the
combination of the 1's and 0's corresponds to an angular value.  Like
the example earlier, if inputs 1, 2, and 4 were to read high, this
would correspond to an angular position of 0 degrees and the program
displays 0 degrees on the screen.   The newest setup we are trying
unfortunately features a repeat in the values that would normally
display 90 degrees.  I am wanting the program to know based off of the
previous value displayed, what the correct value to display is.  For
example, if the program displayed 180, I would want it to know that the next value to display would be 210 not 90.  I hope that cleared things us.
Wiebe@CARYA
2008-08-12 16:16:48 UTC
Permalink
If you have 4 buttons, put them in an array. Convert this array to a number
(Boolean Array To Number). Use this number as an index for an array. E.g.
make an array constant with the 16 values you want, and pick the number. Of
course, if you have 8 buttons, this get old soon. In that case it would be
better to search for some logic in the values, and try to calculate the
result.

Regards,

Wiebe.
Mythilt
2008-08-12 17:10:07 UTC
Permalink
A state machine might be a good approach here since you have so few positions in your encoder.  Let each state read the encoder, and from the encoder value set it to the new state corresponding to the new position.  This also allows the rotation to be counterclockwise as well as clockwise.
 
Example would be with a 2 bit encoder for instance.  Assume that each bit change indicates a 30 degree angle change, it might read something like 00=0, 01=30, 11=60, 10=90, 00=120, 01=150, 11 = 180.....
You would have a set of states {0,30,60,90,120,150,180....} and in my example state 90 would read the encoder and if it saw 11 it would know to go to state 60, and if it saw 00 go to state 120.  Each state would also update the display correspondingly.
 
Note that this works only if you can be certain not to miss encoder readings, and if can handle spurius data. (a 01 read in the state 90 example for instance.)
 

Loading...