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: 

Producer/customer visa application

Hi,

 

In a small application that I am writing, I am continuously acquiring data in the main while loop. This data is used to calculate the misalignment of a hardware part. This part can be tilted with a motor, driven by commands to the serial port. In a previous version, I just added this functionality to the main loop, but then the motor commands lag on what they should be (the device takes some time to respond completion back to the program). As a result I get huge overshoots of the tilt angle and continuous back and forth movement. To solve this I came up with the following:

 

  • Main loop that acquires data as fast as it can (gives more accurate position readings) and calculates the misalignment (small calculations)
  • An additional loop that is only activated when the alignment module is activated. This secondary loop contains the motor controls.
  • The acquired data is put into a queue (using Enqueue element at opposite end, to have the most recent element in front)
  • The motor loop should only take up the newest element of the queue and act correspondingly, the rest of the data should be flushed.
I haven't tested it yet, but I was wondering if there is maybe another, more simple way to do this.
Any ideas? Shoot!

 

Giovanni Vleminckx
---------------------------------------------------------------------------------------
Using LabVIEW 8.5 on Windows7
0 Kudos
Message 1 of 7
(2,421 Views)

Maybe I don't understand this correctly, but is there any reason to have more than one element in the queue. Your design sounds great except I would suggest to just use a single-element queue (by initialising the queue as one). Then you don't have to use the eneque element at opposite end function. The standard enqueue function should be OK.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 7
(2,411 Views)

I agree with your design - if I correctly understood your question -, however if you need only the latest value you can use a notifier instead.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 7
(2,405 Views)

Hi

 

I think both of you understood it. Adnan's remark is valid indeed. So if I were to use a single-element queue, would the motor loop then get the latest element?

 


@pincpanter wrote:

...you can use a notifier instead...


Can you briefly explain how a notifier can be used?

 

Giovanni Vleminckx
---------------------------------------------------------------------------------------
Using LabVIEW 8.5 on Windows7
0 Kudos
Message 4 of 7
(2,399 Views)

OK now that I have understood it, the lossy enqueue element should be used instead of the standard queue element.

 

But, the above suggestion of using a notifier is better. You just need to replace all queue functions with corresponding notifier functions. Have a look through the Notifier palette.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 5 of 7
(2,384 Views)

Generally, you can use a notifier instead of a queue if you can afford to loose intermediate data between two read operations (it seems your case to me).

A notifier is similar to a 1-element queue, however you can write to a notifier at any time overwriting the old value, whereas you can't write a second value to a 1-el queue unless you dequeue the first one. There are other differences, of course: the receiver of a notification can grab the latest value or wait a new one (in the first case a notifier is very similar to a local variable, but it's faster); it's possible to wait on multiple notifiers, etc.

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 7
(2,380 Views)

 


@pincpanter wrote:

Generally, you can use a notifier instead of a queue if you can afford to loose intermediate data between two read operations (it seems your case to me).

A notifier is similar to a 1-element queue, however you can write to a notifier at any time overwriting the old value, whereas you can't write a second value to a 1-el queue unless you dequeue the first one. There are other differences, of course: the receiver of a notification can grab the latest value or wait a new one (in the first case a notifier is very similar to a local variable, but it's faster); it's possible to wait on multiple notifiers, etc.

 


 

This is not true for newer versions of LabVIEW. I believe LV 8.6 was the first version to have a lossy queue so LabVIEW takes care of dropping the oldest data from the queue for you.

 

I would lean toward the queue since there is another fundamental difference between a queue and a notifier. A queue is intended to have one listener. Notifiers are intended to have multiple listeners. From a programming aspect I like to use the "correct" function for a given task. It sounds like this application only needs to have one task listening on the queue. By using a notifier someone looking at the code could be mislead to assume there are multiple acters on the data. I realize this is symantics but little things like this help to keep the code more readbale and understandable.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 7
(2,366 Views)