Allowing through current above a certain level? - Page 1
Forum section: electronics / beginners

author: Michael_Hay_UK
author_rank: Newbie
timestamp: October 04, 2024, 12:15:41 pm
content: Hi all,I have a basic circuit in where there is are two external inputs, V+ and GND. The V+ input (3-12v) goes through an opto-isolator (IR LED I believe) and also a standard surface mounted LED and I think a current limiting resistor before connecting to the ground input. It is to allow external digital signals to be passed to the unit.When a voltage is applied across these two inputs (in the correct polarity - although there is not currently a reverse polarity diode, which I plan to add) the opto isolator allows current through the other side, which is detected by a MCU via a pullup to ground. This currently works as expected.The issue I have is that for something I want to connect to this, it passes a small current to test for continuity (up to 30mA) - which is triggering the MCU as soon as it is connected, not when the continuity testing current limit is removed. Understandably so, but not what I want it to do.I am trying to figure out if there is something I can do, ideally in line with the V+ input, that will block or divert straight to the GND input any incoming current under 30mA (or thereabout, a bit more in fine). Diverting to GND so it doesn't turn on the IR LED in the opto, but still shows continuity, would be ideal - but anything that stops the opto triggering at these low currents would work.My initial thoughts were to try and use a transistor which will not open to any degree with such a small current, but my attempts to SPICE model this have been - not great, alas. Still learningAny advice or ideas much appreciated.Thanks in advance.

author: tinymini
author_rank: Contributor
timestamp: October 04, 2024, 05:04:43 pm
content: Care to attach an image of the schematic?

author: Xena E
author_rank: Frequent Contributor
timestamp: October 04, 2024, 05:19:50 pm
content: If I understand correctly yes it's possible, but why not put a programmed delay on the MCU input rather than dump current?X

author: Michael_Hay_UK
author_rank: Newbie
timestamp: October 04, 2024, 05:28:06 pm
content: HiThe continuity test current could potentially be constant (at 8-18mA or something similar), so I don't think a delay timer will work.Appreciate the suggestion though. Thanks.

author: PGPG
author_rank: Frequent Contributor
timestamp: October 04, 2024, 05:30:06 pm
content: If it is signalling input than 30mA seems for me being big current (I would expect IR LED current in opto-isolator being about 10mA).Assuming (you can check it) that in on-state at IR LED in opto-isolator you have for example 1.5V then when you connect in paralel to it a 50Ω resistor than for currents lower than 30mA you will get voltage at it smaller than 1.5V. So all currents lower than 30mA will flow only through this 50Ω resistor and currents higher than 30mA will be divided into 30mA through this resistor and rest through IR LED. It is not exactly such as IR LED characteristic is not so sharp but it is something like that.

author: Xena E
author_rank: Frequent Contributor
timestamp: October 04, 2024, 05:35:34 pm
content: Quote from: Michael_Hay_UK on October 04, 2024, 05:28:06 pmIn that case, this signaling current is incresing to what?

author: Michael_Hay_UK
author_rank: Newbie
timestamp: October 04, 2024, 06:05:56 pm
content: The signalling current is unrestrained, and the input voltage can be anywhere from 3V to 18V. Unfortunately I don't know the resistance of the 2 LEDs and the in-line resistor. It is much higher than 30mA, that I know for sure.I was just modelling the parallel resistor option - and it seems to do the trick. Slightly concerned by the power dissipation (as the input could be 18V), but I will look at this further. Thanks!(I've attached a simple schematic, as someone asked.)

author: tinymini
author_rank: Contributor
timestamp: October 04, 2024, 07:57:55 pm
content: Thanks for the schematic!First things first, maybe a typo?In the 1st post, 2nd paragraph:QuoteThis sounds like a pulldown to me.Next up, about the current values:As mentioned by PGPG, 30mA seems quite high for a opto-isolator diode.A usual opto-isolator (e.g. TLP222A) has an If rating from 3mA up to 50mA. (As a designer, I'd be cautious going 30mA though)The Vf for a typical opto-isolator is that of an IR diode, usually around 1.2V.As for the other LED, it depends on the color - varying from 1.6V ~ 3V.You should be able to guesstimate by searching a similar color one.As for current controlled devices, a JFET is one - though they usually don't go for high ratings, are rather expensive, and don't have the isolation built-in.If youreallywant precise control or have trouble with power dissipation, a simple MCU, or some circuitry on the isolated side might be required.I guess the input isn't a constant current supply, so several resistors, a zener diode, an LDO, a comparator, and a mosfet might do the trick.Good luck!Edit: silly mistake on TLP222A's rating

author: Xena E
author_rank: Frequent Contributor
timestamp: October 04, 2024, 08:00:20 pm
content: Quote from: Michael_Hay_UK on October 04, 2024, 06:05:56 pmThe thing is, that for a normal led or opto coupler emitter 30 mA is already an uncomfortably high current18Volts through a couple of LEDS and 200Ω resistor you're looking at perhaps 75 mA.Can you give us any more details of what you are working with?Are you saying this 30 mA is from a current source driven fom a maximum of 18 volts supply, I'm having a bit of trouble visualising this.X

author: Andy Chee
author_rank: Super Contributor
timestamp: October 04, 2024, 08:36:35 pm
content: Quote from: Michael_Hay_UK on October 04, 2024, 12:15:41 pmI would ditch the the optocoupler (and series LED), and combine the signalling function with the continuity current measurement circuitry.

author: Michael_Hay_UK
author_rank: Newbie
timestamp: October 05, 2024, 08:58:24 am
content: First, thank you to everyone for their help and their patience with an amateur. It is much appreciated (and very different to my experiences, especially with the software side, where there is always at least one person whose response is "Oh god! I cannot believe you cannot solve this! Get gud newb!"). What a great community.In case it helps, here is a bit more of a writeup of what is what. In hindsight I should have started with this - my apologies.*** The external input:The external input will potentially come from a variety of sources:1) A 3.7v battery (this is what I tested it with, and it worked)2) A 9v battery3) A number of units designed to trigger pyrotechnics. These units (which are sealed and I wouldn't mess with) put out a continuity check current that is limited to the "no fire" level for standard e-matches (which is typically 30mA). I measured this on one unit a while back, and it was about 12mA - but I'd like to design for 30mA, just in case. Once these external units are triggered they go open voltage across the outputs, which if they are connected to an e-match (which is just fine nichrome wire coated in pyrotechnic compound) drawn over 1A for a short time or until the fuse wire burns out. Depending on the unit this voltage can be between ~4.5V to 18V.** The opto isolator:I've just checked, and the board this prototype is using is a cheap Chinese board marked HY-M158. With a bit of digging it appears that the opto-isolator is a PC817 (Datasheet:https://learnabout-electronics.org/Downloads/PC817%20optocoupler.pdf).Also on the board is an in-line surface mount LED (type unknown - it is blue) and a SMD resistor marked "302" - so 3k Ohms (see picture attached).From the initial testing I did, when a 3.7V (and 18650 LiIon battery) was connected to the input the opto-isolator would come on (i.e. the LED on the board would come on, and the MCU would detect the change on the GPIO).** The other side of the opto:The post above about the typo is correct - my apologies. It is pulled to 3v3 and it is the opto that pulls it to GND.On the other side there is a connection from a GPIO of the MCU (an ESP32) to one side of the output side of the opto, and the other side of the output side of the opto is connected to ground. (I have removed the jumpers from the opto board, so the ground for the MCU board and the inputs is separate - with the MCU side connected to MCU ground.)The connection from the GPIO to the opto utilises an internal pullup in the MCU, so that GPIO is HIGH until the opto opens, at which point it is pulled to GND and goes LOW - which the MCU, in software, then processes.** The bigger picture:Just for completeness (and not exactly linked to the thing I am trying to achieve) - once the MCU gets a signal that the opto has opened (i.e. it is pulled from HIGH to LOW, as an external signal is received) it send an output signal to a 5V relay, via a 3.3v-5v level shifter, to pulse on for a set amount of time - this is connected to a 240V circuit that is connected to a device that needs a pulse of 240V to activate - in this case a CO2-powered confetti cannon(!).The timing and working of all that side is controlled by software - and seems to be working fine. The only issue is getting the external signal to work with an external trigger that is also providing a continuity check current (which is high enough to turn on the opto).** Solutions:The suggestion of running a resistor in parallel to the opto-led-resistor(3k) so that for the continuity stage the voltage is too low to turn on the opto seems like it might work. I'm going to try some calcs to see if I can get the sizing right and check the power dissipation. However, if anyone with more experience and knowledge is able to suggest a value for me to check against that would be much appreciated.If there is another way of having it block or divert a current of under 30mA I'd be very interested. Sadly, I just do not know enough at this point to know where to start. There are 5 external inputs, so ideally this would be simple - but I'll consider anything that works. Logically, at least in my mind, it would be a node at which there is 'something' that does "IF current <30mA go this way (back to input ground), ELSE go this way through the opto". I appreciate that may not be possible or even close to simple.Once again, thank you to everyone for their time and their help.

author: Michael_Hay_UK
author_rank: Newbie
timestamp: October 05, 2024, 09:02:04 am
content: ADDITIONAL:In relation to the constant current input for continuity testing - I suspect this is done simply in the external devices using resistors. I'd be very surprised if it was using variable voltage to keep this at a stable level - more just enough resistors to ensure the output current at that stage is below the 30mA limit.In case that helps.

author: Andy Chee
author_rank: Super Contributor
timestamp: October 05, 2024, 10:41:55 am
content: Question for you:Are you attempting to design and build a new device from scratch? Or are you trying to retrofit an existing device?

author: Michael_Hay_UK
author_rank: Newbie
timestamp: October 05, 2024, 12:14:50 pm
content: New, from scratch.I had hoped it would be relatively simple: The MCU monitors a push switch (pulled high by MCU internal pull-ups, and pulled to ground by pressing the switch - software de-bounce) and when it detects this it pulls another GPIO high for a set amount of time to trigger a relay on and off for that time - all controlled in software. This bit all works as expected.In addition to the push button on the unit, it was also hoped that an external trigger could be wired in (via speaker posts) so that a central control box could coordinate the different parts, including triggering this one. This is where the inputs into the opto isolator come in. This works in the same way as the push button - a GPIO being pulled low, this time by the opto being activated, and this being detected by the MCU. Sadly the input signal isn't 0V = off and xV = on, but is yV (30mA limit) = off and yV (no current limit) = on. And this is where my "this should be simple" falls apart, alas. And this is where I am stuck

author: Andy Chee
author_rank: Super Contributor
timestamp: October 05, 2024, 12:45:24 pm
content: Here's my proposed general idea (the e-match is represented by the resistor):Basic idea is that the MOSFET can be briefly pulsed by the microcontroller in order to develop a small current through the e-match, the opamp can then measure the voltage across the intact e-match. Given the same current, an open circuit e-match will read a different voltage.When you need to ignite the e-match, turn the MOSFET on with a continuous signal.

author: PGPG
author_rank: Frequent Contributor
timestamp: October 05, 2024, 02:05:31 pm
content: Quote from: Michael_Hay_UK on October 05, 2024, 08:58:24 amTill now I imagine your input circuit as LED1 + LED2 + 200Ω and don't know where is mentioned by you 3k opto-led-resistor.If you (as I suggested) add 50Ω (or some different value) in paralel to one LED then below 30mA that LED will not light.But the device testing continuity with some less then 30mA current will see 250Ω what may be not satisfy it.Let us assume test current is 20mA. The voltage drop at 250Ω will be 5V. Plus voltage drop at visible light LED - may be 2V so in total about 7V while testing device probably expects to see only small voltage at few Ω.I would try absolutely different approach. Let us 'short' input signal to GND via current source with current set to 30mA. If the current source (semi-current source) have to be powered from input signal you should be able to make it having voltage drop around 1.5V, I think. So when powered by source with internally limited current the voltage drop at our current source will be less then 1.5V while when powered by not current limited source a full voltage will be at it. And these difference between less than 1.5V and higher than 1.5V should be used to switch on your transoptor.I hope that testing continuity device seeing 1.5V will assume load is connected.For 12V and 30mA limited by current source you get 0.36W dissipated in current source transistor.I expect this description can be not clear for you, but I let others to make schematics, simulations and so on. Only one hint - to have a small voltage drop the current source I would (at first) build will have two identical resistors in serie between base and emitter of main transistor and base of second transistor powered from point between these 2 resistors.

author: Xena E
author_rank: Frequent Contributor
timestamp: October 05, 2024, 02:54:30 pm
content: OK. So back of the envelope sketch.Based on current dump, resistive divider provides the load for your 30 mA, Rt will be 20Ω or less to keep the output switched off until input current limit is removed.Rs will allow you to set the current through your existing opto emitter.Values may need playing with, it's crude and the input resistors will need to be power rated to suit your input voltage.Edit: sketch has input on left, output on right, + top — bottom 🙄RegardsX

author: tinymini
author_rank: Contributor
timestamp: October 05, 2024, 03:02:07 pm
content: Also, for the photocoupler's datasheet: It's always better to get from the manufacturer, if it's available.https://global.sharp/products/device/lineup/selection/opto/pc/dip_4pin.htmlhttps://global.sharp/products/device/lineup/data/pdf/datasheet/PC817XxNSZ1B_e.pdfThough I don't know if it's a real SHARP one, or a Chinese clone.

author: Michael_Hay_UK
author_rank: Newbie
timestamp: October 05, 2024, 04:35:08 pm
content: Once again, thank you all.I'm starting to think that the opto-isolator route is not the way to go, and that trying to use it to differentiate between input currents instead of input voltage is adding a complex problem that could be better solved by going back to the drawing board.If the "off" condition is <30mA current, and the "on" condition is >30mA current, with a small resistor as the load, then I am wondering if something that just measures the current flowing is a simpler solution. (I could be very wrong here too!)As such, I've been having a preliminary look at current measuring components.At the moment I am looking at the ZETEX (Diodes Incorporated) ZXCT1021 (https://www.diodes.com/assets/Datasheets/ZXCT1021.pdf)If I have understood this correctly, this will output a variable voltage based on the sensed current (using a 500 mOhm shunt resistor). If this is the case, I could feed this into an ADC (12/16 bit), and then do the comparison of the inputs in software.I've attached a rough schematic of what I am thinking, which includes my assumption of how the external trigger is working with regards to low continuity current on the higher "on" current), as well as a few models of what the current flow might look like. I've had a bit of a guess as to resistor values to keep the max current down for 200mW resistors (although I could use 0.5-1.0W through hole ones if needed).A 16bit ADC (ADS1115 - very available as a module) should hopefully have the resolution to see the difference between the restrained continuity current (which is suspect is just an extra in-line resistor in the 320-480 ohm region) and the more unrestrained current.This is very much outside of my experience, so this could be a terrible idea. But from my beginners perspective, it looks like it might be a potential solution.Any thoughts or comments on this alternative approach very much appreciated.Thanks again.

author: Xena E
author_rank: Frequent Contributor
timestamp: October 05, 2024, 07:44:04 pm
content: So. A current to voltage measurement>ADC>software approach is feasible, however IMHO it seems like a tortured route to achieve a simple outcome.I also wouldn't go dispensing with the isolation of the opto coupler that's protecting your circuitry from the outside world.If the input to your MCU is existing prior art, complete with its opto coupler then what's already been suggested by myself and PGPG will work if you're stuck with this 30mA thing.What is the remote trigger? is the 30mA a transmitted current for local indication at the transmission end? ie., is it a loop.Why does the "transmitter" supply open circuit voltage have to be variable between 3 and 18 volts? Or is this just your observation based on external measurements of what happens in operation.What is the purpose of the 320Ω? (The loop total resistance, if it is just a simple resistor, will be between 100Ω and 600Ω for a range of 3 Volts to 18 Volts.)When the MCU is required to be activated how long is the un limited current transmitted?Just me trying to get a handle on this.As PGPG pointed out, Because you have the series combination of LEDs in the opto input, that does give you the option to have floating voltage at the input before the MCU input is triggered, you could perhaps use the ZXCT1021 to provide the variable voltage directly or if that's not possible by using, say, a 431 as a comparator...X

author: Terry Bites
author_rank: Super Contributor
timestamp: October 07, 2024, 04:20:47 pm
content: Shunt the opto's LED with a small value resistor. Rp willl starve the LED of current untill sufficent Vf appears across it.