04-04-2019 05:18 AM
Dear Labview Community
This is my very first Labview project, since Uni many years ago! I have tried to get my head around designing a four channel timing system, but can't seem to work it out. Please could anyone offer an help or advice...or general criticism to what I'm doing stupidly!
I want all four timers to start at the same time, this will eventually be from a physical switch connected to a DAQ, however for simulation purposes I'm using a Start button for now. I want each of the timers to stop independently of each other, again I want to use four stop buttons to simulate this, as I will eventually add beam break sensors or something similar. I have modified a vi I found online that I think might work, however I cannot seem to separate the stat/stop button.
I have only added two timers for now, as I thought it would be easy enough to add more once I had the logic figured out.
Any help or advice would be greatly appreciated
Thanks
Josh
04-04-2019 05:46 AM
Hi Josh,
some suggestions:
- use shift registers to hold start/stop time for each timer
- you only need one loop to handle all those timers
- usually you should use an array to store same data (to allow easier code scaling)
- use AutoCleanup from time to time
- try to minimize usage of local variables
- event structure is great for UI interaction, but requires a little more effort when you want to handle DAQmx inputs with it…
04-04-2019 07:45 AM
More comments:
Bob Schor
04-04-2019 10:10 AM
Thank you GerdW and Bob for taking the time to reply. I hugely appreciate any and all advice and tips you have.
I'm slowly digesting the information that you have suggested, I really hadn't though that it would be so difficult to implement a timer in Labview! I've tried using a shift register, to output the 'initial time' to feed it back into the subtraction operator to create a time = 0; this isn't quite working as expected, I really need it to be a one-shot operation otherwise the time will just follow the loop.
Thanks for the tip on the AutoCleanup, this does help somewhat even if it can be a little over zealous. I have moved everything into one loop, and simplified the number of variables as suggested - it certainly looks a lot cleaner...
I was planning on using a software timer, simply because I wasn't aware of a hardware timer. I don't think it will matter too much whichever way is implemented as the old PC will just be running the timers and nothing else at the same time? I have a NI-USB6002 module that I will start adding external switches once I have it working. Busy-wait loops? No, I wasn't aware of that either..
It looks like I have a LOT of reading to do, Labview is quite a learning curve even for simple tasks it seems.
Thanks Again
Josh
04-04-2019 10:24 AM
04-04-2019 10:28 AM
Attached is an old timer that I made a while ago. There is a bit Rube-Goldberg, but it works. It uses an event structure that can easily be modified to include DAQmx events, that can serve as a hardware trigger.
mcduff