08-14-2014 01:31 PM
I am working on a program that triggers a relay on/off and logs data.
The user enters two items: duration and delay.
I am using a QMH design for this program. What I have currently done is create a flat sequence that turns the relay on, waits a certain amount of time in ms (duration), then closes it. I then send a 'Start' message to the acquisition and logging queues.
Where I am lost is how to stop the logging and acquisition after a certain amount of time has passed. It is imperative that data logging begins right after the relay closes.
For instance, if a user enters 1000ms for the delay, I should, after the 1000ms, see 1000 samples in the log file (1 each 1ms)
What is the best way to ensure this happens?
08-14-2014 01:36 PM
I would actually tell the logger and acquisition to start before closing the relay. There's nothing wrong with having a little extra data. You should also have a Stop command to tell those loops when to stop logging and acquiring.
08-14-2014 01:37 PM - edited 08-14-2014 01:39 PM
The data that is gathered is looking to see what happens when the relay closes.
Yes, I do have a 'stop' message. My worry is that using the Wait(ms) is not accurate enough. What if the CPU slows down? The clock is off.
08-14-2014 01:58 PM
08-14-2014 02:05 PM
I am using a 6035E with a SCB-68 breakout.
08-14-2014 02:19 PM
08-14-2014 02:32 PM - edited 08-14-2014 02:36 PM
Sorry, do you have an example of how I would implement that?
I use a digital output (PO.4) to trigger my relay on/off. I am reading in voltage via the AI0 line.
Perhaps i do not need a counter or a timing setup? Can my logic be something like:
Acquire samples>log samples>trigger relay on>wait *duration*>trigger relay off; repeat
What I am thinking is, since I am acquiring a sample every ms, that I keep track of how many samples I have, and stop logging after I have acquired enough?? This is probably bad practice...
08-14-2014 02:37 PM
Do you want to see what happens when you turn the relay off?
08-14-2014 02:41 PM
What do you mean "see" ?
I need to see what is saved, as in, if the relay is off (delay) for 1000ms, I need to see a plot of that file that contains 1000 samples (1 sample a ms)
Example:
Relay on for 500ms, off for 1000ms.
Acquisition and logging occurs for the 1000ms that the relay is off. Graph shows me what was logged.
08-14-2014 02:53 PM