Shop OBEX P1 Docs P2 Docs Learn Events
Data Sheet Question — Parallax Forums

Data Sheet Question

simon2simon2 Posts: 10
edited 2006-11-05 18:07 in BASIC Stamp
Hello,
I'm trying to find out which protocol to use to cummunicate with the 21006516·from magtek
I can't figure it out just by reading the Datasheet.
I tried shifout and shiftin but it didn't work
thank you!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-01 23:01
    From the datasheet, it's clear that the reader is acting essentially as an SPI master, so the Stamp would have to be a slave. Both SHIFTOUT and SHIFTIN assume the Stamp is acting as an SPI master. You will have to program the protocol yourself. You need a loop that looks for CardPresent to go from HIGH to LOW (wait for it to be HIGH, then wait for it to be LOW). Then wait for the Strobe to go from LOW to HIGH and read the Data pin (and shift the bit into your result value). If you have all the bits, wait for CardPresent to go HIGH. If not, go back to wait for the Strobe to go from LOW to HIGH. Try something like this subroutine:
    BitsCnt        CON  10
    Value           VAR  Word
    CardPresent PIN 0
    Strobe         PIN 1
    DataPin       PIN 2
    ReadCard:
        Value = 0
        Do : Loop Until CardPresent = 1  ' Wait for HIGH
        Do : Loop Until CardPresent = 0  ' Wait for LOW
        For Bits = 1 To BitsCnt  ' BitsCnt Bits for this example
          Do : Loop Until Strobe = 0  ' Wait for LOW
          Do : Loop Until Strobe = 1  ' Wait for HIGH
          Value = ((DataPin << BitsCnt) | Value) >> 1 ' Accumulate MSB..LSB
        Next
        Return
    
    
  • KatyBriKatyBri Posts: 171
    edited 2006-10-02 01:53
    What are you using the 21006516 for?
  • simon2simon2 Posts: 10
    edited 2006-10-02 02:08
    Thank you!
  • simon2simon2 Posts: 10
    edited 2006-10-02 02:08
    I'm using to decode data from a head
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-02 02:12
    I just looked again at what I posted and the bit order is incorrect. Change the "Value = ((DataPin << BitsCnt) | Value) >> 1" to "Value = Value << 1 | DataPin" if you want MSB first. Keep my first posting if you want LSB first.
  • simon2simon2 Posts: 10
    edited 2006-11-05 07:17
    hello,
    I had tried the code provided by Mr. Mike Green but now I realize that I'm actually getting only half of the data.
    The Magtek Decoder sends the data at a rate of 3750 bits/secs, is the Basic Stamp too slow for it?

    Someone has suggested MAX3100 UART as a solution but I'm not sure I should use it because the data coming from the Decoder is not RS-232, it's actually a track from a magstripe. Between the stop and the start bit there is 37 chars each 5 bits.

    Is is possible to work with the MAX3100 or should I just stick to the Stamp alone?
    Thank you!
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2006-11-05 18:07
    Hi Simon, Iv never really studied this technology so I took a look at the link you provided, I am sure there are many many legitimate reasons for this device, like reading balances on a gift cards for example,·but its kind of scary to think information could be retrieved from a credit card, is that a possibility or am I just being paranoid.

    Jeff T.
Sign In or Register to comment.