Case structure for comparing values

Hi,
i just wanted to know if there is a special way to use comparison in case structures.
I only kow how to create cases for things like if x=0 then ... if x=1 then ...
Now I want to make it if x<0 then ... if x=0 then ... if x>0 then ...
The only solution I found so far is creating a case structure inside a case structure.
Is there a way to keep it all in just one case structure?
Thanks and have a nice weekend,
Bernie

Case Structures are pretty flexible in how you can specify what triggers a particular case. You can specify ranges or various values per case.
In your situation, if you specify three cases with the following values, you'll get what you want.
'..-1' = x<0
'0' = 0
'1..' = x>0
The two periods before or after a number indicate that the case should run if the value is anything less than or greater than the specified number, depending on which side of the number you place it. You can also use this to specify a range of number. '1..10' would trigger the case for any value 1 through 10. Using a comma between numbers lets you specify different non-sequencial numbers. '1,5,10' would run the case only those specified numbers.
The same basic rules a
lso work with text based Case Structures.
Attached image shows the three cases you need.
Ed
Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Attachments:
Case_Range_Values.gif ‏21 KB

Similar Messages

  • How to implement Case Structure for multiple inputs to Pic Ring?

    So I have a reasonably simple program which I am almost completeed with. Basically the data of an array is read and then is indexed and a new array is created from the indexed data. And then I use Match Pattern to see if elements in the new array match certain words. And if they do then a number value is allocated to a Pic Ring at the end. And depending on the final number value the Pic Ring changes from one pic to another.
    However, I have the problem that I will be using multiple Match Pattern functions to compare elements in the final array, but I can't attach multiple Match Patterns and their subsequent logic statements to a single Pic Ring, only one. I've been trying to work this out by implementing a Case Structure or Event Structure. But the Event Structure isn't working and with the Case Structure, it is very messy with multiple True/False Case Structures inside of each other. Anyway, hopefully this all makes some sense. I'm attaching the VI program to this post. Thanks.
    Attachments:
    ArrayTest2.vi ‏495 KB
    ArrayTest2.vi ‏495 KB

    Obviously, you can only display one picture.  So then the question becomes which picture to show.  Therefore, you will have to create some sort of preference of one pattern over another.
    I would use a FOR loop so that you can loop through your available patters and their possible results.  Use the Conditional Terminal on the FOR loop so that you can stop the loop on the first match.  Then you just wire up the selected value for the ring outside of the loop.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to manage a case structure Untill a value is reached

    Dear all,
    I am collecting data with DAQmx and after a value is reached i want to do smthg else, for this reason i created a case structure and i put to the case selector that if a value is smaller than "10" then it is true. If it is false it should stop and do what i say even if the value gets under "10 again". 
     So how can i make this: "once the value is reached then do what i say  even if  the case selector value is back to true state after a while"
    Thanks.
    Kind regards.
    Solved!
    Go to Solution.
    Attachments:
    False-CaseStructure.png ‏15 KB
    True-Case-Structure.png ‏19 KB

    You can use the shift register to make a condition so once it enters into the value greater than limit case then it will not go to the other case even if the value goes below.
    The best solution is the one you find it by yourself
    Attachments:
    Case Selector.vi ‏7 KB

  • How to implement index array inside case structure for searching a 3D array?

    Well I have a 3D array and I want to index certain elements from that array. And I have thought of one way of doing this is to have multiple index array functions on the block diagram to search the array simultaneously, but that would be messy. Or I could setup some kind of case structure and place each index array function into individual cases. I've tried the latter, but when I connect the 3D array to the case structure at the"?" it doesn't give me permission because it says I'm hooking up two different types of data. Case Structure is for T or F and 3D array is not a boolean.
    So how can I setup the Case Structure to work for a 3D array?

    A case structure's selection tunnel cannot accept an array.  What exactly are your search criteria?  It sounds like a few FOR loops will be needed.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Required UDF for comparing values within same context

    I have to compare values within the same context.I am getting boolean values for that field.If all the values in the same context are true,then the result should be true .Otherwise false  should be passed.
    If input is-
    <context>                                  
    true
    false
    true
    <context>
    true
    true
    <context>
    Output should be as-
    <context>
    false
    <context>
    true
    <context>
    Please suggest how to acheive this?..its urgent

    Hi,
    Check with this UDF
    Src>UDF>target
    public void context1(String[] a,ResultList result,Container container)
        int k = 0;
        int arrayLength = a.length;
        if (arrayLength > 0)
            String firstElement = a[0];
            for (int i = 1; i < arrayLength; ++i)
                   if(!(a<i>.equalsIgnoreCase(firstElement)))
                     k = 0;
                     break;
                   else
                     k = 1;
    if(k == 1)
        result.addValue("true");
    else
        result.addValue("false");

  • Multiple boolean values to be used in case structure

    Hi,
    I am trying to implement a case structure with multiple boolean cases and am having trouble with that. What I want to do here is : I have a set of 5 values, each of them being "true" or "false". For each "true" value, I have a certain set of steps to be executed. The "false" of each can be ignored. Ideally, I would like to have a case structure for the 5 "true" cases. I am not sure how to go about wiring these boolean outputs to my case structure. Also am using LabView 6.1.
    Any ideas?
    Thanks,
    Sukanya
    Solved!
    Go to Solution.

    Additional comments regarding code:
    It is a mistake to configure the serial port inside the loop. This is a waste of time and resources. Configure outside, read in the loop, and close outside after the loop is done. The flushing of the buffer would be part of the "configure outside".
    The default values of the controls for the VISA Configure Serial Port VI are such that the termination character for reads is enabled, and the character is set to a linefeed. This means the VISA Read will read until it sees a linefeed or reaches the value wired to its byte count input. Thus, the VISA Bytes at Serial Port isn't really necessary.
    You should not rely on the settings in the LabVIEW option for automatic error handling. You should explicitly handle errors in your code. Thus, you probably want to stop the loop on an error and provide a dialog via the Simple Error Handler.

  • My case structure values chnged form words to numbers.

    I have a case structure and the values changed to numbers, also i am not sure why it is not cycling through? any help would be appreciated.
    Attachments:
    version2.vi ‏121 KB

    You have too many cases (167) That is a number you can't maintain.
    The reason you get a numeric as datatype and not an enum is because you should change the enum into a type def control.
    To do this right click the instance left of the while loop->Create control. On the control on the front panel right click->advanced->Custimize control and set the control to type-def (see attachment).
    Then save this control, and use this everywhere.
    But first limit you cases, or use a plain string to explain the state...
    Ton
    Message Edited by TonP on 10-16-2006 08:05 AM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    labviewTD.PNG ‏6 KB

  • Multi-Case​-Structure

    Hello,
    what is the best way to create an multi-case structure for checking many logic states in once? I need it for a simple state machine which is controlled by some digital sensors in the way:
    WHEN DI0; DI2 = TRUE and DI1 and DI3 = FALSE then .........state1
    WHEN DI0; DI3 = TRUE and DI2 and DI1 = FALSE then .........state2
    WHEN all DI = TRUE then ........ error state
    And so on... has someone an idea? Maybe I am a little bit slow?! ;-)
    Thanks!
    Paul 

    How are you reading the DIO?  I would be tempted to just read the port (8 digital lines) as a U8 and then that value can go straight to the case selector.
    The other option is to read the 3 lines as an array of booleans and then use Boolean Array To Number whose result can then go into the case selector.
    If using numbers, you can set the radix of the case structure so that you can view the state case in boolean.  Might make it a little easier to understand what is happening.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Case Structures

    Can a case be created for Case Structures of a decimal value or range? That is say 0.001..0.5?
    I can create case structure for say 1..5
    can I create it for 0.001..0.5?
    Solved!
    Go to Solution.

    No you can't, the case structure terminal doesn't support decimals. but if you have a hand full of range like [.001;.01[, [.01;.1[ and [.1;.5[ then you could multiply and round the value by 1000 and set your range to 1..10, 10..100 and 100 to 500.
    Just a quick idea, other solutions would be possible.
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"

  • Case Structure Listing

    I've got a case structure with the selector wired to a string input. As it's got a significant number of cases in it, I'm trying to programmatically generate a list of the actual case strings it contains in the selector, without actually executing the structure.
    Anyone got any ideas?
    FYI; Reason being, I'm trying to write a document containing a description of each case, and I don't want to miss any out!
    Many thanks,
    Chris.

    Personally, I would simply search the 1D array of possible strings for the current string and use the index of the found element to pick a description out of an array of strings with the descriptions in it.
    This doesn`t work if you want to operate code based on the cases, but for a simple description allocation it should work.
    I certainly wouldn`t use case structures for this if you`re just looking to link a string value to a particular array.
    Shane
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    case_descriptor_perhaps.vi ‏20 KB

  • Using local variables with a case structure

    I recently decided that I didn't want to nest a bunch of case structures for a program I am creating. I have two variables, N1 and N2, and I want to say execute Case 1 if the integer input to the terminal is less than N2. Case 2 if the integer input into the terminal is greater than N2 but less than N2+N1. Case 3, integer greater than N2 + N1, but less than N2+N1+N2. Case 4, you guessed it, Greater than N2+N1+N2, but less than N2+N1+N2+N1. When I try to type the variable name into the bar and use the ... like you do with integers it changes the variable name to a string.
    Am I just thinking of this the wrong way? I have a sensor setup in a square and I am using a matrix card hooked up to the sensor bundle to send signals from each sensor to each other sensor, but not for those along the same sides.
    Tom

    I see the nested case structures which is what I didn't want to do, but I will have to because I am tired of looking at this. Thank you for the help on this. I appreciate it.
    The sensor network is shown in the image included.  Lets say we number the sensors in a clockwise direction starting on the lower left hand corner. Each element needs to both send and recieve data to all other elements except for the one in the row it is in. So sensor 1 would sent to sensor to sensors 5 - 18. Then sensor 2 would send to 5 - 18. Sensor 5 would sent to 1 - 4 and 10 - 18. Etc.
    Lets say if this were a circular array it would be easy. Two nested while loops. And the only condition I need to worry about is that sensor N is not both sending and recieving at the same time. Each while loop, or for loop - doesn't matter, will start at 0 and go to N-1. Each i and j will have +1 added to them, and as long as they are not equal preform the data operation. 
    Just some fun logic to think about
    Tom
    Attachments:
    rectangular.jpg ‏12 KB

  • CASE STRUCTURES WITH TAB CONTROL

    Hi,
    I have created  tab controlled  case structures for three different cases,
    Tablet type
    Machine Input
    Output
    It seems that data is not interlinked while switching betweeen the cases.
    I have to select the start buttun for each tab to get results.And also if I skip the second tab and jump to third tab, it doesnot give results. SOmehow the data is not acquired.
    Can anyone help me out for the same.
    Attached is the main VI (PAR_LAB_ATT_00_01)followed by a sub VI(gen time array)
    Thanks
    Sumit
    Attachments:
    PAR_LAB_ATT_00_01.vi ‏200 KB
    Generate Time Array.vi ‏15 KB

    Please don't use all CAPS when posting your message subject.
    How are you running your VI?  I don't see any while loop in it, so it only runs once.  Which means only the case structure associated with the tab that is currently highlighted before you press the run button will actually run.
    The vast majority of the time, a tab control is only used to control what is displayed in the front panel and is not used to actually control the execution order of the program.
    I would recommend looking at the online LabVIEW tutorials
    LabVIEW Introduction Course - Three Hours
    LabVIEW Introduction Course - Six Hours

  • Pass the value of the current case in a case structure to a global variable for use in VIs.

    I have built a large queued state machine (>100 cases).  In each state, I run a VI that I have created.  These VIs are usually not very different from one another.  In many cases, I could simply use the same VI over and over again.  There is only one problem with that.  None of these VIs know which case to send the program to next.  I have to change the value of the "NEXT_CASE" constants in the VI and save it under a new name to be inserted into each new case.  Now my program consists of hundreds of VIs whose only difference is the value of their "NEXT_CASE" constants.  This causes all kind of headaches when I have to insert new cases into the state machine, and it is just too much for me to deal with.
    I need to be able to use a global variable to keep track of the current case within my VIs.  I could change it from a string to a number and add or subtract from it to determine which case the program should go to next.  Since I'm usually only skipping from one case to the next (or the previous) I could use the exact same VI in most cases.  Can anyone tell me how to create a global variable that contains the value of the case in my case structure that I could use within my VIs to keep track of the current case?  Let me know if you have any questions.

    Instead of defining the next state inside the subvi, why not do it in the main vi inside each state case?  An output from the subvi could be used with a case structure to determine the next state.  Sort of like, if the subvi returns 0 then next state is State3, else if the subvi returns 1 then next state is State4.
    Message Edited by tbob on 08-19-2005 03:15 PM
    - tbob
    Inventor of the WORM Global
    Attachments:
    NextState.PNG ‏5 KB

  • Multiple booleans controlling one boolean input for a case structure

    Hello,
    I have four boolean buttons and a case structure with a boolean input. I would like to write the program so that whenever any one of the four boolean button changes value, the case structure reads true for one loop interation, and then returns to false.
    I have tried all sorts of things and can't seem to figure it out.
    Ultimately, the ideal function of the program is so that whenever you push any one of the four boolean voltage controllers, that voltage case is chosen in the case structure, the time in seconds is written to a file, and the elapsed time timer is reset.
    I have attached my program. Let me know if you have suggestions. Thanks.
    Attachments:
    Volt_Control_And_Time_Counter.vi ‏71 KB

    Zappow wrote:
    However, with this setup, the time counter still doesn't work.
    The event structure for all four buttons has a true boolean constant connected to my file-saving case structure. If I connect this to my elapsed time express VI reset button, the timer doesn't count.
    The timer does not count because you have not wired a timeout to the lower event structure. The default timeout is -1, so the lower loop never spins via timeout
    It is useless to have a wait in a loop that also has a timeout case. Just wire an approriate timeout value to the timeout terminal and remove all waits. It is also not necessary to have a 1ms ttimeout if your timeout values only displays to 100ms resolution. Can you explain why you think you need two loops and all that extra code?
    Attached is a quick rewrite that solves some of the problem. Since I don't have any hardware, I replace the voltage out with a meter.
    You have way too many FP controls and indicators. Use arrays!
    Let me know if yo have any questions. Modify as needed.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Volt_Control_And_Time_CounterMOD.vi ‏63 KB

  • Calculate maximum value of subarray while creating it using a case structure and shift registers

    I have two 1D arrays that contain cyclical information (kind of like a sine wave).  One that contains information on position in degrees and another that contains torque.  I would like to calculate the maximum torque value each time the position is within a certain range (e.g. from 30-80 degrees).  The ranges are repeated - that's why it is cyclical.   I use the "in range" function, a case structure and shift registers to build a new array with values that fall within the range I specify - this was the easy part (see VI attached).  I'm struggling with a way to calculate a maximum value for each subarray formed when values are "in range".   Your help is much appreciated.
    Solved!
    Go to Solution.
    Attachments:
    Simple Calculate between anatomical position range.vi ‏16 KB

    It's not really noise - it's more inconsistency.  So a position output can run: 20, 30, 40, 50, 60 etc.  OR, it could run: 21, 24, 32, 41, 44, 51, 59 etc. But, it is always cyclical. 
    Attached you will find a .csv file with the data arrays - I'm using POS (ANAT) degrees column (column D if you open in excel).  There you also see torque in ft-lbs along with some other information.
    Attachments:
    025C.csv ‏224 KB

Maybe you are looking for

  • The hard drive on my laptop that contained Elements just died.  Can I get a second copy for installation on my new PC?

    The hard drive on my laptop that contained Elements just died.  Can I get a second copy for installation on my new PC?

  • Speakers in MacBook Pro do not work.

    This morning, the speakers on my MacBook Pro (Early '09) stopped working, but the machine transmits through the headphone jack just fine. I've done a PRAM reset, and that hasn't fixed it. Anyone have a suggestion?

  • Create SDO_GEOMETRY from existing adding SRID

    Hi, I have a SDO_GEOMETRY without an SRID in it, and I need to call like in the following statement : SELECT A.G3E_FID, SDO_UTIL.TO_WKTGEOMETRY( SDO_LRS.CONVERT_TO_STD_GEOM( SDO_CS.transform( a.g3e_geometry, 28992))) g3e_geometry, 28992 srid FROM las

  • [Solved] cp from mount ntfs to mount ntfs-3g

    Hello. I copied some files from a harddisk mounted with the option "-t ntfs" and now want to copy them back but I have to mount with "-t ntfs-3g" to have write access. Some of the files are written in Portuguese and have special characters and accent

  • Trigger a action

    Hi experts, I want to trigger a action which is defined in the action profile in my program, can u please suggest me the right Function module or class to trigger a action. Valuable answers will be rewarded for sure.. Thanks, James