Read Smart Cards With A BASIC STAMP

March 8, 1999
With eight general-purpose I/O lines and a regulated 5-V output, the BASIC STAMP 1 (created by Parallax, Rocklin, CA) can easily be interfaced to a standard smart-card connector (...

With eight general-purpose I/O lines and a regulated 5-V output, the BASIC STAMP 1 (created by Parallax, Rocklin, CA) can easily be interfaced to a standard smart-card connector (see the figure). Only four I/O lines, sometimes three, are needed to communicate with most of the “synchronous” smart cards, such as prepaid telephone cards, loyalty cards, or disposable “token” cards of all kinds.

The P0 to P3 I/O lines are still available for any application, related or not, to the “smart card” function.

Reading a card requires only a very short software routine. The example provided (see the listing) first resets the smart card, then reads 256 bits and stores them permanently into 32 bytes of the BASIC STAMP’s internal EEPROM memory.

Of course, a smaller number of bits could be read, at any valid location. This depends on the requirements of the application (the simplest smart cards contain only 104 bits, and the so-called “ID number” rarely exceeds 96 bits in length).

A very similar routine (using the EEPROM “read” instruction instead of the “write” instruction) could be used to check the contents of the smart card against what was previously recorded into the EEPROM.

Inserting a suitably “learned” card into the connector could energize a relay via one of the P0 to P3 I/O lines. It also could allow the execution of another part of the program, much like the way a “dongle” functions on a PC. Being powered through the “card present” contact of the card connector, the BASIC STAMP will run for quite a long time using a 9-V battery.

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!