Best way to connect Photodiode to get Boolean result?

I’ve been having some trouble getting reliable results with an IR photodiode. Essentially I’m trying to use it as a beam-break detector, so it needs to be fast, which rules out analogRead.

At the moment I’m trying DATAPIN → PHOTODIODE → GND, then setting INPUT_PULLUP on the pin.

I have a feeling this isn’t the best way. My next thought is to use a transistor but with no experience with them, I wouldn’t know where to start.

Online searches show a confusing amount of options which go way over my head as I’m quite new to electronics.

Any thoughts or ideas?

I’ve had a suggestion of a Schmitt Trigger, but I’m unsure how to use one of them? I found this: 74HC1G14GW - Inverting Schmitt trigger | Nexperia but I can’t find how to wire them up properly. I’m very new to this.

TLDR: I need a reliable way of detection a photodiode change for use within a Nerf Ammo Counter.

Hi,
first of all I suggest you read the topic:

Then help us to help you:
Inform which arduino is using;
What is your sketch;
What sensors are using;
The eletronic schematic.
What is “Nerf ammo counter.”; etc etc …
The more information you provide us with, the better our help will be.

RV mineirin

  • IR Photodiode is a PT204-6B
  • Arduino is a Seeeduino Xiao

I’m looking for a correct schematic to use for a beam-break using an IR LED and the IR Photodiode to have a boolean result.

I’d connect the photodiode to give 1’s n 0’s out just like this microphone module:

The bare minimum is something like this:
Which is a schmitt-trigger with hysteris

I think the supply-voltage does not have to be 12V.
Supplying the OP-amp with 7V results in an outputvltage of 5,5V
So maybe supplying the OP-Amp wih 6,5V will be more secure

An OP-Amp is an integrated circuit which has quite some complexity but you don’t have to care about the inner circuitry
it is a small IC looking like this
image

and this is the connection and pinout-picture
image
An LM358 has two OP-amps.
The photodiode uses only one of the two OP-amps (= the triangle)
best regards Stefan

A phototransistor would be easier to work with. Also, analogRead takes about 0.1ms. Nerf ammo traveling at 50 ft/sec would break the beam for something like 4ms … unless you’re using one of these!

Sadly I need to deal with darts of up to 140 ft/sec. I’ve had another suggestion of using a PhotoTransistor and a 38Khz IR LED, but I’m not sure how that would work for dart detection and beam break.

All the code I’ve tried so far has to use an Interrupt for reliable dart detection and I don’t know how the transistor would work with that?

I have a working voltage choice of 3.3v and 5v due to constrained space, will those voltages work with it?

A 2" dart … that’s 1.2ms (12x slower than analogRead).

EDIT: Not pushing analogRead as part of the solution, but the serial plotter could make a good “oscilloscope” for this project.

So you think something like this: Photodiode - The Arduino Workshop would be fast enough?

Problem is that I have to do a comparison of values then rather than just a high-low.

I have done beam break stuff using this technique and it solves many problems. Think of how well your TV remote control works… unless you can control many factors, this will win.

It may not work for you, however, as you must not only have the 38Khz carrier, but some kind of modulation. The little receivers for 38Khz do not work otherwise.

I used a 1000 Hz square wave, my transmitters were made from two '555 oscillators. I also directly synthesized the full signal using a microprocessor.

The detector was either a '555 “missing pulse” detector or, again, directly handled in code.

But I was watching for a cat to cross the beam - 140 feet per second, 2" dart means (agree @dlloyd) only 1.2 mS in the beam, so your modulation would have to be perhaps 5x, which is something I do not know if those receivers can do. The data rate of normal TV remote is similar to 1000 Hz, so…

But I had to say that the modulated beam when you can use it works a treat.

a7

Very, very fast, but photodiodes are sensitive and difficult to work with directly … they need an amplifier circuit or module. Take a look at this project that uses a phototransistor which is easier to work with.

You need to use a comparator for this, maybe you need to amplify the signal first (transimpedance amp using an opamp is the best method), then a comparator to
convert an analog signal to a logic signal. LM339 is a commonly used quad comparator
chip, cheap and good all-round performer. The output of a comparator needs a pullup,
typically a few kohms to Vcc.

Trying to use an opamp (particularly a very slow opamp like the LM358) as a comparator
is shonky at best - far too slow, not guaranteed to be able to create a clean logic HIGH…