Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
   
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   



Keyboard-Mouse Smartcard USB Lock with PICAuthor
Giorgos Lazaridis
June 6, 2012

PAGE 4 of 9 - The smartcard reader PIC Software


I began writing a simple routine for reading and writing smartcards into the PIC EEPROM memory, when i decided to make it more fancy. I planned to use only 2 buttons, but eventually i need all 3 buttons for the operations. The 4 SMD LEDs are used for the EEPROM card memory positions. So, let's name the buttons and the LEDs:

 
 



During prototyping, i soldered the 5-wire strip for the ICSP. Button 1 is the mode selection button. With this button you can scroll through the 2 main modes: the add card mode and the delete card mode. Button 2 is the memory selection button. By pressing this button you can scroll through the 4 memory positions. Finally, button 3 is the enter.

There is also another LED, a bi-color red-green LED. This LED is not mounted on the PCB because it must be visible to the operator. This LED turns GREEN if the correct card is inserted into the slot, and turns RED if a wrong card is in the slot. Additionally, this LED takes active part during memory operations.



The memory operations
1. Add Card
To go into the Add Card mode, press button 1 for some 3 seconds. The bi-color LED turns GREEN and the first free memory is indicated via the 4 memory LEDs. If there is no free memory position, then the 4 LEDs will flash some times and the controller will return to the standby mode. When in Add Mode, press the button 2 to scroll through the free memory positions, and select the one you want to store the card. Then, put the card into the slot and press button 3 for 1 second. If the card is valid, the memory LEDs will run an animation and the card will be stored into the selected memory position. You can only add new cards into empty memory positions. At any time you can exit this mode by pressing button 1 for 2 seconds.


2. Delete Card
To go into the Delete Mode, press button 1 for some 3 seconds to go into the Add Mode, and keep it pressed for another 2 seconds. The bi-color LED will switch from GREEN to RED indicating that you are in the Delete Mode. The first occupied EEPROM memory is then indicated via the 4 memory LEDs. If all four EEPROM memories are empty, the memory LEDs will flash some times and the controller will return to the standby mode. While in Delete Mode, use the button 2 to scroll through the occupied EEPROM memory positions. Select the one you want to delete an press button 3 for 1 second. The memory LEDs will run an animation to indicate that this memory position is now cleared. You can only delete memory positions which have already one card stored. At any time you can exit this mode by pressing button 1 for 2 seconds.


3. Memory Status
You can see which memory positions are occupied by entering the Memory Status mode. To do so, just press button 2 for 2 seconds while in stand by mode. The bi-color LED will flash in a fast rate indicating that you are in the Memory Status mode. Then, the memory status will appear on the 4 memory LEDs. If one memory position is occupied, the corresponding LED will light.


4. Clear the complete EEPROM memory
I added this operation mainly for debugging reasons, but it might be useful during normal operation as well. This operation clears all 4 memory positions. First go into the Memory Status mode by pressing button 2 for 2 seconds. Then, press button 3 simultaneously for another 3 seconds, without releasing button 2. The 4 memory LEDs will flash and the bi-color LED will then flash RED in a fast rate, indicating that you're about to clear the EEPROM memory. If you keep the two buttons pressed for another 3 seconds, then the memory LEDs will run an animation indicating that the EEPROM memory is not empty.



Here is the video of the Smartcard reader and how it works...






The PIC program
So, here is the assembly listing and the hex file for the PIC. I use the PIC 16F1939:


Version 2: Supports the serial interface for the ADG714 board

Download file
USB Smartcard Switch - Assembly Listing - Version 2.0

Download file
USB Smartcard Switch - Hex file - Version 2.0




Version 1: Supports only the relay switch

Download file
USB Smartcard Switch - Assembly Listing - Version 1.0

Download file
USB Smartcard Switch - Hex file - Version 1.0






Continue reading. Click here to go to the next page >>>.
 OR click here to view the presentation.



Comments

  Name

  Email (shall not be published)

  Website

Notify me of new posts via email


Write your comments below:
BEFORE you post a comment:You are welcome to comment for corrections and suggestions on this page. But if you have questions please use the forum instead to post it. Thank you.


      

  • At 25 October 2015, 7:00:24 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Oliver I found this one on ebay


  • At 22 October 2015, 15:06:45 user Oliver wrote:   [reply @ Oliver]
    • Hi,

      Where can I buy a smartcard slot? (the one you solder on the PCB)

      Regards,
      Oliver


  • At 20 August 2015, 22:08:48 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @doug No i do not have them as commercial units. But I do design commercial products for customers. If you wish you can contact me by email and discuss your needs.


  • At 20 August 2015, 17:39:11 user doug wrote:   [reply @ doug]
    • Giorgos, That is great. Are you or anyone commercializing these at all? I would buy 50 right now for a specialized facility I have but not sure I want to build that many myself.....


  • At 19 August 2015, 21:25:40 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Piyush Pandey I use the photographic transfer method.


  • At 11 August 2015, 12:01:12 user Piyush Pandey wrote:   [reply @ Piyush Pandey]
    • This is a very cool project of yours and I must admit that its a very well documented as well with snapshots wherever required.

      But Giorgos I want to know that what is the procedure you followed in making the
      PCB as I am greatly impressed the print and cleanliness of the PCB.


  • At 21 October 2012, 4:54:26 user PCB Assembly wrote:   [reply @ PCB Assembly]
    • This was one of the most well documented blog entries I have read in a long time. It was a pleasure to fill all the gaps I had about this topic. Well written an concise.


  • At 3 September 2012, 21:14:58 user pcb wrote:   [reply @ pcb]
    • Thanks for share this pcb layout design work... its give me more better ideas for my future projects...


  • At 3 September 2012, 21:04:29 user Thanassis Mavrogeorgiadis wrote:   [reply @ Thanassis Mavrogeorgiadis]
    • Very good project. Well done George!


  • At 14 August 2012, 20:56:06 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Pat I see what you mean... I think i will make some tests :D


  • At 14 August 2012, 20:09:12 user Pat wrote:   [reply @ Pat]
    • @Giorgos Lazaridis Yeah, like I said, it'll work... mostly. If you take a look at TPC 12 on the ADG714 datasheet, the frequency response at ~500 MHz is going to be around -8 dB. The maximum attenuation of a USB cable is basically the same as that ( http://www.usb.org/developers/presentations/pres0410/2-2_SSUSB_DevCon_PHY_Heck.pdf ) - so essentially, you've basically just put in a long USB cable.

      So long as you're talking about devices that are attached with, say, like a 1' cable or something like that, you won't notice basically anything. It's all just a question of how much margin you have left.


  • At 14 August 2012, 19:48:27 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Pat this was one of my concerned, it works ok until now, and i have test usb devices like external HDD (which i copied some 300GB of data with no problem) and also my camcorder uses the USB for the video. Nevertheless, have order relays with 4p2t if the adg fails or have slow data transmission.


  • At 14 August 2012, 18:23:49 user playfsx wrote:   [reply @ playfsx]
    • molis eida smartcard lock skeytika oti enas apo ellinas eixe kanei kati paromio me tilekartes kai tsoup na se pali :P ! ekseretiki douleia opws panta !


  • At 14 August 2012, 14:39:43 user Pat wrote:   [reply @ Pat]
    • "I'm not sure if the ADG714 can be used for USB applications."

      No, it can't. It's the bandwidth that matters, not the on-resistance. It has a bandwidth of 155 MHz, which is way below USB spec. This is because the ADG714's input/output capacitance isn't 6/4 pF: I'm not sure where you got that from (the digital input/output capacitance is 3/4 pF respectively). Its on capacitance is *22* pF. This is way, way too high: on a 50 ohm input that's a critical frequency of ~150 MHz.

      Switches designed for USB (like the FSUSB46) have on capacitances more like 4 pF, leading to a bandwidth of well greater than 480 MHz.

      This design will work... some of the time. Probably mainly with short USB cables and devices that are well within USB spec. Definitely with low-speed USB devices. But high-speed USB devices could easily struggle since you're probably tacking on at least ~6 dB of attenuation.


  • At 4 July 2012, 8:01:53 user George Karkalis wrote:   [reply @ George Karkalis]
    • Nice app,useful and educational if I may say so!



    delicious
    digg
    reddit this Reddit this
    Faves



     HOT in heaven!


    NEW in heaven!



    New Theory: AC electric motor working principle



     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS   

    Site design: Giorgos Lazaridis
    © Copyright 2008
    Please read the Terms of services and the Privacy policy