Resistor calculation using Vishay Optocoupler ILQ1 & nano 33 BLE

hi all,

Encountering difficulties in calculating the R2 to be connected between the output of the Vishay ILQ1 optcoupler and nano 33 BLE.
Please refer to attached sketch

A/ Input ON state = 12 VDC / Output ON = 3.3 VDC
When the switch closes, +12 VDC is applied to R1, 10 mA current flows and the phototransistor is saturated.
Voltage at pin 16 = 3.3 VDC
nano 33 BLE reads the state of the digital input as HIGH

B/ Input OFF state = 0 VDC / Output OFF = 0 VDC
When the switch opens, no voltage is applied to R1, no current flows and the phototransistor is open.
Voltage at pin 16 is approximately 0 VDC, but the nano 33 BLE does not read as LOW???
it appears the voltage level is fluctuating??

Calculated R2 as follows:

R2 < Vil / Iil = 0.3 x 3.3 VDC / 2 mA = 495 ohms
R2 > Vih / Il = 0.7 x 3.3 VDC / 5 mA = 462 ohms

have connected a 470 ohms between optocoupler pin 16 and ground, but nano 33 BLE does not read as LOW when switch is open???
Please help.

Sources:
A/
Vishay Semiconductors
ILQ1

B/ nano 33 BLE
https://store.arduino.cc/usa/nano-33-ble

C/
VISHAY SEMICONDUCTORS
Optocouplers and Solid-State Relays
Application Note 02

While I do not know the exact details of the Nano 33 BLE, I would say the diagram is wrong.

The optocoupler output transistor goes between an input pin and ground, using pinMode of INPUT_PULLUP. You use the internal pullup of the Arduino. No other is needed.

Paul__B:
While I do not know the exact details of the Nano 33 BLE, I would say the diagram is wrong.

The optocoupler output transistor goes between an input pin and ground, using pinMode of INPUT_PULLUP. You use the internal pullup of the Arduino. No other is needed.

thanks Paul,
According to the documentation, I can wire the emitter of the phototransistor to the input of an IC such as the nano 33 BLE + connect a resistor to the ground for LOW state nano 33 BLE.,

The problem lies when the phototransistor is in a cut state (open), and the nano 33 BLE needs to supply current to flow through R2, and still maintain LOW state

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.

The following is taken from your data sheet:

I would configure it for saturated switching and either use a 10K pullup or use the internal pullup as Paul mentioned. You only want one of two states.

Ron

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

Ron_Blain:
The following is taken from your data sheet:

I would configure it for saturated switching and either use a 10K pullup or use the internal pullup as Paul mentioned. You only want one of two states.

Ron

Hi Ron, thanks for the suggestion.
I have adopted Fig. 5 and now it works fine!

When the switch that controls the 12 VDC supply, to the LED side of the phototransistor is:
1/ switch open, phototransistor is cut and the voltage at the nano 33 BLE is HIGH (3.3 VDC), since current flows through the pull up resistor connected between 3.3 VDC and internal digital input of the nano 33 BLE)
2/ switch closed, phototransistor is saturated and the voltage at the nano 33 BLE is LOW (0 VDC)

by adopting Fig. 5, voltage level at the nano 33 BLE pin is always fixed at:

  • approximately 0.0 VDC: phototransistor saturated having VCEsat connected to the pin
  • approximately 3.3 VDC: phototransistor cut and the 3.3 VDC - voltage drop across pull up resistor.

since when the switch closes, nano 33 BLE detects approximately 0.0 VDC, we need to invert the logic by software

  • when switch closes, nano 33 BLE detects LOW state at its input pin
  • when switch opens, nano 33 BLE detects HIGH state at its input pin

thanks to all for the assistance

Capture01.JPG

Capture01.JPG

Part of the point was that a 5k resistor - whether as pull-up or pull-down - is unnecessarily low and requires you to take into account the worst case CTR of the opto-coupler. The internal pull-up (well of the ATMega328 at least, I do not as I say, know about the Nano 33 BLE) approximates 47k, so requires very little current to switch.

Of course having the optocoupler pull to ground inverts the logic, but this is never a problem as it is always perfectly trivial to adapt the code to this. :sunglasses:

Paul__B:
Part of the point was that a 5k resistor - whether as pull-up or pull-down - is unnecessarily low and requires you to take into account the worst case CTR of the opto-coupler. The internal pull-up (well of the ATMega328 at least, I do not as I say, know about the Nano 33 BLE) approximates 47k, so requires very little current to switch.

Of course having the optocoupler pull to ground inverts the logic, but this is never a problem as it is always perfectly trivial to adapt the code to this. :sunglasses:

thanks Paul for the response
documentation for the ILQ1 indicates Current Transfer (CT) ratio at IF = 10 mA
worst case scenario is for CT = 50%, hence current flowing through the phototransistor = 0.50 x 10 mA = 5 mA
(source: https://www.vishay.com/docs/83646/ild1.pdf)

Having the phototransistor emitter connected to 0 VDC and collector direct to the nano 33 BLE (GPIO port configured as Digital Input), makes the circuit simpler.
Using the Arduino C like language, very trivial to invert the logic
question
1/ need to find the internal pull-up resistor for the GPIO ports of the nano 33 BLE?
(researched exhaustively the documentation, unable to find it)
thanks in advance for any help
Trajano

“ need to find the internal pull-up resistor for the GPIO ports of the nano 33 BLE?”

You mean the value ?

Use a pull down resistor (try several values), measure voltage drop, then work backwards to calculate what the internal pullup is.

larryd:
“ need to find the internal pull-up resistor for the GPIO ports of the nano 33 BLE?”

You mean the value ?

Use a pull down resistor (try several values), measure voltage drop, then work backwards to calculate what the internal pullup is.

thanks for the response, however prefer to find the value on the documentation.
The Arduino Nano 33 BLE is based on the nRF52840 microcontroller.

and finally I've found the value.
RPU = 13K ohms (typical)
page 198
Source:
9 GPIO — General purpose input/output
19.4 Electrical specification
19.4.1 GPIO Electrical Specification
nRF52840 Objective Product Specification

traja47:
thanks for the response, however prefer to find the value on the documentation.

I like your approach! :sunglasses:

13k sounds very practical. Enough for example, to light a LED.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.