Range setting in case structure

Hello everyone! I'm working on an engineering project where I read in a sound input and if it's on high volume, a red led connected to a MyDaq box lights up, if it's on low, the green LED lights up, and both will be off if there's no sound input. I posted a screenshot of how my vi currently looks. The problem I'm having is, I want to set the range that will be considered as the low volume, and a range considered as the high volume on my case structures. I'm not sure exactly how to do that. I currently have an "In range" function there where I set the max and min values. THe problem with this is, it outputs a dynamic data that I cannot connect to the appended array. Any help would be great. Thanks!
Attachments:
projecttest2.vi ‏91 KB

Thanks for your response. I'm new to labview (which isn't really an excuse) and we just went through the real basic stuff for this course. That's why my code just looks like a mess. I'm just trying to use the case selector because I thought it'd be more efficient, since, if I think of it in written code, they're kind of like if-else statements, right? I thought I needed to multiply by a thousand because I am measuring the amplitude of sound input. Whenever I test it out, the numbers are really small. I just figured it'd be easier to multiply it by a thousand and set the range with bigger numbers. I'm also trying to get an LED to light up on a range of volume. That's why I need two comparisons. Like, if the volume is between the range of 2000 to 3000, the green LED lights up, and if it's between 1000 to 2000, then the red LED lights up. If the signal is equal to zero, then no light turns on. Anyway, I scrapped the whole idea of using case selectors because I don't have time to learn my way through it and finish on time. I attached a new version of my VI. It's a more simplified version. I don't know how to connect the LED boolean indicators into my array and into the DAQ Assistant (it's not on the vi yet but I do need one so the program knows to read the output into the LED's on my myDaq box. Sorry for the trouble! Thanks for any advice you can give. 
Attachments:
projecttest1.vi ‏55 KB

Similar Messages

  • Can I use a formula node to start the execution of a case structure?

    Hi,
    I am working on editing a VI to make it much easier to understand (for colleagues and non LV users). For one reason or another, the VI's creators did not fully make use of the power of case structures and other structure types. In the application we need it for, the instrument cycles and repeats measurements on several objects. We are interested in measuring the motor currents for several motors in the system. As it stands now, for each sample object's run, there is a separate sub-vi diagram which displays its waveform trace and several indicators such as max current, time at max, etc. That code was contained within a T/F case structure and copied and pasted 20 plus times.... Obviously the vi became extrememly cluttered and needed a huge screen to see. The trigger for the current case structures is an EQUALS comparison between one input (which is the sample object counter; and this part I will likely leave unchanged since it makes a lot of sense already) and a constant which was defined 1 through 20+ for case. 
    I have since made one case structure and 20+ instances of that case and have labeled them (at the top selection box near the detent arrows) "1", "2", 3, etc. I am wondering if I can use a formula node to act as the "trigger" which sets each case structure running? I believe that a simple IF statement should work. Please see a snippet of my attempt at making this in C below.
    For the node, I defined X as the input and Y as the output. The input to the node, X, is connected to the sample object counter. The output, Y, is connected to the case selector of the case structure. My attempt at the code is below:
    int32 y
    For(x == 1)
       y = "1";
     For(x == 2)
       y = "2";
    etc, etc.
    Is that above code snippet correct? Do i need something like "ENDIF" or "end if" at the end? Does "y" have to be defined as "int32" or can it be something else?
    Thanks for the help!

    Is your formula node doing anything else besides what is shown?
    Why don't you just wire the value that is going into it at X directly into the selector of the case structure?
    Attachments:
    Example_VI_BD.png ‏2 KB

  • How can I have multiple inputs into the selector terminal of a case structure

    Hi everyone
    I have a question on how to wire multiple inputs in to the selector terminal of a case structure. 
    Currently, I have three switches, each switch determines different case. So if I switch the switch 1 is on, the numeric indicator will show 1. If the switch 2 is on, the numeric indicator will show 2, so on and so forth. However, the selector terminal will not allow me to wire multiply inputs into the case structure, I tried Bundle by Name, Bundle and Array to Cluster, but they did not work. I set the case structure with 3 cases, they are 1, 2 and 3.
    Could someone help me please. I have attach an image and the VI of the work I did so far.
    I have another question, is there a function which can toggle other switches to off when there is a switch has been toggled on.
    Thank you very much
    Tommy
    Attachments:
    Trial - Case Structure.vi ‏7 KB

    Tommy, attached find a cheeseball way of doing this that has given me a LOT of mileage over the years.  IT lends itself nicely to a couple of really good practices that NI recommend, but I have given you the bare-bones to "see under the hood".  
    The recommended practices:
    1. You can make this a nice tight sub-vi where you can put it into a core library of routines that you'll use over the years, even extending the logic to look only for changes, etc.
    2.  If you are thinking about Front Panel design considerations, you'll want to use arrays of controls where possible, as that's a nice neat way of containerizing your switch for both the FP and Block Diagram.
    Have fun.  I have TONS of these types of things, so feel free to PM me if you have any other needs.
    Wes
    Wes Ramm, Cyth UK
    CLD, CPLI
    Attachments:
    Boolean Switch Logic.vi ‏11 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

  • Case Structure Ranges Determined From Input Variables

    Hello, 
             I am trying to write a vi that will read in a random number, and depending on how close or far away from the intial given value it is, it will do something different to the value using a case structure.(Not positive this is the best way)
    Ideally I would like to somehow incorrporate the value that is on the front panel from the user, into the different ranges so they are not set. Is there any way instead of using [ ..10, 11..15, 15.. ] I could use the [..(indicator - 5), (indicator-4)..(indicator +4), (indicator +5)..] as my three different cases? Or is that just crazy and I should be trying to use a different type of structure maybe? 
    Thanks in advance for the help, 
    KT

    What if you would subtract the reference value before wiring to the case structure?
    (assuming you are dealing with integers)
    LabVIEW Champion . Do more with less code and in less time .

  • How can i set case structure always true on boolean impulse?

    Hello everyone! I need a little help. All i want is to set a condition when to acquire data from my acquisition board. I have a sinusoidal pulse and when value its near zero (between 0.5 and -0.5) i want to start to write data and also stop condition. How can i make my case structure to remain set to true until next condition? Thanks in advance!
    Attachments:
    Untitled.png ‏104 KB

    sdadasdas wrote:
    Thank you! I'm a beginner in labview and any advice is welcome!
    I highly recommend tutorials if you are really new.  Otherwise, just keep asking questions.  You'll figure it out soon enough.
    3 Hour Introduction
    6 Hour Introduction
    LabVEW Basics
    Self Paced training for students
    Self Paced training beginner to advanced, SSP Required
    LabVIEW Wiki on Training
    Learning NI
    Getting Started with NI Products
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Programmat​ically change case structure range

    I think I already know the answer to this, but I'm going to ask anyway. In the attached image, is it possible to programmatically change the range of numbers the case uses?
    Tay
    Solved!
    Go to Solution.
    Attachments:
    case structure.png ‏3 KB

    To use a property node on a case selector, you need to have a reference to it.  There are several ways to open the reference, depending on where the object you want to reference is located.
    EASY - If the case selector is not inside another structure and has a unique name, use Open VI Object Reference with the name of the case selector as the input.  The owner is the block diagram reference and the object class is a case selector.
    FAIRLY EASY - If the case selector is inside another structure or structures and all structures and the case selector have names unique to their diagrams, open the structures from outside to inside as in case 1.  After you open the structure reference, get a reference to the appropriate diagram and repeat until you get to the final case selector.
    HARDER - Case selector has a unique name, but is buried in a container which does not.  Use the Traverse method to find all case selectors, then use the Label property of each to find the right one.
    HARDEST - Case selector does not have a unique name.  Use the Traverse method to find all case selectors, then find the one you want by the frame labels.
    The take-home message from this is that your life is much easier if you give your containers unique names.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • Can I put a READ function in a TRUE/FALSE case structure?

    Hi,
    I have a vi that operates as controller for a mechanical system of motors.  There are several sensors of various types, that provide input to the vi, including encoders, whose period is being measured.  The attached vi is the encoder period measuring part. It measures 15 periods and tells me the average of the 15 with each loop iteration.
    In my application, the encoder period measurement is not needed unless the vi knows that ALL THE OTHER sensors in the hardware configuration are measuring values within the desired range.  For example, Sensors A, B and C should all measure between 5-10.  If they are all showing values between 5-10, then, we want the encoder value to read and display.  If only one of the sensors, say A, is measuring 12, then, we don't want the period value to READ or be subsequently processed.  So, it is easy to set up the sensors A, B, C, to give a TRUE or FALSE based on whether they are within range or not, and if all 3 are TRUE, then, that value can easily be passed to the case structure that holds my READ function for the period.  Is this a good way to do this?  The goal is to eliminate unnecessary execution time that the period READ function would consume, as well as all subsequent calculations that are performed on the period value collected.  The period data is of no use if any one of the other sensors is not in the correct range.
    If any one of the other sensors is out of range, we want to skip the encoder READ step altogether.  So, it is easy to structure a BOOLEAN in my vi as shown in the attachment.  If I do it this way, will it throw an error, or just skip the READ until the BOOLEAN is true again?  Is there a better way to prevent the READ from happening if one of my other sensor values is not within the correct range?
    Thanks,
    Dave
    Solved!
    Go to Solution.
    Attachments:
    forum JUly 18.vi ‏26 KB

    Sure, you can put a Read inside a case structure. For your application, just check that your sensors are all within range (Comparisons palette), then AND the T/F's and use the result of that for your case structure. (If you are already doing the in-range check, I can't see it here because you have 5 subVIs that I cannot open here.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ

  • Case Structure Based on Changing Input Controls

    Hello. I am trying to create a control VI for a quad-copter. Right now I've managed to build a basic program that gets input from some sliders and transforms and sends it to the quad-copter motors through I2C and virtual serial port.
    The problem that I'm having is that I want to be able to control the engines either individually or in pairs, so I can achieve motion in all directions. But since I can't have multiple inputs at the same time for each engine, I think I might need a case structure. What I would like to do is have a scenario where depending on whether an input changes and how (either for an individual motor or a group), the case structure switches to that case and takes the inputs specified for that particular case. What I'm thinking is having 10 or so sliders, 1 for each engine, and then 1 each for groups like 1 & 2, 3 & 4 and 1 for all, and depending on whether they change and how, switch to the case where only those particular engines change speed.
    Can you please help me out with that? Thank you. 

    That is one way to accomplish it. I would probably use the event structure. It is not that difficult to use. It is very similar to the case structure.
    I would also caution you on comparing two floating point numbers. Due to rounding it is possible that you will subtract two values which are essentially equal but return a non-zero result. You should use the "In Range" VI and set some tolerance value which indicates the numbers are equal.
    One last item, do you want your shift registers to be unitialized? If they are unitialized they will retain the values from the last execution of this VI. You may not want that since I assume you would want your motors to be off in the initial state.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • 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!"

  • How do I use a Case Structure with Strings?

    I need to use a string list to set up a set of cases to be performed. Is it possible to tell a single case structure to do "a, b, c, and d, but not e or f" or "do a, c, d, and f, but not b or e" etc... when you use a string containing the cases to be used?

    Blackavar,
    A case structure will only execute a single case at a time. If you want to have multiple cases execute in parallel, then you would need to have multiple copies of the case structure and split the string apart and wire them to all of the needed case structures.
    This could be done with reentrant subVIs to run truely in parallel. Anther method would be to have 6 different case structures, all with 7 cases each. The 7 cases would be "a", "b", "c", "d", "e", "f", and "0". Your input sting will need to be built up so that it will always be 6 characters long and then split up so that each character goes to one of the case structures. You would have your needed code for cases a - f. Case "0" would do nothing.
    Randy Hos
    kin
    Applications Engineer
    Nationsl Instruments
    http://www.ni.com/ask

  • How can I pass data generated in a SubVI inside a Case Structure out of the Case Structure?

    Hello,
    I am using a USB 2701 to control a heater.  I have three SubVIs that are all working properly on their own.  I'd like to use an Enum to select which of the SubVIs is running at a given time.  The problem is that no data is passing out of the case structure.  How can I pass the temperatures and heater outputs acquired by the SubVIs to the main VI?  I've attached my some of my code below.  I can't attach more than 3 files, but you can see how the main VI is configured.  Like I said, the SubVIs are working individually, so you shouldn't really need to look at them.
    Thank you,
    CJones581
    Attachments:
    RampHeater6-21-07.vi ‏305 KB
    69_Heater_Case.vi ‏23 KB
    HeaterTCD6-21-07.vi ‏210 KB

    CJones,
    You might check a couple of things.
    Your HeaterTCD... VI has a While loop with a stop button condition.  HeaterTCD pass out values only when it finishes running.  If it doesn't pop open the front panel (which usually doesn't happen when running a SubVI) you could run into a stuck loop because you don't have access to the Stop button.  This could appear in the form of no data being passed out (because the SubVI never stops running).  The primary VI opens the HeaterTCD VI, starts it, and waits for the VI to finish and pass final values .
    Secondary note: Unless you want your SubVI panel (which probably isn't open when running the main VI) to update continuously, consider moving your Temperature Graph and Temperature oC indicators outside the while loop.  Pass final values to them via a tunnel, since the main VI will only read their values after the loop finishes running, anyway.
    It might help to add error management to HeaterTCD like you have for RampHeater.  If you connect error lines with Error Outs to your main VI, that will help tell if there is an error somewhere that is preventing info output.
    RampHeater SubVI has the same issue with the stop button.  It is also probably getting stuck in the While loop waiting for a manual push of that SubVI's Stop button.
    An easy way to test this would be to set up a logic circuit so that when the While loop iteration counter reaches a certain number, it registers True and sends it to the conditional.  I know this isn't what you want to do long-term, but if that lets your SubVI return outputs it means that the SubVI was just never stopping.
    Hope that helps.
    David C, Applications Engineering
    David C
    Applications Engineering

  • Run only once in case structure

    Hello,
    I have a menu set up that is wired to a case structure.  Of course the menu is some boolean buttons that are set to switch when pressed so the case will stay open as long as the button is true.
    inside that case I have another menu and a case structure that operates the same.  In one of these cases I have a piece of code that I only want to run once.  I have tried the while loop that runs once and a for loop that only runs once, but the section of code seems to run continuosly instead of just once.  It works ok if I use any of the latch functions but not the switch when pressed functions.  However, I need the button to stay pressed until the user is finished with that case.
    I really don't want to use an event structure as I was saving that for another piece of code that monitors inputs.
    Anyone have a suggestion?

    Typically, this works easiest with a shift register and and a boolean "implies" function.
    In the code example (see image), the button is set to "switch until released". (Of course you probably don't need the NOT, simply place your one-time code into the FALSE case )
    Message Edited by altenbach on 01-26-2007 01:52 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    implies.png ‏8 KB

  • How to get a case structure to execute only once in a loop

    I have a while loop that is monitoring temperature. Once the temperature meets or exceeds a given setpoint I want to start a timer. At this point I don't want to monitor the temperature anymore. That is, if the temperature should drop below the setpoint, I don't want to execute the case structure again when the temperture meets or exceeds the setpoint(the temp may oscillate about the setpoint for a given period of time). In any event, I need the case structure to execute only one time, not every iteration of the loop.

    You can put a local Boolean variable "Flag" inside that case structure and
    set "Flag" to False. Outside the case structure, use an "AND" function
    output to control the case structure. The "AND" function has two inputs. One
    goes to the comparison results between real temp and setpoint. The other
    inputs connects to the "Flag" variable. In this way, once you entered that
    case structure, the "Flag" will be turned to False, and then in next
    iteration, you won't get into the case again because the "AND" function will
    be False as your "Flag" is False now.
    Hope this helps.
    Rentian
    1. Inside the case structure, put a
    "BB Herman" wrote in message
    news:[email protected]..
    >I have a while loop that is monitori
    ng temperature. Once the
    > temperature meets or exceeds a given setpoint I want to start a timer.
    > At this point I don't want to monitor the temperature anymore. That
    > is, if the temperature should drop below the setpoint, I don't want to
    > execute the case structure again when the temperture meets or exceeds
    > the setpoint(the temp may oscillate about the setpoint for a given
    > period of time). In any event, I need the case structure to execute
    > only one time, not every iteration of the loop.

  • In the attached VI I dont understand why data from the inner case structures are not being transmitted to the array.

    In the attached VI I don't understand why data from the inner case structures are not being transmitted to the array.
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    TEMP.vi ‏25 KB

    It took me some time to figure what you are trying to do but I think I have it now.
    The SR is still required.
    What is happening is your "Bundle By Name" is replacing all of the fields of the cluster, not just the value coming out of the case structure. So to maintain the cluster stuff you do in earlier iterations you can either...
    1) Put the "Index array, Bundle by name, and Replace array" inside the case structure and ONLY bundle the value you are setting in that iteration. (as you will see Tim post shortly)
    OR
    2) Move the Index array before the Case, unbundle all of the fields and feed teh case structure and run them across the case so that ALL of your output tunnels come from the coresponding input tunnel EXCEPT for the filed you are trying to set.
    Ben
    Message Edited by Ben on 05-05-2010 01:31 PM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • No sound after importing mpeg from imovie

    Hello, i'm new to IMovie and i have the problem that all my video files made with my photocamera loose the sound when i import them into Imovie. the FAQ's tell me it is because they are in mpef-muxed structure. Can anybody help me with the solution o

  • Oracle 8.1.5 and JDK 1.2 Thin Driver

    We are doing some prototyping with Oracle 8.1.5, BEA WebLogic 6.1, and JDK 1.3. We needed to know what is the latest version supported by the oracle thing client drivers for that configuration. Or are we the only users doing this and is it mandatory

  • Error when binding Web Module

    Hi, I am deploying an application on OC4J 10.1.3.3.0. It passed the compilation and have the following problem at the end of deployment. Starting up resource adapters Initializing EJB sessions Committing ClassLoader(s) Initialize xxx begins... Initia

  • Service Tax - TAXINJ

    Hi Gurus Need yr expertise... I have followed the OSS instruction to create the service cond type for SD - JSER, JSTE & JSTS but it was marked as statistical.. How do we post it to FI if it is marked as statistical? How can I reflect the % automatica

  • Capturing and logging sound

    Need some help here! I have a sony handycam wide lcd DCR-HC90E PAL with a surround microphone ECM-HQP1. When I capture and log I see that the sound is captured in stereo where it should be in 5.1. May be I do something wrong, but In the user preferen