Silicon ChipBuild A Magnetic Card Reader & Display - January 1996 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Crystal balling the telephone
  4. Feature: Recharging Nicad Batteries For Long Life by Horst Reuter
  5. Project: Surround Sound Mixer & Decoder; Pt.1 by John Clarke
  6. Feature: Computer Bits by Geoff Cohen
  7. Project: Build A Magnetic Card Reader & Display by Mike Zenere
  8. Project: The Rain Brain Automatic Sprinkler Controller by Graham Blowes
  9. Product Showcase
  10. Order Form
  11. Project: IR Remote Control For The Railpower Mk.2 by Rick Walters
  12. Serviceman's Log: The complaint seemed simple enough by The TV Serviceman
  13. Book Store
  14. Vintage Radio: Converting from anode bend to diode detection by John Hill
  15. Back Issues
  16. Notes & Errata: Dolby Pro Logic Surround Sound Decoder, November-December 1995; Five-Band Equaliser, December 1995
  17. Market Centre
  18. Advertising Index
  19. Outer Back Cover

This is only a preview of the January 1996 issue of Silicon Chip.

You can view 22 of the 96 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • Surround Sound Mixer & Decoder; Pt.1 (January 1996)
  • Surround Sound Mixer & Decoder; Pt.1 (January 1996)
  • Surround Sound Mixer & Decoder; Pt.2 (February 1996)
  • Surround Sound Mixer & Decoder; Pt.2 (February 1996)
Articles in this series:
  • Computer Bits (July 1989)
  • Computer Bits (July 1989)
  • Computer Bits (August 1989)
  • Computer Bits (August 1989)
  • Computer Bits (September 1989)
  • Computer Bits (September 1989)
  • Computer Bits (October 1989)
  • Computer Bits (October 1989)
  • Computer Bits (November 1989)
  • Computer Bits (November 1989)
  • Computer Bits (January 1990)
  • Computer Bits (January 1990)
  • Computer Bits (April 1990)
  • Computer Bits (April 1990)
  • Computer Bits (October 1990)
  • Computer Bits (October 1990)
  • Computer Bits (November 1990)
  • Computer Bits (November 1990)
  • Computer Bits (December 1990)
  • Computer Bits (December 1990)
  • Computer Bits (January 1991)
  • Computer Bits (January 1991)
  • Computer Bits (February 1991)
  • Computer Bits (February 1991)
  • Computer Bits (March 1991)
  • Computer Bits (March 1991)
  • Computer Bits (April 1991)
  • Computer Bits (April 1991)
  • Computer Bits (May 1991)
  • Computer Bits (May 1991)
  • Computer Bits (June 1991)
  • Computer Bits (June 1991)
  • Computer Bits (July 1991)
  • Computer Bits (July 1991)
  • Computer Bits (August 1991)
  • Computer Bits (August 1991)
  • Computer Bits (September 1991)
  • Computer Bits (September 1991)
  • Computer Bits (October 1991)
  • Computer Bits (October 1991)
  • Computer Bits (November 1991)
  • Computer Bits (November 1991)
  • Computer Bits (December 1991)
  • Computer Bits (December 1991)
  • Computer Bits (January 1992)
  • Computer Bits (January 1992)
  • Computer Bits (February 1992)
  • Computer Bits (February 1992)
  • Computer Bits (March 1992)
  • Computer Bits (March 1992)
  • Computer Bits (May 1992)
  • Computer Bits (May 1992)
  • Computer Bits (June 1992)
  • Computer Bits (June 1992)
  • Computer Bits (July 1992)
  • Computer Bits (July 1992)
  • Computer Bits (September 1992)
  • Computer Bits (September 1992)
  • Computer Bits (October 1992)
  • Computer Bits (October 1992)
  • Computer Bits (November 1992)
  • Computer Bits (November 1992)
  • Computer Bits (December 1992)
  • Computer Bits (December 1992)
  • Computer Bits (February 1993)
  • Computer Bits (February 1993)
  • Computer Bits (April 1993)
  • Computer Bits (April 1993)
  • Computer Bits (May 1993)
  • Computer Bits (May 1993)
  • Computer Bits (June 1993)
  • Computer Bits (June 1993)
  • Computer Bits (October 1993)
  • Computer Bits (October 1993)
  • Computer Bits (March 1994)
  • Computer Bits (March 1994)
  • Computer Bits (May 1994)
  • Computer Bits (May 1994)
  • Computer Bits (June 1994)
  • Computer Bits (June 1994)
  • Computer Bits (July 1994)
  • Computer Bits (July 1994)
  • Computer Bits (October 1994)
  • Computer Bits (October 1994)
  • Computer Bits (November 1994)
  • Computer Bits (November 1994)
  • Computer Bits (December 1994)
  • Computer Bits (December 1994)
  • Computer Bits (January 1995)
  • Computer Bits (January 1995)
  • Computer Bits (February 1995)
  • Computer Bits (February 1995)
  • Computer Bits (March 1995)
  • Computer Bits (March 1995)
  • Computer Bits (April 1995)
  • Computer Bits (April 1995)
  • CMOS Memory Settings - What To Do When The Battery Goes Flat (May 1995)
  • CMOS Memory Settings - What To Do When The Battery Goes Flat (May 1995)
  • Computer Bits (July 1995)
  • Computer Bits (July 1995)
  • Computer Bits (September 1995)
  • Computer Bits (September 1995)
  • Computer Bits: Connecting To The Internet With WIndows 95 (October 1995)
  • Computer Bits: Connecting To The Internet With WIndows 95 (October 1995)
  • Computer Bits (December 1995)
  • Computer Bits (December 1995)
  • Computer Bits (January 1996)
  • Computer Bits (January 1996)
  • Computer Bits (February 1996)
  • Computer Bits (February 1996)
  • Computer Bits (March 1996)
  • Computer Bits (March 1996)
  • Computer Bits (May 1996)
  • Computer Bits (May 1996)
  • Computer Bits (June 1996)
  • Computer Bits (June 1996)
  • Computer Bits (July 1996)
  • Computer Bits (July 1996)
  • Computer Bits (August 1996)
  • Computer Bits (August 1996)
  • Computer Bits (January 1997)
  • Computer Bits (January 1997)
  • Computer Bits (April 1997)
  • Computer Bits (April 1997)
  • Windows 95: The Hardware That's Required (May 1997)
  • Windows 95: The Hardware That's Required (May 1997)
  • Turning Up Your Hard Disc Drive (June 1997)
  • Turning Up Your Hard Disc Drive (June 1997)
  • Computer Bits (July 1997)
  • Computer Bits (July 1997)
  • Computer Bits: The Ins & Outs Of Sound Cards (August 1997)
  • Computer Bits: The Ins & Outs Of Sound Cards (August 1997)
  • Computer Bits (September 1997)
  • Computer Bits (September 1997)
  • Computer Bits (October 1997)
  • Computer Bits (October 1997)
  • Computer Bits (November 1997)
  • Computer Bits (November 1997)
  • Computer Bits (April 1998)
  • Computer Bits (April 1998)
  • Computer Bits (June 1998)
  • Computer Bits (June 1998)
  • Computer Bits (July 1998)
  • Computer Bits (July 1998)
  • Computer Bits (November 1998)
  • Computer Bits (November 1998)
  • Computer Bits (December 1998)
  • Computer Bits (December 1998)
  • Control Your World Using Linux (July 2011)
  • Control Your World Using Linux (July 2011)
Articles in this series:
  • Railpower MkII: A Walk-Around Throttle For Model Railways; Pt.1 (September 1995)
  • Railpower MkII: A Walk-Around Throttle For Model Railways; Pt.1 (September 1995)
  • Railpower MkII: A Walk-Around Throttle For Model Railways; Pt.2 (October 1995)
  • Railpower MkII: A Walk-Around Throttle For Model Railways; Pt.2 (October 1995)
  • IR Remote Control For The Railpower Mk.2 (January 1996)
  • IR Remote Control For The Railpower Mk.2 (January 1996)
By MIKE ZENERE Build a magnetic card reader & display Have you ever wanted to find out what’s written on your credit card or other magnetic stripe cards? Now you can do it. This unit will enable you to read and display the contents of track two on any magnetic card and could be used as the basis for an electronic door lock. Magnetic cards have been around for many years and have found their way into many fields such as banking, security and vending machines. Most cards follow defined guidelines as to their con­struction and layout and are therefore very flexible to the designer. 40  Silicon Chip Each card has three tracks but the most commonly used is track two. Recalling data from the card has become relatively simple in the last few years with modern card readers. These generally have a single on-board chip to decipher the raw data from the read head. This looks much like the record/play head in a cas­sette deck. The on-board chip generally contains conditioning circuitry to pick up the signal, reject noise and provide a digital output. Most card readers interface via three wires which are Clock, Data and Card Valid. Assuming that a microprocessor is hooked up to the card reader, a typical card read takes place as follows. When a card is swiped through the card reader, the Card Valid line goes low after eight or nine flux reversals, indicating that a valid card is present. The microprocessor monitors the clock line and waits until the Clock Magnetic Card Standards Most magnetic cards adhere to defined standards that de­scribe the physical as well as electrical layout. The standards outline card size, magnetic stripe and track positioning, and format information. The information is recorded onto the card using a technique known as Two Frequency Coherent Phase Recording or F/2F. This allows for serial recording of self-clocking data on each track. The data consists of data and clocking bits together. When a flux transition occurs between Fig.1: the track layout on a magnetic card. Track 1 can record alphanumeric data, clock cycles, a “one” is while tracks 2 and 3 provide only numeric data. obtained and when there is an absence of flux between encoded using 4-bit BCD with odd start of the actual data to be read, cycles a “zero” is obtained. parity. followed by the data, the end sentiStandard magnetic cards have nel, LRC and finally, trailing zeros to All tracks are recorded with the three data tracks and each has its the end of the card. The term LRC least significant bit first and the parity own subtle differences. Track 1 has stands for “longitudinal redundancy bit last. The higher density track three a bit density of 210 bits per inch, check” and is used for horizontal holds up to 107 numerics while track giving it the ability to hold a total of error detection. two holds only 40. The necessity for 79 charac­ters over the entire length start and end sentinels and other By far the most commonly used of the card. Each character on this separating char­acters reduces the track is track two. Although holding track is made up of six data bits and above storage capabilities to a cerless information than the others, this one parity bit, providing 64 differtain ext­ent. track has all the data required to do ent alphanumeric combinations to a banking transaction. If there is a choose from. The card and track Reading or writing of data to the need for the customer’s name to be layout is shown in Fig.1. card generally follows the same present, then track one is used as it is path for all three tracks. First, leadThe remaining tracks, two and the only one that holds alphabetical ing zeros are encoded to indicate three, provide only numeric data characters. The third track is special the presence of data and to provide and have a bit recording density of in that data may be written or read synchro­ n isation. Next, the start 75 bpi and 210 bpi respectively. The during a transaction. sentinel is encoded to indicate the character set for these two tracks is line goes low, indicating that data is present on the data line. The data bit is collected and temporarily stored until a succession of bits is gathered to make a 5-bit word, with four data bits and one parity bit. When the 5-bit word is obtained and stored, the cycle repeats itself until all the 5-bit characters have been read into memory. The processor can now go back over the data and analyse it for parity. Date rate & swipe direction The data rate even for the high density tracks is quite low, allowing almost any microprocessor to sample and collect the data. Let’s assume that the card is passed through the reader at around one metre per second. This translates to around 9983 bps or 1426 7-bit characters per second, meaning that a new data bit is presented about every 100µs. Most card readers are capable of reading two of the three tracks in one swipe. Even allowing for this extra load, most microprocessors running at 1MHz or more will handle this with ease. Although data is written onto the card in a particular format, there being a start and end sentinel, this does not limit the programmer to write software to read a card when swiped forwards or backwards. In a “backward read”, the card data is simply read as usual and stored in memory but this time the last character is first and the first character is last. The program simply detects this by looking for the start and end sentinels and then corrects itself. Card reader The card reader and display unit to be presented here is self-contained on January 1996  41 42  Silicon Chip Fig.2: the circuit is based on a magnetic card reader module with its own on-board decoding. The data from this module is fed via three lines to the microprocessor (IC1) and this in turn drives a multiplexed 4-digit display. The track 2 contents of four cards can be stored in the EEPROM (IC2) and this data can be used as the basis of an electronic door lock. IC3 and its associated parts form a watchdog timer circuit and this automatically resets the microprocessor if signal activity from pin 11 ceases, indicating that the processor has “crashed”. a PC board measuring 128 x 101mm. As well as the card reader module with its integral PC board, there is a 4-digit display, a 28-pin 68705P3 microprocessor (IC1), a piezo buzzer and three pushbuttons. The circuit is shown in Fig.2. The card reader and its integral PC board has all the cir­cuitry necessary to decode and convert the raw data coming from the card being read. The data is transformed into logic levels and is then sent out via three serial lines to the processor. The card reader is connected to the logic board via a 5-way cable, with three of the lines for data and the other two for power. The recording function of the circuit is performed by a small serial EEPROM, IC2. Once the unit is placed in the record mode and a card is swiped through, the data will be saved in the EEPROM. Because timing is not critical in this project, a crystal for the microprocessor is not necessary. Instead, by placing an 18kΩ resistor from pin 5 to the +5V rail, an inbuilt oscillator is enabled, causing the processor to run at near full speed. Beeper & relay driver A DC self-oscillating beeper is connected to port B, pin 12, on the processor. Port B can sink up to 10mA which is suffi­cient for this application and is pulled low to turn on the beeper. The relay is driven by transistor Q1 which is controlled by the line from pin 24. This line is normally low and the relay is off. When a valid card is swiped through the reader, the proces­ sor port pin 24 goes high for a period of time and turns on Q1 which operates the relay. The display consists of four 7-segment common anode dis­plays multi­ plexed together. The cathodes are driven directly by port lines from the processor, while each display anode is driven by its respective PNP driver transistor (Q2-Q5). The processor receives an interrupt every 5ms from an internal timer. Each time an interrupt is received, the processor switches off the current display digit that it is driving and turns on the next. In this manner, each digit is only on for 5ms before the next digit is updated. This gives each digit a total on-time of around 250ms per second; ie, a duty cycle of 25%. The SHIFT LEFT and SHIFT RIGHT buttons are used to move the display laterally to enable the user to view the entire number. Construction Begin assembly of the PC board by mounting the four stand­offs, one at each corner. This done, install the diodes, resistors, links and capacitors. Note the polarity of the electrolytic capacitors and the diodes. Install the 7805 regulator and fit it with a small heatsink. Next, install the transistors, the two small ICs and the socket for IC1 but do not install the processor until after the unit has been powered up and a voltage check performed. When in­stall­ing the four 7-segment displays, their decimal points should be close to the edge of the PC board. The remainder of the components can now be mounted, noting the orientation of the pushbutton switches. The card reader module is attached to the PC board with screws fitted from the underside. The back of the read head should face the outside edge of the board. When all the assembly work is complete, apply 12V DC to the board and check that +5V is present at pins 3 & 6 of the socket for IC1, at pin 8 of IC2, pins 4 & 8 of IC3 and at the emitters of Q2-Q5. If this checks out, remove the power, plug in the pro­cessor and connect the card reader module. Reapply power – the buzzer should beep four times and the display should read “OPEr”. The unit is now ready for a test drive. Before you start, here are a few tips. The mode button is used to cycle through the various available modes. Each time you press this button, the next option appears on the display. The modes are OPEr (operate), rEC (record), d EL (delete), p LAY and rEAd. When in the operate mode, the display blanks out after about 30 seconds to conserve power. If any button is pressed after this time the display will light and programming may con­tinue. Initial set up If this is the first power-up you will need to reset the memory of the EEPROM and this is done by holding down SHIFT LEFT and SHIFT RIGHT and applying power. The EEPROM will be cleared and the relay on-time will be set to three seconds. PARTS LIST 1 PC board, 128 x 101mm 1 magnetic card reader module 1 piezo buzzer 1 12V miniature SPDT relay 3 momentary contact pushbutton switches 1 5-way connector 1 2-way connector 2 3-way PC-mount insulated terminal blocks 4 PC standoffs Semiconductors 1 MC68705P3 programmed microprocessor (IC1) 1 93C46 EEPROM (IC2) 1 555 timer (IC3) 1 7805 5V 3-terminal regulator (REG1) 4 HD11310 7-segment red LED displays (DISP1-4) 3 1N4004 silicon diodes (D1-D3) 2 PN100 NPN transistors (Q1,Q6) 4 PN200 PNP transistors (Q2-Q5) Capacitors 2 100µF 16VW electrolytic 1 1µF 16VW electrolytic 4 0.1µF monolithic Resistors (0.25W, 5%) 1 1MΩ 1 1kΩ 1 33kΩ 7 330Ω 1 18kΩ 1 22Ω 0.5W 11 10kΩ Miscellaneous Screws, nuts, shakeproof washers, solder. Where to buy the parts A complete kit of parts for the magnetic card reader is available from the author. This includes all electronic compon­ents except for the 12VDC power supply and a case. The price is $75.00 plus $7.50 for postage and packing. Completely assembled and tested units are also available at an extra cost of $20.00. The documented source code is a further $8.00 for the print out. Please make postal money orders payable to Mike Zenere, 83 Head­ ingley Road, Mt. Waverley, Vic 3149. Phone (03) 9803 3535. Note: copyright© of the PC board is retained by the author. January 1996  43 Fig.3: install the parts on the PC board as shown here, taking care to ensure that the displays, switches and other polarised parts are correctly oriented. The card reader module is connected to the main PC board via a 5-way cable. The unit can be used in two modes which enable the user to: (1) read and display cards; and (2) operate the relay. Let’s initially talk about the first option. After power-up, the unit should be showing “OPEr” indicating that it is in the door access mode. To change this, push the mode button until the display shows “rEAd”, indicating that if a card is swiped, its track 2 cont­ents will be displayed. Swipe any card through and you should see some digits or letters on the display. These will correspond to the digits stored on the magnetic card with the start sentinel (b) being the first character. The display can only show four numerics at a time so to view the rest, push the SHIFT LEFT button once to view the next character to the right. Keep doing this until the display shows the end sentinel (F) or until the display shifts no further . While doing this, look at the front of the card and its embossed number. You should see this number appear in the display as you move along. If you wish, you can move the display to the right by pushing the SHIFT RIGHT button. To view another card, simply swipe it through the slot. Door lock applications The following functions relate to the operate mode which is when the 44  Silicon Chip unit is used as a door lock. After going through the functions listed below, place the unit in the operate mode by hitting the mode button until “OPEr” is displayed. After a short time, the display will blank out and the unit will now be ready to compare swiped cards with its memory contents. If a match is found, the door release relay will operate for a set time and a single beep will be heard. If no match is found, two beeps will be heard. Recording a card The unit can store up to four cards in the serially fed EEPROM. The MODE button is hit until the “rEC” message is dis­played. If the memory is full, there being four cards stored already, the display will alternate between “FULL” and “rEC” and you will not be able to store any more cards until you have used the delete function. Each time a card is entered, the unit jumps back to the operate mode until the function key is once again hit. Deleting a card You can delete a previously entered card by first hitting the mode button until “dEL” is displayed. Swipe the card to be delet­ed through the slot and if the card is found and deleted from mem­ory, a single beep is heard. If the card is not found the unit will beep twice. Relay operation When a card has been successfully recognised by the unit, it will operate the relay for a set time which will be between one and nine seconds. To set this time, hit the MODE button until the “rLAY” message is shown. Hit either of the SHIFT buttons to display the current setting. Using the SHIFT LEFT and SHIFT RIGHT buttons, set the relay on-time in the display to the desired number; eg, the display may show something like 0002, indicating that the relay will operate for about two seconds. Hit the mode button again to save the new number in memory. If using the unit as a door lock, you can remove the mag­netic card reader module from the PC board and extend its con­ necting cables to enable the two sections to be housed separate­ly. The two separated units can then be mounted on either side of the wall to provide greater security. Battery back-up Provision has been made for battery back-up in case of a power failure. The battery GND is commoned to the power supply ground and the battery +12V SC is connected via D2.