09-17-2020 08:49 AM
@Vojtěch wrote:
Connecting the loops via terminals resulted in unwanted dependency, so I solved it by using variables. The value doesn't change much in time (it is resistance dependent on temperature, you would set the temperature and wait for the resistance to become +/- stable). So you would just change temperature and hit save from time to time. That is why i want 1 quite current value to save with current temperature. If there is better way to convert waveform to single value I would like to hear it. I can attach "final" program now for you to explore.
I was not meaning to connect the loops via terminals. You have unused terminals that you are writing to using local variables. Replace those local variables with the terminals.
Also, if you are wanting to just get on DBL value you can change your DAQmx Read to read a DBL instead of a waveform. Wire that value directly to your input of your Formula node (no need for the extra local variable that will likely be read before you take the data).
Your error handling is also off. Use shift registers to pass the error from one iteration of the loop to the next. Be sure to pass the error through all events.
I suspect that you are going to run into problems with this setup. You are forcing the loop to wait 100 ms with the Event structure. You have your DAQ set to record every 10 ms using continuous samples. Since you're only taking 1 sample off of the buffer each iteration you will quickly fill the buffer and get an error. Even if they are running at the same rate you are asking for problems. If you use the approach that I suggested previously (move the Stop button control to shut down the bottom loop and shut down the top loop with the Event structure) then you avoid this problem and time the loop with the DAQ.
I have attached a quick update showing what I am suggesting. I did change your terminals to not show as icons because I prefer to take up less real estate on the block diagram. This could still use some cleanup, but hopefully it gives you the idea.
09-17-2020 11:51 PM
I meant loop tunnels, not terminals, my bad. Working in multiple environments at the same time messes with my vocabulary.
The code looks nice, thanks, the timing was off bc I just copied it from other VI (that is why there is range handling for 6211 even if I am using just 6001 for this simple task). Error handling is something that I see mandatory, but really don't know what and why I am doing.
I only handle what I must handle, so notes like this are very helpful, bc they bring my attention to other aspects. Thanks.