From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview blocks with memory

Hello,

I'm new to Labview, the major programming environment at my new job.
I'm trying to build some modules for processing streams of sonar data
as they arrive, and I want the module to keep a running total of a few
numbers for processing (averages and the like). How can I make a block
that has a memory? That is, a block that won't be re-initialized every
time the data comes in. What I want to do is similar to the "running
averages" example, but in that case the data is coming from within the
"while" loop. I don't see a way that, if the code is made into a
"block", the data stream could be made to come in from the outside --
each time it gets input, the block re-initializes, so running totals
are lost.

My supervisor is at a loss, and I haven't been able to figure it out
from the manual or the examples. Can anyone explain how to make a
block with a memory?

-- Randall Munroe

0 Kudos
Message 1 of 4
(2,275 Views)
Look at some examples with shift registers within the loop. They posess 'memory' from one iteration to the next.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 2 of 4
(2,273 Views)
...more specifically, uninitialized shift registers, aka LV2 style globals or functional globals.
0 Kudos
Message 3 of 4
(2,264 Views)
Normally when you want to keep data in a subvi, you use a shiftregister
in a while loop,
The essence being that the shiftregster has no initialisation data.
It is called an uninitialised shiftregister.
This implementation was the workaround for globals and locals in lv2.
(no globals/locals)
So sometimes they are called lv2 globals but nowadays people cal this
structure a functional global.
Especially when in the while also a case structure resides that can act
on the data in this shiftregister.
Also sometimes called a statemachine and makes programming with one
instance objects possible.
If you need an example write me directly.

0 Kudos
Message 4 of 4
(2,249 Views)