LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with Notifiers (Labview 2019)

Hi Guys,

 

Newbie here trying to learn some things.

 

so I am working on a DAQmx project that Reads/Processes and logs data and in order to synchronize my loops i have decided to use notifier to send in the sample Rate from my events loops to my producer loop.

 

Everything works fine for the first run.

 

What I have is a start Acquisition & Stop Acquisition Button. Start button takes all the user inputs and initializes the daq and sends in the samples/sec input to the producer loop that does an AI read.

 

If the user decides not to log the data then the samples/Sec value is 1/2 of the sampling rate, if all samples are required to log than the user input samples/sec is sent.

 

 

The STOP button stops & Clears the DAQmx task.

 

What is not working is, if I stop the task once, then the error on send notification occurs when i try to start it again. it is my first time using notifiers, so perhaps i don't understand it properly.

 

my understanding was i would be able to send as many messages through the notifier, but perhaps i can only send the notification once and i would have to clear the notification?

 

I tried clearing the notification after it was received, but that didn't work either.

 

Please help.

Download All
0 Kudos
Message 1 of 15
(3,829 Views)

Sorry, using a laptop, so there is no way I can navigate such a disorganized oversized diagram. But here are some things I noticed within seconds:

 

You really need to avoid all this excessive use of local variables and value properties. For example, in the picture below, you have the "channel settings" disconnected, just sitting there, while you read it via a local variable. Your diagram is just peppered with unnecessary data duplication and potential race conditions, event structure buried deep inside other structure, etc.

 

In places where you cannot eliminate [value property/local variable], use local variables.

 

altenbach_0-1586731014590.png

 

 

Why do you have a timeout event if it does not do anything useful?

Also watch for output tunnels that "use default if unwired". For example, at one point you are writing an empty array to "channel settings" via a local variable.

"Quit LabVIEW" has no place in a serious application.

Message 2 of 15
(3,817 Views)

Thanks for the feedback. I am using a laptop too and i realize the oversize block but it was too late for me to try an fix it with a 13 inch screen. 

0 Kudos
Message 3 of 15
(3,810 Views)

I would still appreciate if someone could answer to my original Question.

 

Thanks.

0 Kudos
Message 4 of 15
(3,779 Views)

I can have a look at it tomorrow. Can you outline the exact steps to reproduce the problem (run, what to press in what order, what to observe, what do you expect to happen and what happens instead? etc.).

 

I also don't have any DAQmx installed. can you modify it so it does simulation instead? We are also missing the typedefs.

 

(as I said, aborting LabVIEW in the exist state is a really bad idea, because the shutdown code after any of the loops might not execute.)

Message 5 of 15
(3,769 Views)

THanks for considering to help.

 

So below are the steps

 

Run the mainscreen.VI

insert number of channels  1

Device name- optional

select the hardware- simulated

go to channel settings and activate the channel by clicking on the Active button.

select the Daq Channel.

insert max and min value. -10 & +10

go to Log tab and activate logging and select a folder location. now deactivate logging. i have an error here because i try to close the tdms file and if the file is not selected it barks at me. haven't gotten to fixing that.

Now hit start. and everything runs fine. if you go to the graph tab you should see the signal.

Now stop Acquisition and restart and that is when the error happens in the notifier. i have labelled the error wire but the error happens inside the 'check log settings' case structure.

 

it should restart the acquisition, i should see the signals on the graph but I don't see anything.

 

What I am trying to achieve is after the DAQ initializes and the log  setting is checked, depending on different settings i use the notifier to send the samples/S value to the Daq Read Poly VI and when the Notifier receives the notification the DAQ should start to Read.

 

I don't know what you mean by modifying to do simulation. i am using the hardware as simulated Hardware but perhaps i don't know how to modify to do simulation. i have attached all the required files .

 

Thanks.

0 Kudos
Message 6 of 15
(3,747 Views)

Any input in this will be appreciated.

 

Thanks

0 Kudos
Message 7 of 15
(3,647 Views)

Hi PG,

 


@PGgautam1 wrote:

Any input in this will be appreciated.


Way too much local variables, used in parallel running loops!

"Stop Acquisition" event kills the DAQmx task, but at the same time in a parallel running loop this very task is used to read DAQ data. In the end you try to stop the task again and even need to handle specific errors due to such unorganized code…

 

What about a better code structure, maybe with a clear state machine (or a QMH)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 15
(3,641 Views)

@PGgautam1 wrote:

Any input in this will be appreciated.

 

Thanks


I don't know about your notifier problem, but you have other issues:

  1. Clean up the block diagram, hard to read and debug
  2. Overuse of property value nodes and local variables.
  3. Where is your timing information for the DAQ? I can't find where you set the sampling rate, etc. When you start Log Periodically since you are not reading all of the samples your buffer is going to fill up.
  4. Suggestion 1 - Continuously read all of your DAQ samples. When you want to Log periodically set the number of the samples such that sampling rate times number of samples equals the log periodically rate. You can either get the average of the array, midpoint, etc.
  5. When you change DAQ settings you typically need to stop the task, update it, then restart it. I do not see anything like that.

mcduff

0 Kudos
Message 9 of 15
(3,638 Views)

Hi GerdW,

 

Thanks for the Input.

 

So the reason I went with a producer consumer pattern with a state machine is because I am trying to do few things in parallel. I also have to achieve a few more things with this very solution.

 

A while loop to handle all my events with a event structure.

Daq Read to read data at different sampling rate depending on what the user selects.

A loop to run analysis on the data that was read.

A data Log loop to continuously log data at different time interval/All samples (Depending on Sampling Rate)

 

so you think a QSM would be a better choice for this ?

 

Thanks

 

0 Kudos
Message 10 of 15
(3,634 Views)