Changing Scale on voltage divider.

Thread Starter

Pepe333

Joined Feb 12, 2018
86
Hi all!,
I have a photodiode, and I want it to work in 2 ways:
-Connected to an ADC to obtain a value from light level.
-Connected to a transistor to obtain a digital signal 1/0.

The easy way will be to have 2 photodiodes, but itsn't possible.
I think in having to different scales with 2 voltage divider. Selecting R1 I'll have an analog reading the ADC, and selecting R2 I'll have a switching value, by the transistor, to obtain digital input for a GPIO.

In my circuit, I have a PCF8574 (I/O I2C expander) that work open drain.

How can I achieve it?

(circuit attached)
 

Attachments

Last edited:

ericgibbs

Joined Jan 29, 2010
13,615
hi Pepe,
As this is homework I will just give a hint.

What will the voltage be on the transistors Vbe junction, when in the ADC mode.???

E
You posted:
BTW: -Connected to an ADC to obtain. To obtain what.???
 

Attachments

Thread Starter

Pepe333

Joined Feb 12, 2018
86
Hi ericgibbs!
It will be from Vcc (3.3v) to 0v depending the light on the photodiode.
But when in ADC mode, I'll dont care about the GPIO. And when in digital mode I'll dont care about ADC.

Connected to an ADC to obtain a value from the light level. (sorry)

What I need, in digital mode, is to have a "0" when light becomes very strong, and "1" rest of the time.
 
Last edited:

ericgibbs

Joined Jan 29, 2010
13,615
hi P,
How can the ADC signal be from 0v to 3.3V. ???
The Vbe junction is like a forward biassed diode across the ADC output line, as you may know a diode will limit the Vbe to approx +0.65V.

E
 

Attachments

Thread Starter

Pepe333

Joined Feb 12, 2018
86
Yes, You're right!
Maybe controling the emitter with an I/O from the PCF8574.
When I need ADC, I'll put "C" high. And when need the digital output turning "C" to low.
 

Attachments

Thread Starter

Pepe333

Joined Feb 12, 2018
86
Thank you very much!
Really I'm using the PCF8574 with some inputs/outpus and it works properly.
My problem is how to make active the voltage divider on R1 or R2 without using relays.
 

Thread Starter

Pepe333

Joined Feb 12, 2018
86
(SOLVED)
I think the solution was work with collector comun, not emitter comun.
Now the circuit works like expected.
:)
 

Attachments

ericgibbs

Joined Jan 29, 2010
13,615
hi,
Pleased to hear that your circuit works OK.
Do you plan to carry out performance tests , using different light intensity levels.?
E
 

Thread Starter

Pepe333

Joined Feb 12, 2018
86
Hi,
I tested from the ADC. I achieve 0 to 990 (1024 max) when point with a laser to the photodiode. Enough. I need the ADC to see ambient light variations. And the digital output stays on 0 with ambient light and change to 1 when pointing with the laser. Just what I wanted to make a laser barrier.

Thank you very much, ericgibbs, for your help.
 

crutschow

Joined Mar 14, 2008
27,712
I need 2 inputs, one analogic and one digital, from the photodiode.
Please, what you mean?
You don't need two inputs, just two outputs.

I mean, you said you want a digital output when the light is above a certain level, so why not detect that level with the microprocessor from its ADC readings, and generate a digital signal at one of the microprocessor outputs if the ADC count is above that level?
It's simpier and more accurate than using a transistor.
 

Thread Starter

Pepe333

Joined Feb 12, 2018
86
I understand.
The thing is velocity. When I read trough ADC, it takes a lot of time (hundred of microseconds). But with a digital level I can use an interrupt associated to a GPIO. The fall/rise time for a photodiode is some nanoseconds, so I can detect something really fast breaking the barrier.
 

crutschow

Joined Mar 14, 2008
27,712
Okay.
If speed is important, than you do need separate inputs.
To allow easy adjustment of the trigger threshold, you might consider a high-speed comparator.
How fast a response do you need?
 
Top