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: 

event handling

I am trying to develop a temperature and humidity monitoring system in LABVIEW. At the moment I have two vi's each for the temperature and humidity. Each of these vi's are exactly same; they only differ from the formula I have used to calculate the respective temperature or humidity. The data acquisition and parsing from the serial port remains the same. I will attach the temperature vi for the reference which includes the formula node for the temparature calculations. I am not attaching the humidity vi as it only differs from the temperature vi by the formula it uses to calculate the appropriate humidity.

Now I want to colloborate these two vi's (two formula nodes) such that they appear as a single vi. In other words, I want the temperature calculations to be carried out when I request the temperature by writing '1' to the serial port, and humidity calculations to be carried out when I request the humidity by writing '2' to the serial port.

I also wannna replace writing to the serial port by just clicking some button such as "Request temperature" or "Request Humidity" ; just wanna improve the look of the front panel.

Is there any easy way to perform the tasks I have mentioned above as I am not much acquainted to LABVIEW. Everytime I go over a long process and ultmately I find there is always a easy way out to do work efficiently in LABVIEW. Any help is appreciated.
0 Kudos
Message 1 of 34
(3,962 Views)

Hi Mozill,

Here's one take: So it looks like you want to write one of two strings across your serial port, depending on whether you're reading temperature or humidity.  Since these commands to your instrument are fixed, you should be able to have these commands as string constants in your block diagram.  Then, depending on which reading you select on your front panel (say, a toggle button between temperature and humidity), you can pass the corresponding string constant to your serial write block.  To do this, a "Select" function would be useful.  You can get this funtion from your block diagram (Programming>>Comparison>>Select).  Essentially, the user will select whether they would like to read temp. or humidity.  Based on this selection, we'll send that command constant serially to the instrument.

Then, when you read in your data from the serial port, you can send the information into a case statement (the selector for this case statement is also the output from the toggle switch on your front panel that chooses temperature or humidty) and within one of the cases you'll have the formula for the temperature reading and in the other you'll have the formula for the humidity reading. 

Hope this helps!


Regards,
Anna M.
National Instruments
Message 2 of 34
(3,912 Views)
Hi Anna,

Thanks a lot for the solution.  I haven't tested it yet, but seems good so far. I have a few more problems which I believe you can solve very easily. 
Following are the problems:

1. I want to get rid of the Go button on the front panel. I am not sure if I can remove that because it is the selector to the first case structure.         What  should I do for that?

2.Could you shed some light on the focus function on the key navigation tab of the switch?

3. Also, is there a way I can have two different controls for the request rather than having only one tab with 'Get Temperature' and 'Get Humidity'?

I am attaching an updated vi.

Again, I would like to thank you for help.

Regards,

Dushyant

0 Kudos
Message 3 of 34
(3,895 Views)
Hi Dushyant,
 
The key focus essentially sets up a shortcut key on your keyboard associated with that switch/button.  You can get more information from LabVIEW Help under "Boolean Properties Dialog Box" & go to the key navigation section.  Your other questions (1 & 3) would probably best be solved with an Event Structure (ie. a structure in which you can have a different piece of code execute when a certain event occurs - like a button press).  However, this structure is not available in the Base Package of LabVIEW.  If you have the Full or Professional, etc. LabVIEW packages, you may consider this structure.  You can find a more detailed description of the event structure here: http://zone.ni.com/reference/en-XX/help/371361B-01/glang/event_structure/ and an example of using it here: http://zone.ni.com/devzone/cda/epd/p/id/4013
 
Hope this helps!

Regards,
Anna M.
National Instruments
Message 4 of 34
(3,862 Views)
Hi Anna,

I will definately try the steps you mentioned. But before working on that I am facing one more problem. In my vi, according to the boolean input to the second case structure, only one waveform should execute; however, the humidity waveform works all the time. What could be the reason for that? I am attaching the vi for your reference. I just want your advice; I am not asking you to do the work for me.


Thanks a lot for your help.
0 Kudos
Message 5 of 34
(3,845 Views)
Hi Dushyant,
 
Hmm, yeah, I see what you mean.  I think that's because in the false case of your first case statment you selected "Use default value on that boolean output tunnel".  Essentially this means that whenever your "Go" button is not pressed (it is False), the Case Structure will output that default boolean which goes to your second case structure.  My guess is that the default is for the Humidity analysis/graph 🙂
 
To avoid this you might try nesting those case statements (put your analysis case statement inside the first case statement) - that way, if the go button is not pressed, there is no analysis being done at all.  Hope this helps!
 

Regards,
Anna M.
National Instruments
Message 6 of 34
(3,828 Views)
Hi Anna,


All your solutions are working out really very well. Thanks for saving my day. Now I have one more question to ask you. I want to capture an image from a wireless usb security camera. In other words, I want to control the operation of the camera from the labview. I went over the forum in order to solve this problem. I believe there is something like 'activeX' through which I can solve this problem. The manufacturer has provided the activeX drivers. But I dont know where are they stored. I am trying to load the activeX methods using 'insert activeX object', but I dont know which are my activeX drivers. Is there a way I can find out the appropriate drivers. Could you also recommend me any particular vi which I can use as  a reference to solve my problem.

Thank you very much for your time.
0 Kudos
Message 7 of 34
(3,808 Views)
Hi Dushyant,
 
You're exactly right to look to ActiveX for your Webcam application.  After you put an activeX container on your front panel & then right-click and chose "Insert ActiveX Object", there should be a list of ActiveX applications that you can access through LabVIEW.  I would imagine the the ActiveX object you're looking for would be named similarly to the driver you installed courtesy of the manufacturer - double-check that this was installed properly.  You may want to refer back to the manufacturer to determine if it goes by a different name that you aren't recognizing once installed for some strange reason.  There are examples of using ActiveX with other programs within LabVIEW in the Help>>Find Examples under Communicating with External Applications>>ActiveX for your reference as well, once you're able to access that application.  If for some reason your camera driver isn't compatible with ActiveX, if they have .dll's, you should be able to call these in LabVIEW using the Call Library Function Node, but you'll need to be very familiar with the functions in those .dll's you're calling.

Regards,
Anna M.
National Instruments
Message 8 of 34
(3,778 Views)
Hi Anna,

Again I need your help. I am totally lost at the moment. I created an event handler for my application as attached. I will briefly explain what I want to do here. I set up the port number and baud rate before I start anything else. This enables the serial read from the serial port. I press request button so that the serial write function writes to rs 232 so that my mcu sends me back the temperature or humdity value thru rs232 port and i read it through the serial read function; parse the required digits and process them through formula node to get the temperate and humidity. I want to create something like 'Acquire- Analyze-Present.vi'. But I am not able to trace the steps they have gone through out there.

1. Currently I have to set my baud rate and select the com port before I do anything else. I want to do this in event structure such that clicking a button called 'port settings' will ask the user to change the settings which are currently on my vi in the 'port settings' tab. I dont want it to be present all the time on the front panel.

2. I have only one button for requesting the temperature, humidity, and direct the robot (which I will be adding soon). Is it possible to have three differnent buttons for each option; and that too in the event structure case. I went over the examples,  but  I still do not understand how to wire the port number I require in the event numbered '1- Request- value change' from the event numbered '0- com settings-value change'.

It would be really helpful if you give me some basic idea or steps in order to solve the problem. You are the only saviour for me at the moment.


Message Edited by Mozill on 01-31-2007 10:18 AM

0 Kudos
Message 9 of 34
(3,744 Views)

Hi Mozill,

It sounds like you're almost there.  You can definitely have a separate button for port settings, humidty, temperature & whatever other sub-program you want to run.  For each button you have you'll create a new event for that button (right-click on the event case at the top of the event structure and select to Add Event).  In the pop-up box that follows, you'll want to select your button control on the left-hand side and on the right hand side you'll choose the event for that button (typically value change should work fine).  This will create a new event case in the drop down menu of your event structure.  In this event case you'll put all the code you want to execute when that button changes value.  If you need data to be passed from one event case to another (like the COM port settings need to be passed between the "Set Port Settings" event and the "Temperature" or "Humidity" events), you can use shift registers on the while loop to "store" that information for you from loop iteration to loop iteration.  The Acquire, Analyze and Present vi you referenced is a great resource.  You may want to start there.  Save the example under another name & then add in your functions one by one.  Hope this helps! 


Regards,
Anna M.
National Instruments
Message 10 of 34
(3,729 Views)