Sample multiple photoransistors from one pin - Page 1
Forum section: electronics / projects

author: mower
author_rank: Contributor
timestamp: November 05, 2023, 07:41:09 am
content: Hello Everyone,I am wondering if I am going about this the right way. My goal is to be able to sample multiple phototransistors independently using 1 ADC pin on my MCU, the RP2040/RPi Pico. What I am thinking is that the power for each phototransistor will be sourced from a GPIO pin, and only one sensor will be active at a time. Schottky diodes will prevent each phototransistor from interfering with one another. My schematic is attached.More information about my application: I am using IR LEDs and phototransistors as distance sensors for a micro-mouse robot. To increase the brightness of each IR LED, they will be pulsed for <100 uS at a high current, up to 1A. Since the IR is on for such a short time, the phototransistor circuit will need to respond fast enough to be sampled by the ADC. One phototransistor would be turned on at a time, and after waiting for an appropriate rise time, it would be sampled, and then turned off, next one turned on, etc.Does anyone have any suggestions, criticism or helpful literature?Thank you in advance for your help!

author: Psi
author_rank: Super Contributor
timestamp: November 05, 2023, 07:51:58 am
content: I would probably look at having a extra nfet on each phototransistor to gnd to switch it on, instead of the diodes and separate pullup resistors.You avoid the annoying diode vdrop variations with current and variations between diodes, so your accuracy is better.And you are adding 3 parts and removing 5 partsAlternatively, you could use the GPIO to pull to ground and enable a channel, instead of the fets.Then you only need 1 resistor and the 3 phototransistors.Set one GPIO to output low to select the channel and set the other 2 to highZ input mode.

author: Ian.M
author_rank: Super Contributor
timestamp: November 05, 2023, 08:06:10 am
content: The original is probably not going to work well, if at all, as SS12 Schottky rectifier diodes are fairly leaky, have significant junction capacitance, and you are using fairly high value pullup resistors.I'd go with Psi's alternate suggestion: Use a single fixed pullup to the ADC pin, connect all the phototransistor collectors to it, and switch the emitters of the phototransistors by connecting them to GPIO pins, set as inputs to disconnect the inactive phototransistors, and one set as output low to select the active phototransistor.Another potential issue is sensitivity to background illumination. If the ambient light level is high, you may need the capability to switch in a lower value pullup to get the ADC reading back up to midrange with the IR LEDs off. Again use a GPIO, connected to the top end of a supplemental lower value pullup resistor, but this time, set it output high to activate and as input to deactivate.

author: mower
author_rank: Contributor
timestamp: November 05, 2023, 08:20:50 am
content: Quote from: Ian.M on November 05, 2023, 08:06:10 amYeah I should have mentioned, I haven't researched component values/specific devices yet, just wanted to draw out the schematic and theses were the components that popped up in Altium. We will also have 3-6 IR sensor pairs, I just drew 3 to get my idea across.Quote from: Ian.M on November 05, 2023, 08:06:10 amI really like the sound of this idea, saves a lot of components and complexity.Quote from: Ian.M on November 05, 2023, 08:06:10 amYes, this is exactly why I am now planning on pulsing high brightness IR LEDs, and taking control readings with the IR turned off. At our last competition, the room was lit entirely by sunlight at a 45 degree angle, wrecking havoc on everyone's mouse. My goal is to have our new mouse work outdoors in full sunlight and indoorsHaving control of the pullup to readjust the adc range and sensor's sensitivity sounds like a good stretch goal.Thank you everyone for your great ideas!!!!

author: PCB.Wiz
author_rank: Super Contributor
timestamp: November 05, 2023, 08:30:43 am
content: Quote from: mower on November 05, 2023, 08:20:50 amThat's tough, you will likely need a synchronous detection on a carrier design for that to work.ie you modulate the IR and look for the change caused by the modulation, and remove the DC sunlight.If the environment has sudden changes in light, by location/time, that's even tougher, as the unwanted signal is no longer simple DCPhoto transistors are high capacitance devices, so emitter switching may not work too well, a simple CMOS analog switch with low Cs may be better,

author: mower
author_rank: Contributor
timestamp: November 05, 2023, 08:47:42 am
content: Quote from: PCB.Wiz on November 05, 2023, 08:30:43 amBecause the IR is being modulated around 1KHz at a very low duty cycle (1%), I am hoping there is enough time to cycle between phototransistors without their rise/fall times being a problem. In addition, I don't actually need accurate distance readings from the sensors, I need to know if there js a wall or not, which is more binary. My plan is to sample each phototransistor with the IR on and off, in order to take a control reading of the background IR and a reading to determine the presence of a wall.Thank you for raising the concern of phototransistor capacitance, I think I simply have to build my circuit to see how it performs.