LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Measurement

I'm trying to have a new log file created everytime the button goes from the off state to the on state. The problem is that when in ON state, the data in the new event is logged in the same lvm file. I think i need a boolean trigger or latch or something but not sure how to implement it. Any ideas?

 

0 Kudos
Message 1 of 9
(2,587 Views)

You might need to do this.

 

 Check the image2013-06-29_1344.png

 

0 Kudos
Message 2 of 9
(2,564 Views)

The reason why this won't work is because the case structure operates on every iteration... so when the button is ON, new file is triggered on every iteration (giving a log file for whatever my sample rate is)

 

When the button is off, the new file is off but the write to measurement is still enabled which will cause it to continually write to most recent log file... 

 

What i want it to do:

When ON, write to a new log file continuously.

When OFF, don't write. 

 

This is why I had it wired to the enable from teh button, because when button is off, enable is off, and writing won't occur. When button is ON, enable is on and it continues to right to same log file.

 

What I need is to use the button as an input to a pulse/trigger/latch, so when the button goes ON, it sends a pulse/trigger to the new file but only does it once when it changes, not on every iteration.

0 Kudos
Message 3 of 9
(2,544 Views)

bump...

0 Kudos
Message 4 of 9
(2,506 Views)

My thoughts on this:

 

Why did you wire the Log button to the "new_file" input?

You said you want that your input work as a "latch". But your boolean mechanical action is Switch... 😉

I'm a bit confused, but I would use a case structure. Put the "write to measurement file" block inside the TRUE case. Wire the "Log" button to the Case Selector.


Hope this helps.

Mondoni
0 Kudos
Message 5 of 9
(2,496 Views)

All i want is when the button is turned on, to record to file A.

When button is off, stop recording to file A.

When button is on, record to File B

When button is off, stop recording to file B

 

Can't figure this out and have no idea what i need.

0 Kudos
Message 6 of 9
(2,478 Views)

Case structure.
Inside the true case, place the "record" functions. In the false, simply don't "record" (don't do anything).

Consider what I've said about the boolean mechanical action.
Do you want to log one sample when the button is pressed (latch action) or do you want press once and change the boolean value (switch action) to keep logging until you click again?

 

Regards

Mondoni
0 Kudos
Message 7 of 9
(2,475 Views)

I want to continuously log when the button is on and not log when the button is off. Every time the button turns on, a new log file shall be created. I don't think you can directly wire the button to the enable on  the write to measure because than every iteration it is writing to the same log file (never creates a new one)

0 Kudos
Message 8 of 9
(2,462 Views)

You have a classic case of insufficient program structure.  You want to do two things - log data and monitor a user interface for changes.  The easiest way to do this is to use two loops with a queue to message between them.  In one loop, put an event structure to monitor the buttons.  In the other loop, put your data acquisition and file storage.  Create a queue for messages (message is usually a name/value pair of some sort) and run the queue reference to both loops.  When one of your buttons is pressed, send the appropriate message to the file storage loop.

 

The file storage loop may be a bit tricky to implement.  There are a few ways to do it, but here is one.  Use a shift register to hold the timeout of the queue read that will be the first operation of the loop.  Initialize this with a -1 (infinite wait).  When one of your buttons is pressed, this will send a command to the queue.  The queue will then feed this command to a case structure switched by the name of the command.  For example - StartLogging would start the logging operation and the value would be the name of the log.  When logging, change the timeout on the queue to 0.  If the queue times out, keep logging.  When the queue receives a message (e.g. StopLogging), the timeout will then be set to -1 and the loop will wait for further messages.

 

This is a bare bones outline of a way to solve your problem.  Look up producer/consumer and master/slave in these forums and the LabVIEW examples for many examples of this type of thing.  Let us know if you need more help.

0 Kudos
Message 9 of 9
(2,449 Views)