0

I am trying to use this library to connect a Nikon lens to an Arduino. https://lainy.github.io/NikonLens/classlain_1_1t_nikon_lens.html

I'm finding it very hard to understand the correct wiring.

Connections are as follows (with Arduino Uno pin numbers):

SS (10) is unused.

SCK (13) is connected directly to lens SCLK.

MISO (12) is connected to the lens Data line, which must be pulled high.

MOSI (11) drives the lens Data line through a transistor, open-collector. So: MOSI -> Base, Data -> Collector, GND -> Emitter

handshakePin_In is connected directly to lens H/S

handshakePin_Out drives lens H/S through a transistor, open-collector.

I would like help to understand this.

drives the lens Data line through a transistor, open-collector. So: MOSI -> Base, Data -> Collector, GND -> Emitter

It uses a variant of SPI interface. I'm just finding it hard to wrap my mind around it.

1

It is simply a way of splitting a single-pin read/write function between two pins. It's easier to visualise with schematics:

schematic

simulate this circuit – Schematic created using CircuitLab

Under idle conditions the resistor pulls the data signal high. When the lens wants to transmit the open-collector output (represented by a transistor here) either pulls the data line low (for a 0) or releases it to be pulled up by the resistor (for a 1).

The Arduino reads that data in through the data in pin.

When the Arduino wants to transmit it does the same thing, but the "open collector" is external in the form of the transistor. It drives the transistor using the data output pin to get it to pull the data line low for a 0, or release it to be pulled up by the resistor for a 1.

This is exactly the same way (on an electrical level) that I2C works and studying that protocol can help you to understand what is going on here.

  • great answer! Can you describe how the correct wiring would look like for interfacing Arduino with a Nikon camera? I.e. Arduino with MISO and MOSI pins acting as an SPI slave and Nikon camera with a single data pin as master? – burax May 14 '17 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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