-1
\$\begingroup\$

I'm sorry if this was posted somewhere, but I'm trying to trigger a FLIR camera for acquisition using a USB port. I already purchased a USB split cable, and have queried the ports, so I know exactly which one I want:

Bus 003 Device 092: ID 1004:633e LG Electronics, Inc. G2 Android Phone 

I also checked the FLIR camera and it can be triggered for acquisition in principle with any 3-5V pulse.

I just would like to know how to send out a pulse via Python to one of those channels.

What is the best Python package for doing this? I saw pyusb. Is that the best and simplest to use?

enter image description here

\$\endgroup\$
4
  • 3
    \$\begingroup\$ Please provide a link to the manufacturer's datasheet for the "split cable" and for the camera. How do you intend to trigger this pulse? Tell us what operating system you are using. Why does the "split cable" show up as an Android phone in the list of USB devices? \$\endgroup\$ Feb 14, 2020 at 1:39
  • \$\begingroup\$ I'm guessing the cable is actually an RS232 adapter and it uses the DTR or some other pin to trigger the camera. \$\endgroup\$
    – Ron Beyer
    Feb 14, 2020 at 1:44
  • \$\begingroup\$ @RonBeyer a USB UART perhaps, but not RS232! \$\endgroup\$ Feb 14, 2020 at 20:28
  • \$\begingroup\$ @ChrisStratton That's what I meant, a USB->UART, TTL level most likely. Usually the chip (FTDI or similar) is embedded in the molding. \$\endgroup\$
    – Ron Beyer
    Feb 14, 2020 at 20:54

2 Answers 2

4
\$\begingroup\$

Python has a library for nearly everything:

Python flying

From xkcd.

It unfortunately does not include a module for "make USB do things it wasn't built to do."

You can't send single pulses over USB. It isn't designed to do that.

The port information you showed is about a connected device. Looks like you had an LG phone plugged in to your computer.

You can get a USB to serial adapter, and twiddle the output signals through pyserial to send your command to the camera. You can directly change the states of DTR and RTS. Your RS232/USB adapter must provide those two outputs on the RS232 cable.

You'll probably need a bit of hardware to convert the signal levels. The RS232 signal levels aren't really directly compatible with modern electronics. A small relay or a couple of transistors (at most) should do.

Another alternative would be to write a small program for a small microprocessor with a USB connection (like an Arduino Nano.) The program would listen for commands from the PC and activate its outputs as needed. You'd also have to keep the signal levels in mind.

In either of the above cases, you could use an optocoupler to provide the signal to the camera. The camera would typically only need to have two connections (trigger and ground) shorted together to make a photo.

\$\endgroup\$
2
  • \$\begingroup\$ In the past, I have used DTR and RTS pins as digital output and CD, CTS, DSR pins as digital input with great success. It was at the time when the real RS232 connector could be found even on the laptop. \$\endgroup\$
    – h22
    Feb 14, 2020 at 10:21
  • \$\begingroup\$ The cable pictured would not have RS232 levels to begin with \$\endgroup\$ Feb 14, 2020 at 20:28
3
\$\begingroup\$

You can buy a USB-Serial converter with "TTL" output that should be appropriate to trigger your camera. Various modules are available, very inexpensive.

enter image description here

Engineers and programmers frequently use them for microcontroller development, and they're used by hobbyists for modding devices as well. They usually have a standard USB-serial chip such as the Chinese CH340, the FT232RL or the CP2102 etc. They require no drivers on computers, but I think you'll want to refer to this answer on getting them working on an Android phone.

If you send a 0xFF character with 9600/8-N-1 you'll get a single negative-going 5V->0V pulse of width 104 usec (it idles high). That can be easily stretched and/or inverted if it doesn't directly suit.

If you send a 0x00 character with 9600/8-N-1 you'll get a pulse 9*104us long, or almost 1ms.

By changing the baud rate to 300 and sending a 0x00 you can get a pulse 30ms long (see below). 30ms = 9/300 seconds.

enter image description here

Similarly, you can set the baud rate very high (the above type supports 921600 baud) and send a 0xFF to get a very short pulse (just over 1us).

\$\endgroup\$
2
  • \$\begingroup\$ Thanks so much for this response and taking the time to explain in simple words. Do you happen to have a recommendation for a python library to do this with? Or even a stack overflow link or start code would be appreciated. I spent a lot of time trying to figure out these py-USB tools, and some were abandoned, and wasn't clear what was best. Is github.com/felHR85/UsbSerial the best option? \$\endgroup\$
    – catubc
    Feb 15, 2020 at 15:26
  • \$\begingroup\$ For clarity, I am not trying to trigger or use a Cell phone with the trigger (I only plugged it in so I could identify a specific port that I wanted to use). \$\endgroup\$
    – catubc
    Feb 15, 2020 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.