From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed data acquisition and logging

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?

0 Kudos
Message 1 of 11
(2,955 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 11
(2,953 Views)

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.

 

0 Kudos
Message 3 of 11
(2,951 Views)
What hardware are you using? Does it support hardware timed digital or analog output? That's much more reliable than software timing.
0 Kudos
Message 4 of 11
(2,941 Views)

I am using a 6035E with a SCB-68 breakout.

 

 

0 Kudos
Message 5 of 11
(2,930 Views)
I don't think that old card has hardware timed digital I/O. You can use the analog output or the country.
0 Kudos
Message 6 of 11
(2,919 Views)

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...

0 Kudos
Message 7 of 11
(2,911 Views)

Do you want to see what happens when you turn the relay off?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 11
(2,905 Views)

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.

0 Kudos
Message 9 of 11
(2,898 Views)
Are you now saying that you don't care if the time varies with the jitter imposed by the os?

Examples for analog out and counter tasks are with the rest of the examples - Help> Find Examples.
0 Kudos
Message 10 of 11
(2,893 Views)