Shop OBEX P1 Docs P2 Docs Learn Events
P1 opto input concepts? — Parallax Forums

P1 opto input concepts?

Hello all. On the first image, this is what I have done on lots of this particular board for external buttons/contact closures, etc. I run 5V from the main Switching power supply out to buttons over shielded 22G stranded wire. Tie the drain to the main board GND terminals. The 5V returns from the switch and is held low with a resistor. Before the Propeller input is a 1.5K Resistor and .1uF to GND. This R value seems low for 5V but I have never damaged an input with 5V to 1000+ P1's with this method.

The current method requires an external INPUT board with screw terminals, that connects with a 12" cat5. I want to simplify the whole thing and move the screw terminals for inputs onto the main board, reduce the work and cables. There once was a reason to park the external board outside the main box, now I put it all inside.

The new concept is to simplify and dummy proof the install for others. Ideally, I'd like to get rid of the shielded cable requirement. But since the 5V in this new idea still uses the main 5V power from the switching power supply chip, I'm concerned about noise if running multiple cable runs to switches. The Prop is on an LDO 3v3 reg. One thought is to add another 5V 7805 style switching reg ($5) and use that 5V rail to go to all external buttons, maybe that would keep noise separate from the main board? As shown, the external switch just takes the low side of the LED input to GND after the series resistor so the 5V is not full current at the remote switch.

I have never had a damaged P1 input using this. So why not just keep the same method and move the screw terminals to the main P1 board? Forget the optos? The only reason is to avoid installers having to track down 2 or 4 Con 22G shielded which is not always local. Use 2 con any type wire, unshielded, even 18G stranded simpler for installers.

Thoughts welcome!

Comments

  • JonnyMacJonnyMac Posts: 8,941
    edited 2023-09-02 16:11

    When I did designs for EFX-TEK we used this circuit -- it allowed users to send anything up the line from 5v to 24v.

  • For my Isolated inputs I use a LTV-846

  • T ChapT Chap Posts: 4,198
    edited 2023-09-02 21:49

    Thanks guys for the input! I had the H11AA1 on my bench already. I wired this circuit. I don't have anything around 680 so I used 1K's.

    I wonder if this is sufficient a design to not need shielding assuming I use some other 5V power rail or run the existing 5VDC from the switching supply through a 5V LDO to try to create some noise reduction from the outside world getting on my main 5VDC rail. The main rail only feeds the 3v3LDO.

    I wonder if any noise sources ie RF, WIFI, vaccuum cleaners, other motors could put enough noise on an unshielded line to trigger this device since 1V is turning it on. Maybe I'll test with higher R values on the inputs, try to push it to turn on around 5V.

    Obviously to go direct into the P1 inputs I'll use 3v3 and not 5V as shown.

  • You can remove one of those 1Ks if you going to be use 5V as the input voltage; looking at the datasheet this should give you just shy of 4mA through the LED. It has a max Vf of 60mA, so you have a lot of leeway. I'd drop down to 330 which would give you about 11.5mA; this gives you margin for long leads and connection losses.

    I always incorporate software debouncing, too; no matter the input circuit.

  • jmgjmg Posts: 15,148

    @"T Chap" said:
    I have never had a damaged P1 input using this. So why not just keep the same method and move the screw terminals to the main P1 board? Forget the optos?

    Opto's are a useful way to isolate and reduce damage flow on, on longer cable installs. Lightning is a common damage pathway.

    SSR are usually an overkill for input sensors, but they do have one great advantage : you can flip them around for an output pathway, so they can be a very flexible interface, for a few cents more.

    For polarity insensitive drive, the dual-diode AC/DC optos are very simple, lcsc have those from about 6c/100+
    The EL3H4(B)(TA)-VG parts have a good CTR spec, for 7.2c/100

  • @jmg said:
    For polarity insensitive drive, the dual-diode AC/DC optos are very simple

    This and 24v is my standard. 24v is the industry standard for field wiring.
    I believe in buffering and was shocked to find that Arduino's Portenta Machine Controller brings 24v field-wiring, right on to the PCB and relies on some form of voltage divider. The designers clearly have no experience of the real world.

    Craig

  • T ChapT Chap Posts: 4,198
    edited 2023-09-03 14:51

    Thanks guys.

    On my drawing earlier, I put 5VDC at the collector and when the transistor turns on I get 5V at the emitter. I realize on the NPN the most common circuit for this part is to have a pullup ie 10k on the collector, emitter is at GND.

  • Actually, I see others doing the exact thing I drew.

  • evanhevanh Posts: 15,209
    edited 2023-09-03 17:00

    Yep, that's called PNP switching, switch to positive, and is the common arrangement for industrial input wiring outside of USA and Japan. NPN switching being the term for alternatively switching to negative.

    Since these two terms, NPN and PNP, both state that you are talking about a pull-up/down circuit rather than a push-pull/bipolar circuit the terms are also used for generally indicating the way I/O like plain contact switches and relay/valve coils have been wired.

  • jmgjmg Posts: 15,148

    @"T Chap" said:
    On my drawing earlier, I put 5VDC at the collector and when the transistor turns on I get 5V at the emitter. I realize on the NPN the most common circuit for this part is to have a pullup ie 10k on the collector, emitter is at GND.

    Both work.
    Some MCUs have pull-up resistor options internal, and some have options for both pullup and pull down.
    These days, you would generally use 4 pin optos, which are smaller and avoid bringing out the sensitive base connection.

    Actually, I see others doing the exact thing I drew

    I hope they do include a series resistor, missing from that snip ?

  • @jmg said:

    I hope they do include a series resistor, missing from that snip ?

    Oh I didn't even pay attention to the LED side inputs, but yes that's odd. They may have just drawn it for crude illustration. I thought at first you meant no resistor on the collector direct to 5V.

  • Here is the result of the discussion. Since I had H11AA1 in my shop I could test the circuit in advance of building the boards. The board has +12VDC connected to where it says +VCOM. The +VCOM is selectable between 5VDC on the main board OR 12VDC alternate power supply that is exclusive to this role for the opto triggers. The H11AA1 has a .1uf cap at the LED input. the collector/emitter "output" is 3v3 held low via 10K with a .1uf.

    There are ground terminals for the purpose of drain/shield on cables.

    The question is, if the 12V is dedicated to this purpose of connecting switches, relays, buttons etc as dry contact only, is there any benefit at all to requiring shielded cable now?

  • evanhevanh Posts: 15,209

    Oh, that's very rugged looking. Just to spoil your tidy work, the other component missing on inputs like this is a resistor across pins 1 and 2 of the optocoupler. The LED of the optocoupler can be triggered from RF pickup in very noisy electrical environments. Having such a resistor absorbs the excess.

  • What kind of value are you suggesting? I can fit an 0603 on the first batch. Add it to the next boards. I only ordered 5 of the first to test.

  • evanhevanh Posts: 15,209
    edited 2023-09-15 01:45

    Umm, 1k maybe. Depends on your preferences to some extent. The 330 ohms is very low. You only using 5 volt signals?

    EDIT: Maybe 2k2 would be better value across the pins. At 1k you're diverting 3 mA odd.

  • Thanks for the suggestions. The default is 12v. I have 330 at the opto input. But I have 100 ohm on the 12v rail. Total is 430ohm not including cable resistance and loss, variable lengths from 10’ to 50’.

  • For low frequency applications the OPTO configuration you have works just fine. If you want to do PWM stuff (i.e. motor speed control) over the OPTO barrier it may fall short of what you would expect because of the "Miller effect" properties of the transistor acting like a low pass filter reaching a cutoff point at the higher frequencies.

    "In electronics, the Miller effect accounts for the increase in the equivalent input capacitance of an inverting voltage amplifier due to amplification of the effect of capacitance between the input and output terminals." - In this case the inverting voltage amplifier is the transistor within the OPTO. A PN diode is a better option, but has similar issues.

    One way around this is to apply the transistor in a reverse biased mode where it acts like a capacitor. In this mode the Input OPTO LED proportionally discharges the capacitor based on the intensity of the OPTO LED. This method does not suffer any amplifying effects on the input capacitance and will only work with a pulsed input signal.

    Reference:
    https://en.wikipedia.org/wiki/Miller_effect

  • Let’s say I want to simulate rf noise and use 2 - 18g stranded wires attached to an input without a shield. What can I rig up to put some noise on the lines so I can test if the LED could be turned on with rf?

  • evanhevanh Posts: 15,209
    edited 2023-09-16 21:33

    A relay or clean contact switch switching a big-Smile solenoid, valve or cheap geared motor. The sort of setup that ends up welding the relay contacts.

  • bob_g4bbybob_g4bby Posts: 401
    edited 2023-09-17 12:32

    I worked as an EMC test manager for a railway signalling company here in SW U.K. The most common threat to our signalling electronics was from fast transient bursts, caused by passing electric trains and other arcing contact sources. Part of our product compliance program was to test products to standard IEC 61000-4-4 - you can hire test generators and coupling clamps to do that test yourself. The European railway standard called for a withstand of 2kV, but I used to insist on 4kV withstand, based on personal experience. Our equipment became very reliable as a result. Safety was never an issue, but we ceased to have certain locations where our kit was unreliable - mostly shutdowns, but no fault found (typically 5% of installation before we applied the railway EMC standard)

    The protection to fast transient bursts provided by optocouplers varies a lot, depending on the driver circuit - opto capacitance. We used to choose our optos, based on (a) low capacitance defined in the datasheet and (b) bench tests with the transient generator. The internal capacitance needs to be very low (fractions of a pF) to be effective, as the transient burst energy extends well up to around 100MHz. It follows that good use of ground planes, keeping clean circuits well away from dirty circuits, keeping circuit loops small is essential. Think VHF radio layout technique throughout for best results. Much of our gear ended up with four layers - two signal, one 0V plane, one supply plane and quite often a chassis plane (sharing the 0V layer) The chassis plane was bonded to chassis at multiple points by fixings, often. The optos would straddle the insulating moat between 0V and chassis plane. Clean electronics sat in the 0V plane, dirty input filters etc sat in the chassis plane.

    Cheers, Bob

  • T ChapT Chap Posts: 4,198
    edited 2023-09-17 13:56

    Thanks for the insight. What I’m most concerned about is if someone used unshielded cable and they ran the cables over some other 120VAC stuff or 240 VAC cables, or near Wi-Fi transmitters or repeaters or 900 MHz devices or other gadgets, like that found in a typical residential application that produce noise. I can easily continue requiring shielded cable tied to ground at my board, but I’m exploring the possibility to not require shielded cable which simplifies matters to some small degree as unshielded cable is more easily found at your basic hardware stores.

  • jmgjmg Posts: 15,148

    The advice to select/test lowest pF Optos is solid, as is the RF design.
    Avoid the base pin opto couplers.
    You could drive the LED with a resistor in each leg, and a cap across the led as rf filtering.
    You could also nudge up the trigger current, so more energy is needed.

  • This way worked great on my project

  • bob_g4bbybob_g4bby Posts: 401
    edited 2023-09-18 07:37

    As to cable type, twisted pair can provide quite a bit of protection at power line frequencies, as the induced voltage is mostly cancelled from twist to twist. Lay a test system out on the floor and see the effects of running your cable on top of a power cable carrying X amps. Practical test eliminates worry.

    The threat from UHF sources is not so bad since the plant wiring and input circuit are naturally quite lossy at those frequencies. You would usually have to be right on top of the source before it disturbed.

    We often moan about increasing legislation, but I can say 100% that the railway EMC standard (which called up around 9 different tests for susceptibility and emissions) did the european railway industry a big favour. The amount of unreliable electronics went down big time and saved the networks a ton of money in reduction of broken train timetables. EMC test houses charge an arm and a leg, but the savings downstream can be much higher.

  • @DigitalBob said:
    This way worked great on my project

    Agreed. Pretty much what you get with PLCs and the field wiring is straight 18awg. EMI on these conductors has never been a thing.

    Craig

Sign In or Register to comment.