Reading Magnetic Card on Pic16f876


Closed Thread
Results 1 to 8 of 8
  1. #1
    Finn's Avatar
    Finn Guest

    Default Reading Magnetic Card on Pic16f876

    Question:
    I am fairly new to pics so please bare with me. I am using the Les Johnson program to scan the keypad(Keypad12.bas), After the keypad is scanned and the # key is pressed the following code is executed:


    Define OSC 20 'Crystal is 20MHZ
    Out1 VAR BYTE
    Card VAR BYTE[11]

    IF Key = 11 Then
    Write 0,Key 'Writes Value from Key to Memory Location "0"
    Read 0,Out1 'Reads Memory Location "0" and saves it as Out1
    Pause 30
    'SerOut PORTB.7,N2400,[#Out1] 'Sends Out1 to RS232 Transmitter ,8N1 Format
    Debug I,Clr
    Debug I,Line2,Clr
    Debug I,Line1,"Processing" 'Prints Processing to Serial LCD Line1
    Pause 3000
    Debug I,Line2,"Swipe Card Now" 'Prints Swipe Card Now to LCD Line2
    Pause 30
    SerIn2 PORTA.4\PortA.5,16468,300,Main,[Wait ";",Ao),STR Card\11] 'Trying to read data line from Mag Card Reader
    Serout PortB.5,N2400,[I,Line1,#STR Card\11] 'Trying to Print Data from Mag Card onto LCD

    EndIF

    After the "# "key is pressed I want to be able to read the Magnetic Card Data via A mag Card Reader: 9600/8/N/1. The data is being read from track Two in this format:
    TrackID/Data/'?'.
    the Track ID is ";" which is also the begin sentinel, the data follows and then the end sentinel is "?". I am trying to connect the mag card reader to the Pic16f876 and have pins 4 and 7 on the mag reader(DB9) connected to 5 volts, pin 5 to ground and Pin 3 connected to PortA.4. I cannot read the card data from the card reader. Can anyone help...maybe telling me what im doing wrong or guide me in the right direction?
    Thanks in advance.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I posted a Mag Card Reader program quite some time ago done in PBP at the Melabs website. Download it from ...

    http://www.melabs.com/resources/samp...ed/MagCard.txt

    Mag Card readers do not conviently output asynchronous serial data that can be read with SERIN. The bit stream is totally alien and SERIN, DEBUGIN, HSERIN etc just don't hit the mark.

    Melanie

  3. #3
    Finn's Avatar
    Finn Guest


    Did you find this post helpful? Yes | No

    Default Reading Magnetic Card on Pic16f876

    Thank you Melanie, I am checking it out now...Appreciate your response.

  4. #4
    Finn's Avatar
    Finn Guest


    Did you find this post helpful? Yes | No

    Default Magnetic Card and Pic16f876 (PicBasicPro)

    Melanie,
    I have a question on the Mag reader card hookups in your source code. Which pin is considered the clock pin on the DB9 Config and which is considered the card loaded and running signal. The pins I have hooked up are Pin 3(TX) Pin5(GRD)
    Pin4(DTR) to +5volts With 1,2,6,7,8 and 9 disconnected.
    Thanks,

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    The fast answer is I don't know your Card Reader. The program I put together was for a 'bare drive'. All the bare drives have basically the reading heads giving a Clock and Data output, and a sensor that detects when the card has been inserted. If your Card Reader is an intelligent one with some form of processing and an RS-232 interface built-in, then you should refer to the manufacturer for details. I would add that just because it's got a DB9 connector on it, doesn't mean it's got a standard Serial interface. It may have those basic signals brought out to the DB9 pins. I've seen people couple the wierdest things thru those 9-pin connectors.

  6. #6
    Finn's Avatar
    Finn Guest


    Did you find this post helpful? Yes | No

    Default Reading Magnetic Card on Pic16f876

    I checked through the datasheet and found pins I think I can use. For the Running and loaded signal im going to use DTR, or a constant 5 volts and the TX Pin for data. I was looking through you code and it seems that the program is ready to execute and recieve data when the clock signal is low, So maybe I can just set that pin to low and have it work? Also the data is coming in at 9600bps, which i imagine is the same as your "bare" reader. Is there a Define needed for the data rate?
    Thanks,

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    The first thing you have to do is identify if your Card Reader is intelligent with Serial RS-232 type output, in which case my program will not be suitable. You must ID the reader and it's connections first, otherwise you're just stabbing blindly in the dark.

    With separate Clock and Data lines, the host program syncs to the speed of the Clock signal. This Clock will vary in speed depending how fast a Card is swiped thru the Reader. As I recall, in tests, you couldn't physically swipe a card thru the reader so fast that the host PIC at 4MHz didn't catch it every time.

  8. #8
    Finn's Avatar
    Finn Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Melanie. Im going to do a little more research on the reader I have and go from there. Thanks for your help.

Similar Threads

  1. TTL magnetic card reader interface ith PC
    By attabros in forum Schematics
    Replies: 3
    Last Post: - 24th February 2016, 07:04
  2. Pot reading jumping like crazy!!!
    By champion in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 20th November 2006, 21:24
  3. Problems with CF card!
    By tom in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 16th November 2006, 06:48
  4. Magnetic Card Reader
    By humex in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st August 2005, 04:57
  5. Smart card reader with PIC16F84A
    By bangunprayogi in forum Serial
    Replies: 0
    Last Post: - 12th August 2005, 10:36

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts