LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to a control during an event.

Hi,
 
I am attempting to setup a peice of software that controls a nanopositioner so we can write small structures.
 
The functionality I want to program to have is that when run continuously, the program constantly recieved feedback from the hardware so the user knows what it is doing, but it is only when the user clicks a particular button that the program begins to send commands to write the structure.
 
To do this I have been using the event structure to respons to buttons such as "Load Data" that loads the structure information into an array, and "Write Structure" that begins the process of moving the nanopositioner to the desired locations. The problems so far, is that by using the event structure, several other functions do not work. In particular, I am unable to write to a control using local variables when used in an event case.
 
I need this functionality as the number of structure layers is loaded from a data file along with the distance between layers. The user though, must be able to change those values if required. A control by itself is not adequate, as it can not be written to. An indicator itself is not adequate as the user needs to be able to change it if nesessary. I need to be able to set the default value as read from the data file, then have the user change it if they need to.
 
Outside of a case structure, this works by using a local variable of a control, and writing to it. Put it in an event structure though, and LabView refuses to write to it. I can't understand why being inside an event structure would stop this from occuring.
 
I want to take a peice of data and write it to a control when a button is pressed.
 
Attached is a block diagram picture of the setup that does not work. Press the Ok button and the Numeric (Control) value is written to Numeric 2 (Control). A constant is also written to Numeric 3 (Control) and to Numeric 4 (Indicator) - all of which are using local variables for the read/writes. The only part that works, is the writing of the constant the Numeric 4 (Indicator) yet when outside of the case structure, everything works.
 
Is there something I am doing wrong when implementing the case structures? I know there are a few issues with using them beside or in while loops, I am just not sure how and if that could help me. 


Message Edited by benthegeek on 02-24-2008 09:51 PM
0 Kudos
Message 1 of 6
(2,394 Views)
You're screenshot really doesn't show anything.  Why don't you post your VI?Smiley Wink


Message Edited by Ravens Fan on 02-24-2008 10:52 PM
0 Kudos
Message 2 of 6
(2,391 Views)

Too late to edit now 🙂

control_write.vi uses the event case (not working) and control_write_2.vi uses no event case (working)

Download All
0 Kudos
Message 3 of 6
(2,387 Views)

First, how are you running this VI?  Are you allowing it to run once, or are you using the Run Continuously button?

You should have the event structure wrapped in while loop.  Have a stop button and an event case for that which will stop the while loop.  Move your Okay button inside the event case for the OK:Mouse Up so that it is read in the event case and the button will be allowed to pop back up when it is read.

In your message you talk about using case structures, but I don't see one at all in your VI.  Only the event structure.

The VI seems to behave just like I would expect it to, so I don't know what you mean by:

"The problems so far, is that by using the event structure, several other functions do not work. In particular, I am unable to write to a control using local variables when used in an event case." and

"Attached is a block diagram picture of the setup that does not work. Press the Ok button and the Numeric (Control) value is written to Numeric 2 (Control). A constant is also written to Numeric 3 (Control) and to Numeric 4 (Indicator) - all of which are using local variables for the read/writes. The only part that works, is the writing of the constant the Numeric 4 (Indicator) yet when outside of the case structure, everything works."

When I run it the value in Numeric goes to Numeric2, and 100 goes to Numeric3 and Numeric 4 whenever the OK button is pressed.

 

0 Kudos
Message 4 of 6
(2,376 Views)
I must be having a bad day.

If I mentioned case structures, I meant event structures, and that control_write_2.JPG is meant to be a VI (the pic is of the interface of control_write1.vi). Can't change it now though.

I am running the program in continuous mode, the reason being i want it to continually update with information from the hardware, then react to an event whenever different buttons are pressed. I do get the program to work when run once though, but I don't want the program to stop after the button is pressed. Maybe loops will allow that? 
0 Kudos
Message 5 of 6
(2,371 Views)
Important first lesson in Labview.  Don't use the Run Continuous or the Abort Execution buttons.  They are only there for quick, dirty VI debugging, or to end a VI that won't stop for some unknown reason.
 
Use loops and stop buttons in Labview code to get the program to run continuously.
 
You must be new to Labview and not had any NI training courses because that is one of the first things they teach.  I would highly recommend looking at the NI website for the Labview tutorials.Smiley Wink
 
The VI you posted doesn't reflect any communication with other hardware.  You will want to handle that in parallel while loops.
0 Kudos
Message 6 of 6
(2,366 Views)