Replacing shift registers with queues or notifiers?

Hello World,
I'm using labView 7.1 with my first application, which is essentially a spectrum analyser and comparison to limits. now due to the parameters of the sampling 12000 samples/sec with 4096 point I have quite large chunks of data involved in rolling averages of 1 minute and rolling buffers that are an hour long. I'm pretty new to labview but I'm finding pretty easy to pick up except when it comes to optimisation and performance (I've been used to the microsoft approach until now) due to the fact that the instrument I'm building has to run in psuedo "real time".
I've been looking at replacing the shift registers with either queues or notifiers but I'm unsure if these techniques would result in improvements or not.
I'll attach a jpg of my main loop, I've only got the one but it is separated into three separate tasks but they are all governed by the data flow, DAQ then PROCESSING then REPORTING.
I've been told that by separating the loops and making them run in parallel LV will be able to compile it more efficeintly, but I'm unsure how to do that .
Cheers
Andrew
90% of all experts aggree that 1 out of 10 experts are wrong
Attachments:
Step 14 -Post Course Mk4d.jpg ‏376 KB

Fat Controller wrote:
Hello World,
I'm using labView 7.1 with my first application, which is essentially a spectrum analyser and comparison to limits. now due to the parameters of the sampling 12000 samples/sec with 4096 point I have quite large chunks of data involved in rolling averages of 1 minute and rolling buffers that are an hour long. I'm pretty new to labview but I'm finding pretty easy to pick up except when it comes to optimisation and performance (I've been used to the microsoft approach until now) due to the fact that the instrument I'm building has to run in psuedo "real time".
I've been looking at replacing the shift registers with either queues or notifiers but I'm unsure if these techniques would result in improvements or not.
I'll attach a jpg of my main loop, I've only got the one but it is separated into three separate tasks but they are all governed by the data flow, DAQ then PROCESSING then REPORTING.
I've been told that by separating the loops and making them run in parallel LV will be able to compile it more efficeintly, but I'm unsure how to do that .
Cheers
Andrew
Don't convert shift registers into queues or other things for performance reasons! LabVIEW has a lot of internal optimization logic when compiling your code which works best on shift registers. On a queue you will always copy the entire data of a message in or out even if you only need one byte of it.
Try to look at your architecture. You do want to do as much as possible in place. Try to completely avoid Append Array or Append String inside loops if possible. They are costly operations as they have to reallocate memory each time and often copy the entire data from the first array into the resized array. Better is to once preallocate an array of the necessary size, keep it in your shift register all the time and then use Replace Array Subset, Index Array and Array Subset nodes only on this. You will also have to maintian some index shich tells you up to where you have currently filled that array and that one is usualy best put into a shift register as well.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • LV 8.21: strange behavior with DAQ tasks, parallel running VI's and shift registers

    Hello,
    I have made a VI using DAQmx vi's. The VI uses shift registers to store DAQ tasks and other (internal) information. I have implemented  several modes of operation (enum control with a case structure) like 'init', 'read AD', 'config AD' etc. If I use this multi mode VI in a single main VI everything work as expected. I have attached a jpg that shows one example where the DAQ VI is called from 2 parallel running while loops. One loop aquires the data (LOOP 1) while the other loop configures the aquisition task (LOOP 2). If I implement the same thing by putting LOOP2 in a different VI that runs seperately from the first VI I get an error message (200428):
    Possible reason(s):
    Measurements: Value passed to the Task/Channels In control is invalid.
    The value must refer to a valid task or valid virtual channels.
    Task Name: EasyDAQ_AD
    Of course, the second VI is started manually after the 1. VI has passed the initialization part. The error message is triggered from the 1. VI that executes the DAQ task. From my understanding of the LV execution system this seems like a bug to me. Does anyone have an idea what could go wrong here?
    klaus
    Attachments:
    problem.jpg ‏30 KB

    1. In general, this kind of technique is something I've been using successfully for years.  (Ben recently wrote up a very nice treatment of these "Action Engines" as a "Community Nugget.")  So I don't start by expecting this to be a bug in the LV execution system.
    2. Your description of the problem sounds almost backwards.  You say you manually start the 2nd vi ("Config AD") *after* running the 1st vi ("Read AD").  Seems like you'd need to do the Config 1st and then do the Read, right?   I kinda suspect you actually did it in the right order, but described it wrong.
    3. The next likely scenario is that the Config failed, but you didn't trap the error and were unaware of it.  Then it makes sense that the Read would also fail.
    4. A couple issues I regularly deal with in these DAQ Action Engines is internal error handling.  I often keep a shift register inside to store errors generated inside the Action Engine.  But it can get a little tricky doing sensible things with both the internal error and any other error being wired in as input.
    I said all that so I can say this: if you have complex nested case statements, or lots of different action cases to handle, double check that the task wire makes it from all the way from left shift register to right.  Sometimes they get lost if they go through a case statement, the output tunnel is set to "use default if unwired", and 1 or more of the cases don't wire the output.
    -Kevin P.

  • Shift Registers not working properly with counter group .vi

    Because I'm not sure how to refer to them as a group.
    Well, because my previous vi only let my DAQ(STC) model no. 6020E read on one channel, I switched to a new set of .vis. They solved my channel problem, but in exchange, they introduced a set of new ones.
    First, when the .vi runs without shift registers(used a function generator for testing), the count ascends at a steady linear rate. That means with shift registers, I should be getting a horizontal line or close to it, right? For some reason, instead of a horizontal line, I instead get a zigzaging line that steadily ascends the amount its supposed to. 
    Sometimes, the count just zigzags up in down from 4 mill to 0 and back again for reasons I do not comprehend.
    I'll upload my new .vi and my old .vi.
    Screenshots too
    http://imageshack.us/g/192/shiftregisterproblem.pn​g/
    http://imageshack.us/photo/my-images/560/idonteven​p.png/
    Attachments:
    Pulse Counter attempt mkIII.vi ‏96 KB
    Pulse Counter attempt mkII.vi ‏43 KB

    Ok, here are the pictures and one of the vis uploaded .
    Attachments:
    idontevenp.png ‏238 KB
    shiftregisterproblem.png ‏223 KB
    daq-stc.llb ‏1736 KB

  • Need help with while loop and shift registers

    I have a large data set and need to read in the data at maybe 200 samples at a time, process these samples through my VI, and have it append and concatenate a separate lvm file.  The part where I am confused is the shift registers. How do I limit the number of samples read in an iteration? How do I get the while loop to stop when all the data are read in?
    I've attached my diagram, maybe there is something wrong with my technique?
    Solved!
    Go to Solution.
    Attachments:
    shiftreg.JPG ‏56 KB

    This will give you an idea.  There are plenty of other (probably more efficient) methods.  This is a basic, quick and dirty solution to help you grasp the overall concept.
    Using LabVIEW: 7.1.1, 8.5.1 & 2013
    Attachments:
    ShiftRegLoop.JPG ‏54 KB

  • Is there and alternativ​e to shift registers for saving data across iterations in a subVI operating inside a loop?

    I am creating a subVI state machine (case structure) which will run inside a while loop which will be executing every 250ms. The reason I wanted to make the state machine case structure into a subVI is because I want to execute 64 of the machines within the same loop. The goal is to monitor certain types of voltage changes on 64 I/O channels on a FP2200 RT module and report periodic details about state changes to a database. My thinking was that by executing each independent machine in the same loop structure, I will only worry about one thread. It seems that the alternative of having one state machine thread per I/O channel is probably more than the RT module can handle. Please correct me if I am wrong on that.
    The issue I'm now having is as I'm creating the state machine, I am finding that I need to keep track of some pieces of data from one loop iteration to the next. This is easy enough to do with shift registers but in order to use them, I have to create additional input nodes to my SubVI as well as output nodes. For example, I want to use a queue to buffer some I/O data but as of now, I have to create this queue outside the loop, pull it into the loop across a shift register, feed it to the subVI, and output it to the out Shift register. It would be better if I didn't have to output this queue because there's no reason for anything to have access to it outside the subVI. It just creates an extra set of wires to look at and makes me worry a bit about maintainability. 
    Is there a better way to approach this problem? 

    You could place a while loop inside your sub vi that has a true constant wired to the stop condition. Then add unitialized shift registers to that while loop to keep data between iterations.
    or you could use a feedback node inside the sub vi

  • Bypassing shift registers

    Being a beginner, I was experimenting with loops and shift registers. Originally I had an add operation that added 1 each time and the results passed back around via a shift register. Maybe I was thinking of op amps at the time but I thought why not just loop the output back to the input instead of going thru the shift register. Seems to work, is it a reliable design?
    thanx,
    jh 
    Solved!
    Go to Solution.
    Attachments:
    feedback.vi ‏19 KB

    jvh75021 wrote:
    Maybe I was thinking of op amps at the time but I thought why not just loop the output back to the input instead of going thru the shift register. 
     Your shift register has absolutely no function here, because you never even use its output anywhere. Click on the shift register and delete it. Run the VI again. Notice no real difference! Now you could right-click the feedback node and "replace it with shift register and still retain about the same functionality. Shift registers and feedback nodes are interchangeable to some degree.
    Important Details: Shift registers and feedback nodes are not completely equivalent. Notable differences exists in the way they can be initialized. A feedback node does not require the presence of a loop (at least in newer LabVIEW versions) and shift registers cannot be globally initialized. Feedback nodes can exist entirely inside a single case of a case structure. Shift registers require a loop on the same subdiagram. Shift registers can be resized on the left to access earlier histories. Feedback nodes can only access one history (selectable in newer versions).
    Shift registers and feedback nodes are central to elegant and efficient code, so make sure to become completely familiar with them. New users often do ugly local variable hacks to approach some of their functionality.
    LabVIEW Champion . Do more with less code and in less time .

  • Using a loop back node to build array okay instead of shift registers?

    Attached is a sample of how I want to accomplish appending to multiple arrays and would like an opinion wether it is acceptable or not.  I didn't want to use 12 shift registers wired from the 6 possible case structures mainly because of esthetic reasons.  Each case will be called in turn during program execution only once.  So case 0 builds it's array then later case 1 and so on.  It seems to work but frankly manipulating arrays in LV confuses me a bit.  I cannot test in the actual program since the hardware the complete program controls is not yet installed.  Your input as to the wisdom of doing this or proposing a better solution (maybe one that actually works) is appreciated
    Mike
    Attachments:
    sample2.vi ‏33 KB

    You never have more than one element in each array since you initialize the shift register with every call of the VI.
    Use "built array" instead of "insert into array", it's cleaner. However, since you only kep one elements, maybe you can jist place the scalar value inside a shift register. Make sure the default value is NaN so you know when it contains valid data.
    All you probably need is an array of fixed size (12) and replace appropriate elements as need arises.
    What you probably want is an action engine. See http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=240328#M240328
    LabVIEW Champion . Do more with less code and in less time .

  • Replace build array with replace subset array

        Currently I am using a build array function, but would like to replace it with a replace array subset, but I am new to labview and having a lot of trouble.  I've attached a screen shot of the code I am struggling with.  Does anyone have any ideas?
    Attachments:
    Build array code.JPG ‏29 KB

    First, I'm assuming this is inside some sort of loop.  Second, I would recommend cleaning up the code a bit so the feedback node is not overhanging the edge of the case structure.  It's unclear as to what is wired to what.  Third,  I would recommend using shift registers instead of the feedback node.
    Fourth, and the main thing is that you are currently initializing a 64 element 1-D array and appending it to your array on every iteration with the build array.
    If you want to use the replace array subset.  Initialize the array to the size you want outside of the loop.   Feed it into the left hand shift register.  Replace each row (or column) with your new data.  You will need to track the iterations, and possibly add special code to shift the array, or enlarge the array in the event you have more data come in then the original size of your array.

  • Multiple shift registers in For loop

    I'm using multiple shift registers to find the number of different string in a string array. However, the shift register got refreshed every time it finds a different string and returns back to 0. How can I have the register remember its previous value after it encounters a new string value?
    Solved!
    Go to Solution.
    Attachments:
    count.vi ‏19 KB

    You should think about making your code scalable. At the moment, you need to re-architect the VI from scratch whenever the sensor names or their number changes. If you suddenly have 1000 sensor names, the code would be unmamangeable because the sheer number of cases and shift registers!
    Attached is an simple alternative. As you can see, the code remains the same, even if the number of sensors or their names changes in the future. See if it makes sense. (You can easily modify it to also count unrecognized names, for example).
    Modify as needed.
    Some other possible bugs in your VI:
    You should initialize the shift register with zero, not one. Right now the results are one too high.
    Case "B" is actually "B." and the count is only accidentally correct because it is also the default case and there are no other sensor names (e.g. F) in the input array.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    CountMOD.png ‏19 KB
    countMOD.vi ‏19 KB

  • How to generate pseudo random noise(PRN) binary sequence using shift registers?

    what is the block diagram to generate pseudo random noise (PRN) binary sequence of 1's and 0's using shift registers
    please help
     i need 2 submit this project in this week

    This is a fairly simple homework problem. My hints (on the LabVIEW side):
    1- look at while loops
    2- look at shift registers on while loops with multiple input elements
    3-look at the logic components, AND, OR XOR
    Look at this wiki article: http://en.wikipedia.org/wiki/Linear_feedback_shift_register
    Do the work, you won't learn if someone shows you how it is done! The palette that the previous post points to are of PRN and other "noise generators" but I suspect that is not what you are after.
    Know that creating a PRN with a reasonable number of shift register taps produces very pseudo results, as the "random" pattern begins to repeat pretty quickly, thereby making it not a truly random number. 
    When you have an attempt that is sort of working and want additional suggestions, post the code here. We won't do your work, we will help you try to do it, and learn it, yourself.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Any way to sample segment length longer than loop iterations w/o shift registers?

    Hi all,
    My loop iterates approx every 0.06s and now i've been asked to add to the program a function which will sample the most recent 3s of data and return the max/min value for two of the signals.  I can think of a programmatically clumsy way to do this with shift registers- take the max/min for each iteration, save-repeat-compare until you have enough iterations to fill 3s of time.  But I can't help but think there has to be a cleaner(better?) way to do this. 
    Any help?
    Thanks
    Solved!
    Go to Solution.

    Hi there,
    Try looking into a circular buffer.  
    http://zone.ni.com/devzone/cda/tut/p/id/7188
    Once you've determined how often you're putting entries into the buffer, you'll know exactly how big of an array to grab and do the Min/Max on.  
    Another option is to use a circular array.  
    http://decibel.ni.com/content/docs/DOC-3414
    I would set this up to function a little like a Functional Global or an Action Engine.   The subVI would then be used in your DAQ loop to "stack" new data.   And then called in another loop or part of your code to be read every three seconds.  
    Patrick Allen

  • How to replace an MDB with a servlet

    I got a situation to replace an MDB with a servlet,How can I do that,more appreciated if u send me some sample code.

    Hi,
    An MDB can be replaced by a normal java class by doing the following.
    Make a jndi lookup for the queue/topic connection factory and then create a javax.jms.QueueConnection. Then create a javax.jms.QueueSession using this connection. Make a JNDI look up for the Queue. Create a javax.jms.QueueReceiver using the created QueueSession. Call start on the QueueConnection and receive a message by calling the receive method on QueueReceiver.
    Thanks,
    marvlex

  • Queues and notifiers - please help?!

    Can someone explain to me how to effectively utilize queues and notifiers? I understand the fundamental difference between the two but I am having a difficult time establishing when I should use one over the other or how to utilize both of them at the same time.
    Essentially what I currently have is a master loop that contains (among other things) an event structure. The event structure contains controls which dictate when notifiers are sent and destroyed. The notifiers “turn on” other loops (all within the same sequence frame as the master loop). These other loops are used for various controls, data logging, etc. Within some of these “sub-loops” I would like to step through a sequence of events – this is where I’m having trouble.
    Here is what I would like to happen: When the user clicks a certain button, a notifier is sent to sub-loop-A and it begins to run. The user then selects from a pull-down menu one of a few different options. Depending on the option selected, a specific set of events occur (whose progress is dictated by both user interaction (pressing buttons) and successful events (data being fed back). I would then like the sequence to “reset” and allow the user to select another option from the same menu – I don’t want to exit all the way back out to the main loop and force the user to re-select sub-loop-A again. However, if from the front panel the user selects sub-loop-B I would like sub-loop-A to exit and sub-loop-B to begin running. I have attached a sample of the basic layout I have so far (in LV 8.2) – I apologize in advance – I’m still learning labVIEW and I’m probably not going about this in the most efficient manner.
    A couple other things to note – I’m trying avoid polling because speed is important. Also, the template I’ve attached is far from complete – it will require additional sub-loops and additional sequence loops (which I have been advised to use que-based state machines - which I'm also not familiar with).
    Any assistance you guys can provide would be great – examples, web links, etc.
    Thanks again!
    -Erik
    Attachments:
    LayoutExample.vi ‏72 KB

    I do see a problem in the operation in that if I hit the stop button, the inner loop of auto starts running like crazy.  I think it is because if the wait for notifier returns an error due to it getting destroyed when the stop button is hit, it still sends out the notifier as the default, which starts the default case structure operating and thus its inner loops.  And they don't stop.
    You should probably get the loops out of the default case.  Any case structure should have a default case that does nothing. 
    A better practice would be in the stop button case, send out a notifier that is for a specific exit case that tells all outer loops to stop.  Then destroy the notifiers.
    In your 4 loops, you have the stop button NOR'ed with the other condition rather than OR'd.  So if you say stop = true, the OR results in a True, but the negation turns that into False and the loop does not stop.  In the top button, you had the enum compared to exit, then that was NOT so the loop would stop immediately if the enum was anything but Exit.  Because the Boolean logic in these loops was convoluted, I think the loops weren't behaving the way they should.
    I made some modifications to clean up the default case and the boolean stop loop logic in each of the loops.  See attached.
    Attachments:
    MultipleLoopsV82 MOD.vi ‏90 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

  • Better method than using a large number of shift registers?

    I'm trying to work with example code provided free by stanford research systems (http://www.srsys.com/downloads/soft.htm).
    Their example software alows the user to run an analog scan across 100 masses (the x axis) which progressively produces a graph of all the data. It repeats scanning (and updating the graph)until the user hits stop.
    My goal is to find a way to make the program display the graph of the last scan while it is displaying the current scan (this way it is possible to compare the graphs and see how they change). But as best I can tell the data is generated and plotted in a while loop piece by piece so the best thing my labview inept mind has managed so far is using a large nu
    mber of shift registers and graphing the points as they generated along with points that were generated 10 cycles ago in a different color.
    So I hope to either find a good way to use shift registers to get values from over 100 cycles ago (which doesn't really seem to work unless i just make space for over 100 little arrows in my loop) or to find a better approach to the whole mess.
    The example does not seem to use XY plot and to tell the truth I don't know exactly what its using to plot.
    Can anyone offer any guidance or at least understand my question enough to point me in the right direction.
    I'm including the stock example and my adaptation to it but if you need to use the included sub vi's the package is on that SRS webpage I listed above (look under RGA).
    I suppose this may all be too much to ask but I can dream can't I?
    Attachments:
    original.vi ‏87 KB
    changed.vi ‏92 KB

    I certainly agree that the DAQ programming is the part leaving me most confused. I'll attach the package that I am trying to modify, the trouble is there are so many sub vis involved in actually acquiring the data that I am not entirely sure what format the data comes out in.
    Perhaps to someone more skilled than I am with lab view the inner workings of this package would be clearer. If you are up for it then look at SRSRGAa simple analog.vi in SRSRGA61.lib and you can see what I'm working with.
    I'll also attach my attempt to modify the code to make it work like altenbachs example... however somehow it would seem my timing/synchronization is off. Hope some of this makes sense, I'll see what luck I can have with get w
    aveform components, I suppose I have been approaching this so far as if my DAQ was just giving me data points as opposed to a waveform.
    Attachments:
    rga_lv_61.zip ‏2132 KB
    graph_app.1.vi ‏101 KB

Maybe you are looking for

  • Re-using existing client application minus Swing.

    Our company has developed a desktop application over the years and I'd be comfortable in stating that it's close to legacy status. The application has a Swing View and throughout the years, unfortunately, the BL and the presentation layer has become

  • Which Adapter? External Monitor to Macbook Pro

    I'm confused as to which adapter I need in order to connect my external monitor to my Macbook Pro. The monitor is a Samsung P2250 (21.5", LCD). Any help would be appreciated.

  • Professional Level Certification - P_ADM_SYS_70

    To All BASIS Community, May I have some guidance for the preparation of Professional Level Certification - P_ADM_SYS_70. My total experience is 6 Years. Looking forward for hearing a favorable response. Best Regards, Unni.

  • COPA Characteristics Derivation

    Hi All, Good day! I would like to seek help regarding my concern in COPA. We are trying to derive certain COPA characteristics but this derivation rule will only be triggered whenever we post Freight for Sales. My question is how can I technically kn

  • Unknown error 306 when clicking on a song in the iTunes Store

    I'm new with ITunes...I recently got a new ipod and some itunes giftcards, so I downloaded itunes to my HP and the front page has a bunch of question marks in places that should be pictures. Also when I actually look a song up and click on it, I get