

Objective
Design an IR sensor to count the no. of pills dispensed for a smart pill dispenser. Utilize the max voltage of the MCU's ADC for the highest resolution.
Design
Op-amp: LM358 operation amplifier for signal amplification
IR Led to emit IR light and Photodiode to sense the IR light, placed parallel to each other
Voltage divider for feedback to set gain of 9.34, resulting in a signal of 0 - 4.667V, which utilizes 93.34% of the ADC range.




Validation
The circuit was designed in CircuitLab simulator, and a DC sweep of photocurrent from 0 to 50 uA results in a signal output of 0 to 4.667 V, and the relationship is linear.


Calculations

