LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

instrument Synchronization

Hello,

 

I have a genreal question in LabView.

 

I wrote a program that interface some (serial) instrument.

 

I can send commands and change the state of the instrument and I can read data from it.

 

I was ask if it is possible to fully synchronize the program and the instrument and not just control it.

 

for example, If I close the program (without closing the insturment) and load it after a while - my program initialize with my defind default value, but the instrument is not at the values as in the first run.

 

or for example, if the computer crashes or not responding from some reason - I can still do everything when I reload it - but the initial state of the machine is now different than the intiail values of the program.

 

is there some elegant way to handle this?

how can you read and write new default values for contorollers and indicators and assign them to the progeam efficiently?

 

thanks, Avishay

0 Kudos
Message 1 of 5
(2,321 Views)

Hello Avishay,

 

I want to make sure I understand what you are trying to do. When you first start a session with the serial device, you want to use defined default values. If you run the code at a later time, you want to use the last values rather than the default values, correct?

 

I have a few questions:
1) What are these values? Is it to configure the serial port? Is it the command you are writing to the port?
2) Is your code using shift registers?
3) You say you close the program. Is communication with the serial device continuing when the program is closed? Usually closing a program ends the session with the serial device.
4) You also mention computer crashes. Are there specific crashes that you are concerned about?

 

I have an idea for what you are trying to accomplish, providing that I understand the requirements correctly. You could write the values to a text file. Then when you launch the program later, prompt the user if they would like to use the default values or the values stored in the text file.

 

Taylor B.
National Instruments
0 Kudos
Message 2 of 5
(2,277 Views)

you understand correctly.

 

for you question:

 

1.  the values are control command - not related to the serial port configution.

2. My code uses shift register when needed. the code is built at a while loop with event cases inside - so the program respond only to commands or value

     change. I do not write or read data from the instrument constantly.

3. when the program is closed - the session should end. I'm not sure this happens if the computer crashes from some reason and the program is not 

     responding (as any other program at the computer - not something specific to the LabView.

4. no specific crashes I worry about...

 

I provide a simple example,

 

lets say I interface with a radio (my real instrument is a controller with more functions). The radio has an On\Off button. Volume control and Volume indicator.

These are also shown on my computer interface. I set the default value (manualy not in code) to Off and Volume 0. These values apears when the program is loaded for the first time - and I turn my radio on and set the volume to some value.

 

if the program is close, by me or a computer crash, the radio stays on with the volume I set, but when the program is reloaded - it shows radion off and Volume zero.

 

I thought of storing the values in a file but:

 

1. I'm not sure I know how to do this. I think I can manage writing text into a file, but then I will have to read a specific line to each contorller. I don't have any

    experience with that.

2. I will have to write default values by code - I don't know how to that either.

3. this wil work well if I close and open the program my self. but how will this work if the computer suddenly crashes?

 

Avishay

0 Kudos
Message 3 of 5
(2,263 Views)

Hello Avishay,

 

If i well understood your question, it is not about instrument synchronization but about keeping the last state of your program  when failure ?

If your program is running on computer, i guess you have developed drivers to command your instruments... If drivers are programmed as they should be, if an error occurs, the instrument closes (even reset sometimes). And in your initialize step you should reset and open your instrument communication.

What you can do is to save last values in a log file when an error occur and load theses last values command on initialization if that's what you need.

 

If your question is about instrument synchronization, we need more specifications about instruments you are driving in.

 

BR,

Vincent

0 Kudos
Message 4 of 5
(2,254 Views)
One basic option for saving control values is with an ini file. You have a palette for reading and writing. Look at the example and search the board. This has been discussed numerous times. This is one of the free instances where local variables are appropriate.

Of course, of you let someone manually change an instrument, saving the last settings does not do you any good. In that case, you could query the instrument for its current settings and update the controls as needed.
0 Kudos
Message 5 of 5
(2,249 Views)