Hello all. I am making a program to detect current fluctuations of heater plates. The program will decide if a heater plate is cycling by detecting the current draw. If the amps are above a certain threshold, the plate is considered heating. I am using rising edge detection to determine heat on/heat off cycles. The program works, although we do have to zero in on the threshold limits to make the program correctly decipher a cycle.
My main concern is the efficiency of my method of detecting edges. I am doing the same decision-making for 12 plates, and as a result I have repeated the same code 12 times. Is there a better way? I could put all the
My vis are attached. The VI named Cycle Count is where I am doing the edge detection. This vi is the one I wanted to see if I could optimize.
Solved! Go to Solution.
That sounds great, but I did read that the Basic Detection VI that I am using advises against using it in a For Loop when manipulating multiple channels.
I made the mistake of opening Cycle Count first, and wondering "Why didn't he use the Multi- channel version of the Basic Threshold Detection VI?". Then I noticed that your input, which should have been an Array of Waveforms, was wrong -- it was an Array of (Cluster of Array), which made no sense.
When I did finally open Main, and saw the Dreaded DAQ Assistant and its evil Twin, the Dynamic Data Wire, I understood how you had been misled. DAQmx, when used as intended, likes to produce an Array of Waveforms, which bundles Time of acquisition "efficiently" into a Waveform Cluster along with the array of data. Now you can present this Array of Waveforms to the (polymorphic, but that's not so obvious!) Threshold Detection VI.
Here's what you do to rewrite Cycle Count so it looks like this:
So how to fix Main? Here I usually say "Learn DAQmx", but here's a quicker way to "Undo the Damage" -- convert the Dynamic Data Wire to a 1D Array of Waveforms, like this:
Note that by default, the Convert from Dynamic Data does not use Array of Waveform (its First Choice) as the default, so you'll have to right-click it and choose Array of Waveform. With all of the changes you made to Cycle Count, you might find that (as I did) you forgot to connect the new Inputs and Outputs to the Connector Pane, so do that, then wire your Array of Waveforms, Level, Hysteresis, and Reset, and enjoy the results.
Thank you. This is excellent, and is just the kind of code optimization/simplification I need. Also, I really didn't want to use the DAQ Assistant, but I couldn't get the DAQ Read function to work correctly. It kept outputting a waveform, which I couldn't get to work with Split Signal, as I kept getting 0 for the Split Signal outputs. That's another topic for another day, so thank you both for the help here.
I'm not using LabVIEW 2019 yet so I can't open your file, but you don't need split signal with waveforms. If you have multiple channels then you should have an array of waveforms - just index out the array to get the data from the individual channels.
The DAQmx Read should give you a 1D Array of Waveforms, exactly the input I used in my VI. Each element of the Array is a different Channel, just what you want -- wire it directly into the function I rewrote for you.
Ah yes, thank you for this. That worked excellently. This gives the solution to the issues we have always had with needing to use a DAQ Assistant with Split Signal. Now we can forego the assistant and have better control of our VI. Thank you yet again.