Author Topic: Circuit to drive Wiegand output  (Read 786 times)

0 Members and 1 Guest are viewing this topic.

Offline jfuu_Topic starter

  • Newbie
  • Posts: 8
  • Country: gb
Circuit to drive Wiegand output
« on: September 03, 2024, 10:52:33 am »
I'm working on a design to drive a Wiegand output via a microcontroller (3.3V logic).

My only real requirement for the output is that it has protection to ensure nothing bad happens if an output is connected incorrectly (e.g. it is accidentally shorted to GND or connected to 12V). I'm not expecting the output to be connected incorrectly for long periods, I just want to protect against incorrect installation.

I initially designed it to use an NPN transistor like so:



But I received a suggestion on Reddit to use a MOSFET instead, as disconnecting WIEGAND_OUT_D0 (or connecting it to a high-impedance input) would result in only 0.5mA through Q5, leading to a slow fall time.

I've updated the design to use a 2N7002 MOSFET and also added some protection inspired by the first 3 methods listed on https://www.rugged-circuits.com/10-ways-to-destroy-an-arduino:



Is this suitable for my needs? Here's how I decided on the values for the components (please tell me if my thinking is wrong!):

  • R46 - Some sources say a gate resistor isn't needed, but I found this StackExchange answer indicating otherwise. I want to draw a maximum of 5mA from GPIO22, so I used Ohm's law to get R = 3.3V / 5mA = 660 Ohms (rounded to nearest available resistor value)
  • R47 - There's not much information online about the required pull-up resistors for Wiegand. I've got a device with a Wiegand output and that uses a 10K resistor (although they also drive the output directly from the uC), so I just followed that. My understanding is that the strength of the pull-up will mainly affect the maximum cable run length, so I may end up adding some switchable resistors using DIP switches to allow the end user to adjust the pull-up for their application.
  • F2 - In some cases, Wiegand devices may be connected to the same D0/D1 pins (like I2C), so I added a 100 Ohm resistor here to limit the current coming from other devices to 50mA (at 5V). I've not specified the trip current in the schematic, but I'm thinking of looking for a part with ~100mA of trip current.
  • Q6 - I don't really know much about choosing MOSFETs for my application - this one showed up on Digikey and the 2N7002 seems to be a jellybean-ish component which should switch at 3.3V.

Thanks!
« Last Edit: September 03, 2024, 10:57:29 am by jfuu_ »
 

Offline PGPG

  • Regular Contributor
  • *
  • Posts: 212
  • Country: pl
Re: Circuit to drive Wiegand output
« Reply #1 on: September 03, 2024, 02:48:29 pm »
as disconnecting WIEGAND_OUT_D0 (or connecting it to a high-impedance input) would result in only 0.5mA through Q5, leading to a slow fall time.

Wiegand is not the fast transmission connection so I don't understand this suggestion (specially - what is the problem if disconnected).

I've updated the design to use a 2N7002 MOSFET and also added some protection

2N7002
https://www.mouser.pl/datasheet/2/916/2N7002NXAK-1623722.pdf
will be working correct but ...
I would never use this transistor controlled by 3V3 source. It is because RDSon is specified only for 5V and not for 3V3. Gate threshold (max 2.1V) is defined for Ids=250uA so it is not a voltage that switches transistor seriously on but the voltage that starts to switching it on. You can conclude from Fig.8 that 3V switches it on enough good (for lower voltage - we can't be sure). But it is clearly written that it is for typical values. If Gate threshold is 1.1-2.1 than typical I assume 1.6V. So if from Fig.8 I read 3V is enough than for worst case (Vgs threshold of 2.1V) I would say 3.5V will be enough. And, assuming some tolerances your 3V3 can be 3V2...
Of course in 99,99% situations it will be working.

I don't know what you have at output. It is 100R resistor, 100mA PTC or a resistor with PTC functionality included (I have never heard of such devices but that doesn't mean they don't exists).
If it is PTC than have in mind that PTCs are very slow. If you connect 12V (what for human is a moment for electronic is everlasting) your question is what power will be in PTC and what in Zener and which of them will win.

You can configure your output as current source to limit power released in output transistor when connected to 12V.
 
The following users thanked this post: jfuu_

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22380
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Circuit to drive Wiegand output
« Reply #2 on: September 03, 2024, 03:19:34 pm »
Surely they meant rise, not fall: the transistor turns on as hard as it does regardless of resistor, producing a short fall time.  The rise can only be with the transistor off as suddenly as possible, followed by an RC time constant as the collector/drain capacitance charges up.

Which might be a good reason to prefer BJT over MOS: you can get smaller ones, i.e. smaller die --> less junction area --> less capacitance.

A 3.3V compatible jellybean is BSS123.  If you don't mind tiny parts, RUM001L02T2CL and friends is another option, small enough to be comparable to BJTs in many applications, but without the base current.

But what does the load look like, anyway?  Logic input? Coil driver? Something else?  Would anything else ever be connected?  How fast does it go?

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: jfuu_

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4305
  • Country: nl
Re: Circuit to drive Wiegand output
« Reply #3 on: September 03, 2024, 03:32:10 pm »
Wow I did not knew that the Wiegand interface/protocol is still used.

What system and in what environment uses this where it might be physically disconnected and connected to something else with the risk of being connected to a wrong voltage?

The one usage of Wiegand that I encountered was way back in the late 90's to control a coffee vending machine. The connection was made inside the machine to never be disconnected or connected to something else. In that case also not wise to have it exposed since it would allow for hacking and getting free coffee.

Can't recall how I rigged up the hardware back then.

Offline PGPG

  • Regular Contributor
  • *
  • Posts: 212
  • Country: pl
Re: Circuit to drive Wiegand output
« Reply #4 on: September 03, 2024, 07:05:38 pm »
Wow I did not knew that the Wiegand interface/protocol is still used.

EN IEC 60839-11-5:2020 was introduced with intention to replace Wiegand. And (to put it mildly) I don't like this new standard. Standards are not mandatory, but people seeing that one exists just write it into specification and that way we are forced to use it with the following consequences:
- in small system (most of them are like that) increasing about 100 times power used on RS485 communication (while the whole world is trying to limit energy use),
- in big system (40 devices on bus) urgent signals (tamper violation) instead of being send 'at once' have to wait until pooling will come. Standard gives each device max 200ms to answer (it says that it should be typically less than 3ms, but only should) and (which is already bizarre) allows in frame transmission to have up to 20ms breaks between bytes.

We use RS485 since 90s but we never used pooling and and never interrupted frames being sent. May be in 80s someone had to break frame because controller was too slow. But specifying something like that in 2020...

 
The following users thanked this post: jfuu_

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7909
  • Country: nl
  • Current job: ATEX product design
Re: Circuit to drive Wiegand output
« Reply #5 on: September 03, 2024, 07:56:54 pm »
Wow I did not knew that the Wiegand interface/protocol is still used.
I think it's usage is almost exclusive to entrance card readers.
OP, I wouldn't overthink this. The easiest way to handle these communication interfaces is always optocouplers. Or digital inputs and outputs on a PLC. You don't know how long cabling will there be on these devices, or when there will be a lightning strike next building. Go for galvanic isolation.
 
The following users thanked this post: jfuu_

Offline jfuu_Topic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Circuit to drive Wiegand output
« Reply #6 on: September 03, 2024, 10:51:08 pm »
Wiegand is not the fast transmission connection so I don't understand this suggestion (specially - what is the problem if disconnected).

I'm not really sure to be honest. Their comment was:

Quote
With WIEGAND_OUT_D0 unconnected Ic = R43/5V = 0.5mA. Therefor, if Ib = 5mA, Q5 may slow to drop-out

I don't know what you have at output. It is 100R resistor, 100mA PTC or a resistor with PTC functionality included (I have never heard of such devices but that doesn't mean they don't exists).

I found these on Digikey - they sound like they might have an initial resistance of 100R and then increase from there with temperature?

If it is PTC than have in mind that PTCs are very slow. If you connect 12V (what for human is a moment for electronic is everlasting) your question is what power will be in PTC and what in Zener and which of them will win.

Ah that's good to know. I guess it just depends on how much current is going through the PTC? What would you recommend in place of a PTC+Zener to ensure 12V doesn't damage my input?

Surely they meant rise, not fall: the transistor turns on as hard as it does regardless of resistor, producing a short fall time.  The rise can only be with the transistor off as suddenly as possible, followed by an RC time constant as the collector/drain capacitance charges up.

Yeah it isn't really clear - it does make more sense that it'd be the rise time as opposed to the fall time.

Which might be a good reason to prefer BJT over MOS: you can get smaller ones, i.e. smaller die --> less junction area --> less capacitance.

A 3.3V compatible jellybean is BSS123.  If you don't mind tiny parts, RUM001L02T2CL and friends is another option, small enough to be comparable to BJTs in many applications, but without the base current.

But what does the load look like, anyway?  Logic input? Coil driver? Something else?  Would anything else ever be connected?  How fast does it go?

I don't mind small parts - I'm having a PCB manufacturer assemble it anyway.

I'm not really sure what the load looks like - it's an existing access control system I'm connecting up to. I've done some testing and it seems like the downstream (i.e. the Wiegand input on the access control board) sinks about 2mA, and it outputs about 3V when nothing is connected (maybe a voltage divider with an on-board pull-up?).

I'd like to support a wide range of Wiegand inputs if possible, but I'd expect they all work very similarly for compatibility. In terms of speed, the shortest pulses (i.e. 5V->0V->5V) are usually around 40uS, with the gaps between them being around 2ms.

Wow I did not knew that the Wiegand interface/protocol is still used.

It seems like it's still in reasonably wide-spread use for access control (at least in the specific domain I work in). The main issue I have with it is that it's pretty poorly documented overall - there isn't one "specification" and lots of devices require different setups.


What system and in what environment uses this where it might be physically disconnected and connected to something else with the risk of being connected to a wrong voltage?

The device only really needs protection during installation - ideally I'd like holding it wrong to not release the magic smoke ;D

The easiest way to handle these communication interfaces is always optocouplers. Or digital inputs and outputs on a PLC. You don't know how long cabling will there be on these devices, or when there will be a lightning strike next building. Go for galvanic isolation.

I like the sound of isolating the device (makes it harder to hold it wrong!). How would a pull-up work if I want to keep my input isolated?

Thanks all for the help! Certainly a lot to think over.
« Last Edit: September 03, 2024, 10:59:00 pm by jfuu_ »
 

Offline jfuu_Topic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Circuit to drive Wiegand output
« Reply #7 on: September 04, 2024, 12:29:46 am »
Thinking about it some more, I'm probably just going to go with something close to my original design:



Can someone please confirm my calculations are right?

  • R1 - GPIO is 3.3V, so I calculated this resistor using:
    Ib = Ic / hFE(sat)
    Ib = 4mA / 10
    Ib = 0.4mA

    Rb = (Vb - Vbe(sat)) / Ib
    Rb = (3.3V - 0.7V) / 0.4mA
    Rb = 6500R (rounded down to 4700R, better to overdrive to ensure saturation?)
  • R2 - 1k pull-up alongside R3 limits the short-circuit current (i.e. if WIEGAND_OUT_D0 gets grounded) to 5V / 1200R = ~4mA
  • R3 - 200R resistor limits the current through Q1 to 5V / 200R = 25mA if WIEGAND_OUT_D0 is shorted to 5V

Also, is there a better BJT I could be using here? This one seems a bit overkill (600mA collector current!).

I've decided I'm not really fussed about people connecting it to 12V - I'll tell them to hold it properly  :-+
« Last Edit: September 04, 2024, 12:31:59 am by jfuu_ »
 

Online ArdWar

  • Frequent Contributor
  • **
  • Posts: 687
  • Country: sc
Re: Circuit to drive Wiegand output
« Reply #8 on: September 04, 2024, 12:47:02 am »
The lack of defined or documented I/O characteristics make things a bit complicated here, as we can only guess which compromises are acceptable and which aren't. At first glance, I thought why not just use logic gates or myriad of line drivers. But then I thought that was kind of obvious, so there must be other obvious thing that I don't know of that makes you avoid those choices.

Another example, you said the input sinks 2mA. That much input current will cause your 1k2 impedance drive to drop VOH signal down to around 2.6V. That's marginal for typical 5V logic, but that might be normal for your protocol, I don't know.
 
The following users thanked this post: jfuu_

Offline PGPG

  • Regular Contributor
  • *
  • Posts: 212
  • Country: pl
Re: Circuit to drive Wiegand output
« Reply #9 on: September 04, 2024, 12:59:26 am »
Quote
With WIEGAND_OUT_D0 unconnected Ic = R43/5V = 0.5mA. Therefor, if Ib = 5mA, Q5 may slow to drop-out

They suggest that rising edge can be slow. I don't want to discuss with it. If you drive base with small resistor than when you switch transistor off you take charge from base also with this small resistor so comparable fast. But you can absolutely don't care how slow rising edge is - see later.

I found these on Digikey
I'd like to look at it. So link please.

What would you recommend in place of a PTC+Zener to ensure 12V doesn't damage my input?
I have already written. I drive npn base with 4k7+3k3 divider and use 33R in emitter and 4k7 pull-up. It should withstand 12V. But 12V is not what you should be aware off - see later. Risk of mistake is rather small. People connect things with power switched off. If 12V wire will be red then they should not connect other wire to +12V. If other wire touch it temporarily when power is switched off nothing will happen.

I'd like to support a wide range of Wiegand inputs if possible,

We manufacture access controllers since end of 90s. Our controllers never had Wiegand input. For special cases (when someone needed this and only this Wiegand reader) we have made an extension module - interface Wiegand to our RS485 bus. So I know only what are at our Wiegand inputs - 4k7 pull-up to 5V.
I am surprised that anyone is constructing anything with Wiegand thinking about adapting to multiple devices when we already considered it outdated in the 90s. Wiegand comes from metal identification cards with two rows of holes in it so the transmission speed depended on the speed of user swiping the card in the reader.
Readers are part of access system that are installed in not protected area. Using an unencrypted interface (like Wiegand) there is simply irresponsible.

In terms of speed, the shortest pulses (i.e. 5V->0V->5V) are usually around 40uS, with the gaps between them being around 2ms.
So you have much, much more time for rising edge and you worry when someone says that the transistor is slowly turning off.

The device only really needs protection during installation
You don't realize how wrong you are.
When lightning strikes near the building in which your device is installed, you can expect a ground difference of up to 50V within one building and several kV between buildings.
I use SMB 600W 18V transils at all inputs/outputs. 18V to ensure 12V doesn't damage it

I like the sound of isolating the device
There is no idea to isolate signal wires while you transfer not isolated supply in the same cable.
« Last Edit: September 04, 2024, 01:02:13 am by PGPG »
 
The following users thanked this post: jfuu_

Online coppercone2

  • Super Contributor
  • ***
  • Posts: 10567
  • Country: us
  • $
Re: Circuit to drive Wiegand output
« Reply #10 on: September 04, 2024, 01:14:17 am »
I wonder how that wire was invented. Did someone get locked in a boiler room with a roll of galvanized wire?


Wiegand wire is kind of a sad invention

or was it from torturing paper clips in meetings?
« Last Edit: September 04, 2024, 01:16:14 am by coppercone2 »
 

Offline jfuu_Topic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Circuit to drive Wiegand output
« Reply #11 on: September 04, 2024, 01:20:40 am »
The lack of defined or documented I/O characteristics make things a bit complicated here, as we can only guess which compromises are acceptable and which aren't. At first glance, I thought why not just use logic gates or myriad of line drivers. But then I thought that was kind of obvious, so there must be other obvious thing that I don't know of that makes you avoid those choices.
I'm pretty clueless when it comes to this kind of stuff - I just designed what I could understand. From looking around online, Wiegand outputs are usually open-collector and have a pull-up on them (although it's hard to tell what end this is usually on). I've just found that there's an "official" specification for Wiegand but it's paywalled (SIA AC-01-1996.10) - hopefully it might contain more information (looking to purchase it later).

Another example, you said the input sinks 2mA. That much input current will cause your 1k2 impedance drive to drop VOH signal down to around 2.6V. That's marginal for typical 5V logic, but that might be normal for your protocol, I don't know.
The 2mA sink is without any resistors on the output, so I think the impedance of the input is closer to 2500R. Still doesn't give a great VOH though - 3.3V from my calculations.

Looking around online, some Wiegand readers don't have pull-ups, some allow them to be configured (e.g. https://www.turnstiles.us/wp-content/uploads/2024/01/www.TURNSTILES.us-WSOI-100-Wiegand-Signal-Optical-Isolator-Product-Manual.pdf offers optional 1500R pull-ups) and some have fixed pull-ups. I'm going to do some testing to see what kinds of voltages this device can recognise as high on its input.

I'd like to look at it. So link please.
Apologies - I thought I'd linked it in my reply: https://www.digikey.co.uk/en/products/filter/ptc-resettable-fuses/150?s=N4IgjCBcoGwBwGYqgMZQGYEMA2BnApgDQgD2UA2uGAAwAEAtgIIgC6xADgC5QgCqAdgEtOAeXQBZfJlwBXAE74QAX2IAmagHYYyEGkhY8RUhXDU6IgBb1crDt0h8hoiVNkLlKkNughBAEx4AWhoIOx4QYk4AT3ZFB2k0JSUgA

I have already written. I drive npn base with 4k7+3k3 divider and use 33R in emitter and 4k7 pull-up. It should withstand 12V. But 12V is not what you should be aware off - see later. Risk of mistake is rather small. People connect things with power switched off. If 12V wire will be red then they should not connect other wire to +12V. If other wire touch it temporarily when power is switched off nothing will happen.
Yeah I think I've come to terms with not trying to prevent incorrect connections like this  :D

We manufacture access controllers since end of 90s. Our controllers never had Wiegand input. For special cases (when someone needed this and only this Wiegand reader) we have made an extension module - interface Wiegand to our RS485 bus. So I know only what are at our Wiegand inputs - 4k7 pull-up to 5V.
I am surprised that anyone is constructing anything with Wiegand thinking about adapting to multiple devices when we already considered it outdated in the 90s. Wiegand comes from metal identification cards with two rows of holes in it so the transmission speed depended on the speed of user swiping the card in the reader.
Readers are part of access system that are installed in not protected area. Using an unencrypted interface (like Wiegand) there is simply irresponsible.
The device I'm building is an interposer to retrofit on systems that are already using Wiegand - I agree that it's not something that should really be used going forward. It's interesting that you had the pull-ups on your input - as I mentioned above it seems hit-or-miss as to where the pull-ups are actually located a lot of the time.

So you have much, much more time for rising edge and you worry when someone says that the transistor is slowly turning off.
Fair enough! I find it hard to gauge the scale that things like this operate on. I guess the easiest thing for me to do is just breadboard something like this and see how it behaves.

You don't realize how wrong you are.
When lightning strikes near the building in which your device is installed, you can expect a ground difference of up to 50V within one building and several kV between buildings.
I use SMB 600W 18V transils at all inputs/outputs. 18V to ensure 12V doesn't damage it
Ah that sounds worthwhile haha! I'll take a look at adding TVS diodes between all of my inputs/outputs and GND. Thank you!

There is no idea to isolate signal wires while you transfer not isolated supply in the same cable.
Yeah I guess having a pull-up on my end of the wire pretty much ruins any hopes of this ;D

I wonder how that wire was invented. Did someone get locked in a boiler room with a roll of galvanized wire?


Wiegand wire is kind of a sad invention

or was it from torturing paper clips in meetings?
I'm sure it was a great invention for the time, but I'd rather not have to deal with it |O

Thanks again everyone for the help! I really do appreciate it (apologies for being clueless!)
« Last Edit: September 04, 2024, 01:36:58 am by jfuu_ »
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4305
  • Country: nl
Re: Circuit to drive Wiegand output
« Reply #12 on: September 04, 2024, 06:48:29 am »
A simple solution can be to have the pullup at the receiving end, or at least powered from the receiving end. Same for the ground wire.

How to do this is to just make an open collector output with an optocoupler. The MCU drives the LED of the optocoupler via a suitable resistor. The transistor of the optocoupler is connected to the target wires including ground. Do not connect the ground of the interface wires to the MCU ground.

Choose an optocoupler with high enough max collector voltage and it won't have problems when wrong fully connected, as long as you add some series resistor to limit current.

This of course stands or falls with how your MCU is powered.

Another option for protecting the transistor is to use a TVS instead of a zener diode. They can withstand higher power surges and react faster.

Offline PGPG

  • Regular Contributor
  • *
  • Posts: 212
  • Country: pl
Re: Circuit to drive Wiegand output
« Reply #13 on: September 04, 2024, 10:48:28 am »
Looking around online, some Wiegand readers don't have pull-ups
I suppose the idea was open collector and pull-up at input.
But when you want to see outputs at your reader just powered pull-ups inside help a little and as they don't interfere with anything...

I thought I'd linked it

You are right - it really have specified resistance.
I knew about standard PTC thermistors (with their characteristic simply temperature dependent) used as temperature detectors (self heating avoided).
I knew about PTCs used as fuse (with as small on resistance as possible). They have hysteresis (after trip they get higher permanent resistance).
I didn't knew about PTCs with some specified R25 resistance being also specified as fuses. They clearly claim in datasheet to have no hysteresis so are different from those PTC I use.
I use 0ZCJ0020FF2E - 0.2A/30V PTC. It has 0.6Ω before first trip and 2.5Ω after.
In linked by you PTF serie closest would be 0.34A/25V with 5Ω. It have to have higher R as have higher volume to be heated. I suppose these both are the same kind of devices but one sold before being trip and other with paying attention to get exact resistance after trip and intentionally tripped during manufacturing.
If you want them as fuse and you expect to never being trip in your device live cycle than you probably prefer 0.6Ω than 2.5Ω. But as my PTC is SMD so during reflow soldering... . But THT you are able to assemble without heating them over their trip temperature of about 80°C, I think.

The device I'm building is an interposer to retrofit on systems that are already using Wiegand
So something opposite to our Wiegand-RS485 bus interface. Our device is not simple converter as it can operate in our RS485 bus having up to 50 devices and no pulling. We try to connect Wiegand readers, you try to be visible as Wiegand reader :)

It's interesting that you had the pull-ups on your input
I think pull-ups at input are mandatory in Wiegand concept while in outputs are optional but never investigated it deeply.

I guess the easiest thing for me to do is just breadboard something like this and see how it behaves.
Simulation will be enough. It is really hard to build OC transistor output to not switch off in 1ms.
 
The following users thanked this post: jfuu_

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7909
  • Country: nl
  • Current job: ATEX product design
Re: Circuit to drive Wiegand output
« Reply #14 on: September 04, 2024, 01:56:19 pm »
I like the sound of isolating the device (makes it harder to hold it wrong!). How would a pull-up work if I want to keep my input isolated?

Thanks all for the help! Certainly a lot to think over.
I don't think your schematic is correct. At least not from what I remember.
Wiegand is pulled up on the door controller's side. It has two open collector outputs.
The card reader can pull either of these low to send 0 or 1. It doesn't need it's own pullup resistor.
Especially, since several card readers can be connected to the same controller, in parallel.
 
The following users thanked this post: jfuu_

Offline jfuu_Topic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Circuit to drive Wiegand output
« Reply #15 on: September 04, 2024, 06:20:26 pm »
I've purchased the SIA document and it confirms what PGPG and tszaboo have said:

Quote
The use of open collector outputs for the signals Data "ones or zeros" and LED (Auxiliary input) control is permitted. Biasing must be provided at the input.

It also provides this nice table:



And states:

Quote
The Data One, Data Zero, and LED Control conductors provide logic signals between the reader and the panel. The logic voltage level for the Data Outputs (Data 1 and 0) indicated are the voltages measured at the panel. The logic voltage levels for the Control and Auxiliary inputs (LED) are the voltages measured at the reader.

From the table saying that Ioh is limited to 1mA, does that imply that the input is what is limiting this current (as that's where the pull-up is located)? From my testing with the panel I have, it's happy to source 3.5mA from D0/D1 to GND (it's also only pulling up to 3.3V - naughty!).

I initially thought this would mean I could use an optoisolator, as I no longer need a pull-up on the output, however it seems like any high-speed optoisolators (i.e. ones with <1uS switching time) require VCC on the output side. I guess something like this would suffice instead? The 100R resistors would probably be 0.5W to ensure they can handle dissipating the 50mA if WIEGAND_OUT_D* is shorted to 5V (although I can't see how this would happen).



EDIT: The bottom input would be GPIO23 not GPIO22.
« Last Edit: September 05, 2024, 04:04:21 pm by jfuu_ »
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7909
  • Country: nl
  • Current job: ATEX product design
Re: Circuit to drive Wiegand output
« Reply #16 on: September 04, 2024, 06:26:18 pm »
I initially thought this would mean I could use an optoisolator, as I no longer need a pull-up on the output, however it seems like any high-speed optoisolators (i.e. ones with <1uS switching time) require VCC on the output side. I guess something like this would suffice instead? The 100R resistors would probably be 0.5W to ensure they can handle dissipating the 50mA if WIEGAND_OUT_D* is shorted to 5V (although I can't see how this would happen).

(Attachment Link)
From what I remember the protocol is very-very slow. I think we were sending it at 9600 baud, and any higher the controller didn't even read the bits.
I wouldn't worry about switching speeds. But you should try it. This is a very simple circuit, just prototype it and test it with your controller.
 
The following users thanked this post: jfuu_

Offline jfuu_Topic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Circuit to drive Wiegand output
« Reply #17 on: September 04, 2024, 06:34:13 pm »
From what I remember the protocol is very-very slow. I think we were sending it at 9600 baud, and any higher the controller didn't even read the bits.
I wouldn't worry about switching speeds. But you should try it. This is a very simple circuit, just prototype it and test it with your controller.
The Wiegand specification lists the pulse width (signal low duration) as 20uS - 100uS and I'd like to be able to control this with uS accuracy in software (some panels don't really adhere to the standard and require specific timing). I'll have a bit more of a browse as there may be faster optoisolators that don't require VCC about, but the few I took a quick look (e.g. PC817, TLP2301) mentioned rise/fall times of ~20uS.

I agree it's probably easier to breadboard - I'll get a few different ones ordered and have a play around.
« Last Edit: September 04, 2024, 06:48:04 pm by jfuu_ »
 

Offline PGPG

  • Regular Contributor
  • *
  • Posts: 212
  • Country: pl
Re: Circuit to drive Wiegand output
« Reply #18 on: September 04, 2024, 08:29:15 pm »
It also provides this nice table:

The only way I can find to understand this table is:
Output in high state even loaded with 1mA current (towards GND) will ensure at least 4V.
Output in low state even loaded with 25mA current (toward VCC) will be below 1V.

My output (with 4k7 pull-up to 5V will ensure 4V when loaded with 0.2mA. So in state 1 is too weak.
My output (4k7+3K3 with 33R in emitter) is about 16mA current source so will ensure output below 1V loaded with 16mA (for higher current output will be higher then 1V). So in state 0 is also too weak.

If my understanding the tabele is correct than pull-up have to be 1k to 5V. And transistor should be able to sink at least 30mA (5mA into 1k and 25mA into load).
 
The following users thanked this post: jfuu_

Offline jfuu_Topic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Circuit to drive Wiegand output
« Reply #19 on: September 04, 2024, 09:41:20 pm »
The only way I can find to understand this table is:
Output in high state even loaded with 1mA current (towards GND) will ensure at least 4V.
Output in low state even loaded with 25mA current (toward VCC) will be below 1V.

My output (with 4k7 pull-up to 5V will ensure 4V when loaded with 0.2mA. So in state 1 is too weak.
My output (4k7+3K3 with 33R in emitter) is about 16mA current source so will ensure output below 1V loaded with 16mA (for higher current output will be higher then 1V). So in state 0 is also too weak.

If my understanding the tabele is correct than pull-up have to be 1k to 5V. And transistor should be able to sink at least 30mA (5mA into 1k and 25mA into load).

I'm not sure I understand sorry. The specification seems to indicate that there is no pull-up on the reader side, so how could current flow from the reader to the panel?

I'm also a bit confused by the negative current - could it be saying that the panel can sink up to 1mA from the reader (not sure how if there isn't a pull-up in the reader :-\) when pulling the signal high and the reader can sink up to 25mA from the panel (through the panel's pull-up resistor into GND) when pulling the signal low?
« Last Edit: September 04, 2024, 09:50:13 pm by jfuu_ »
 

Offline PGPG

  • Regular Contributor
  • *
  • Posts: 212
  • Country: pl
Re: Circuit to drive Wiegand output
« Reply #20 on: September 04, 2024, 09:51:41 pm »
I'm not sure I understand sorry. The specification seems to indicate that there is no pull-up on the reader side,

Where from this idea?

I'm also a bit confused by the negative current

For me positive = source, negative = sink.
So table says: 1mA source, 25mA sink (like digital circuit output specification).
 
The following users thanked this post: jfuu_

Offline jfuu_Topic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Circuit to drive Wiegand output
« Reply #21 on: September 04, 2024, 10:11:49 pm »
Where from this idea?
The specification says:
Quote
The use of open collector outputs for the signals Data "ones or zeros" and LED (Auxiliary input) control is permitted. Biasing must be provided at the input.
It doesn't explicitly say it can't be provided at the output, but from looking at other readers online, it seems like the pull-up usually appears only on the panel (some readers have an optional or built-in pull-up).

For me positive = source, negative = sink.
So table says: 1mA source, 25mA sink (like digital circuit output specification).
My confusion was around which direction the source/sink is - is it from the perspective of the reader or panel? I re-read the specification and found it says this:

Quote
The voltage, current and timing of the data pulses are measured at the reader in reference to the power supply/signal ground at the reader.
Which makes it sound like it's the reader sourcing 1mA and sinking 25mA, which I think makes the most sense to me. It does specify that the minimum current for high is 0, so I guess compliant panels shouldn't have a problem with there being no current flowing from the reader to the panel.

It seems like Wiegand is probably rather forgiving, given the mix of pull-ups and no pull-ups I've seen on readers. I'm probably going to just go with the latest schematic I posted unless anyone can see any glaring issues with it. An axial resistor can just be installed between 5V and D0/D1 if needed for a specific installation (I've seen a few reader manuals suggest this if the voltage is dropping too much).

Thanks!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf