LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use a shift register to hold a value

I have a weather station that collects data on wind speed and direction. The problem I have is that while it shows the value as soon as it cycles back through to sample again it zeros itself. So while the wind speed may continue to be 40 mph it shows on my graph as going from 0 to 40 to 0. Can I and how do I use a shift register to hold a value until the new value is sampled.
0 Kudos
Message 1 of 5
(4,483 Views)
The shift register is a fundamental construct in LabVIEW. In your case (I hjope) you have a while loop that runs every n ms, and with each turn you add another point to your graphs. If you read the value for wind speed inside the loop then this should be sent to the graph. If your sensor isn't ready and returns zero then these may be the zeroes you are seeing. So, if you test if the reading has gone to zero then you could ignore this and take the previous value (which you sent to the shift register last cycle and now read this cycle). There is a problem here, since the wind sensor may not be ready, or it may be reading a still day.

Read more about shift registers, you will need to have a very firm grip on them to make much progress with LV

Yours Sincerely
John
www.tradersmicro.com
0 Kudos
Message 2 of 5
(4,483 Views)
You can use a Shift Register to hold a value, but you shouldn�t need to with what you are trying to do.

The only way your indicator can be going back to zero is for something to write a zero to it. You might just want to look at your application architecture to see where the zeros are being written and try to reconfigure it so they don�t.

You could also try posting your application (or a simplified version) so we can look at it and give some hints as to what is going on.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 3 of 5
(4,483 Views)
A shift register can be added to a for loop or a while loop. Pop-up on the vertical edge of the loop and select Add Shift Register. Connect your data to be retained to the right terminal and pick up the previous value on the left terminal.

The help for the loops has links to information on the use of shift registers.

I suspect that you may have something else going on in your program. The graph will not go back to 0 unless you write a 0 to it. Your program may be updating the graph even when it does not receive any new data from the weather station. Without seeing your program I cannot tell why.

Lynn
0 Kudos
Message 4 of 5
(4,483 Views)
Are you using a serial connection to your weather station ?
Yes ?
So probably your problem is the way you are reading the serial port. To start with, just add a wait node (in the Time and Dialog sub-palette) in the loop to decrease the pooling rate (I guess that 1000 ms could be a good start) , and see what happens.

CC
Chilly Charly    (aka CC)
Message 5 of 5
(4,483 Views)