06-16-2013 12:07 PM
I'm a student who is doing thesis about electrical vehicle monitoring system in labview. I'm collecting analog measurement data from usb-6009, transfer it over daq assistant and use state machine inside while loop to do monitoring process.
So, I have one state which determines sampling frequency of the loop cycle, and I've made able to change this rate in values of 0.1, 1 and 5 Hz. I've realised it with Elapsed Time Express VI which is in loop but outside case structure for states. I'm setting frequeny rate in Elapsed Time "Time Target" input, And the boolean "Time has elapsed" output goes to the case structure, which changes to the next state when the time runs out. In the next state it resets the Elapsed Time and the cycle starts from the beginning.
So, everything works fine until I see in my log file (txt file where I save the measurement values) that it made on the frequency of 5 Hz only 3 or maximum 4 samples per second.
I have pretty good computer with i7 processor and 8 gb of ram.
What could be the problem?
In the picture below it can be seen how I realised this with timer.
Thank you in advance.
Solved! Go to Solution.
06-16-2013 12:58 PM
Looking at visible portion of your design, I can't tell if you are using that elapsed time vi to first wait specified milliSeconds and THEN doing your other logic which reads analog channel(s). Perhaps you could post the vi!
For example, in case of 5Hz, it could be that you are first waiting for 200mSeconds and then doing your analog read/etc logic which is taking another 100+ milliseconds. If that were the case then you're essentially reading at 3.3Hz (which would explain why you're reading 3 or 4 readings).
In above case the fix would be quite simple - just use a "Wait until next ms multiple" AFTER you do a reading - in fact you can do it all in a very simple while loop without any case structure (unless if you're doing more things and/or need to grow your design in future, then state-machine would be best approach.)
Hope that I'm making sense...
06-16-2013 03:05 PM
I'm sending my VI in attachment so you could have an overview to whole process. Explanation and titles are in croatian, but you will get the logic.
Thank you in advance
06-16-2013 03:16 PM
Attach the subVI called "Sampling.vi". The secret may lie in there.
(PS: You don't need all of those index array functions. Use one and drag the bottom border downwards. You'll automatically get indices 0 through 7 in order without needing the other 6 Index Arrays or any of the constants to define the index.)
06-16-2013 03:21 PM
06-16-2013 05:47 PM
As I mentioned in my previous note, your problem is that you're starting a new target time for Elapsed Time vi AFTER your analog reading is completed. This essentially ADDS whatever time is taken by Analog reading on top of the time you're asking Elapsed Time vi to wait.
I have modified your vi and I believe that should take care of your timing issue.
However, I would suggest using "Wait Until Next ms Multiple" because unlike the express vi you're using, the one I mentioned lets other processes do their job while waiting.
Hope that helps...