08-14-2015 03:40 AM - edited 08-14-2015 03:43 AM
Hi Everyone!
I am currently trying to implement a 2bit counter in LabVIEW. Luckily I was able to find examples from the NI forums.
However, in real life, 2 bit counters' speed are controlled by a switching clock frequency to produce 4 different outputs.
In the VI I downloaded, the 2 bit counter plays rapidly with an unknown speed. I tried putting delays in it and other timing tools, but I need to at least be able to control the "actual" speed of the 2 Bit counter inside the While loop.
Is there any basis on what is the iteration speed of the While Loop when doing the loop? I really need to know the actual speed and how to control that speed because I need to synchronize it for demultiplexing purposes.
Thanks and Best Regards.
____________
Falsehope
Solved! Go to Solution.
08-14-2015 04:15 AM - edited 08-14-2015 04:16 AM
Hi FalseHope,
Where are the delays you tried to implement ?
Have you tried to use the Wait (ms) function ? By providing it with a constant, you should be able to define a period between two states. But as Windows isn't a deterministic system, the delay may vary slightly from one iteration to another. Hopefully it will not impact your application...
Hope it helps 🙂
08-14-2015 04:16 AM
If you place a wait inside the loop, that will be determine the loop time and thus the rate.
The loop cannot proceed to the next iteration until everything in it has completed. Since your code is trivial, the wait will be the slowest part.
08-14-2015 08:44 AM
Hmmm.. I guess this one is really trivial. And it really varies with the speed of the Computer's processor?
So the suggestion was for me to add a delay to theoretically put a time stamp on the While Loop? Let's say If I put a 1ms delay, I can say that is about 1kHz? is that what you guys are saying?
Thanks for answering my post by the way. 🙂
______________
Falsehope
08-14-2015 08:47 AM
Yes. About 1kHz. But as said before it will not be precise.
08-14-2015 08:52 AM
@FalseHope wrote:
Let's say If I put a 1ms delay, I can say that is about 1kHz? is that what you guys are saying?
Nope you can't say that, all you can say is that your while loop will take at least 1ms to execute. Will it be 2ms? Will it be 100ms? Will Windows lock up and not respond for 10 seconds?
The point is unless you have a real time operating system (which you might you didn't give much details) then you are at the mercy of the OS and it may choose to go out to lunch while you are trying to toggle some bits.
You jitter on Windows is high, your jitter on a real time OS is less, your jitter on an FPGA is even less, but even on an FPGA there is some delay in the propagation of the data on the hardware. That being said a 1KHz rate isn't that crazy fast and FPGA and RT can do that no problem. Can Windows? Maybe some times, but wouldn't make a system that relied on it. I wouldn't make a system that relies on Windows to respond in 10ms.
If you want determinism, you need hardware that was build for that. Luckily NI sells several DAQ devices that you put the waveform you want it to play on the hardware and say "Play" then it handles the timing and stops when it is done. Windows can then poll the function to know if it is done every once in a while.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-14-2015 09:00 AM
08-14-2015 09:08 AM
@FalseHope wrote:
If that's the case, is there any way on how i can control the speed of that 2bit counter vi i posted?
As was said, you cannot have precise timing in Windows. If you want precise timing, then I recommend going with the FPGA route (there are FPGA DIO boards that you can put into a PCIe or PXI slot).
08-14-2015 09:28 AM
08-14-2015 09:37 AM
Also don't forget the timed loop.