I'm quite new to labview (although I am enjoying getting to grips with it and do wish I knew about it much earlier) and I have run into an issue with synching data collection between two different serial sensors for pressure and weight.
Both sensors continually stream data. Pressure is driven at a pre-defined value on the hardware itself (1-10s) and sends the time in ASCII along with the data itself, whilst weight continually updates in the milliseconds. My goal is to collect the value of the latter at the same interval as the prior so it is in synch. I wish I could control it via commands and place it in a timed loop but it isn't feasible with the hardware.
This is probably quite a simple thing to rectify and I lack the knowledge. My gut instinct is to run a greater than test for return count on VISA read and use that to drive a case structure to read from the other sensor. But this value would be an old value which didn't reflect the weight at the time (probably early in the buffer?). So alternatively I tried a while loop within a while loop to capture the last value from the weigh balance- but I quickly learned the inner loop would fire and never end. I have tinkered with the VI since (attached) but its clear I'm missing some fundamental function somewhere.
Any help would be greatly appreciated.
Solved! Go to Solution.
What I would do is use 3 loops. One loop just reads the pressure data. The second loop reads the weight data. The third loop receives data from the other two is some fashion. I would use a queue with a data type that is a cluster, with the cluster built from an enum or string to state the data source and then data. Use a case structure to decide what to do with the data. If you received weight data, store it in a shift register. If you received pressure data, log it and the last received weight data (stored in the shift register).
Sensors... sensors... sensors... One beautiful approach can be... a simple graph with two plots (or whatever number of plots...) that will automatically synchronize all inputs along the time scale. Once synchronized... well... you can export the graph or make what you want with the synchronized data. It is my opinion, the simplest way I think.
Best regards, Marcelo
Thanks very much for this. I read up on the queue system and implemented case structures. Whilst I haven't applied it to my equipment sensors yet (Covid so restricted access), I generated a substitute with some random number generators firing at different times with the intention of filling them in with the proper serial read later.
And it works! Its in sync. This was a huge help and I learnt quite a bit on queue side of labview.
One thing that I can see though in my test VI, is that blank spaces in the final weight and pressure arrays are generated. I'm guessing this is where the weight reading is taken and passing through a shift register, but yet a blank space is recorded. Is there a way to prevent this from happening?
I would use Conditional Terminals so you only add values to your arrays when you read the pressure. Right-click on the output tunnels and you will see an option to make it conditional.