clam-:
Is there some basic diagnosing I can do with the C and E connections? Like if I test resistance with a multimeter, it should react shouldn't it?
Yes:
- If you can access the "A" and "K" pins on the Opto [unclear from the diagram], then using a Multimeter, measure the voltage across the "A" and "K" pins. There are two conditions to test for:
- Current flowing - to turn the inner LED "ON".
- No current flowing - to turn the inner LED "OFF"
When current is flowing, the voltage should be around 0.95 to 1.2V . When the current isn't flowing, the voltage should be around 0.
If you see a voltage that is lower than 0.95, then, consider that there might not be enough current to properly light up the internal LED. The best test would be to actually measure this current, but that requires a break in the circuit, and if this is on a PCB, then that might be difficult. If this is a prototype, with wires that can easily be lifted, then measure this current, and note it for later. - Set the meter to Diode test or Continuity [if your meter doesn't have any of these settings, then set it to Resistance/200 and be sure to do this test twice, once with the probes one way, and again with the probes reversed -- unless you happen to know the polarity of your probes when the meter is set to Resistance]. Then, with the output of the Opto disconnected, with the negative probe to the 'E' pin, and the positive probe to the 'C' pin, see what reading you get when you apply current to the inner LED [i.e. the "A" and "K" pins]. If it's working, and if you're using the Diode tester setting, you will see a voltage of around 0.4 (might be lower -- 0.4 is the Max condition)
-- otherwise you will get a continuity reading. It might not cause the beeper to sound, but you will see numbers -- when I tried this, I saw anything from around 200 to around 90, but your experience might be different -- as long as it starts to show numbers]. - With the output of the Opto disconnected from the Arduino, the voltage at the Arduino pin should be at or near 5V. If it isn't, then the pin is either bad, or it isn't configured properly [see #5, below].
- If you were able to measure the current going through the inner LED, then, with the Opto output connected to the Arduino, measure the current coming out of the Collector [i.e. the "C" pin]. The current at the Collector should be at one half [or less] of the current at the Input of the Opto [this device has a minimum CTR of 50%]. If this current ratio is not Iout/Iin <= 0.5, then you will need to increase the current going into the Opto at it's input. In fact, the current should be set for the worst case condition at the input of the Arduino. The worst case is a 20k pull-up resistance, which would cause around (5V-0.4V)/20k = 230µA at the Opto output [the 0.4V value is the Max VCE(sat) of the Opto's output transistor]. Which means, the current at the input [the current driving the internal LED] should be at least 230uA/[50%/100] = 460µA
- With the output of the Opto connected to the Arduino, the voltage at the Arduino pin should toggle between around 0 to ~5V, when the current is applied and removed from the input of the Opto. If it doesn't, then something is wrong with the Opto, or the Arduino pin is either bad, or not configured properly [See code, below]
#define OPTO_READ_PIN 6 // Or whatever number it actually is.
const bool OPTO_OUT_HIGH = true;
const bool OPTO_OUT_LOW = false;
bool optoState;
void setup() {
pinMode(OPTO_READ_PIN, INPUT_PULLUP);
delay(1); // Give this transition time to "settle"
// Get the initial state of the Opto-isolator output
optoState = digitalRead(OPTO_READ_PIN);
}
void loop() {
// Read the current state of the Opto-isolator output
optoState = (bool)digitalRead(OPTO_READ_PIN);
// Make productive use of this value. [This could be used as a nice little test!]
if (OPTO_OUT_HIGH == optoState) {
// Light the onboard LED if the Opto output is High
digitalWrite(LED_BUILTIN, HIGH);
}
else
{
// Turn the onboard LED OFF, if the Opto output is Low
digitalWrite(LED_BUILTIN, LOW);
}
}