Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-VISA Drvier Issues with USB Devices

Solved!
Go to solution

Good morning all; 

Over the last couple of months I've been dealing with a maddening issue related to NI-VISA drivers, NI-MAX, LabVIEW, and Windows 7 and 10. 

 

Our production lines utilize between one and three thermal printers to print product specific labels. In setting these printers up, the NI-VISA Driver Wizard was used to create the driver. These printers, when initially plugged in, show up in Windows Device Manager as a USB Printer. With the VISA driver created and assigned, these printers readily appeared in NI-MAX. From MAX, an alias is assigned; for this example I'll use is 'Zebra'. 

 

On some machines, MAX/Windows/whatever has a tendency to drop the alias altogether, reverting back to the original raw USB resource. This is especially prevalent first thing in the morning as the Windows 10 machines are turned on. Sometimes this happens multiple times a day; other times a machine can go weeks between an alias being dropped. Some machines have been rock solid and have never lost an alias. 

 

Another issue that most if not all of our machines have is the numbering of the alias. Sometimes MAX will reassign a resource with another alias name. For example, if 'Zebra' has been set and the production line runs into printer issues, I'll look in MAX and the assigned alias will be 'Zebra-5.' I've written some code that deals with this issue, but I can't write anything for the completely dropped alias. There is a push to standardize all printers and cables across all production areas in the plant, so I can't just whip up band-aid fix. 

 

Power options in the USB settings have been adjusted appropriately. I'm frankly at a loss as to the potential cause of this issue and I'm looking for input from anyone who has ever had to deal with a similar situation. I've probably left out some pertinent information with this post, so let me know if any additional info may lead to a solution. 

 

Thanks!

0 Kudos
Message 1 of 7
(3,714 Views)

One fine detail I am aware of, aside from the connection loss issues which tend to be very individual for each PC) is that a Serial Number for a USB device is included in every device configuration (it's defined in the USB standard).

 

It's optional whether each device has a unique serial number or not. Many simply have an empty serial number.  When Windows (or any OS for that matter, this isn't strictly a Windows issue) detects the device after disconnecting and re-connecting (OS can't differentiate between brief power loss and a human detaching and re-attaching a device) then if the serial number os empty, it has no way of knowing if it's the same device or not, and (being overly cautious) creates a new alias.  If the serial number is not empty, then it generally tries to re-apply the old alias (as it remembers the device).  If the serial number is not empty, and it's a different device (serial number different) then it will behave as it does now and give a new alias.

 

One can argue both sides of the behavioural rules, but this seems to be the way that Windows/NI (where the line is to be drawn between Windows and NI is unclear to me) handles it.  For me personally if the device is plugged in the same port, it would be wise to re-use the alias even if the serial number is absent. Alas, I am not in control of such things.

 

If you can get the device descriptor of the device, check to see if the serial number is being used. Choosing hardware which properly implements USB serial numbers will greatly reduce your pain.

 

Having said that, it's not the only possible root cause of this particular problem, just a possibility.

0 Kudos
Message 2 of 7
(3,697 Views)

Hi jkeller19,

 

Can you check if the printers have a serial number? If they don't, the resource name would be of the format "USB0::<manf id>::<model code>::NI-VISA-nnnn::RAW". Also, if you have a system where you have previously assigned an alias and has currently lost an alias, could you check to see what shows up in NI MAX where VISA aliases are listed? They are in NI MAX at: "My System >> Software >> NI-VISA <version>". When you click on the NI-VISA item, they would be in the "My System >> General Settings >> Aliases" tab on the right hand pane.

 

Thanks,
Pankaj

0 Kudos
Message 3 of 7
(3,693 Views)

Thank you so much for the replies. I will see what I can find regarding the printers and internal serial numbers tomorrow. 

 

Thanks again!

0 Kudos
Message 4 of 7
(3,679 Views)

Pankaj; 

The new printers that I am installing currently do have serial numbers indicated in MAX. The older printers do not. The new printers are constanly dropping their alias and not reconnecting correctly. The old printers have a habit of either swapping aliases or the aforementioned incremented  number. I have forgotten to mention that these are plugged into USB hubs as opposed to being directly connected to the PC. 

 

With the new printers, does it make sense to setup something in my programs that automatically connect to the USB0::<manf id>::... address and just skip over the problems that have arisen from using aliases? 

0 Kudos
Message 5 of 7
(3,657 Views)
Solution
Accepted by topic author jkeller_beckettcorp

For the old printers without an alias, the issues you have described make sense. NI-VISA uses the "Location information" property for a USB device to generate a fake serial number if the device doesn't have a serial number. In device manager, you can look at the properties of the device and the Location Information is of the form "Port_#0001.Hub_#0001". Based on what else is connected on the system and specially with hubs, this value can change across reboots. If that happens, the resource name of your device changes and the old alias 'zebra' no longer applies to this resource, even though VISA still has it in its records. If you then go into NI MAX and assign 'zebra' to this new resource name, the old resource name that had the 'zebra' alias gets its alias renamed to something like 'zebra-1'. If this happens a few times, VISA will have a list of USB resources with slightly different generated serial numbers with aliases such as 'zebra', 'zebra-1', and so on. On a subsequent reboot, if your generated number happens to match one of these resources, then that alias shows up on your system as an available device.

 

As far as I can tell, this shouldn't happen for a device with a valid serial number. If you could get a technical support report from MAX (File >> Create Report... >> Technical support report) and post it here, I may have some suggestions.


Thanks,

Pankaj

Message 6 of 7
(3,636 Views)

Honestly, I've resorted to referencing the VISA device by the RAW address and haven't had a single issue with the devices with serial numbers for the last few days. 

 

If I can get out on a line and produce the technical support report I will post it here. 

 

Thank you again for your help. 

0 Kudos
Message 7 of 7
(3,632 Views)