Tag Archives: operational amplifiers

Voltage window comparator front end

The Problem

The comparator circuit presented in the course detected flex in the sensor for only one direction, as this is a single rail circuit. This presents a challenge, as my robot platform uses a single long whisker straight out the front to detect collision. An obstacle could strike the end of the sensor and bend it in either direction. Thus it is crucial that the micro controller be able to read a flex in the sensor in either direction.

My original flex sensor bridge circuit with comparator front end.

The Question

Having measured the voltage differential across the Wheatstone bridge flex sensor circuit, I noticed that a negative voltage when the sensor was flexed in the direction opposite from what the datasheet advises. It stood to reason that this change in voltage might be detectable.

After posting my circuit and question on the discussion board, Thomas_91 was kind enough to supply the following voltage window circuit. It is a dual comparator circuit that detects an upper and lower reference, and gives a HIGH when within the window of the reference and LOW when outside the reference, or the inverse. In my case, I want to measure when the sensor is at rest, and provide a HIGH signal when outside the window. This solves my design problem of wanting to detect a flex in either direction.

Thomas_91’s circuit posted on the EE40LX discussion board. He used a sine generator to demonstrate the window effect.

Thomas_91 produced a graph to demonstrate the window effect using a sine voltage generator.


Having installed LTSpice but never really used it in solving a problem, I recreated Thomas_91’s circuit, and adapted it for my purposes. Verifying the window and threshold behaviours in simulation, I breadboarded the circuit and included trimpots to adjust the upper ceiling of the voltage reference. The flex sensor is measured with a trimpot for adjustment to its balance.

My window comparator circuit. R6 = flex sensor, R9 & R2 = trimpots.

My voltage window circuit with flex sensor (out of frame) and trimpots.

I created a small program in Arduino to read the output of the dual comparator on a digital pin. After fine tuning the trimpots, I was able to get a very satisfactory sensitivity range.

The Sensor Rig

A nut captive in some hot glue allows mounting on the front end of the robot.

After reading the many comments about how this particular flex sensor can break easily, I followed the instructor’s example and mounted my sensor on a tie wrap. Smooth sided tape was used to fashion a sheath that allows the sensor and tie wrap to bend together without bunching up.

The flex sensor bends together with the tie wrap without bunching up thanks to the green sheath. The sheath is affixed to the tie wrap with hot glue.



Filed under analog, DIY, edX, ICs, Robots

EE40LX: two sensor bridges with power blocking


Two photo sensors with bridge and comparator front ends. Power supplied by a MCU pin, which switches high only when measurement is needed. This reduces overall power consumption, which is 11.355mW for both bridges.


Leave a comment

Filed under analog, edX, ICs, micro-controllers, Robots, Uncategorized

BerkeleyX: EE40LX: comparator front end


To be interfaced with a digital input to detect light over a certain threshold.

Leave a comment

Filed under analog, edX, Robots