Shifter register for array of waveforms

Hi guys,
I was trying to use shift register to append waveforms from multiple channels to their previous waveforms correspondingly.
The problem is when I click the stop button on the front panel and saved the data, the data file contains nothint except for some words like "waveform","t0", and "dt".
The attachment is the image of my VI.
Thanks!
Jude
Attachments:
screencap3.png ‏101 KB

Your problem is your FOR loop at the bottom.  When you first call this VI, the shift register will have the default value for the data type.  In this case it will be an empty array of waveforms.  A FOR loop will iterate the smallest of the size of the smallest autoindexing input array or the N.  Well, the smallest will be 0 because of that empty array.  So the FOR loop actually does not run at all.  It just outputs an empty array.  What you need to do is put a case structure around that FOR loop.  When the loop index of the WHILE loop is 0 (first time reading anything) set the output to the waveform you just read.  If the loop index is greater than 0 run the FOR loop like you have now.
If you look at the VI I gave you here you will see what I mean.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • User event for array of waveforms with attribute

    I have been transferring data in a Producer/Consumer architecture via User Events.  The data consisted of an array of waveforms. When I added an attribute to the waveforms the code breaks with two errors about Create User Event: User event data type is unnamed or has elements with no names or duplicate names, and Contains unwired or bad terminal.
    From reading the help on user events it is not clear that arrays are even allowed: "user event data type is a cluster of elements or an individual element whose data type and label define the data type and name of the user event."
    From experimentation it seems that arrays of numerics and arrays of wavefroms without attributes work. A single waveform with an attribute can also be used. But an array of the same waveform with attribute leads to a broken run arrow. It also appears that I can put the array of waveforms with attributes inside a cluster and then create the user event.
    Is this a bug, an undocumented corner case, or some "feature" that I do not understand?
    Searching for User Event for Array of Waveforms generates some interesting, but mostly irrelevant results.
    Lynn

    tst wrote:
    Another option would be typecasting, but it looks like you can't typecast a waveform. Variant to Data or Coerce to Type might also work, but I haven't tried.
    I have also done the Flatten To String and Unflatten From String to send data around.  It would be preferable to not need to do that though.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Is there a way to save state of shift register for initializing next time vi is started?

    Hello all,
    I've a quick question. I have right now....a numeric constant...starts with "1" intially when starting the vi.
    I use this as a shift register on my main while loop....as the counter to use when the user clicks various items on my vi.  This tracks the order the user wants things to happen later.
    It has now occured to me..that the user might not have selected all possible options, before quitting the vi....and might need to restart it...and begin to select other options...needing to keep place form when he left off last.
    Of course, with how I have it set up no...when the vi is started...the counter is reset to "1".  All the objects on the screen, are in the state it was when it was stopped...objects selected prior to quitting are still selected in the proper order...but if the user starts to select anything unselected..rather than starting at the next count..it starts at 1.
    Is there any way, upon quitting..to set the initialization counter to whatever number was last in the shift register..so that when the vi is started again...it will start up where it left off?
    Thank you in advance,
    cayenne

    I want to clarify. I'm assuming you have a config window or something that you open and close, but you don't actually stop the program? However, if this is your main window and you are stoppping the program then restarting, in reality you should have the program actually exit. The user should never have to press the run arrow in an executable to keep it consistent with other windows applications. It's (generally) confusing to an end user if they click the "x" and their program stays open. Then they have to click an arrow to make it start again. 
    CLA, LabVIEW Versions 2010-2013

  • Pointer Manipulation: Wrap Around/Rollover/Rotation of LabVIEW Arrays and Waveforms???

    I know we can't use pointers in LabVIEW, but I was wondering if there's any way we can do wrap-around [or "rollover," or "rotation"] of Array [or Waveform] values without having to make copies of the Array [or Waveform]?
    For instance, suppose I'm reading one second's worth of data into a five second buffer. After the first five seconds, I've got
    1st (1/5)th: 1st second's worth of data
    2nd (1/5)th: 2nd second's worth of data
    3rd (1/5)th: 3rd second's worth of data
    4th (1/5)th: 4th second's worth of data
    5th (1/5)th: 5th second's worth of data
    Now I read the sixth second's worth of data, and overwrite the [original] first second, so that I have
    1st (1/5)th: 6th second's worth of data
    2nd (1/5)th: 2nd second's worth of data
    3rd (1/5)th: 3rd second's worth of data
    4th (1/5)th: 4th second's worth of data
    5th (1/5)th: 5th second's worth of data
    and in C, or C++, I'd just move the pointer up to the second (1/5)th of data, and start from there.
    The LabVIEW Complex FFT is another place where this would be really useful. The Help File for the Complex FFT is in
    Help | VI and Function Reference | Analyze VIs | Signal Processing VIs | Frequency Domain VIs | Complex FFT.
    If you read the Help File, you see that LabVIEW returns an FFT with values in the range
    [0, 2n - 1)
    rather than the standard
    [-n, n - 1)
    i.e. LabVIEW takes the negative frequencies and tacks them on at the end, after the positive frequencies.
    I'd like to be able to view my FFTs with the negative frequencies where they're supposed to be [i.e to the left of zero], and this would be SO easy if I could just move the underlying data pointer of the Waveform forward to the halfway point.
    But, of course, in LabVIEW, I don't have pointers, so I was wondering: Are there any built-in VIs for Array [or Waveform] manipulation that will perform this sort of wrap-around [or "rollover," or "rotation"] of the data? If so, I couldn't find them. Ideally, such a VI would have two inputs: {old Array, new starting point}, and one output: {new Array}. Similarly with Waveforms, only you'd need to manipulate t0 as well.
    Or do I have to copy the entire data set to a new Array [or Waveform] each time I reach the end of the buffer?
    Thanks!

    > Ideally, such a VI would have two inputs: {old Array, new starting point}, and one output: {new Array}.
    Have a look at "rotate 1D array" in the array palette (second row, fourth column).
    (Sorry, I dont use waveform data).
    LabVIEW Champion . Do more with less code and in less time .

  • How to avoid the double memory assignment for an array which I connected to the shift register?

    Hi,
    I need to read a big block of data into an array. When I stop the program and then restart, I hope  the program to use the previously load arrary instead of reloading it. So I put the initiat Data loading in a for loop (N =1) and connect the array to a shift Register. The problem here is it assigns memory twice,  for the initiator data loading and shift register. Is there any way to limit the memory assaignment to 1 since I only need one copy.
    Thanks.

    JWJ wrote:
    Since my original file is more than 2M and really comlicated, I just make a simple demo file to show my purpose.
    Your current code is way too confusing, so I assume that the full code makes more sense. The program is unusable because the main FOR loop gets locked in an inner loop that consumes all CPU doing nothing.
    I think that branching the main array into the (1) case structure and (2) inner while loop costs you an extra allocation. Here's a more reasonable way to do things. It elimiates the buffer allocation going into the case structure.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    DemoMOD.vi ‏11 KB

  • Shift Register while Indexing Arrays in Formula Node

    Hello, 
    I am having trouble using the formula node while indexing my two arrays.  I keep getting "NaN" for my output array. I believe the problem lies within my shift register.  My guess is that for the first calculation there is not a PreviousAngle so that is why it is giving me "NaN."  For the first index I would like the value of the PreviousAngle to be 0. I am new to LabView and unsure what to do.
    Thanks!
    Christian Seymour
    Solved!
    Go to Solution.
    Attachments:
    Complementary Filter.vi ‏21 KB

    The shift register should contain 0 by default since you are using a double [if uninitalized, the shfit register takes the default value of the data type.  In this case, the default Double is 0], but you should explicitly initalize the shift register to a default value in most cases.
    To do so, right click on the "previous angle" shift register and select "Create constant".  This will create a Double value of 0 to fill in the register for the first calculation.
    If you need a number other than 0 to start, you can just change this constant.
    **Note:  This is a good habit to have.  Shift registers retain value as long as the VI is in memory.  So if you run this more than once, it will have the value from the last execution automatically!  This is usually unintended behavior for new LabVIEW users -- however you can sometimes take advantage of this feature in some applications and make it intended behavior
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If someone helped you out, please select their post as the solution and/or give them Kudos!

  • Iterative addition of 2D array using a shift register

    Hi
    I'm trying to add 2D array iteratively using a shift register.
    However, the indicator for the output of 2D addition shows nothing.
    Do you know Why? and How to fix this problem?
    Thx
    hiyang

    Ok, looked at ur attached VI
    You are not getting any output because, you are adding an array with an empty/blank array
    First, initialise an array of zeroes of required size and pass it to shift register,  Initialise your other array which u are adding inside the loop also of similiar dimension, and later, keep changing its elements
    Do as shown in modification of your attached VI
    Regards
    Dev
    Attachments:
    2DArray_shiftRegister.vi ‏30 KB

  • Problem saving an array using a shift register

    In the attached VI I'm building a 1D array of strings, then trying to save it using a shift register. For some reason my data isn't being saved and I dont understand why.
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    Shift_Reg.vi ‏15 KB

    Try this...
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Shift_RegMOD.vi ‏10 KB

  • How to quickly clear an array used in a shift register?

    Hello all,
    I'm sure this is a quick one, but I'm missing the concept.
    I have an array of boolean in a shift register. I have a case where I need to basically 'reset' the array rather than append to it....what is the best way to do this?
    Thank you,
    cayenne
    Solved!
    Go to Solution.

    stevem181 wrote:
    Of course, it is possible that my benchmark program is flawed.
    Yup, disable debugging and you will see that the inner FOR loop is folded in both cases and the time drops to about zero.
    Testing with debugging enabled is potentially unfair, because the reshaping will have more debugging code because there are more potential places to probe a wire, for example. All that said, I don't really know what's more efficient. That would require much more sophisticated testing. My point was just a reminder that there are always many ways to do things.
    (This is under LabVIEW 2012. Constant folding and dead code elimination of course differ between compiler versions)
    Granted, I typically don't use any of these two versions: I also omit the diagram constant, set the tunnel to "use default if unwired" and keep in unwired in the "clear" case. Less diagram clutter and quicker coding.
    Here's how it would look like.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Folding.png ‏13 KB
    UseDefault.png ‏3 KB

  • Writing data to spreadsheet in FOR loop without shift register

    My program has a case window within a For loop.  The loop iteration index is wired to the case, so there’s a case for each iteration of the loop (about 30 cases).  In each case, data points are gathered, formatted to a spreadsheet and written to a file, along with some occasional header strings to describe the data.  This works fine, as I can simply write the data to file as soon as I get it. 
    At some point in the loop, I’m gathering from two sources (rpm data for two fans) over several iterations that is to be written to two separate but similar formatted tables in the same output file.  Since I’m writing two tables to one file simultaneously, I can no longer write on-the-fly in a linear fashion; I’d need to store all the information until I complete the iterations, then format the header & raw data to spreadsheet and write to file in two chunks – at least, this is what I believe is the way to go, but I’m all ears if there’s another way.
    In order to buffer the data, I could use a shift register, but this requires me to wire an array across my loop for all loops, whether I’ll be using it or not.  I’ve also considered initializing an array at the case I’ll need to start buffering, then writing to a local variable of that array, but in fiddling with this approach, I don’t see how to specify what index to which I’m storing the data point.
    So I’m looking for advice on whether (1) there’s another way to accomplish my goal and/or (2) how to execute the initialize array and local variable approach. 
    Below is a picture of what I want this portion of the spreadsheet to look like.  Also included is a much abbreviated mock-up of my program for a case where I’m writing on the fly for a single table or column of information and a case where I’m setting up the write to local variable approach.  
    Message Edited by TESTIE on 04-03-2008 12:48 PM
    Attachments:
    illustration22.JPG ‏52 KB
    output_file2.JPG ‏120 KB
    illustration3.JPG ‏50 KB

    An Action Engine can thought of as an encapsulated shift register.
    AE's out-perform locals while alos elliminating possible race conditions. You may want to review the Nugget I wrote on Action Engines.
    Just trying to help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How do I plot an array of waveforms?

    The computer on which I am building my VI doesn't have access to the internet, so I can't post any of my code (so I'll use as much detail as possible)
    I am taking DAQ measurements for four devices that come in as (I believe) an array of dynamic data type. I split the signal and I have each channel outputting its own dynamic data type. After a user-specified time interval, a timed while loop will trigger the DAQ to take a measurement and write the data to a file and plot the data. The file writing was easy, but I am stuck on the plotting aspect. 
    What I have: Since efficiency won't be an issue (~15 minute average time delay), I have created a shift register of dynamic data type. Each iteration of the while loop, I append the newly acquired data to an array of dynamic data using the BuildArray function. I need to be able to take this and plot it in a graph, but every time I try it tells me that the dimensions of the source and sink don't match. Also, I need to do this for each of the four sets of data (and put them on the same plot). 
    What can I do to get plottable data from my shift register?
    I cannot open .VI files, so I would really appreciate it if I could get responses in pictures of block diagrams or text. Thanks.
    Solved!
    Go to Solution.

    Hi nc61,
    stay away from DDT (dynamic datatype) and you will be fine. Especially when trying to collect data by building up arrays of DDT (which probably isn't doing what you really want)...
    - Use DAQmxRead to get either arrays of data or waveform(s). Use BuildArray for simple data or waveform functions for waveforms to collect data in shift register. Plotting will be easy with those data!
    - There's the well-known example finder in LabVIEW's help menu. Try it...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Unxepected behaviour with clusters inside of while loop with shift register

    Colleagues,
    I just would like to post here small, but important bug (I guess this is the bug), which was found by coworker today morning. Just would like to share knowledge, and probably this will save some debugging time for you...
    So, the problem that you can get wrong content of the cluster in some cases. The cluster used inside of while loop with shift register (we using this construction for functional globals), and after bundle operation you can get data, which are not expected:
    See also attached code for details (LabVIEW 8.6.1, WinXP Prof SP3).
    best regards,
    Andrey.
    PS
    Bug report already sent to NI.
    Message Edited by Andrey Dmitriev on 10-16-2008 12:30 PM
    Attachments:
    BugwithClusters.png ‏15 KB
    BugwithClusters.zip ‏10 KB

    Thanks Andrey for brining this to our attention!
    The "Show Buffer Allocations" reveals that LV is not processing the code in the right order.
    Under ideal conditions, all of the data should be manipulated using the buffer "A". But as this demo shows the data is being processed in the wrong order.
    The previously posted workaround get around this by forcing the array operation to happen first, but this resluts in two additional buffers "C" and "D" and then copy this back into "B".
    Using an "Always Copy" is another workaround that uses a seperate buffer "F" to hold the data being moved from the first cluster to the second inside "E".
    I think you won a shinny new CAR* Andrey!
    Ben
    CAR = Corrective Action Report
    Message Edited by Ben on 10-16-2008 08:05 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Cluster_Bug.PNG ‏57 KB

  • Can I do the equivalent of a shift register with a variable start value?

    I have an array of samping frequency values (determined by an external signal) and I would like to extract one value at a time from this array to use as the sampling frequency for another signal.
    The shift register almost does what I want. The problem is that I don't always want to start at element 0, but rather at the first positive sampling frequency value, which has a slightly different index each time. Once this value is reached, I want the index to increment by 1 each loop iteration (which it already does).
    I have attached a VI for reference. Any suggestions?
    Solved!
    Go to Solution.
    Attachments:
    indexing question.vi ‏69 KB

    Laura121,
    I can think of two ways to do that. One is to place a copy of the DAQ Assistant outside the loop. Take one reading to get the initialization value for the shift register then proceed as you are now doing for subsequent measurements.
    The other way is do the initialization in a case structure. When  i = 0 (first iteration), initialize the shift register. For i > 0, use existing code.  This method would only require one DAQ Assistant.
    It is not clear that your code or either of the approaches I described actually does what you said you want to do in the original post: "...extract one value at a time from this array..." Each time through the loop you take another set of readings, discard all the old data, and take one sample from the array at the index determined by the shift register.  This is not what I would consider extracting one value at a time from the array.  If you really want to go through the entire array, you need to do the sampling frequency extraction many times for each DAQ Read.
    You also should have some error handling to consider the case where no element in the Array of Sampling Frequencies is positive or the case where you have reached the end of the array.
    Lynn

  • Questions about shift register

    hello!When I use the shift register,A problem occur!what I want to use is the serial in shift register function,But found only use parallel shift register,someone can give me any suggestions?(The best way has an example of a serial shift register),thanks!!!
    Solved!
    Go to Solution.

    I want to achieve :Each element of the array in the shift register Compare with 5,If less than 5, the output is 1, otherwise 0;but as you can see the vi is wrong ;Error reason is because of the shift register only for computing the entire array but not Single element,any suggestion?
    Attachments:
    the vi.png ‏8 KB
    array.png ‏5 KB

  • Generic shift register initialization

    Sometimes I know I want an initiaized shift register, but I am not sure about the data type, because it might change during program development. Sometimes I have a cluster holding a few variables, but later I need to add a few more elements. If I initialize the shift register with a diagram constant, things break whenever I change the cluster inside the loop and I need to redo the diagram constant by "delete the constant, right-click the SR,  create constant". I would prefer a mode where the initialization is generic and simply adapts to whatever type is wired from the inside. This simply ensures that no data is retained between calls, just between iterations of the loop as often needed. In summary, we should have an option to generically initialize a SR (or feedback node) and it would look different to indicate that fact. For example it could have a small cap as in the attached image.

    It's not just for cluster, but sometimes I am just dabbling with code and might have a simple boolean initialized SR but later decide I actually need an integer to have more than two values. This feature can also come in especially handy where we are building an array in the SR. Most often, these need to be initialized. Sometimes I start out with an I32 array, but later decide for DBL and even later for CDB. Typedefs would be overkill here. Yes, for a serious projects it is typically typedefs all the way, of course.  We often see newbie posts in the forum where arrays grow forever after multiple runs. Wouldn't it be simpler to say "simply initialize your SR generically" instead of having to give instructions on how to make a diagram constant of the appropriate type.

Maybe you are looking for

  • ITunes sound cutting out

    When I try to play songs in iTunes, the sound will cutout sporadically, then when it starts up again the sound is garbled, and sounds like a cd skipping. Has anyone else had this problem? Any fixes?

  • Please advise about internal hard drive

    I just ordered this internal hard drive from Mac Mall... Seagate Barracuda 7200.12 1TB Internal SATA 3Gb/s Hard Drive (ST31000528AS) http://www.macmall.com/p/product~dpno~7758831~pdp.fddjgjb The phone person said it's compatible with my Mac Pro from

  • Smart objects and rasterizing

    I open most of my photos as smart objects, but over the last little while I have started using tools that require me to rasterize the photo.  Will I lose significant quality in the photo itself by doing this?  Or should I look at a different way of o

  • Anyone still experiencing errors when syncing over WiFi?

      I have upgraded to the latest version of iTunes and I still get this error... "An (iPhone/iPad) has been detected, but it could not be identified properly. Please disconnect and reconnect the iPhone, and try again."  There are less errors than with

  • KEFC currency exchange rate issue - using end of period exchange rate

    Hello, We are experiencing currency deviations for manual upload file because  exchange rate type M is using exchange rate at the beginning of the period. We would like to use the exchange rates at the end of the period instead beginning of the perio