It’s been some time since I’ve played with passive components and analogue design. I will be using the humble op-amp (operational amplifier) to compare the input signals and translate it into digital output. It will save CPU resource for other important tasks.
A line following robot will detect a contrasting line, meaning black line on white background or white line on black background.
Black colour will absorb all the light while white colour will reflect all the light. By using these characteristics, we can utilize the LDR (light dependent resistor) to detect how much light is available at that instance. When it is on black, the resistance will be very high because there is very little light reflection from the black surface. When it’s on the white surface, the resistance will be low because white surfaces reflect most of the light.
Be sure to get all of the LDRs from the same shop at the same time to ensure that they are manufactured in the same batch. Doing this will ensure all of them will behave the same way and eliminates the need of tuning each sensor individually.
Let’s start with a simple comparator circuit.
A voltage reference is being sent into the inverting input while an external signal is sent to the non-inverting input. When the non-inverting input is higher than the inverting input, Vout will saturate to V+. Otherwise, Vout will saturate to V-.
With this basic idea, we can compare the input level of the LDR to a reference level.
Comparator output conditions
This is my test circuit and video for a single sensor.
I’ve used two LM324 Quad Op-Amp IC to get eight comparators.
This is my circuit on a donut board. It has 8 LDR sensors.
Super bright red LEDs to illuminate the surface. There are 9 of them so that each LDR has uniform coverage.
The reason why I didn’t use a normal copper PCB because this kind of circuit will require two layers and it’s quite a hassle.
Instead I just have jumper wires flying around the board. Very messy but it works.
A single 10k ohm potentiometer to calibrate all 8 sensors at once.
In the dark.
Here’s a demonstration video.