Can't get an LM311 comparator to work as it appears it should - probably something obvious but due to ignorance on my part but I cant see it. Have hooked it up as follows: pins 1 & 4 to ground, 8 to 5v+, 5 & 6 not connected, pins 2 & 3 are inputs (differing voltages) and 7 the output. Cant get pin 7 to turn on though. Is there something obvious about this chip that I am not aware of that would be the problem?
Like many comparators, the LM311 has an open collector output. Did you tie a pullup resistor (try 10K) to VCC on pin 7? The following app. note may help:
I have tried as you suggested but with no luck. I have attached a diagram of what I am trying to do, hopefully you will be able to see where I am going wrong
Your problem is that the LM311 has an open loop gain of approx. 200,000.
This means that the output will swing to one or the other supply rails with a miniscule input level (approx. 25uV difference between inputs). In your case because of the resistor in the line for pin 3 it goes high turning of the LED.
You need to reduce the gain of the circuit using Feedback. Place resistors between the o/p and the input pins. Have a look at any textbook on negative feedback or search the web. Also read up on Hysteresise (probably spelt wrong) to stop the o/p oscillating at the switch over point.
There are some other problems with your circuit. The input signal range for the 311 doesn't include the supply rails (GND and +5V in your case. Note that many of the circuits in the app. note have the reference input biased around 1/2 VCC). Also, assuming the LED has a forward voltage drop of 2V, the 47K resistor can only supply ~ 60 uA; you need 10 - 20 mA for most LEDs (270 ohms should work). Here are some other links for more info:
The 311's output transistor has an open emitter as well as an open collector, so you can drive ground-referenced loads from pin 1 (the input polarity is inverted when you do this - see p.13 below)
Please excuse my ignorance but I really am a complete newbie on all of this. Just checking I understand your comments correctly, Does the voltage
for the reference input pin (pin 2 or 3) need to be approximately half that supplied to pin 8? And that the 47k resistor (by led) needs to be replaced by one of (approx) 270 ohms?
No, but it has to be within the specified signal range for the part. The datasheet specs the signal range with a +/- 15V supply, worst case 2V under VCC and 1/2V over the negative supply (GND in your case). I'm not sure how much this spec changes with a 5V supply, you may want to try the online simulator to find out.
And that the 47k resistor (by led) needs to be replaced by one of (approx) 270 ohms?