LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA&USB and separate window display

Hello All,

 

I hope you all well 🙂 

 

This is my first post in this valuable forum. 

 

I have two questions:

 

1- If I insert aUSB dongle for data acquisition (I design this), is there anyway to detect this USB as automatic not manually! becuse when I insert this USB I have to choose it from combobox. I want whenever insert the USB the port is automatically open not I have to open it.

 

2-The second question is related to the first, I have two USB to read deffrent data (LDR,potentiometer), I want design a one VI for both but whenever insert the first USB , the front panel just show and display this particular window and when insert the second USB the same VI display the second window and disappeare the first window!

 

Kind Regards

ennng

 

0 Kudos
Message 1 of 21
(4,037 Views)

Hello All,

 

I found some answers by using subVI, sub pannel .. 

if any-one can give simple example. 

 

For instance, if the number come from VISA or USB is 1 then display pannel 1 and so on..

instead of using VISA or USB you can use numerical input. 

 

Please any help in this and I appreciate that!

 

Regards

ennng

0 Kudos
Message 2 of 21
(4,002 Views)

It is not really clear what you try to do. First of all, you should specify the two devices you try to interface from LabVIEW. You say "VISA or USB", this sentence does not make any sense, these are two different categories/things. I guess you have two USB-to-RS232 adapter, yes? Tell us what kind of devices you have (manufacturer, model number, etc.)?

 

So you want to auto-detect during runtime when the two devices are connected to LabVIEW? It is easy to do, and you do not even need pop-up windows. You could have a while loop at the beginning of your code, which iterates lets say with a speed at 1 Hz. If you connect one device to your PC, this loop could recognize it, and perform an ID request or a simple measurement using the VISA commands (do you have LabVIEW drivers for these devices, or at least the available command list from the producer?).

 

First you need to get a list of the available serial resources (real and virtual com ports). Then you iterate through this list and try to make an ID request or take a measurement (in my example below this is symbolized by the subVI). If the actual request was not successful, you get an error. You need to handle this error (selective erase) and move to the next COM port to try again. You can do this for both devices, until you get proper connections. Then after the while loop you get the two COM ports corresponding to the devices (keep them in a shift register), and use these ports automatically in your main code.

 

Something like this is in my mind, I could give you better example if I had the LV drivers for your devices (to make ID request, or taken test measurement):

 

discover_VISA.png

0 Kudos
Message 3 of 21
(3,959 Views)

Hello Blokk;

 

Thank you very much for your valuable reply and I am sorry for unclarity. Acutally, you make the design is better what I asked for!

 

The idea here is that I have two USB devices (I design them my self base on Microcontroller) as I said in first post ( reading analog and digital signals), I was able to read from the USB device without any problem but what I am looking for is that: (we will plug the usb device, one at a time not both at the same time)

 

1-When I plug the first or second USB, the labview detect the device and  I used manually to choose the USB and open the port to receive the signal (work fine!) but what I am looking for is that for example when I plug the first USB, the labview detect this one and open it automatically. 

you said ID request, that really what I thought off, but I don't know how to implement?? so my idea is that when USB pluged, the labviwe detect and open and the Microcontroller send lets say (1) to tell the labview I am the first USB to measure (analog signal, temperture) and so...

 

2- I want one VI but the front panel just display what plug in the USB, is it possible or not! For example if I plug the first USB, what should appear in the front panel is just analog display and when disconnect the USB and plug the other USB the digital display appear and the analog display disappear. 

 

I am really sorry for long post and kind regards

ennng

 

0 Kudos
Message 4 of 21
(3,949 Views)

What you describe can be easily done. You can use my example code as a starting point. I do not have time to program everything for you, you should try to do it yourself, and when you stuck at some point, you can upload your code here and people will help you (if you explain the problem properly). People will not help you if you do not show effort, this is a general "non-written" rule here 😉

First of all, if you are beginner in LabVIEW (as you are), you should go through the learning material (like Core 1-2 self-paced learning), it will help you a lot. Good luck, and nice studying!

 

ps.: Since you want to dynamically initialize and close VISA resources (i guess you use Arduino with virtual com port, yep?), plus display different things and hide them at certain conditions, you could learn about State Machines. A simple State Machine would be a good candidate for your project...

0 Kudos
Message 5 of 21
(3,945 Views)

Forget to attache the design:

 

1- VI_2015

2-VI_2012 in case anyone interested and have old version.

 

If you can modefied the VI design I really appreciate it !

 

Regards

ennng

Download All
0 Kudos
Message 6 of 21
(3,943 Views)

As I said, you should learn the basics in LabVIEW before you start to design your code. What you show here is still very far from the functionality what you want. Actually does it even work? I never worked with such microcontrollers, but do you get data at all using this code? And where is the analogue signal? Do you really want to deal with raw USB communication? What kind of microcontrollers you have? Is it possible to use VISA Read and Write functions to communicate? The While loop in your code is non sense: it stops if there is error, otherwise it would run forever indefinitely (it will not, since you try to close the resource at every iteration, so I guess this while loop will iterate twice)...

 

So as you see the given info is far not enough (at least for me), plus you should learn much more of LabVIEW. Take a couple of weeks with learning LabVIEW, go through the available teaching materials.

0 Kudos
Message 7 of 21
(3,941 Views)
Hello Blokk,
Thank you for your advice, I will keep learning and if any one have comment please do so.
The code works fine for me and received data successfully, just I need to add more functionality.

Thank you again Blokk!
0 Kudos
Message 8 of 21
(3,925 Views)

Hello Bokk,

 

Can you please attache the VI design that you post! I have got an idea and will share this if I sucussful. 

 

 

Regards

ennng

0 Kudos
Message 9 of 21
(3,902 Views)

@ennng wrote:

Hello Bokk,

 

Can you please attache the VI design that you post! I have got an idea and will share this if I sucussful. 

 

 

Regards

ennng


What I shared is a snippet, you can save it and insert it into your block diagram.

http://www.ni.com/tutorial/9330/en/

0 Kudos
Message 10 of 21
(3,895 Views)