I am very new to labview and I have written a basic program to run the NI cDAQ-9185 with the NI-9220, NI-9485, and two NI-9214 cards. The program monitors and logs the voltage and temperature of a test, and turns relays on and off based on the user pressing buttons and input levels. The program runs fine and I don't experience any other problems as far as I can tell, however when I run the code for a prolonged period of time (ie overnight), I get error -209836 thrown at some point indicating the program cannot be synchronized (it is always the relay DAQ assistant that triggers this). I have run the program for 4 hours while monitoring it without issue, so I am unsure why it turns up on longer time scales. I am very new to labview and fully self taught, so I am aware my code is not great, however I am on a very tight timeline (needs something working in 2 days), so I do not have time to rewrite my code to best coding practices at the moment. If anyone has any advice on how to fix this bug, that would be much appreciate, especially if you can provide specific details on how it might be done.
Sincerely, a very stressed out intern (programming is not my main field of study)
PS I am aware DAQ assistant is not ideal, however I do not have time to change it unless it is necessary to fix this bug, as my timeline is exceedingly tight at the moment due to a work deadline.
I think this is likely related to your DAQ assistants but it's hard to say. I'd try changing your data acquisition settings to not be continuous, as most systems only have one AI timing source. I bet your two loops are colliding very rarely and it can't take measurements simultaneously.
As a band-aid, try changing to on-demand sampling if you don't need high speed data. If that doesn't work, you may need to just disable automatic error handling (File->VI Properties) and see if the DAQ assistant can restart the task automatically. You'd get some bad data when the error happens, but your program wouldn't just stop on you. (You could also just throw an error indicator on the output of the DAQ assistant, that will just display the error instead of halting the program.)
When you get some time you would REALLY benefit from the free LabVIEW training that NI offers. I can tell you're trying to keep your code organized, clear, and well-commented. It's definitely one of the neatest giant-block-diagram-code-examples I've seen on this board, so you're off to a good start 🙂
I think you'd do very well with some of the training, which could help you dramatically reduce your code footprint. From a quick glance, you could get your very large loop there down to something that'd fit on an index card if you'd switch to Waveform datatypes (or just arrays) instead of the Dynamic Data type that comes out of the DAQ assistant.
I know you don't have time now, but when you do, read this article: https://www.ni.com/en-us/support/documentation/supplemental/06/learn-10-functions-in-ni-daqmx-and-ha...
I've been in the "need data in 2 days just get it done" camp before myself, so I feel your pain. Good luck, these long-duration bugs are hard to track down even with good code practices. Just know that if you want to keep going down this path, you'll need to learn "the right way" at some point. Once it clicks you'll be happy you took the time to learn.
I am surprised that this works at all. There's lots of commenting (GOOD!), but that's where the good ends. You have while loops inside of event structures. Your code is riddled with local variables which likely cause race conditions. You're having to do 3 times the work because you chose to use the DAQ Assistant with the dynamic data type. Your block diagram is so large that I have to scroll on my large monitor. There's just so much wrong that finding the source of your problem is really difficult.
Honestly thank you so much for your kind and understanding response, it has been one of the nicest I've received on this forum. I do plan on learning the right way to do things, but my current time frame certainly hasn't allowed for that. I will try your fixes and run it over the course of the day and overnight again, hopefully that will solve the issue 🙂
I have 100% been trying my best to at least keep it neat, legible and easy as possible to follow through organization and commenting, if I don't have time to learn the right way, at least others will be able to understand what I did do.
Hah, don't worry about it. I've had times where I open some of my old code and see a comment that I wrote to myself in the future "I'm sorry, I know this is terrible but it works and I have a deadline." Got a good chuckle out of that one 🙂
(And I do want to emphasize, the Dynamic Data Type wire is the devil's datatype and should never be used. Once you wean yourself off it you'll be happy you did 😉)