Crazy People
Crazy People
Introduction
We all surely must remember those thick cut books, if not from our children's childhood then from our own. Those books whose pages were divided into three. Open it up and there would stand some perfectly ordinary character, but turn one third of a page and he would acquire a different head, body or legs. Some of these chimeras were interesting and some were even funny. However, one wonders in these politically correct days, if it is quite all right to laugh at a bearded business man wearing a short skirt, or a girl with bulging biceps. That not withstanding, I want to take this concept into the computer age with this project and produce a system where you can produce you own art work or even photographic mixed up crazy people.
RFID Readers
Internal Wiring
Finished unit
Theory
The concept is quite simple, there are three RFID readers, each one represents head, body and legs. The RFID cards represent the characters and depending on which reader you put which card you end up with the appropriate piece of an image displayed on the computer screen. The whole system is tied together using an Arduino and a program written in Processing provides the final display system.
RFID
Radio Frequency Identification systems comes in many flavours from the basic technology to implement it to the data format produced by the reader. It’s main aim it to transfer a number encoded into a card or token and pass it on to an electronic system. So each card carries a unique number, we can use these numbers to identify that a card has been placed next to a reader. In many ways it does not matter which system you use, but the one I used was the low frequency EM system. This runs at 125KHz and uses cards containing 64 bits encoded with a Manchester Encoding system. This is a popular low cost system and there are many readers available although generally they are not cheap. This has little to do with the complexity and more to do with the intended market, access control. There are the cards that allow you access, or not, to a place of work or special room. There are many different formats that can be used to transfer the number on the card, serial, RS232, Wiegand, Barcode and magnetic stripe. However, out of all these the oldest and perhaps most universal is the Wiegand format, and out of the many variations of the format Wiegand 26 is perhaps the most common. This is because it is the only one with a published format most others being propriety extensions using more bits.
A new twist on an old game
By Mike Cook
System
This was originally conceived as a project that would require an Arduino Mega board as each of the RFID readers would require a serial port of it’s own to handle the serial format. However, the reader I used, the PAC OneProx from Stanley Security Products can be configured to have many different types of output and I released if I used Wiegand 26 then I would not need three serial ports at all.
Weigand Format
A Wiegand reader is one of the earliest types of ID card, it was a crude type of magnetic swipe card. The card consisted of a series of small embedded magnets in two parallel stripe, one stripe containing the zeros in the number and the other containing the ones. Therefor the output of the reader consisted of two signals, one pulsing to indicate a one and the other pulsing to indicate a zero. Although cards like this are long since gone, the concept lives on in the two signal pulse format known as a Wiegand format output. The term Wiegand 26 refers to the fact that there are 26 bits that make up the transmitted number. The first bit is a odd parity bit for the first half of the number and the last bit is an even parity bit for the second half of the number. However I am not too concerned with this because for any given card the parity bits are always going to be the same and so they can be considered to be just bits in the unique number. In an access control situation there are also different fields in the Wiegand number that can be used to indicate things like a site code, issue code and ID number. Again, for this project it is is not an issue as we will take the number as a whole.
Sometimes the term Wiegand reader is wrongly applied to any reader with a Wiegand output. However, a Wiegand output is easy to handle with an Arduino as there is xx mS between each pulse and the reader produces the code only once when it is presented to the reader. If the card is held against the reader then no further outputs occur, which is exactly what we want for this application.
Construction
The main consideration of the construction is that you mount three readers side by side. RFID readers will by their nature interfere with on another if they are too close together. The readers I used are recommended to be used at least one meter apart. However, I found they worked quite well down to about 5 cm although the range, that is the distance that the reader could read the number was reduced. I would recommend that you try your readers before construction a box for them and make sure you have a bit of extra margin. The box consists of the three readers mounted on MDF board surrounded by an aluminium U channel that provides support for an ABS plastic lid. One very important thing to note is that there should not be electrical connection between all the pieces of aluminium otherwise you are going to create one single shorting turn that will suck all the power out of the magnetic field produced by the readers and stop them from working.
I placed a strip of plastic across the readers to hold them in place and I had to rout out a small area of the base to get the wires from the back of the reader.
Wiring
The wiring is quite straight forward and simply consists of connecting the Wiegand outputs to the Arduino input pins. The reader outputs are open collector and so rather than use a pull up resistor I enabled the internal pull up resistor in the Arduino software. I used some tag board to help cope with all the power wires coming from the readers. The whole thing, including the Arduino, was powered from an external 12V power supply as the readers required 12V. The power was taken from the Vin output of the board which is the same point as the external power jack.
To finish things off, the whole thing was given several coats of blue metallic paint and, as a final touch, two red stripes were painted on, showing the three areas covered by the readers.
Software
The software is in two parts, the sketch that fits into the Arduino and the one that runs under processing. I have zipped them both up together and you can download it here:- Crazy.zip.
The Arduino software is quite straightforward. Basically it consists of some code to implement an interrupt on a change of state on any one of the six input pins. Then these is an interrupt service routine for each input. This does nothing if the input is low but when it finds the input is high it clocks a zero or a one into it’s accumulation of bits and increments a bit count for that reader. Finally the main loop looks at the bit counter for each reader and if it has reached 26 it then sends the number and a character indicating what reader has generated the number. The only problem I had with this was tat it appeared to not work properly the first time a card was read, after that it was perfect. A bit of investigation showed that it was missing the first pulse. I suspected this was because the reader inputs started out high, therefore to correct this I put a small routine in the set up routine. I made the pins outputs and then toggled the pins before restoring them to be inputs. This reset the processor’s internal registers so that they worked first time. The number is sent using the decimal format of the serial print procedure. This has the advantage of being simple but the disadvantage of being potentially a variable number of bits. That’s a problem I can relegate into Processing.
The Processing sketch has a relatively simple task. Accept the number and reader identification and look up what image to display in what third of the screen. This basic routine is used in the file Crazy_People. This is not in the right folder because there is no point in duplicating the images but they are exactly the same as in Crazy_People2. This contains all the functions of the first one and adds the background functions. There is a look up table in the code to assign a card number to an image, as your codes will be different to mine you will have to edit this to suite the cards you have. This also goes for the background card. This is used to set a plane background if it is the top reader, a random pattern of ellipses for the middle and a simple pattern for the bottom reader. The random pattern of ellipses is always drawn the same for subsequent cards by saving the random seed and re initialising the random number generator.
Any card that is not in this look up table is used to set the background colour. The number on the card is split into three and assigned to the red, green and blue components of the background colour. Which component is assigned to what colour is decided by the reader used. This gives three different colours from the one unknown card.
As a final touch I printed the pictures out and laminated them onto the card by using the transparent plastic you use for covering books.
The fun starts when you start adding your own characters or photographs.