PDA

View Full Version : Problem, LM358 comparator circuit


Yuright
05-01-2011, 06:09 PM
I have designed this circuit to compare the input from a pot in a control console and a feed back pot on a hydraulic pump. The pump is a hydrostatic design and controlled by positioning a swashplate. The swashplates position is changed by energizing and de-energizing two solenoid valves. These valves receive their command signals from the comparator. When a position is selected in the console the comparator sees the difference in the inputs and energizes one of the two solenoids which through the action of the swashplate moves the feed back pot. When the feedback pot inputs the same value the comparator outputs go low de-energizing the solenoids. I put this into a breadboard and it worked perfectly. When the two pot values equaled out both outputs went low. After putting my circuit on a pcb and testing it I found both outputs went high instead of low, which is unacceptable. I recreated the circuit in my breadboard and it is doing the same thing. I can't understand what changed, does anyone have an answer? Also the two trimmers in the schematic are for adjusting the range of output to match the feedback pot. thanks

Bill_Marsden
05-01-2011, 06:21 PM
Just curious, do you have any filter caps anywhere?

Decoupling or Bypass Capacitors, Why? (http://forum.allaboutcircuits.com/showthread.php?t=45583)

Yuright
05-01-2011, 07:11 PM
No I don't. I am a beginner in electronics and have been learning over the past year. No formal training just what I get from the internet. I came up with this design by trial and error and what I found on the internet. I have a photo of the breadboard when it was working and duplicated it this morning but still the problem exists where instead of outputs being low when the inputs match they are high. As you can see I have two 33k resistors in the feedback to give me the hysteresis I wanted. Basically the circuit behaves the same way it did before only inverted.

I missed your link to article on caps. Interesting. I put a .1 uF cap in power supply but no change. I guess my question is how is my circuit supposed to behave? Is the high output what you would expect when inputs are the same?
I built this thing in Yenka and got the same results, outputs high. It looks like maybe my breadboard was the anomaly. Any ideas would be appreciated.

Audioguru
05-01-2011, 07:18 PM
Your opamps have negative feedback through the 33k resistors so they are not comparators. Pin 2 and pin 6 on the opamps are an extremely low input resistance due to the negative feedback. The opamps will work as comparators if the 33k resistors are removed.

Hysteresis is provided by positive feedback, not negative feedback.

Yuright
05-01-2011, 07:40 PM
Thanks I shall experiment.

shortbus
05-01-2011, 10:45 PM
When you went from breadboard to PCB, is it possible that you switched the signals to the inverting and non-inverting pins on the comparator/op-amp? That would also explain the negative and positive feed back change.

Yuright
05-02-2011, 01:26 AM
Since my finished board works correctly other than it isn't inverted, I will add an additional circuit which will invert the output. Messy but easier than building a new board. By the way I tried switching the inputs but it didn't make any difference. My goal with this device is to get zero output when the two pots are close to the same output. Any more suggestions or comments are welcome. Thanks

Bill_Marsden
05-02-2011, 01:39 AM
Just switching the inputs would do the same thing. It is the nature of op amps, they can invert or non-invert based solely on that.

Yuright
05-02-2011, 12:49 PM
Thanks Bill but I am not sure it applies in this case as I am using both op amps in the LM 358 and have pins 5 and 2 in common and pins 6 and 3 in common which on the bread board, gave me the desired effect of getting an output from one or the other op amp depending on which direction I moved the command potentiometer. I think I had found a similar schematic on line that gave me the idea to wire it this way. It was a circuit using two op amps to provide directional control of a motor through an H Bridge.


I just found a link to what I was talking about. http://www.solarbotics.net/library/circuits/bot_walker_quadopamp.html

I remember visiting this site but it was a few months ago and thanks to a laptop crash most of the info from my research was lost. Not sure this will solve my problem but I can see some changes that need to be made. In my circuit I have feedback on both op amps which may be why switching inputs won't invert the output. Back to the bread board.

Audioguru
05-02-2011, 04:17 PM
You copied the circuit wrong so that the incorrect pin numbers are connected.

Yuright
05-02-2011, 10:52 PM
Thanks Audioguru, I made the changes and found it still did not do what I want. The good news is I have been playing around with this thing all day and think I have found the problem. My general lack of understanding in the basics of electronics. In this case negative and positive voltages. I failed to recognize that when the output of the op amp is low it provides in this case -24 volts which is an ample amount to pull the gate on the P Chan mosfet (IRF5305) down and switch it on. Because I am using 24 volts I installed a voltage divider to keep the gate below -20V. So now my circuit is even simpler having removed the intermediate BS170's. Now if only I could modify the board I have already built.

Yuright
05-03-2011, 11:45 PM
Success, I removed the BS170's and a couple of resistors and installed jumpers. I tested the board and it works as I had intended. Hopefully it will work in the machine. I still don't know why the circuit had inverted though but will continue to experiment. Just glad I didn't have to scrap the board. Thanks for your time.

SgtWookie
05-20-2011, 01:30 AM
Thread is continued here: http://forum.allaboutcircuits.com/showthread.php?t=54714