WattsThat:
An Arduino pin configured as an input will not source current unless it is declared as “INPUT_PULLUP”. As connected, you don’t need that because the transistor in the opto will source current to create a HIGH input state, the resistor will sink current to create a LOW.
But...
I see R1 and RL but not R2. Assuming RL is in fact R2, the values don’t past the smell test if the coupler has a CTR of less than 100%. If your 1LQ1 is in fact at low end of its spec range, dumping 10ma in will only provide 2 ma on the output. Voltage wise, that would give you about 1 volt across 470 ohms which would cause, well, keep reading.
Why do you believe “the voltage level is fluctuating”? Are you using a print statement to print the digital value? Measure the pin with a multimeter if you have one. I would expect the input to be changing state if the opto cannot source enough current to bring the voltage above the digital input threshold voltage which should be about 1.1 volts.
Edit PS: You need very little current to activate an input. Using 5K for R2 is more than adequate to insure a high input level.
G'day WattsThat
Firstly, thank you for the help
commentary follows
An Arduino pin configured as an input will not source current unless it is declared as “INPUT_PULLUP”. As connected, you don’t need that because the
A: correct, however the data sheet for the ILQ1 optocoupler suggests that if phtotransistor emiter connected to a TTL input (know that nano 33 BLE uses 3.3 VDC as opposed to 5 VDC), the IC input (nano 33 BLE) should produce enough current (source) to flow through R2 (or RL) and not exceed the low voltage threshold to detect as LOW state
I see R1 and RL but not R2. Assuming RL is in fact R2,
A: correct, R2 and RL are the same
the values don’t past the smell test if the coupler has a CTR of less than 100%. If your 1LQ1 is in fact at low end of its spec range, dumping 10ma in will only provide 2 ma on the output. Voltage wise, that would give you about 1 volt across 470 ohms which would cause, well, keep reading.
A: as per ILQ1 documentation and calculation, after degeneration CTR estimated to be 50%.
Assuming LED side of the phototransistor current is 10 mA, then the transistor side of the phototransistor will yield to 5 mA
The resistor calculation as per Vishay documentation.
Assuming we have 5mA flowing through the collector and emitter of the phototransistor
RL < VIL / IIL = 0.3 x 3.3 VDC / 2 mA < 495 ohms
RL > VIH / IIL = 0.7 x 3.3 VDC / 5 mA < 462 ohms
Hence, adopted RL = 470 ohms
Why do you believe “the voltage level is fluctuating”? Are you using a print statement to print the digital value? Measure the pin with a multimeter if you have one. I would expect the input to be changing state if the opto cannot source enough current to bring the voltage above the digital input threshold voltage which should be about 1.1 volt
when the phototransistor is cut, put a multi meter to measure the voltage at the nano 33 BLE configured as input, and the reading varies around 0 VDC????
I am assuming very low current being sourced by the nano 33 BLE, flowing thorugh RL, not enough to hold the voltage level below 0.3 x 3.3 VDC = 0.99 V
For nano 33 BLE read HIGH, when the phototransistor is saturated, is around 3.24 VDC
I've just measured now with a multi meter, and works fine
Edit PS: You need very little current to activate an input. Using 5K for R2 is more than adequate to insure a high input level.
A: according to the Vishay optocoupler ILQ1 datasheet, for the IC (nano 33 BLE) to read a LOW state, the IC must produce a very low current (source).
Anyway, have fitted a 5K resistor and still no LOW state read, when the phototransistor is cut
Thanks in advance for any help