Jedi Engineer
Jedi Engineer

Reputation: 493

Passing data between different speed loops in LabVIEW

I have a (desktop) LabVIEW program running several large While loops. Each loop corresponds to the functions on an IO card in a myRIO DAQ system. Each card operates at a different speed, therefore each loop and subVIs in my code run at different speeds as well.

However, I'm now finding that I need to pass data from a low speed loop to a high speed loop, and I'm not sure how to best go about it.

The low speed loop actually connects via TCP to a Yokogowa power analyzer, and the loop speed is 50ms (20Hz). The high speed loop runs at 50kHz, and performs math operations using inputs from a high speed ADC to calculate motor torque, and needs the info from the low speed loop (power analyzer) to proceed. There's an 816:1 data flow difference.

At runtime, it appears to work fine, until I spin the motor up, then the overtorque routine kicks in and shuts me down.

So I next tried to queue the data, and that only significantly slowed the high speed loop.

That being said, my thought was to take the incoming data on the low speed loop, and fill an array with that data (816 deep) and queue it up to the high speed loop, but I'm not quite certain how to go about that as well.

How should I accomplish what I'm trying to do in a more efficient and proper manner?

Upvotes: 1

Views: 1516

Answers (2)

jamesmc86
jamesmc86

Reputation: 324

If the high speed loop is running faster then it only really needs the latest value so you need a variable/tag type communication.

Depending on what you are aware of already there are a few options:

  • Local/Global Variable
  • Functional Global Variable (but globals are faster)
  • Notifier (if you use get staus you can read this like a variable.

I would pick one you are comfortable with and try that.

Upvotes: 2

srm
srm

Reputation: 3166

Look to the Real-Time FIFO palette. The functions here create and operate a lockless-FIFO system explicitly designed for passing data in a deterministic way between loops. Used correctly, they guarantee that the slower loop, trying to write data, will not lock the FFO in a way that throws the faster loop off of its schedule.

You can find a simple example of the RT FIFO code here. You'll find more in the LabVIEW shipping examples.

Upvotes: 2

Related Questions