04-12-2020 05:26 PM
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.
04-12-2020 05:50 PM - edited 04-12-2020 05:51 PM
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.
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.
04-12-2020 06:02 PM
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.
04-12-2020 07:22 PM
I would still appreciate if someone could answer to my original Question.
Thanks.
04-12-2020 07:56 PM - edited 04-12-2020 08:07 PM
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.)
04-12-2020 09:47 PM
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.
04-16-2020 01:05 PM
Any input in this will be appreciated.
Thanks
04-16-2020 01:36 PM
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)?
04-16-2020 01:43 PM
@PGgautam1 wrote:
Any input in this will be appreciated.
Thanks
I don't know about your notifier problem, but you have other issues:
mcduff
04-16-2020 01:49 PM
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