So far with the OpenAccess system I’ve talked about the rs485 terminals I tried to use, a clever low pin count display and keypad, the final display and keypad controller I built, and the ability to log to a dot matrix printer. Now I’ll talk about another I/O system that I tried but didn’t end up going with: a fully wiegand keypad and rfid reader.
I don’t think I’ve discussed wiegand here before. This protocol is like a cross between rs232 and rs485, but originated with magstripe readers. I’m going to spin you a tale that may not be entirely accurate, but I’ll tell it in such a way that it could be. Back in the day when magstripe ID cards were starting to be used for everything there would be readers on tons of doors in every building of an entire campus. This could be a government facility, a college, or just a security-conscious private company. Having lots of distributed computers doing local processing or encryption and all sending data back along the same tcp/ip based network is how we do things now. There was a time that paying people to run lots of wire was cheaper than put in micro computers everywhere. In these dark times the magstripe readers would be at the end of a long cable, untwisted because that too cost money. We have been sending high voltage (the spec doesn’t specify voltage, but I’ve seen as high as 30V peak-to-peak) rs232 from building to building for a while, but with no control lines and no communication back to ask for a re-transmit there needed to be a way to get the data transferred correctly the first time and do it cheaply: wiegand was born.
Wiegand is digitally signaled by sending the ‘ones’ down one line and the ‘zeroes’ down another. This is effectively like having a deferentially signaled line, except the timings are such that both lines are low between bits. If you relax your timings a bit you can get away with using just one of the wires (I don’t know anyone else who does that… GM) but it’s not generally good practice. There may be no way to ask for a retransmit from the microprocessor, but you can certainly ask the user. My wiegand readers have LED and buzzer outputs that can be driven by the controller. I said this was born of magstripe cards, lots of magstripe readers put this out natively, or they do inside between some controller chips. In order to keep up with the changing security concerns facilities went to rfid cards, but due to rampant and perpetual cheapness they kept the same backend hardware, software, wire… and just slapped these readers on the front which spit out the same codes as the magstripe ones. I may put up some documentation I have about probing a facility in transition later.
Now that we know what wiegand is (and hopefully you hate it like I do) let’s talk card length. The cards I use are 125khz, unencrypted, and have a 26bit code in them. There are ones up to 34 or 37 bits, some that use different frequencies, encryption, and some that have dual frequencies for compatibility. There are no cards as short as 4 bits, that would be crazy, you could only have 2^4 combinations. What would you possibly do with 1/16 possible combinations. Oh, right, the keypad has 12 positions. So, in order to read this keypad you have to poll for wiegand data and if you have accumulated 4 bits of data and after a short while are accumulating no more then you have a button press. Now, if you don’t know you’re looking for button presses differently you may press 6 buttons and find yourself having read a card that doesn’t look like any card you’ve seen before. Could the designers of this keypad put in 16 full 26 bit streams that correspond to key presses? yes. Did they? No. Is this a good design practice? You decide. If you want to be all exact about it you can start a timer when you get the first interrupt and figure out if there’s an unusual pause between the fourth and fifth bit which would indicate someone pressing buttons, you could also just poll constantly and assume that the buffer will be exactly 26 bits or 4 bits when you read it because of how fast you poll. I split the difference, if the buffer has more than 25 bits in it I assume it has a card, remove 26 bits, act on it, and check again. Else if the buffer has exactly 4 bits I assume the buffer has a button in it and read that. I make no provision for polling the buffer while the interrupts are filling it up and that’s not been a problem for me yet.
There’s how to read the wiegand keypad. If you ever have trouble feel free to throw it away and get a real protocol before calling me. Or call me, I’m not usually busy.
the keypad test code is here