Using a shift register to detect input...

Hi guys,
I'm creating a LabVIEW VI that needs to be able to detect when a user changes an input. I read a previous post that suggested using clusters and shift registers to compare previous data.
My question is how do I use shift registers? I've created a shift register on a for loop, but I'm not sure when to compare the "previous" data to the "new" data. Do I need to add an element to the left side and compare it there? Is the right side the output? I'm just not sure how it works. An uploaded example would be nice. Thanks.
-Mike

Shift registers are very powerful but difficult to use for the first time.
The shift register you just created has two "arrows", one on either side of the structure. The arrow to the left is the value from the previous (i:th) iteration and the arrow to the right you have to feed with the (i+1)th value.
Now, if you want to compare values and look for a change you can compare your old value (the one coming out from the left) with the new value in your for loop. The feed your new value to the right arrow so that it becomes the old value for the next iteration.
If you have many parameters to compare, clusters are very useful since they make things very compact. If you are comparing clusters, do not forget to change the setting on the comparison to compare aggregates (r
ight click on it and select that option).
Also, in most cases you need to set the initial (start) value for your shift register. This is done by feeding the left arrow with the default value from the outside of your loop.
I attached a simple example, CompareSettings.vi, that shows how it works. Hope this helps. /Mikael"
Attachments:
comparesettings.vi ‏32 KB

Similar Messages

  • 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

  • Problem in using the shift Register

    I have a problem regarding shift register when i was using it in my application.
    During the runing of the application i found that sometime shift register not pass the value to the case structure. at that time result is not displayed.
    i have attached the application in which that problem occur and the process regarding the execution, how bug produce and how to check where the shift register stop. please find the attachment and reply on the same.
    Attachments:
    Shift Register Checking Application.zip ‏173 KB

    I'm sorry but I don't understand your program.  I only see one shift register in Result Display.vi.
    What I do see is a lot of odd constuctions of while loops that only run once in your Main.VI.  Also, a heavy reliance on global and local variables that I suspect are leading to race conditions.
    Have you tried using the debugging tools such as probes and highlight execution to see our your application is behaving?
    I'd also be concerned about how you have "Lock Front Panel Until Event Completes" in the cases of your event structure.  And those event call other subVI's that may take a while to run and rely on user interaction with the front panel.  I also don't understand why when I hit "OK", the subVI front panel remains open.  It just makes running your application that much more confusing.

  • Use of shift register and similiar C code

    Hello LabVIEW Gurus,
    I am very new to LabVIEW and I did searched the forum for my short question but the answers were not that clear to me. My question is what is a shift register and could you please give me one similiar C code and where shift register can be used.
    Thanks for your time.
    Vasu

    there is no direct analogous to a c construct to a labview shift register but a shift register is an unnamed temporary variable for use with itterative loop structures (for and while).  See the following code
    int sum = 0;
    for(i=0; i>100: i++)
    sum = sum  + i;
    return sum;
    This can be done in LV without naming the variable sum .  In addition the shift register can be initialized or not.  If you do not register the shift register it will remember the value from call to call (a very cool feature when you learn to utilize it). See below
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • How to program shift register to read only when a new user is detected from user?

    Hi,
    I'm currently developing a program for position control in labview. The program is quite simple, whereby user will input the distance that he wants the table to be in the labview program, and labview will send signal to move a motor that will turn a ball screw to move a table horizontally to the targetted position. The criteria is that the profile of the motor depends on the distance it needs to move, whether a two-phase (acceleration and deceleration) or three-phase (acceleration, constant velocity, deceleration) to reach the target position.
    The problem occurs when the user wants to enter a new position (second input) for the table, as the input by user is position the table needs to be but the input required to determine which profile the motor follows depends on the distance that the table will move to get to the targetted position. Therefore, I would need a function to store the input by user temporarily, and recall it only when a new input from user is detected. By this, I would be able to use the difference of the input (input [n+1] - input[n]) and feed it to determine which profile the motor follows and the input by user can be kept as the position he wants the table to travel to (to compare with encoder).
    I thought of using shift registers to do this, but I am not able to make it to perform the deduction ([n+1] - [n]) only when it detects a new input. When i try using shift register, it travels to the targetted position, and one it reaches it will travel back to the original position. For example, when a user input 90, it means the table needs to move to point 90. As the shift register is initialized to 0, it will move to point 90 (90-0 = 90) but upon reaching 90, the shift register sends a signal of 90 (90-90 = 0) and the table returns to it's initial position.
    Is there any way that I can delay the reading of shift register only when a new input is detected or is there another way for me to achieve what i want?
    I've tried searching the discussion forum and ni website but couldn't find similar problems. Thanks for your help in advance.
    Solved!
    Go to Solution.

    Hi,
    I've managed to get what I needed by using a shift register + event structure as suggested by Adnan. However, I face another problem after implementing SR+event. I've attached two files, first the original program and second the updated program using SR + event. (it's only the jpg file as I've forgotten to save the labview program, will upload the program by tomorrow.
    In the original program, I have an elapsed time that is able to run continuously when I run the program. In the updated program, my elapsed time don't seem to run continuously when I run the program (as shown by elapsed time indicator). I need the elapsed time to run continuously as a input to calculate my motor profile.
    I suppose this is caused by the introduction of the event structure, will adding a case structure to wrap the event structure solve the problem or is there another way to get pass this. Appreciate if someone could drop me a pointer or two.
    Thanks
    Attachments:
    Mar 16 - continuous elapsed time.png ‏12 KB
    Mar 16 - elapsed time not continuous after introducing shift register + event structure.png ‏17 KB

  • What is the maximum number of the parallel blocks or maximum pair of shift register used in FPGA VI time loop with cRIO 9104?

      I am writing a FPGA VI with module cRIO 9104, I need to do a lot of parallel execution of inside a timed loop. In total, I have used 20 pairs of shift registers in the timed loop, which simply means there is 20 parallel exceution across ONE time loop. However, it tells me that there is an over-used of the FPGA resources in the compliation report. One is the Slices and the other is the number 4 of LUTS ( see the attached file), would the compile will be sucessful if I change it to ALL block diagrams cascaded in series without using any shift register accross the timed loop? And do you think that it is reaosnable to have 20 pairs of shift register arranged in parallel inside a timed loop.
      Thank you!
    Attachments:
    afternoon912.jpg ‏2305 KB

    Your compilation report has 2 useful numbers to help answer your question, I'll summarize:
    Number of Slice Flip Flops = 27%
    Number of 4 Input LUT's = 100% *
    You are using the Timed Loop Shift registers to pass a value from one iteration of your loop to the next.  The LabVIEW FPGA compiler will use Slice Flip Flops to create this behavior in the FPGA fabric.  You are only using 27% of the Flip Flops, therefore the 20 Shift Registers are not your problem. 
    LUT's (Look Up Tables), which are the basic logic building block of an FPGA, are your problem.  You are using over 100% of the LUT's in this FPGA.  To fit in this FPGA you will have to reduce the amount of logic (and/or gates, additions, comparisons, etc.) in your design.
    -RB

  • Any way to save data in loop without using shift register or feedback loop

    Hello all
    I was thinking, is it possible to save data in a loop to next iteration without the use of a shift register or a feedback loop?
    I need the possibility to reload data within a loop from a lvm file, but I want to use the same data until i load some new ones.
    The reason why I don't want to use the shift register or feedback node is due to speed, even though I am not sure if the shift register
    actually moves all the data from one register to another, or if it is stationary until a change in the data occur.
    The data I want to reuse is medium-large (6 force measurements, 2 pressure, 1 flow channels)of about 10sec data in each file with samplingsrate of 2kHz..
    In my analysis program I have many CPU demanding calculations and 3D graphs, so I just want to minimize the CPU load as much as I can for each part of the
    software..
    I have attached a small VI to explain what I am talking about.
    I now I shouldn't use the express VI, and I am going to change that as well - this is just a proof of concept! 
    Hope you guys can help me understand this shift register better...
    Thanks!
    - Tommy 
    Running LabVIEW 2009 32bit SP1 on Windows 7 64Bit
    Solved!
    Go to Solution.
    Attachments:
    visual.vi ‏34 KB

    tombech wrote:
    [...]The reason why I don't want to use the shift register or feedback node is due to speed[...]
     Tommy,
    shift register are the fastest you can ever get...........
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • How to use Shift Register?

    Hi
    Today I spend hours to ficure out how to use a shift register with labview.
    I am going to calculate the acceleration of the wheels of an RC-car.
    I want to use the simple function to calculate the acceleration.
    a=(v1 -v0)/time
    From this it follows that I need two speed (ms) values. I was thinking about including a shiftregister that I made before (attached) into the SpeedAngle.vi
    But that doesn't work.
    Is there maybe an other way to store two following values of the calculated speed? So that I can use it for further calculations.
    Thank you!
    Attached the two program files.
    Bye
    Attachments:
    ShiftRegister1.vi ‏23 KB
    SpeedAngleAdvancedEDIT.vi ‏187 KB

    Hi
    Thank you very much. Now it works. Attached you will find the program. Now I need to adjust the car with the program. Hope this also works.
    One more question. Why isn't it possible to use a Numeric Control twice?
    Because I wanted to use the Numeric Control that I use for the time constant (time) also for the calculation of the acceleration.
    That doesn't work. Than I placed a Numeric Indicator to display the value of the time constant. But it just displayed the default value.
    Bye
    Attachments:
    SpeedAngleAdvancedEDIT.vi ‏214 KB

  • Shift register versus comparison in while loop

    Hello,
    I have a question regarding the "proper" (i.e. cheaper in terms of system ressources, easier to read, etc)  way of testing the first entry in while loop. One way would be by using a shift register another by detecting if the loop iteration is zero (see the exemples attached here).   I am doing some calculations in this loop, typically 300 iterations or so.
    Which way is better ? Are there other (simpler) waysofdoing this ?
    Thanks
    N
    Attachments:
    while_loop1.png ‏54 KB
    while_loop2.png ‏53 KB

    Express vi's are not entirely evil. And the time delay express vi's are harmless. I have found express vi's to be very useful if I'm trying something new. Besides, once you get everything working the way you want it to you can always open the front panel and clean out any extraneous code that might slow things down. Once you have done that it will perform just like you wrote it yourself.
    PaulG.
    "I enjoy talking to you. Your mind appeals to me. It resembles my own mind except that you happen to be insane." -- George Orwell

  • Using the counter to create a input variable in while loops

    I'm using a loop to increment oscillator freq on my lock-in. I want this incrementation to be based off the loop counter. But when I do this, it gives me some kind of circular reference error. Can I make my own counter inside the loop instead? How? See the attached screen shot for details.
    Attachments:
    loop_problem.JPG ‏138 KB

    Hi Jesse,
    You can attach a copy of your vi instead of a screen capture, because the the screen capture is difficult to read. Unless there is confidential code, of course.
    The first thing I noticed is that there are some improperly wired vi's. I can't comment much because the screen capture was not clear.
    However, the "circular referrence error" means that you have a wire which exits a loop and re-enters it.
    If you need to pass a value back to the beginning of a loop, then use a Shift Register. Right click on the edge of a loop and select "Add Shift Register". It can be initialized by wiring a value (or control) to the input of the loop.
    -JLV-

  • Problems about shift register

    i am using shift register to detect the change of state of my system. --- to detect when the temperature exist the limit, say 50 degree
    therefore, i want to set a constraint that when the past value is below the limit, and the present value is over the limit, the loop is runned and value, time is recoreded.
    My problem is that the system can't run well.
    here is my sample program
    Attachments:
    shift_regiter.vi ‏225 KB

    Hi,
    Yes I did see your eaxample.
    Your inner loop will only ever get one reading if it is inside your limits because it will never exit and therefore your outer loop will never take another reading. Your limit checking needs to be in a parallel loop for it to have a chance to work.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Why won't my shift register work?!

    I am trying to calculate the volume by multiplying the rate by the time plus the previous volume. The previous volume is the part that I can't figure out. I used a shift register and it's not working.
    Attachments:
    screen shot of program test 12.gif ‏13 KB

    The first thing I notice is that the loop will never exit since the "Loop Done" is never being written to inside the loop.  I'm not seeing what the point of the while loop is.  Are you trying to wait so long until a certain volume is reached and then report it?
    From a general programming view, you should breakup your code into subVIs.  It'll make it a lot simpler to understand.
    I'm also noticing several "multiply by 1" in there.  Those do nothing, get rid of them.
    I also don't see the point in having separate code for the positive and negative flow rates.  The math works the same (V1 = V0 + rate).  The negative will subtract on its own.
    I would convert to a single flow rate.  For instance, if the rate is in ml/h, convert to ml/min inside a case structure and then do the volume calculation after the case structure.  If the rate is in ml/min, just pass the flow rate through the case structure and do the calculation.  This will eliminate duplicate code.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • 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

  • 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

Maybe you are looking for