09-06-2021 01:44 PM
I'd like to measure average torque, rpm, and electrical power of a test stand for motors and propellers. I'm measuring torque using a strain gauge module, rpm using a counter, and electrical power from an external instrument via VISA. I can acquire this data without any problems and graph it live on my front panel.
When I press an "average" button, I want LabVIEW to start taking a X second average of each reading and record them to a text file. X depends on what I input to a front panel control (ex: 2000 ms, 5000 ms, etc.). This feature lets me record the readings only when I see the torque, rpm, and power have reached steady-state.
I've implemented a bare-bones version of this in the attached VI for a single simulated channel. The producer loop acquires and plots the readings to a waveform chart. When I press "average", the consumer loop appends queue elements until X readings have been achieved and then computes the RMS value. The array size indicator value should match the averaging period control value.
My questions are as follows:
Solved! Go to Solution.
09-06-2021 02:00 PM
Why is your wiring so messy?
09-06-2021 02:55 PM - edited 09-06-2021 02:55 PM
I tried to minimize wiring as much as possible. I didn't want to use sub-VIs so I could just upload 1 file to the forum. Do you have any suggestions to further organize the wiring?
09-06-2021 04:12 PM
@aeroAggie wrote:
I tried to minimize wiring as much as possible. I didn't want to use sub-VIs so I could just upload 1 file to the forum. Do you have any suggestions to further organize the wiring?
Minimize wire bends and hidden wires.
09-06-2021 04:18 PM
I realized I'm complicating the averaging function, but I can't work on this problem again for a few days (maybe weeks). I will post my 'fix' as soon as I can.
09-14-2021 01:32 PM - edited 09-14-2021 01:34 PM
I developed the attached code. I would appreciate review by another set of eyes. All files are saved for LV16, and the main file is "testbed". All other are dependent sub-VIs.
A producer loop "reads" data from N signals. When the "average" button is pressed, the consumer loop takes an average of M data points for each signal and writes the averages to a text file. In this instance, N = 3 and M = 10, but you can adjust as needed.
Some other controls handle the file location & name and any applicable headers for the output data file.
Note that the input signals must be scalars. If one of my input signals is an array (such as a DAQmx reading), then I must somehow downsize that array into a scalar (first value, last value, average, etc.).
Questions
Thanks!
09-15-2021 03:37 PM
Still a lot of zigzags on the wires; and many are jammed close together. I'm not going to try to follow them.
09-15-2021 04:20 PM
I don't know how to organize the wires without the cleanup feature moving them again.
Do you just not use auto-clean?
09-16-2021 01:27 AM - edited 09-16-2021 01:32 AM
Hi Aggie,
@aeroAggie wrote:
I don't know how to organize the wires without the cleanup feature moving them again.
Do you just not use auto-clean?
Autocleanup only works nicely for rather small/simple VIs.
When you want to cleanup larger/complicated VIs you need to implement your own coding style rules:
(When the arrays have the same size then you can also eliminate the FOR loop in the first case structure.)
I don't see how your VI is related to your problem description: there is only an array of (simulated) samples, but you asked for atleast 3 different data sources (analog input, counter, VISA)…
Btw. I suggest to rethink your program design: I don't think it's a good idea to access UI elements used in the producer loop also in the consumer loop, especially when you need property/method nodes to do so…
09-16-2021 11:43 AM
Hi GerdW thanks for the feedback.
@for loop: I will try to remove that for loop. Earlier, I encountered mismatched array sizes, so I used the loop to manually add along one array's dimensions. However, I think the "array size != 0" check I now have just before the case structure should alleviate that problem.
@how this addresses my problem: I don't know how to implement the averaging. I know how to create a VI to access data from the various sensors and instruments. I created this VI with dummy signals (the array of numeric controls) to try and code the averaging feature. In the future, I will replace the dummy signals in the producer loop with actual data from DAQmx and the instrument library. Does that make sense?
@Program design: Do you have any suggestions? How else can I reset the averaging button?