Posts: 1
Joined: Mon Oct 01, 2018 11:28 pm

Adjustable Photodiode input

Mon Oct 01, 2018 11:59 pm

Hi All,
I'm getting back into electronics as a hobby after many (too many) years, and my knowledge wasn't too great back then. So please excuse any misunderstandings on my part.

So I have a Pi Zero W, and I want to use it to send me the trigger time of a broken laser beam. I have the laser control side already, and the software is not an issue for me (I'm in IT). And, I have developed a basic circuit that will give me laser on/off input on a single GPIO, and abiltiy to turn the laser on/off through a GPIO output. The circuit uses a Photodiode and an NPN transistor and a couple of resistors and works well - in lowish light. The laser will be bounced off of a retroreflector.
This setup will be used in full daylight. I don't want to use Infrared because I have seen similar systems perform very badly in full sunlight. Obviously the PD will be shielded and baffled, but I'm concerned ambient light will alter the floor level of the voltage passed through to the GPIO input, possibly triggering it falsely.
What I would like to be able to do, is adjust for the ambient light. I've been experimenting with a voltage divider network using GPIO outputs to sort of simulate a 4 bit adjustable divider (on a circuit simulator). That way I could flash the laser and choose the 4 bit value that gave the best reading. I've tried a few different circuits to do this, but they never seem quite right, and I'm really just fiddling around without knowing quite what I'm doing. I've also found different advice on what the trigger voltage is - from 0.8v - 1.2v.
Any suggestions?


Posts: 66
Joined: Sun Jun 10, 2012 7:25 pm

Re: Adjustable Photodiode input

Thu Oct 04, 2018 1:28 pm

Ideally you prob want to post this problem on an electronics forum.
However I will suggest how you may go about doing this without getting into detail. You will likely need to up your game on the electronics side though?


Suggest you pulse the laser with a square wave 50% duty cycle at a standard serial bawd rate. Perhaps Eg 9600

On the PD side, you will need a simple filter circuit ( and prob some amplification) to remove all else other than the expected pulse train. This prob need to be no more than a capacitor and a resistor or two. The pulse signal will need to be cleaned up to make it a bit more like a square wave. There are single chips around than can do all of this for you. Ask & research.

You can now read the pulse train into the Pi. You could go straight into the UART and read that. Should be seeing a register with 10101010etc if it is set to the laser pulse bawd rate. If you dont see the pulse train your beam is broken ( Or you have not done it right :) )
IE you are clearly identifing that it your signal that is being detected and not something else.

Yes sounds a bit of bother doing it like this, but will have a high level of immunity to noise and any changes in ambient light conditions.

As said there are plenty of single chips about that can do this on the PD side, and it is prob a whole lot easier than it seems.

Also, final bonus note... You can now drive the laser harder as it only operating at 50% duty cycle

Good luck

User avatar
Posts: 4552
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Adjustable Photodiode input

Thu Oct 04, 2018 2:16 pm

Trigger Voltage ?
As in the voltage the gpio goes from high to low?
For me it in the 1.7V's on my light gate setup.

Stick a variable resistor in your potential divider circuit and find and test it manually you'll then have you lasers trigger point.
(Measure the voltages it triggers the gpio at too for reference)

No ambient light is going to alter that point really, though ambient may/may not be 'brighter' but you'll need another method if that happens.
Like the one above.

Return to “Automation, sensing and robotics”