LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement code behind RT FIFO Create

How to implement code behind RT FIFO Create?

 

I would like to obtain the mean average of the last 200 data-points (sampled at 100Hz), and publish the running average at 10Hz.

My preferred solution is modeled on the RT FIFO that is available from within the LabVIEW Real Time module. I plan to have 4 VI's as follows:

 

1) "Averaging FIFO Create.vi"

Description: this VI will have similar functionality to: RT FIFO Create.

Inputs: String name, Int32 size, Boolean create if not found, Error Cluster error in

Outputs: Refnum fifo, Error Cluster error out

 

2)  "Averaging FIFO Write.vi"

Description: this VI will have similar functionality to: RT FIFO Write.

Inputs: Refnum fifo, Single element, Error Cluster error in

Outputs: Refnum fifo, Error Cluster error out

 

3)  "Averaging FIFO Read.vi"

Description: this VI calculates the mean average from the specified number of elements

Input: Refnum fifo, Int32 number of elements, Error Cluster error in

Outputs: Refnum fifo, Single average, Error Cluster error out

 

4)  "Averaging FIFO Delete.vi"

Description: this VI has similar functionality to RT FIFO Delete.

Inputs: Refnum fifo, Error Cluster error in

Outputs: Error Cluster error out

 

Unfortunately, I do not know how to implement the solution in LabVIEW.

Is the LabVIEW RT FIFO, implemented in LabVIEW or C?

I am not sure if it is possble to obtain the required functionality (e.g. dynamic memory allocation) in LabVIEW?

Then again, maybe it can be done in some other way?

 

How do I create the FIFO object/cluster and store it in memory? I also need a reference to the stored object/cluster.

Do I need to use LVOOP?, and if so can I hide the OOP from the user? e.g. by implementing the four VI's in a library?

 

Please advise.

 

Thanks
Mark

 

 

0 Kudos
Message 1 of 5
(3,492 Views)

 


Is the LabVIEW RT FIFO, implemented in LabVIEW or C?


 

Thats a funny question. LabVIEW of course!

 


I am not sure if it is possble to obtain the required functionality (e.g. dynamic memory allocation) in LabVIEW?

Then again, maybe it can be done in some other way?


 

For FIFO functionality, you should take a look at 'lossy queues'. You can allocate a certain size for the queue, then use 'lossy enqueue'. This will exactly replicate the FIFO functionality you are looking for.

 


How do I create the FIFO object/cluster and store it in memory? I also need a reference to the stored object/cluster.

Do I need to use LVOOP?, and if so can I hide the OOP from the user? e.g. by implementing the four VI's in a library?


 

All you would need is a top level VI. Make the other 4 VI's you mentioned subVI's and call them in the top level VI. You can move this FIFO queue from subVI to subVI no problem.

Cory K
0 Kudos
Message 2 of 5
(3,490 Views)
LabVIEW queues do not help.

 

For "Averaging FIFO Read.vi", I need to average all elements in the FIFO with-out dequeing any data.

I need a lossy FIFO/queue, just like RT-FIFO. But unfortunately, you can not read the data in an RT FIFO without removing it.

This is why I need to have my own implementation of a FIFO, rather than use the LabVIEW built in functions.

 

At a lower level, I (think) LabVIEW built in functions are actually written in C?

I am not sure whether it is possible to obtain the functionality of a LabVIEW RT-FIFO by using only LabVIEW itself?

To create a FIFO (with create if not found input) I will need some form of dynamic memory allocation and management.
Is there are a way to do this in LabVIEW RT?

 

 Thanks

Mark


 

0 Kudos
Message 3 of 5
(3,478 Views)

Well I recommended queues, but if you need to operate on elements without dequeuing them,

you could use an array. Its slower, but it works.


The averaging would be pretty easy:

average.PNG 

 

You would just need to find an efficient way to make the array FIFO.

Hmmm, let me think of an efficient solution to this, I will let you know if I come up with something.

Cory K
0 Kudos
Message 4 of 5
(3,475 Views)

Thanks Cory, but that's obvious and does not solve my problem.

 

To create a FIFO (with create if not found input) I will need some form of dynamic memory allocation and management.
Is there any way to do this in LabVIEW RT?

 

The problem is, how to create the FIFO's (object/cluster) by name, and store/manage them in a dynamic list. I will need to Create  the refnum/reference to the FIFO,  so that it can be passed to the Read, Write and Delete VI's.

I could insert a new cluster into an array of FIFO (object/cluster), but then I do not have a refnum because I can not create one programmatically.

 

0 Kudos
Message 5 of 5
(3,463 Views)