This safety-lock circuit uses the new AVR microcontroller series, the ATtiny. This micros (and new ATmega8, ATmega16 etc) are powerful microcontrollers with new features like
and much more...
Schematic of safety-lock circuit
Most of the source code of this project its based on my Telecard reader project of my web site. The components for this project are few and ordinary, that means low-cost and easy-to-be-found. The "keys" are empty or not telecards (Phone cards. Not cell phone SIM cards), that can be found discarded on any telephone booth with no additional charge. To learn more about telecards read the phonecards_204.zip.
This circuit doesn't write any data to the telecard. The ATtiny26 reads the 16 first bytes of telecard and then store them in to the internal eeprom of ATtiny26.
When you insert any telecard in to the telecard holder (telecard`s slot) will be pressed the switch SW1. The ATtiny will see that a card was inserted in to the slot and reads the card. Temporary will save the 16 first bytes of the card to the RAM and after that the ATtiny will search in to its internal eeprom to see if this telecard was registered to the system. if not, it will turn-on the Red LED. The ATtiny has 8 groups of 16 bytes each, summary 8*16=128 bytes of eeprom memory.
The ATtiny of this circuit works with internal RC oscillator at 1MHz, that is the default setting from the factory.
1. Register a telecard to the system:
With any telecard in to the slot, press the SW2 for registering the card in 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 registered this telecard in 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
2. Unregister an registered telecard from the system:
If for some reason you don't want to use any of the 8 registered telecard, you can un-register it from the system. You have to insert this card in 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 were 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 un-registered 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.
3. 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 un-register one of the 8 already registered cards (step 2.) or by erasing the entire eeprom (writing the value $0F to all locations). For erasing the entire eeprom (128 bytes 0-127) you have to press the SW3 button with NOT any card inserted in to the slot, for 2 seconds, to ensure that we are not pressed the button SW3 accidentally . At this case the ATtiny it will flash the Red LED 4 times. After that, the internal eeprom of ATtiny will be cleared.
The values of default internal eeprom bytes are $FF. If we insert the telecard with wrong pins position (reverse), the ATtiny will read 16 bytes with $FF values because of internal pull-up resistor of PB4. If we let the eeprom to default value ($FF), when we insert any card (anything with a telecard dimensions) just to press the switch SW1, the ATtiny will read 16 bytes with $FF value (because internal pull-up 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 .
The internal eeprom of ATtiny26 with 8 different registered telecards (safety_lock.eep file)
You can not find ATtiny26 in the markets ?
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.
The AT90s2313 version of safety-lock
Your comments to My email
(c) 28.12.2003 by Serasidis Vasilis
updated at 29.01.2004