logo1.bmp (61374 byte)

home

nutchips

designs f.a.q.

provokations

crc guide who am I ? awards

 

an electronic key that fits your pocket and requires no batteries

Smartcard-controlled Relay

a clever pirate-card application

What is it | Schematic | Truth table | Prototype | Smartcard, how to

  Smartcard "funcard Purple Galaxy"


From a designer's perspective, there are no "good" or "bad" circuits. This article will show how to transform a "pirate" smart card (cheaply available almost everywhere nowadays , as consequence of digital TV piracy plague) into a legal and pacific electronic key application.

Opposite to popular belief, most TV smartcards are not clones of the original and trusted ones. Instead, they often are minature versions of general purpose microcontrollers - well known to the electronics enthusiasts - like PICs from Microchip or AVR from Atmel.

 

The relay triggers exclusively with the mating card

This design uses a smart card to enable a relay. A Nutchip recognizes its mating smart card among thousand similar ones, because you choose the code to be programmed in the card's memory. No speacilized knowledge is necessary, as we supply the card program and codes. Nutchip truth table is simple as well, so you should be able to adapt it to your needs (e.g., adding more than one card, or timing the relay). Even in its actual form, the board is ready to work in many useful applications:

  • open gates e.g. for park lots...
  • access control to gyms, swimming pools, tennis play fields...
  • switch on central heating or showers, or the football field lights...
  • enable TV viewing, photocopyng, faxing, coffe machine use, telephones etc.

Smartcards are very handy as they are compact, lightweight, and require no batteries. Cards are tough compared to remote controls, are resistant to dirt and wet, and don't break apart falling from a tabletop. If a card gets lost or stolen, you can reprogram the Nutchip in minutes, discarding the old code in favour of a new one, therefore making the old card useless.

      

AT A GLANCE

  • It's a board which fires a relay when a card with the correct code is inserted
  • The Smarcard sends a digital code among thousands different codes

HOW IT WORKS

Thanks to a nice trick:

  • The card provides a digital code which is virtually indistinguishible from a standard remote control code
  • The Nutchip senses the signal through its REMOTE input pin, and interpretes it as if it came from an ordinary remote control!

 

Schematic diagram

This card-activated realy requires just an handful of parts and is very simple. The active components in addition to the Nutchip are a 74HC00, a reset generator (IC3) and a transistor for relay switching.

Thereset integrated circuit IC3, an MC34064 from Motorola, guarantees a clean Nutchip RESET even in presence of electric noise coming from the power network. Its duty consists of discharging the capacitor C2 as fast as possible when a power drop is detected.

The Nutchip (IC1) is the heart of the device. Nutchip output OUT1 drives an LED (LD1) which is in series to a current-limiting resistor (R3). A separate output is used for dirving the relay (RELAY1) through a transistorized relay driver stage (TR1, R2, D1). The transistor works as an electronic switch, amplifying Nutchip output current from tenths of mA to tens of mA - a level suitable for driving the relay coil. Diode D1 protects the circuits from high voltages that are induced on the coil during switchoff.

schema elettrico

Schematic diagram. For simplicity's sake, card is depicted as viewed from top:
the actual connection is provided by means of a special slot connector.


But let's introduce the smartcard. We choose a "Funcard Purple": this is the usual name for a card embedding a powerful processor, an Atmel AT90S8515, and a serial EEPROM memory. Other "Funcards" similar to the "Purple" are the "Funcard Prussian" and "Funcard Prussian 256": these should be theoretically compatible, although more expensive. However, please note that we have not tried them, so take our word at your own risk.

As the Funcard Purple embeds a microcontroller, you must load it with a program written for this specific task before using it in our circuit. The program is a free download from the file "card_1234.hex", and we supply it ready made so you need only a programmer to get up and running. Once programmed, the Funcard's microcontroller will act as a remote control, generating a pulse train undistinguishible from a radio (RF) remote control. The resulting waveform is output on the smartcard pad labelled "OUT, which connects -though a suitable slot connector- to the Nutchip remote control input (REMOTE, pin 6). We placed a series resistor, R4, in order to protect the Nutchip from noise and spike pulses that can be generated during card insertion and extraction.

For semplicity's sake, the schematic diagram does not show the smartcard connector: instead, the smartcard picture is shown as it appears looking at it from the golden pads side.

We suggest to connect free gates inputs (there are 3 unused gates left from IC2, corresponding to input pins 4,5,9,10,12,13) to the negative power rail. This gates are high-impedance and should not be allowed to "float": caonnecting to GND avoids any floating.

Truth table

The truth table which implements our smartcard-controlled relay counts just a few rows. It is very similar to any truth table implementing a remote control with a Nutchip;

tavola della verità

You can type in the truth table or load it from file card.nut: it is just a starting point. It is easy to change it to get -for example- a longer timeout after removing the card, on to implement an on/off relay behaviour, so that a first card insertion causes the relay to switch on, a second one switches the relay off, and so on.. Another useful addition could be a second relay, with different timings: examples of this can be found on parking lot gates, when a first output opens the gate and an auxiliary one switches on the light. Well, more experienced users will now begin to see how to include a photocell in order to get the light on only at night... This is the beauty of Nutchips: start simple, and grow gradually adding more features!
Stop dreaming, let's continue with our description, and don't forget to set the remote control type to "Custom RF" and to input the correct key1 code. The code must be the same as the one programmed on the smartcard. Default code for our file card_1234.hex is 1234; instructions to chage this code are included in the same .zip file.

 

Prototype

We assembled a quick prototype on a breadboard. Despite the small component count, a great deal of care and attention is required. The photo show a simplified version of the circuit, which does not include the relay, the associated transistor driver, the RESET circuitry. This is perfectly OK in order to perform many lab experiments before going for a more definitive implementation, like preparing a printed circuit boards and soldering parts (note: PCB drawings not available).

Try to keep connections short, always less that 10 cm each, as shown by the photo. If possible, use a smartcard connector with all of the connection are clearly visible, like ours: this will help preventing errors. Always use colour-coded wiring: our example uses red for +%V, black for GND, light blue for 4 MHz buffered clock, green for unbuffered clock, orange for OUT.

Take care not to revert any part: LED, ICs (the photo shows both with pin 1 towards left side), power supply. In case of doubt, check the parts pinout page for details.

When you are finished with the circuit, and before applying power to the circuit, check once more all the connections. If everything corresponds to the schematic diagram, it is time for connecting the interface, switching on power, and programming the Nutchip.

Run Nutstation and load the truth table "card.nut", and select the "custom RF" remote control. From the remote control selection window click on key 1 and input "1234" as the key code. This applies if you are using the default .hex file for the smartcard, otherwise change it accordingly to the new code.Program the Nutchip.

Programming the smartcard with the file "card_1234.hex" is a separate task. You can ask your card supplier to do the job for you - it takes only a couple of minutes - or you can do it yourself with one of the many smartcard programmers commercially available.

Once the Nutchip and smartcard are programmed, you are ready for the conclusive test! Power the circuit, and slide the card in gently. Does the LED light up? Yes? Congratulations, everytihs works to the perfection!

 

foto montaggio sperimentale

Parts placement for a simplified lab experiment. We prefer a card connector whit all of the contact clearly visible, in order to prevent connection mistakes. This prototype omits relay and RESET circuitry (R2, TR1, D1, RELAY1, IC3, R1, C2).

 

Smartcards, connettors and programming

Smartcard, connectors and special programmers are sold online by may sites and often found in flea markets and ham fairs.

As this smartcard use is 100% legal, feel free to ask your supplier to program your card with the file "card_1234.hex" when you buy it.

You can also get a card programmer for a sum varying to less than the price for the connector itself to very expensive and fancy ones. We succesfully used the cheapest one, known as "Funcard Light", which costs a few euros and is made from just three resistors (!) other than the PC parallel port and card connectors.

Funcard Light schematic is available online from the following site:

http://www.funcard.net    

 
foto programmatore
The "funcard light" programmer is litlle more than three resistors

You need also a suitable software to drive the programmer. We used Funprom, that we have downloaded from the same web site. Although most softwares ask for THREE files to be loaded to the smartcard (flash, internal, external), our project needs only the "flash file" to by loaded, that is "card_1234.hex".

Parts list:

IC1: Nutchip NUT01-AK (buy it from Nutchip dealers)
IC3: reset generator IC type MC34064
IC2: CMOS logic gates IC type 74HC00
R1: 100 kiloohm 1/4W resistor
R2: 4700 ohm 1/4W resistor
R3: 390 ohm 1/4W resistor
R4: 1000 ohm 1/4W resistor
C1, C2: 100 nF capacitor (ceramic)
RELAY1: SPST relay , 5 Volt coil
CN1: programming interface connector
CN2 (non drawn on schematic): Smartcard "slot" connector
CARD1: "Funcard Purple" smartcard, programmed (see text)
OSC1: 4MHz, 3-pin ceramic resonator
D1: 1N4007 diode
DL1: LED (red)
TR1: NPN transistor type BC337
M1, M2: pcb mount,bipolar, screw clamps

 

you need also: 5 volt regulated power supply, 20-pin socket for Nutchip, 14-pin socket for IC2, prototype board or printed circuit board.

 

home

nutchips

designs f.a.q.

provokations

crc guide who am I ? awards
home | nutchips | designs | f.a.q. | provokations | crc guide | who am I ? | awards