arduino controlled digital camera via modbus

Error message

  • Notice: Undefined index: taxonomy_term in similarterms_taxonomy_node_get_terms() (line 518 of /home/cabsoluw/public_html/absolutelyautomation/sites/all/modules/similarterms/similarterms.module).
  • Notice: Undefined offset: 0 in similarterms_list() (line 221 of /home/cabsoluw/public_html/absolutelyautomation/sites/all/modules/similarterms/similarterms.module).
  • Notice: Undefined offset: 1 in similarterms_list() (line 222 of /home/cabsoluw/public_html/absolutelyautomation/sites/all/modules/similarterms/similarterms.module).
administrador's picture
Circuito to control a digital camera remotely

REMOTE CONTROLLED DIGITAL CAMERA

It's very likely that a lot of people have a digital camera in a relatively good shape, getting dust or hidden in some drawer because actual smartphones have cameras with better resolution. Those abandoned cameras could get a second life as trap cams adding some circuit with a PIR sensor, time lapse cams, or a camera to take automated pictures in a small production chain, etc.

* Este articulo tambien esta disponible en Español haciendo clic aqui

There are many ways to adapt those cameras to other purposes without much trouble, if the cam has the option for an external shutter switch, or if it is one of the lucky ones that supports CHDK (Canon Hack Development Kit)

If none of the aforementioned options are available for a particular digital camera, there is a "less elegant" alternative soldering wires to the push-buttons that triggers some functions in the cam, like focus, shutter, zoom, menu, etc.

The process requires a lot of patience, because the camera needs to be disassembled (as possible using a kind of plastic tool used to open cell phones to avoid cracks in the soft parts) to reach the push-buttons and solder very thin wires to their pads. There is a mystery than needs to be solved with every cam: That particular switch is active low or active high?. To overcome this a little bit of knowledge/experience is needed if there is no repair/service manual of the camera in sight.

In this particular case, extension wires have been soldered to the focus and shutter test pads on the PCB, if there are no test pads, wires have to be soldered directly to the push-button pins. Because the signals are active-low, a wire to a GND pad was soldered. A little bit of Kapton tape was used to protect the thin wires.

Wiring of focus and shutter buttons to be connected to the Arduino

ARDUINO AND MODBUS RTU PROTOCOL

ModBus protocol is widely used in industrial automation hardware like PLC, HMI, VFD, etc. Usually over twisted pair using RS-485 standard in distances up to 1200 meters. Because is an open protocol, well documented and easy to implement in many languages/platforms (Java, Python, Arduino, PIC, etc.) is an ideal candidate for the remote control circuit.

The goal is to use an Arduino Nano to receive commands (focus, take pictures, etc.) and execute the respective push button actions electrically simulating manual operation. Optocouplers were used like in another project to optically isolate the camera from the remote control circuitry

In this example, a Panasonic Lumix DMC-LS3 camera, has 2 position push-button. Pressing to half position, the camera focuses, and when pressed full, camera takes a picture. The push-buttons should keep hold for some amount of time, because if "pressed" too fast, the debouncer algorithm in the camera will reject the action. This delay time should be found experimentally because debounce times vary from camera to camera.

The following commands were implemented:

1. Press and hold focus.
2. Release focus
3. Press and hold focus, wait for some time, press and hold shutter, wait for some time and finally release focus and shutter.

The first and second commands are very useful to keep the camera powered on, because if the time between taking pictures is very long some cameras automatically power off to save energy. In some cameras the auto power off feature could be disabled or it's time extended, but in others isn't possible. The commands could be used to focus the camera periodically as a sort of "ping" to keep the camera on.

The third command takes a picture and emulate the human push-button sequence process.

For the execution of each command, a non-zero value should be written to their respective ModBus register

Schematic of the digital camera remote controller using modbus

PC FIRST TEST

For this test a personal computer (PC) with a ModBus RTU Python client app were used. A USB to RS-485 converter is required to connect the Arduino to the computer. This combination makes the Modbus RTU network master.

The Arduino remote controlled digital camera circuit, and the converter were wired with a cheap twisted pair. This makes the ModBus RTU network slave

A command to write a non-zero value to holding register 10 was sent. This register triggers the picture taking command sequence. Note the red leds used to debug the delay hold time for focus and shutter buttons.

Testing modbus protocol with a PC using an USB-RS485 converter

TESTING IN AN RS485 NETWORK WITH A PLC AND A RASPBERRY PI

To simulate a more complex ModBus RTU network, some industrial equipment was added. The setup is as follows:

- Raspberry Pi, with a USB to RS-485 converter will be the network master
- Panasonic FPX-C14 PLC with an RS-232 to RS-485 will be a network slave
- Arduino Nano with the camera will be a network slave

In this test the master reads a value from a register in the PLC, if this value is greater than some fixed number, the command to take a picture will be sent to the Arduino Nano. The PLC was programmed in a way that the register value can be modified with an external potentiometer built into the PLC.

ModBus RTU command logic running inside Raspberry Pi, was implemented this time, with Node-RED. A ModBus RTU didactic flow was written and only requires serial port nodes and no other external library or dependency. It wasn't written in the most efficient way, but is very didactic, because all the steps in the request packet frame building are easily spotted. Also, it is very easy to add new ModBus functions.

Finally to give it a more "industrial appeal", the Raspberry Pi was placed in an enclosure with added plastic clips for DIN rail mount.

Testing Arduino controller in an RS-485 Modbus network with a PLC and a Raspberry PI

TESTS AND CONCLUSIONS

- An initial test was done with a Celeron 900 Mhz, 2B RAM PC, Lubuntu 14.04, Node-Red v0.15.2 and Node.js v0.10.25. Node-RED cyclic trigger was configured to fire reads from the PLC and writes to the Arduino every 15 seconds. No noticeable delay was observed.

- A second test was made with a Raspberry Pi (1 B+) Broadcom 700MHz, 512MB RAM, Raspbian Jessi Lite 4.4, Node-Red v0.15.2 and Node.js v0.10.29. A delay was observed (about 10 seconds + ) to the 15 configured for the reading cycles. There are no big gaps between versions of Node-Red and Node.js, but there are a big difference in the hardware of the two tests and probably is the cause of the "slowness". Remember again the flow wasn't written in an optimal way!.

- In every of the two tests the results were the same: A picture is only taken if the value read from the register in the PLC is below the fixed number programmed in Node-RED logic.

- ModBus RTU implementation for Arduino works pretty well, so it can be used as a node in an RS-485 network with other industrial equipment.

- As a future upgrade, the circuit could be miniaturized to place it inside the camera.

- Explore low power options for the microcontroller, so it can be powered by the camera batteries.

- Node-RED is a very useful tool to develop communication protocols in a graphic and quick manner.

DOCUMENTATION

(See bottom part - Attached files)

* Complete Article in PDF
* Arduino source code
* Schematic diagram of the Arduino ModBus RTU remote controller for digital camera
* Node-RED control logic to read PLC and write to the Arduino using ModBus RTU
* Node-RED ModBus RTU didactic flow
* Python ModBus RTU test client.
* Program for the Panasonic FPX-C14 PLC, to map from potentiometer value to ModBus register.

VIDEO

The following video shows all the components and working tests