Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] USB based Magnetic Card Reader Schematics

Status
Not open for further replies.

embedsys

Member level 3
Member level 3
Joined
Jan 18, 2011
Messages
57
Helped
19
Reputation
38
Reaction score
17
Trophy points
1,288
Location
India
Activity points
1,592
Dear All

I would like to design 3 Track Magnetic card Reader which is based on USB interface.

Please guys! help me to find the right Encoder or controller for my design.
 

fine. it was valuable. but i am looking for USB based solution.3 track magnetic card reader (Swipe method)
the PCB form factor is very less. So if it is a Single chip solution, that will be helpful to me.

Thanks in advance.
 

Use PIC with USB and the following code:
Code:
/////////////////////////////////////////////////////////////////////////
////                           EX_MCR.C                              ////
////                                                                 ////
//// This example program demonstrates the use of a magnetic card    ////
//// reader and MCR.C. The program calls mcr_read() and passes in    ////
//// pointers to two arrays. The mcr_read() will fill the arrays     ////
//// data read by the card reader. The data is then displayed and    ////
//// any errors are reported.                                        ////
////                                                                 ////
/////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996,2003 Custom Computer Services         ////
//// This source code may only be used by licensed users of the CCS  ////
//// C compiler.  This source code may only be distributed to other  ////
//// licensed users of the CCS C compiler.  No other use,            ////
//// reproduction or distribution is permitted without written       ////
//// permission.  Derivative programs created using this software    ////
//// in object code form are not restricted in any way.              ////
/////////////////////////////////////////////////////////////////////////

#if defined(__PCM__)
#include <16F877.h>
#device *=16
#fuses HS,NOLVP,NOWDT,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOLVP,NOWDT,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif

// Included for card read functionality
#include "mcr.c"

void main()
{
   int index;
   int error;
   char Track1[79];
   char Track2[40];

   while(TRUE)
   {
      printf("\r\n\nWaiting to read magnetic card...\r\n");

      // Read a card and get any errors
      error = mcr_read(Track1, Track2);

      // Display the data in track 1
      index=0;
      printf("Track1 Data:\r\n");

      // Loop until the end sentinel (?) is displayed.
      // This loop does not display the LRC character.
      do
      {
         // Display the character and increment the index
         putc(Track1[index++]);
      }while(Track1[index-1] != '?' && index<79);


      // Display the data in track 2
      index=0;
      printf("\r\nTrack2 Data:\r\n");

      // Loop until the end sentinel (?) is displayed.
      // This loop does not display the LRC character.
      do
      {
         // Display the character and increment the index
         putc(Track2[index++]);
      }while(Track2[index-1] != '?' && index<40);

      // Check for card reading errors
      if(error & MCR_ERR_PARITY1)
      {
         printf("\r\nTrack 1 parity error");
      }
      if(error & MCR_ERR_PARITY2)
      {
         printf("\r\nTrack 2 parity error");
      }
      if(error & MCR_ERR_LRC1)
      {
         printf("\r\nTrack 1 LRC error");
      }
      if(error & MCR_ERR_LRC2)
      {
         printf("\r\nTrack 2 LRC error");
      }
   }
 
Last edited by a moderator:

    V

    Points: 2
    Helpful Answer Positive Rating
Thank you verymuch for the program
if anyone knows the schematic design please share here.
 

Code:
#include <16F877A.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz)
#FUSES PUT                      //Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)


#ifndef MCR_CARD_PRESENT
#[B]define MCR_CARD_PRESENT   PIN_B0
#define MCR_DATA          PIN_B4
#define MCR_STROBE        PIN_B5[/B]
#endif


#define MCR_ERR_PARITY 2
#define MCR_ERR_LRC    8

int mcr_read(char* track2)
{
   int   error    = 0;
   int1  dataBit  = 0;
   int1  ST       = 1;
   int1  ST_old   = 1;
   int1  firstOne = 0;
   int1  parity   = 0;
   int   count    = 0;
   int   index    = 0;
   int   LRC      = 0;

   // Wait for card to be present
   while(input(MCR_CARD_PRESENT));

   // Loop until a card is not present
   while(!input(MCR_CARD_PRESENT))
   {
   // Check for NULL pointer and an index less than 40
      if(track2 != 0 && index < 40)
      {
         // Get strobe
         ST = input(MCR_STROBE);

         // If the strobe was high and is now low (falling edge),
         //then data is present
         if(ST == 0 && ST_old == 1)
         {
            ST_old = 0;

            // Check if the first 1 was received
            if(firstOne == 1)
            {
               // Check if 4 bits of data were received
               if(count == 4)
               {
                  // Reset the bit counter back to 0
                  count = 0;

                  // Shift the bits right by 4
                  *(track2+index) >>= 4;

                  // Verify the LRC
                  if(*(track2+index-1) == '?' && LRC != *(track2+index))
                  {
                     error |= MCR_ERR_LRC;
                  }
                  else
                  {
                     LRC ^= *(track2+index);
                  }
                 
                  // Add 0x30 to convert to ASCII
                  *(track2+index) += 0x30;

                  // Check the parity bit. The parity on a 0 is not checked
                  // because of the trailing zeros after the LRC character
                  if(!input(MCR_DATA) != parity && *(track2+index) != '0')
                  {
                     error |= MCR_ERR_PARITY;
                  }
               
                                   
                  // Reset the parity check
                  parity = 1;
                 
               
                  // Increment the index into the array
                  ++index;
                 
               }
               else
               {
                  // Get a bit of data from the card
                  dataBit = !input(MCR_DATA);

                  // XOR the data with the parity bit
                  parity ^= dataBit;

                  // Store the new bit of data
                  shift_right(track2+index, 1, dataBit);

                  // Increment the bit counter
                  ++count;
               }
            }
            else
            {
               // Check if the first 1 has appeard on the data line
               if(!input(MCR_DATA))
               {
                  // Set the first 1 received flag
                  firstOne = 1;

                  // Store the first 1
                  shift_right(track2, 1, 1);

                  // Increment the bit counter
                  ++count;
               }
            }
         }
         else if(ST == 1)
         {
            ST_old = 1;
         }
      }
   }

   // Return any errors
   return error;
}

void main()
{

   int index;
   int error;
   char Track2[40];

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   // TODO: USER CODE!!

while(TRUE)
   {
      printf("\r\n\nWaiting to read magnetic card...\r\n");

      // Read a card and get any errors
      error = mcr_read(Track2);
// Display the data in track 2
      index=0;
      printf("\r\nTrack2 Data:\r\n");

      // Loop until the end sentinel (?) is displayed.
      // This loop does not display the LRC character.
      do
      {
          //Display the character and increment the index
         putc(Track2[index++]);
      }
      while(Track2[index-1] != '?' && index<40);

      // Check for card reading errors
      if(error & MCR_ERR_PARITY)
      {
         printf("\r\nTrack 2 parity error");
      }
      if(error & MCR_ERR_LRC)
      {
         printf("\r\nTrack 2 LRC error");
      }
   }

}
 
Last edited by a moderator:

Thank you klystron. I am looking for Hardware Schematics..
Guys atleast, let me know what controller we use for encrypting the Magnetic card data.
 

Dear All!
Please let me know the MCU used in the USB magnetic card reader.
so that, I can design the schematics.
 

The card reader has the following inetrface (apart from ground and power supply) Card present signal, Data signal and the strobe or clock signal.
 

My suggest is to use IntelliHead from MAGTEK (magtek.com). It is magnetic head with incapsulated microcontroller. You can find modification with USB HID interface...You do not need any PCB design in this case.
In other case you will need any USB microcontroller and F2F decoder (magnetic card reader IC).
 

hello alexeink. you mentioned that intellihead has in built MCU.i have seen the datasheet(attached below). i wanted to know how to program that MCU since there are only two signal pins STROBE and DATA ( apart from voltage pins). also if i want to save that data on an on-board memory chip . do i have to use another MCU to control it or can i use that inbiuld MCU for this purpose. i am new to this website so pardon me for any mistakes.

https://www.magtek.com/documentation/public/99875258-9.02.pdf
 

Hello!
There is few types of IntelliHead. USB, UART, ShiftOut...and may be some else. First two have MCU inside. Theese MCUs provide data processing that comes from Delta ASIC and provide interface to PC. Theese types of IntelliHead have no DATA and STROBE pins(wires), but have appropriate interface pins (UART or USB). MCUs are preprogrammed for special functions and you can not change their functionality. If you want control data processing, you could use ShiftOut IntelliHead that not content MCU inside - it is Delta ASIC integrated in magnetic head. Delta ASIC it is magtek21006536(21006540 or 21006541) IC. This type of IntelliHead have DATA and STROBE pins(wires). Actually magtek Delta ASIC also have MCU inside, that process signals from magnetic head, but again you cant program it. What ever you use (USB, UART, ShiftOut IntelliHead) you have to use separate MCU and memory chip if you want save data onboard.
My suggest was according USB based Magnetic Card Reader but not according portable MSR.
 
  • Like
Reactions: azmati

    azmati

    Points: 2
    Helpful Answer Positive Rating
thank you alexeink . so this means that i will have to use an external MCU with shiftout intellihead.
 

Thank you all. planned to go for MagTek intellihead..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top