For a project, I want to detect the red part on the moving disk of Ferraris electricity meter. I want to do this with an Infrared LED and a phototransistor that receives the reflected light. The amount of light received by the phototransistor will be lower when the red part is in the illuminated area. As I don't know how much light will be necessary and to cancel out ambient light, I want to dim the LED with a DAC from a Microcontroller, to let it automatically detect how much light has to be emitted.

So, I need a simple circuit to dim the LED from 0 - 70mA without using a PWM, as this would probably cause problems on the phototransistor. As simple as it seems, I couldn't find any suitable solution on the internet.

I thought using a transistor in combination with an Opamp for feedback control: enter image description here

The DAC Output will be from 0 - 3V3 and this must match to 0 - 70mA through the LED.

I'm not sure if this circuit will work, especially I don't know which FET or BJT I should use.

The LED I want to use draws 70mA at 1.5V.

The sensitivity of the phototransistor will be configured by the internal comparators of the MCU.

My question now is whether this circuit works the way I imagined it would.

Thanks a lot!


I thought of using this structure for detecting the metal disk. That guy was successful using that structure:

enter image description here

Source: https://www.kompf.de/tech/emeir.html

enter image description here

This is the ADC Reading of that Phototransistor over time.

My structure would look similar, that's why I think it would work as intended.

  • \$\begingroup\$ I see the following brochure on their products. They are weather proof, it seems. How exactly do you intend to observe the rotating disk? I think this could be an ill-conceived idea and, since details matter a lot here, I'd like to see a more complete expository on your plans. Exactly which unit are you discussing, how exactly will you place your device for observation of the wheel, etc. Like, provide distances from emitter to wheel and so on. \$\endgroup\$
    – jonk
    Nov 28, 2019 at 20:56
  • \$\begingroup\$ Your circuit will work in general. You have to be very careful about the gate- source threshold voltage of the fet, if you you plan to use a five volt supply. A higher supply voltage for the op amp would allow many more mosfets to be used. \$\endgroup\$
    – user69795
    Nov 28, 2019 at 21:36
  • \$\begingroup\$ If you want to avoid the effects of ambient light you can either shield it to reduce the ambient or modulate the infra-red so you can distinguish it from the background. \$\endgroup\$ Nov 28, 2019 at 22:06
  • \$\begingroup\$ why do you feel that the red paint will reflect less light? \$\endgroup\$
    – jsotola
    Nov 28, 2019 at 23:51
  • \$\begingroup\$ I did this for a prototype some years ago. I assume that you do not have access to the meter interior - ie meters are usually security sealed - so you may not be able to either mark the disk or be able to optimally position the sensor. I had to work through the meter front glass using the existing black on white stripe. This was feasible with adequate playing with illumination level, LED and sensor positions and a largish area light shield patch over the outside to much diminish ambient light in the sensor area. Using an oscilloscope to see what signal the sensor is "seeing" can help greatly. \$\endgroup\$
    – Russell McMahon
    Nov 29, 2019 at 7:51

2 Answers 2


With your signal you see the high levels of DC which is the sum of all reflections during the red strip including stray light not focused on the edge. As a result in the short term , the SNR appears to be 10:1 with signal = 82~92 and noise =1. The hysteresis must be greater than the noise yet much less than the drift of the signal of long term.

LEDs are known to reduce with age and heat, so pulsed current in sync with the S/H of the ADC may be considered to reduce any random noise. A secondary PD or PT could be used to keep the LED in calibration just aimed at the LED to regulate current.

Other experience

We did this 25 yrs ago successfully in every mechanical power meter (before being bought out by ITron the #1 competitor in AMR business). We discovered all the pitfalls of reading a rotating power meter disk. The stable solution that we ended up with was simple and reliable.

  • Use a Sharpie stripe with a recessed pulsed IR reflected onto a recessed Photodiode (PD) with an accurate comparator and carefully selected geometry and R value.

Infrared will not only make red look "white" most black paint will do the same. The best exception we found was a thin black stripe using a Sharpie {Pen}. In order to block stray solar light at sunset even the daylight blocking filter was not enough. Both emitter and detector had to be recessed not only to prevent scattering but to block stray light.

Being a point sources of incident light path loss is inverse squared, then the aluminum disk also scatters the light.

Photo-transistors (PT's) are great for gain but terrible for tolerance on gain while PD's are rock solid 0.5 mA/mW or as per datasheet. So you choose the best Vishay-(Sharp designed) IR emitter and IR PhotoDiode with a stable comparator to get a very high SNR that drops off dramatically with gap. We adjusted the angle between both parts to focus the reflection near 8mm gap where it was designed to peak.

We used injected a single molded plastic housing for both 5mm parts and a precise narrow angle emitter for the highest focused pulsed current to achieve high SNR off the scattered alum. rotating disk.

If you are just making one unit, you have more design latitude than designing for 1 million.

Red ink vs Black stripe

Consider a Blue LED to make the Red paint look "black" and the Aluminum look "white" if you can't make a black Sharpie stripe.

Answer to question

(which may become irrelevant)

Since a good comparator is very accurate down to millivolts, choose a current sense R that is 50 to 75mV max. Then R-divide scale your DAC Vout down to match your Isense.

  • \$\begingroup\$ I did this for a prototype some years ago. A very likely major issue for the OP is that they may not have access to the meter interior - ie Meters are usually security sealed - so he may not be able to either mark the disk or be able to optimally position the sensor. I had to work through the meter front glass using the existing black on white stripe. This was feasible with adequate playing and a largish area light shield patch over the outside to much diminish ambient light in the sensor area. \$\endgroup\$
    – Russell McMahon
    Nov 29, 2019 at 7:48
  • \$\begingroup\$ yes it may be possible to use a laser mouse which has a low res optical imager if one probes around the chip pins for reflection signals. \$\endgroup\$ Nov 29, 2019 at 13:04
  • \$\begingroup\$ I will have a look at photodiodes, this may be the better solution. That's a great idea with the laser! With a focused beam, it will be able to only detect the disk and not the white metal sheet behind it. Could you explain me, why a lower Rsense would be better? I thought that a high Voltage will increase the SNR for the Opamp. \$\endgroup\$
    – VinFar
    Nov 30, 2019 at 9:43
  • \$\begingroup\$ 50 mV drop is std for Current sensors to 1) minimize voltage drop 2) reduce waste heat 3) reduce need for a large power resistor. \$\endgroup\$ Dec 2, 2019 at 2:24

It won’t quite work the way you intend because the op-amp output can only reach about 3.5V and the MOSFET will need some Vgs to fully turn on.

If you divide the DAC output down to 0-1V (eg 47K+20K) and replace the 47 ohm resistor with 14 ohms you can then use a MOSFET with 2.5V drive. You can add 33 ohms in series with the LED to make the MOSFET run cooler. A suitable part for the latter might be the Si4866.

  • \$\begingroup\$ A rail-to-rail opamp would probably also be a good thing here. \$\endgroup\$
    – pipe
    Nov 28, 2019 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.