# Using op-amps and comparators to turn on LEDs based on sensor readings.

#### shmup

Joined Sep 7, 2021
4
Hey everyone,

so I got this project a month ago and I've been working on it but I just can't seem to figure this out. Now very important thing is that this is not a "real" project and I won't build it, it's just to teach us how to use op-amps and comparators. The project says:

"The pressure that the foot exerts on the surface is measured using 8 sensors that are arranged in the insole of the shoe
so that they measure the pressure that the foot exerts on the front, back, left and right part of the shoe and the intermediate positions.
There is also a button that is activated when the patient leans on the leg on which the measurements are performed.
When the button in the shoe is activated (when the patient leans on the foot on which the schedule is measured
loads), the pressure on all eight sensors should be measured. The sensors are resistant, linear and identical,
resistance 18 kΩ when unloaded and with a positive slope of 2 kΩ / kg load. Based
pressure differences should turn on one LED of eight, which shows the approximate position of the foot,
that is, which sensor burdened the patient the most. If the load on the two sensors is equal (in
limits +/- 10%), two LEDs should be switched on. Make a signal to turn on the LEDs
using differential amplifiers and comparators that compare the difference of two voltages with zero, and if
the difference is less than zero, turns on one, and if it is greater than zero, turns on the other LED.
"

Now for the linear reading of the force exerted on the sensor I used 2 PNP transistors to create a constant current flowing through the sensor and giving me a linear voltage.

Next I thought about finding the highest value of voltage coming from the sensors and comparing it to the voltage of the sensors and based on that I would either turn on LED or do nothing. This is pretty bad as far as I can see it and I think there is an easier way to do it.
Biggest problem I have is coming up with the logic to turn on the LED based on the difference of 2 voltages. I thought about using window comparator but I'm not sure if I can set the negative voltage as the lower bound and it seems it would take a lot of work to turn positive voltage to negative. Other thought I had is to use hysteresis comparator but I have no idea how to set that up.
This is one idea I had about logic for LED but I still need that 10% window.

This is the second idea and professor said that op-amps don't like to be in saturation and that I should use comparators instead.

Note: I don't have any prior experience building any kind of circuit, I just solved circuit problems in my 1st year.
Any help would be amazing even if it's to say how bad something here is. Thanks

#### dl324

Joined Mar 30, 2015
15,098
Welcome to AAC!
I don't have any prior experience building any kind of circuit
What comparators are you using? What do the disembodied voltage readings indicate? Are they voltages at the probes closest to them? What do you expect the comparator circuit to do?

#### dcbingaman

Joined Jun 30, 2021
720
First decide on how the entire circuit is going to be powered there are two main choices. One is to have two power forms say +/-12V with one ground or you can have one power form with one ground. It will be a little harder to implement the design with just one power form. Dual power forms make it easier to work with the op-amps. But a single power form has it's own advantages.

After that:

Being this is a fairly complex set of requirements. I would recommend you first break up the problem into its individual parts. There is a series of electronic 'black boxes' that you will want to design. Once you have a solid idea what each 'part' needs to do you can move on to developing each 'black box' using specific parts. You will want to define each one and verify proper operation using say LTSpice. Keep this in mind as well: Each 'black box' input should be very high impedance and each black box output should be very low impedance. This will allow you to develop and connect these parts without concerning yourself with loading effects. Once you have a working design you might be able to go back and optimize based on circuit loading, eliminating input and output buffers where not needed.

Last edited:

#### RBR1317

Joined Nov 13, 2010
704
There are 8 pressure points for each shoe. Is it a reasonable assumption that the entire weight of the person might be supported by just 3 of those points? And what is the maximum possible weight of a patient? (250 lbs or 320 lbs?) What would be the maximum possible resistance of a sensor?

#### shmup

Joined Sep 7, 2021
4
Welcome to AAC!
What comparators are you using? What do the disembodied voltage readings indicate? Are they voltages at the probes closest to them? What do you expect the comparator circuit to do?
I don't plan on using any specific comparators since I don't have to compensate for them. I would use "conceptual" comparators since I'm only doing this on paper. I don't have a patient and I won't build this in a lab I don't need to worry about exact components it's just a "theoretical" project that I have to create a schematic for. So I guess I could use any comparator that I want as long as it works.

I expect comparator circuit do decide which LED to turn on which I sort of built already ,If it's good, now I just need to add that +/-10% voltage limit so they both turn on if both voltages are are close to each other in that limit range.

Apologies for the delayed response.

#### shmup

Joined Sep 7, 2021
4
There are 8 pressure points for each shoe. Is it a reasonable assumption that the entire weight of the person might be supported by just 3 of those points? And what is the maximum possible weight of a patient? (250 lbs or 320 lbs?) What would be the maximum possible resistance of a sensor?
Short answer is I don't know.
I don't have information about the sensor and I'm guessing that the maximum weight is something average.
As I've said before, I'm not building this project in a lab, I just need to create a simple schematic that you could later on redesign to compensate for real components ( max weight, different sensors ,etc.). This project is given to us to test our knowledge of op-amps and comparators and how to apply them to create something useful.

Apologies for the delayed response

#### shmup

Joined Sep 7, 2021
4
First decide on how the entire circuit is going to be powered there are two main choices. One is to have two power forms say +/-12V with one ground or you can have one power form with one ground. It will be a little harder to implement the design with just one power form. Dual power forms make it easier to work with the op-amps. But a single power form has it's own advantages.

After that:

Being this is a fairly complex set of requirements. I would recommend you first break up the problem into its individual parts. There is a series of electronic 'black boxes' that you will want to design. Once you have a solid idea what each 'part' needs to do you can move on to developing each 'black box' using specific parts. You will want to define each one and verify proper operation using say LTSpice. Keep this in mind as well: Each 'black box' input should be very high impedance and each black box output should be very low impedance. This will allow you to develop and connect these parts without concerning yourself with loading effects. Once you have a working design you might be able to go back and optimize based on circuit loading, eliminating input and output buffers where not needed.
I think I would use +/-12V since I would have a bunch of op-amps. I did that, I broke it into 3 sperate circuits 1 for getting linear voltage across the sensor ( const. current), 2 for getting the highest voltage out of all 8 ( which I think I might not even need) and 3 is a circuit using op-amps and comparators to decide which LED to turn on.
I just don't know if what I've built would work and how to add that +/- 10%V so that both LEDs turn ON when 2 voltages are close to each other and within that limit and other time it's just 1 LED turned on, the one with the most pressured sensor.

Apologies for the delayed response

#### dl324

Joined Mar 30, 2015
15,098
I don't plan on using any specific comparators since I don't have to compensate for them.
It makes a difference which comparators you're using in your simulation and what the supply voltages are. Traditional comparators have open collector outputs. Whether ground is allowed on the inputs depends on the comparator type and supply voltages.

We also need to know what your simulator does for input offset voltage because you've set both inputs to the same voltage and the output can't be determined.

#### dcbingaman

Joined Jun 30, 2021
720
I think I would use +/-12V since I would have a bunch of op-amps. I did that, I broke it into 3 sperate circuits 1 for getting linear voltage across the sensor ( const. current), 2 for getting the highest voltage out of all 8 ( which I think I might not even need) and 3 is a circuit using op-amps and comparators to decide which LED to turn on.
I just don't know if what I've built would work and how to add that +/- 10%V so that both LEDs turn ON when 2 voltages are close to each other and within that limit and other time it's just 1 LED turned on, the one with the most pressured sensor.

Apologies for the delayed response
I would recommend you 'test' your circuit(s) with LTSpice. This will give you a confidence in knowing if your circuits will work properly (apart from actually putting it together on a solderless breadboard). It will also give you some experience with LTSpice (assuming you don't already have it).