11-30-2015 01:42 PM
Hi Everybody,
So I have this program to read from a scale.
This is going into a much larger program, so I wanted to turn this into a sub-vi.
As a sub-vi, I want it to continuously read weight measurements, (so this program would be cycling/running every 10 ms) much like a DAQ, and I was hoping I could directly connect an output connection to a waveform graph/write to measurement file.
Where do I put the numeric control variable so that it will continue to read weight measurements and not just once?
Thank you for your time!
11-30-2015 02:05 PM
11-30-2015 02:09 PM
Please attach the actual VI instead of a hard-to-read-and-understand picture of the VI. Not only can we see what you are doing more clearly, we can actually test your code and any changes we suggest.
BS
11-30-2015 02:13 PM
You can put the reading into a SubVI and run it many times, but the open and close functions (like initializing the serial port) should only be used once, at the beginning and end of your program respectively.
If you want to update an indicator from a SubVI, you will have to pass reference to the SubVI as an input. You cannot simply drop an indicator into your SubVI. To get the reference you would right click on the actual graph that you want to update (on the front panel of the main program) and click create >> reference. (This is just one way to get it). Then you can use property nodes to udpate the graph. This will slow things down considerably and you probably won't be able to read data as quickly as you'd like. But, you probably don't need to update the graph every 10ms (as a human, it would make it hard to read), so perhaps only update it once a second with the current value, or the average of all the values that occurred since the last reading.
If updating the reference is too slow, you can make a queue. In your main program you would use de-queue to receive elements and update the graph (often in a loop with many UI elements in different cases of the loop). Then when you want to update the graph from your SubVI you will just enqueue another element on the queue which is very quick, and should not slow down your acquisition at all.