Raspberry Pi Pico Lanc controller - Weird transistor issue - Page 1
Forum section: electronics / beginners

author: AshW
author_rank: Contributor
timestamp: January 29, 2023, 06:31:20 am
content: Hi everyone!I'm following the following article to create a LANC controller using a Raspberry Pi Pico (Running Arduino)http://controlyourcamera.blogspot.com/2011/02/arduino-controlled-video-recording-over.htmlUnfortunately it only works while using an external +5V source or when any lead of the transistor / Lanc out pin is disconnected and reconnected while the camera is powered on as it appears the Transistor is pulling the +5V Lanc communication line low. As the line is pulled low the Pico is also unable to boot until either an external voltage source is connected or transistor lead disconnected and reconnected.Am I missing something about what is happening with the transistor when it is pulling the line low when not using external power?(I can also send the .sal or .csv from the logic analyser)Thanks!

author: wasedadoc
author_rank: Super Contributor
timestamp: January 29, 2023, 06:49:49 am
content: Please clarify. A RPi Pico is not an Arduino and does not "run Arduino". Yes the Arduino IDE can be used to compile code and upload to a Pico.The schematic you show, copied from the original article, is not for a Pico. That article is dated 2011, almost a decade before RPL released the Pico.

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 29, 2023, 07:23:58 am
content: The schematic is for a 5V development board, which mostly means an Atmel based micro. The Raspberry pico is a 3.3V based development board and does not like 5V on the IO pins.To be able to use it with a pico you have to modify the schematic so that the feedback signal on pin 5 (D11/PWM) is not directly connected to the LANC signal. It depends on the speed of the signal if you can use a resistor based divider or need an active level converter for it. Also the power input to the pico module needs to be looked at. Not sure if it can take more then 5V on VBUS.Easy solution is to just get a regular Arduino nano or micro and build it with that.

author: tooki
author_rank: Super Contributor
timestamp: January 29, 2023, 03:37:07 pm
content: Quote from: wasedadoc on January 29, 2023, 06:49:49 am…and when you do that, the Arduino core runs atop the Mbed RTOS that the Pico runs, so it’s very much correct to say that it “runs Arduino”. Also, you can program the Pico with the Arduino framework without using the Arduino IDE (for example, with PlatformIO).Quote from: wasedadoc on January 29, 2023, 06:49:49 amWhich doesn’t really matter much, except for the IO voltage problem (which would affect 3.3V Arduino-branded boards, too).

author: AshW
author_rank: Contributor
timestamp: January 29, 2023, 03:49:17 pm
content: Thanks for your help everyone, Tooki is correct. I am also using the exact schematic from the control your camera blog post but with a pico instead of an Arduino. Only after I tested it did I realise the pico wasn’t 5V tolerant but THE CIRCUIT DOES WORK! (For the most part).Currently I am having a new issue where unless my logic analyser (knock off 1st Gen salae logic) is plugged into the recButton port the circuit will continually trigger as the recButton like is pulled low. When hooking up the logic analyser to the recButton the line is pulled to 3.3V (as seen on an oscilloscope). Adding a 100nF decoupling cap hasn’t helped either. I apologise for my explanation but I don’t see how the logic analyser could be affecting this.I apologise if any of my terminology or explanations are insufficient as I am new to programming microcontrollers.

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 29, 2023, 04:41:18 pm
content: It sounds like you need a pullup resistor on the input. I'm not familiar with the RP2040 (the processor on the pico) but GPIO can be often configured in ways that it either has a weak internal pulldown or pullup resistor. It might well be that the code you are using did not set either and then the input is floating and can at random decide to be low or high.

author: AshW
author_rank: Contributor
timestamp: January 30, 2023, 02:56:53 am
content: I added a 10k pull up resistor (All I had on hand) and it now properly works when powered from the LANC 5V. The pin was set to use the internal pullup resistor but I guess something was going on there.Pullup code for the recButton input:Code:digitalWrite(recButton, HIGH); //turn on an internal pull up resistorThanks for everyone's help!

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 30, 2023, 05:59:43 am
content: Quote from: AshW on January 29, 2023, 03:49:17 pmNow it is wait and see for how long.The wrong IO voltage might burn out something over time.Quote from: AshW on January 30, 2023, 02:56:53 amThat says nothing. It depends on the low level implementation of the digitalWrite function for the pico if it actually enables an internal pullup.

author: tooki
author_rank: Super Contributor
timestamp: January 30, 2023, 09:53:32 am
content: Quote from: pcprogrammer on January 30, 2023, 05:59:43 amNot only is it implemented, it even supports the Pico's configurable output pin current limit:https://arduino-pico.readthedocs.io/en/latest/digital.htmlQuote

author: tooki
author_rank: Super Contributor
timestamp: January 30, 2023, 09:58:08 am
content: Quote from: AshW on January 30, 2023, 02:56:53 amThe RP2040's internal pullups are 50k, so they are probably not strong enough for many applications.

author: tooki
author_rank: Super Contributor
timestamp: January 30, 2023, 10:10:35 am
content: Quote from: pcprogrammer on January 30, 2023, 05:59:43 amI concur. 5V is way outside the absolute maximum rating for the RP2040's IO's, so I wouldn't expect it to last for too long.LANC (and its related systems, like Control-S, Control-A, etc) are open-collector buses, similar to I2C. One common way voltage conversion is done on I2C is with MOSFETs, and this approach should work here, too.https://www.hobbytronics.co.uk/mosfet-voltage-level-converter(from which the attached schematic is copied) explains the theory of operation.Or, as someone else said, just use a 5V MCU board like an Arduino Uno or nano, assuming you don't need the other features/power of the RP2040.P.S. This is a cool project for me, in that I've been wanting to experiment with Sony wired control for a while, since I have a bunch of gear that has it.

author: wasedadoc
author_rank: Super Contributor
timestamp: January 30, 2023, 12:06:45 pm
content: As already said above, a couple of resistors to reduce 5 Volts to 3 on the Pico input pin is sufficient. On the output side, the transistor is already handling the 3.3 to 5 level conversion.