Electronic safety-lock

[b:0498ae6123]Introduction[/b:0498ae6123]
Most of the source code of this project its based on my Telecard reader project of my web site ([url]http://www.serasidis.gr/circuits/telecard_reader/telecardreader.htm[/url]). The components for this project are few and ordinary, that its mean low-cost and easy to find them. The “keys” are empty or not telecards that you can find them on any telephone booth and with no charge. To learn more about telecards read the phonecards_204.zip.

[b:0498ae6123]Circuit description[/b:0498ae6123]
This circuit its not write any data to the telecard. The ATtiny26 read the 16 first bytes of telecard and then store them to internal eeprom of ATtiny26.

When you insert any telecard to the slot (telecard`s base) it will pressed the switch SW1. The ATtiny it will understand that new card insert in the slot and go to read it. Temporary will save the 16 first bytes of the card to the RAM and after the ATtiny will search in internal eeprom to see if this telecard is registered to the system. if not, it will turn-on the Red LED. The ATtiny have 8 groups of 16 bytes each, summary 8*16=128 bytes of eeprom memory.

The ATtiny of this circuit its working with internal RC oscillator at 1MHz, that is the default setting from the factory.

[b:0498ae6123]1.[/b:0498ae6123] Register a telecard to the system:
With any telecard in to the slot, press the SW2 to register the card to the system. The ATtiny will search the internal eeprom for empty memory group (1 group=16 bytes with $0F values). If there is empty group, it will read the 16 bytes from RAM and store them to the eeprom. Then, the ATtiny will reboot, reset the telecard, read it again and check if the card is registered (by compare the 16 bytes of telecard, with 1 group at the time, with internal eeprom) .

Now it will turn-off the Red LED and turn-on the green LED because we have register this telecard to the system. At the same time it will arm the relay connected to PB6 pin via BC547.

The internal eeprom of ATtiny26 is 128 bytes. So, we can register up to 8 telecards (keys) to this memory.

(8 telecards)*(16 bytes for each telecard)=128 bytes of internal eeprom

[b:0498ae6123]2.[/b:0498ae6123] Unregister an registered telecard from the system:
If for some reason we don’t want to use any of 8 registered telecard, we can unregister it from the system. We have to insert this card to the slot, the ATtiny accept it (by turn-on the green led). If we press the SW3, the ATtiny will search to internal eeprom to find were the 16 bytes are stored and delete them by write the value $0F to this memory group. Now the ATtiny will reboot, read again the telecard, compare the first 16 bytes of the card with the internal eeprom and because we have unregister this card it will turn-on the red LED. This telecard is unregistered now. We can register the card again if we want to, by follow the step 1.

[b:0498ae6123]3.[/b:0498ae6123] Erase entire internal eeprom of ATtiny26:
If we have register 8 telecards to the system and will try to register 1 more (9th), when we press SW2 to register the card, the ATtiny it will flash the Red and Green LEDs 4 times alternately. The only way to register some other telecard, is to unregister some one of 8 registered cards (step 2.) or to erase entire eeprom (writing the value $0F to all locations). To erase entire eeprom (128 bytes 0-127) we have to press the SW3 button with NOT any card inside to the slot, for 2 seconds, to ensure the ATtiny that we are not press the button SW3 by asccident . At this case the ATtiny it will flash the Red LED 4 times. After that, the internal eeprom of ATtiny it will cleared.

The values of default internal eeprom bytes are $FF. If we insert the telecard with wrong pins position (reversely), the ATtiny will read 16 bytes with $FF values because of internal pullup resistor of PB4. If we let the eeprom to default value ($FF), when we insert any card (anything with telecards dimensions) just to press the switch SW1, the ATtiny will read 16 bytes with $FF value (because internal pullup resistor of PB4) and will arm the relay. By set the eeprom to $0F value, at the phase of programming the safety_lock.eep file of ATtiny, we protect the system from this mistakes.

You can replace the $0F value of the source code with the value of your choice, for example $AB or $CF etc. Remeber to replace all the $0F values of the source code, not only the 128 bytes of eeprom. The telecard base and the main circuit are build them to different boards for more commodity.

Below is a picture of the internal eeprom of ATtiny26 with 8 different registered telecards (safety_lock.eep file)
[img:0498ae6123]http://www.circuitdb.com/download.php?fileID=72[/img:0498ae6123]

Schematic, hex and source code of safety-lock project are in safety_lock.zip

[b:0498ae6123]You can not find ATtiny26 in the market?[/b:0498ae6123]
If you can not find the ATtiny26 in the markets, you can use the AT90s2313 that is most ordinary. For that i made a new version of safety-lock for AT90s2313 microcontroller. The characteristics of the safety-lock are the same with ATtiny26 version (erase-register-unregister card-, functions). The only change is the different pins-ports connections between telecard and microcontroller and the addition of 4 MHz crystal, because the ATtiny26 works with the internal RC oscillator at 1 MHz.

Schematic, hex and source code of the AT90s2313 version safety-lock project are in safety lock 2313.zip

Copyright 2003 Serasidis Vasilis ([url]http://www.serasidis.gr/[/url])

Leave a Reply

Your email address will not be published. Required fields are marked *