Jump to content

How to tell if USB camera has failed/disconnected

Recommended Posts

I am using USB cameras (several different vendors on different projects) and have noticed that sometimes my image acquisition fails as the camera has just disconnected (or failed in some manner). My camera is configured for Continuous Acquisition and I am using IMAQdx Get Image 2.vi. When the camera has failed (or is physically disconnected) I do not get any error out of that VI, just the last image is returned. I have tried various other techniques like looking at the buffer number etc but cannot seem to get anything to work reliably.

Any ideas on what I am doing wrong or a strategy I can employ for figuring out if the camera has failed?



Link to comment

Hi Neil

Your cameras are powered by USB or other power supply ? USB is very delicate when there is different power sources for devices. Few time ago i have encounter lot of problem with this , and solve lot of it with one galvanic converter added on USB Link.

Something like that https://electronics-shop.dk/usb-isolator

It's a bit difficult to know if USB link are fall because with this kind of problem is low level protection who are activated and only windows can detect and restart it. Sometime on old PC you need to shutdown PC' power-supply to restart USB Link.

The only wait i show to see if it fall, is to cyclically request something to camera, and detect when there isn't reply.


Edited by Bobillier
Link to comment

If a USB device does not implement a Device Serial Number correctly, Windows cannot distinguish between a second instance of the same camera being attached and the reconnection of the same camera. This leads to numerous "instances" of devices being installed in the system.  If done correctly, the OS should be able to assign a driver to an instance of a specific device (taking serial number into account).

The serial number of a device is normally defined in the device configuration package which an OS needs to read before it can even assign a device class.  A lot of devices simply don't implement this.

Also see HERE for info on where this data SHOULD be stored.

Link to comment

My post seeks only to explain why the renaming takes place.  If there's a rapid power off and on, not supporting a proper Serial Number can lead Windows to whink a new camera has been attached.

I think the base problem you have is a power supply issue, and there USB is flaky at best.  The issues you see with MAX are understandable from an unstable power point of view.  Sorry that I didn't portray that information more clearly.

Filtering of power over USB is nororiously crappy for most motherboards, for possible fixes, Bobillier's suggestions above soumd perfectly reasonable.

Link to comment

No problem, no hostility detected. Honestly. Also none implied at all.  I just noticed that the focus of my answer wasn't explained properly.  Your "oops" while acknowledged, is not neccessary at all.  Nothing whatsoever to apologise for.  :beer_mug:

Although I knew my post was only focussing on the "multiple devices" issue, I simply didn't convey that properly.  My bad.  I only realised it after your post.

  • Like 1
Link to comment

Be sure as well to never use hub. I have many issues with USB hub.

If you want to get the list of USB device connected, you can use this VI. note that if your web cam do now have embedded serial number, the device path is reported according to the USB port connected. if you connect the same model of webcam at the same port, Windows will use the same friendly name.

I use Spinnel USB cam 2M. they do have a embedded serial number programmed upon request... 50$ per unit. quite decent for this usb camera with a low distortion lenses.

USB Scanner.vi

  • Like 1
Link to comment
5 hours ago, Benoit said:

if you connect the same model of webcam at the same port, Windows will use the same friendly name.

Ah yes, I remember this now,  I "abused" this when doing some USB programming of my own to install LibUSB drivers for a given device on one port, and standard NI-USB drivers on another port for testing.  In order to change driver, all I had to do was switch USB port instead of constantly uninstalling and re-installing.  It was a nice trick (in XP at the time), I don't know if it still works with Windows 10.

Link to comment
  • 3 years later...

Have being using on a system 2 usb 3.0 cameras with Continuous Acquisition and I am using IMAQdx.   The system can work for days without any problem.  Eventually at some point int time only the last image of both cameras is returned. In order to see if the cameras are still working, I exit the program and check to see if the cameras are still active and yes, they are still active. l  start the program again and it works correctly for some more hours, of sometimes for a few minutes.

They are connected to a 3.0 HUB.     What can it be?   I am thinking to trigger the cameras instead of Continuos Acquisition.

Link to comment

If the snap does work, but returns the exact same image, you might be able to detect a locked up camera by comparing the last two images and seeing that they are exactly the same.  At that point I don't know if closing all references, and re-initing would help or not.  I've had some success with this, depending on what caused the lock up.  I've had other cameras that really seem defective and the only fix was to power off and on the camera.  For that something like a relay could be used to kill the power and turn it back on.  But in general I suggest using high quality ethernet based cameras because of some of these issues that I've seen in the past.  Still ethernet cameras aren't without issues.  I've seen firewall or antivirus software cause camera images to not acquire properly.

Link to comment
13 minutes ago, Neil Pate said:

After getting burned by the system with the USB cameras I switched over to GigE and never looked back. Multiple USB cameras running at full frame-rate is a recipe for disaster!

When using GigE make sure your network adapter supports jumbo frames. Or at least be aware that this is necessary at times.


Link to comment
14 hours ago, Jordan Kuehn said:

When using GigE make sure your network adapter supports jumbo frames. Or at least be aware that this is necessary at times.


It's not entirely without its own pitfalls. Different network controller chips support different support for jumbo frame, some older do not support it at all, and all your routers, hubs and whatever in between needs to support it too.

It's definitely helpful for full HD and higher resolution cameras and/or when you need to use multiple GigE cameras in parallel, but it makes your setup more sensible to quickly switching to a different ethernet port or replacing intermediate network infrastructure suddenly causing issues. 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.