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.

SPICEy

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.

Advertisements

4 Comments

Filed under analog, DIY, edX, ICs, Robots

4 responses to “Voltage window comparator front end

  1. Nawaz

    Do you still have the arduino code for the flex sensor/bridge circuit??

    • Hi Nawaz, thanks for your comment.
      I will be posting the code from a robot project that uses the flex sensor circuit featured in a previous blog. Though no code is really needed, as the output of the dual comparator is either LOW or HIGH. Simply reading a pin set as INPUT will allow you to know if the sensor is being flexed. How you incorporate this into your program depends on your application. You may wish to poll the pin, or set a flag via an interrupt, as I have done. The former might work best, as I have had numerous issues with the interrupt approach. Hopefully this answers your question. If not, please write back. Thanks again.
      -Chris

      • Nawaz

        Hi chris

        I was planning on interfacing the circuit to an arduino board if it was possible to get a more accurate output, as im
        Working on a project all about six axis force sensors using quarter bridge strain gauge circuit, also looking at flex sensor circuit and flex sensor / wheat stone bridge what you have designed, will you still have the simulations and a code possible as i want to look in to it and could use it in my project report.

        Thanks nawaz

      • Hi Nawaz, reading voltage levels via ADC as you describe was outside the scope of my project. While I don’t have code to do this, can I suggest checking out http://users.ece.utexas.edu/~valvano/Volume1/E-Book/ ? I am busy working at this course to understand better how to solve the problem you’re asking. 🙂
        – Chris

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s