Custom Search

Saturday, August 28, 2010

Electronic safety-lock with telecard as key

This safety-lock circuit use the new Atmel AVR microcontroller series, the ATtiny26. This micros (and new ATmega8, ATmega16 etc) are powerful microcontrollers with new features like
  • internal RC calibrated oscillator for 1,2,4 and 8 MHz speed (working with external RC up to 16 MHz too)
  • Analog to digital converter 10-bit (10 channels)
  • Very high speed In System Programming (compare it with AT90Sxxxx series)
  • internal Brown-out detector
and much more...
Circuit description
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.
Electronic safety-lock with telecard as key
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.
1. 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
2. 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.
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 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.
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.

No comments:

Post a Comment

saran dan coment teman teman sangat membantu pertumbuhan blog ini,terimakasih

My Headlines

Laman