Arduino Forum

Using Arduino => Sensors => Topic started by: chuckcfs on Feb 17, 2012, 11:17 pm

Title: Magnetic reader
Post by: chuckcfs on Feb 17, 2012, 11:17 pm
Hi there, I'm working on a project where I have to read a magnetic stripe like the ones on credit cards, i have a magnetic-head like this one, https://www.cardreaderfactory.com/support/index.php?/Knowledgebase/Article/View/15/1/magnetic-read-head-connections
The thing is that I'm unable to get any signal at all, currently I've connected the Track 3 pin to an amplifier and the output to the pin A0 on the arduino, I'm connecting the "head common" pin to ground, and I'm printing in the serial monitor the value on the pin A0, however it remains 0 ... any ideas on what I'm doing wrong, I've read on the forums something about using the ADC for this, can you guys explain a little about this, if this is the case?? =O

Thank you very much in advance!!

chuck
Title: Re: Magnetic reader
Post by: Grumpy_Mike on Feb 18, 2012, 07:18 am
The signal out of a magnetic read head is tiny, much smaller than you need to make any impact on the A/D converter on an arduino.
You need an amplifier in order to boost the signal to a suitable level. Google for - magnetic card reader schematics

This is a typical one:-
(http://www.hackersrussia.ru/Cards/Images/cop2.gif)
Title: Re: Magnetic reader
Post by: chuckcfs on Feb 20, 2012, 07:00 pm
Hey thanks for the answer, although I think you upload an image I'm unable to see it =S ... and also another question, should I connect the head common pin to ground???

Many thanks in advance  :)
Title: Re: Magnetic reader
Post by: Grumpy_Mike on Feb 20, 2012, 07:03 pm
Quote
although I think you upload an image

Yes I did, I can see it.
The link is:-
http://www.hackersrussia.ru/Cards/Images/cop2.gif (http://www.hackersrussia.ru/Cards/Images/cop2.gif)
Is your ISP blocking Russian web sites, naughty.
If so just google for a schematic. 

Quote
should I connect the head common pin to ground???

It depends on the circuit of the amplifier.
Title: Re: Magnetic reader
Post by: chuckcfs on Feb 20, 2012, 08:07 pm
thanks I'm looking at the schematics now, I found it weird in the amplifier for the +6V supply in the positive terminal of the op-amp, and also in the -input what is the write node?? the 393 if I'm not wrong it's a comparator isn't it with a pull-up resistor at the output, I think I'm interpreting this right
as far as the head common pin I think in this diagram should be connected to the (-)input right? and the track-3 (in my case) to the (+)input, but do you have what kind of signal should I be expecting to get in the arduino?? and can I read it directly in an analog input pin??

Thanks again :)
Title: Re: Magnetic reader
Post by: Grumpy_Mike on Feb 21, 2012, 07:45 pm
Quote
if I'm not wrong it's a comparator isn't it with a pull-up resistor at the output,

Yes that is right.
Quote
, but do you have what kind of signal should I be expecting to get in the arduino??

Yes it is a digital signal, because of that comparator. It will output pulses with the data being encoded in the pulse width. So you connect it to a digital input not an analogue one.
Title: Re: Magnetic reader
Post by: chuckcfs on Feb 21, 2012, 08:15 pm
Ok thanks a lot, I'm testing it in this moment, I'll let you know :)
Title: Re: Magnetic reader
Post by: chuckcfs on Feb 22, 2012, 08:59 pm
Hi, I'm able to read the signal now :) I'm not using the comparators only the amplifier and I'm reading the signal through the analog input pin in the arduino, however now I want to get the data from that signal, I'm thinking that I need the ADC but how can I do this since the encoding of the data in the magnetic stripe doesn't change in amplitude but in space between the peaks,

any ideas??

thanks a lot
Title: Re: Magnetic reader
Post by: retrolefty on Feb 23, 2012, 12:25 am
Quote
any ideas??


Yes, don't attempt to process the mag head signal via A/D, that way leads only to madness. The mag head signal needs to be conditioned and processed as a digital signal only. Trying to decode the encoding used to generate that signal in the analog domain is just wrong.

Lefty

Title: Re: Magnetic reader
Post by: Grumpy_Mike on Feb 23, 2012, 12:51 am
Use the comparator and feed it into a digital input. Then you can use the pulse in function to measure the width of the signals. That's where the data is.
Title: Re: Magnetic reader
Post by: chuckcfs on Feb 23, 2012, 01:45 am
Ok, first thing tomorrow I'll got for the comparators and try to get the data from the card by this way, I was trying to use an interrupt to "catch" the signal peaks and store 'em in an array to generate the F2F signal.

I'll try with the comparators,

Thanks a lot for all the help
Title: Re: Magnetic reader
Post by: retrolefty on Feb 23, 2012, 01:58 am

Ok, first thing tomorrow I'll got for the comparators and try to get the data from the card by this way, I was trying to use an interrupt to "catch" the signal peaks and store 'em in an array to generate the F2F signal.

Nothing prevents you from using interrupts once the signals (clock and data) has been conditioned and turned into a digital signals. In fact a cardreader project posted here several years ago did just that, the clock pulse wired to a arduino interrupt pin and the data wired to any digital input pin.

Lefty

I'll try with the comparators,

Thanks a lot for all the help
Title: Re: Magnetic reader
Post by: chuckcfs on Feb 24, 2012, 01:04 am
Hi I'm at this moment building the circuit with the comparators, I'm planning in using the interrupt to check when the card is being swiped, as far as the clock signal that lefty mentions I should feed the arduino with, where this signal come from?? the circuit with the comparators uses no clock right?? it just generates the F2F wave from the read head, am I wrong??

Cheers, :)
Title: Re: Magnetic reader
Post by: chuckcfs on Feb 24, 2012, 02:53 am
Hey by the way, in the circuit the comparator has a retro to the (-)input, why is this? I've never seen this kind of circuit using a comparator

thanks :)
Title: Re: Magnetic reader
Post by: retrolefty on Feb 24, 2012, 03:23 am

Hi I'm at this moment building the circuit with the comparators, I'm planning in using the interrupt to check when the card is being swiped, as far as the clock signal that lefty mentions I should feed the arduino with, where this signal come from?? the circuit with the comparators uses no clock right?? it just generates the F2F wave from the read head, am I wrong??

Cheers, :)


My reference to a clock and data signal was in regards to using those cheap surplus credit card readers (I got one for $5) where the analog conditioning and decoding of the low level analog read head signal is done internally and the user is given just TTL level digital output signals including serial data, serial clock, and card detected signals.

As you are taking on this low order conditioning yourself you will have to understand the magnetic encoding method being used before you can decode it properly. There are magnetic encoding methods that include both clock timing information as well as data value information on the single magnetic track and you are tasked with extracting the clock and data information from the composite analog signal. As I have no idea what encoding/decoding method you will be dealing with I can't give any better or more specific information or advice on the subject.

Good luck with your project.


Lefty
Title: Re: Magnetic reader
Post by: chuckcfs on Feb 24, 2012, 04:23 am
thanks a lot for the reply, in this project I've to use a magnetic head, not a pre-built reader so I'll have no clock data but that on the track itself, the encoding that I'll be dealing with (when I'm able to retrieve the F2F signal and the binary from that) is the ABA of the middle track of a credit card, however I've assemble the circuits on this forum and the one of this application note:
http://www.eettaiwan.com/ARTICLES/2001OCT/PDF/2001OCT04_AMD_CT_AN2112.PDF
However with both I'm having problems, the first (the one on this forum) the output changes from 0 to 1 even though I'm not swiping and when I pass the card it does nothing, the second one stays low all the time, and the voltages that I get are not the ones for the stable state presented in the app note, but I've built it three times from scratch with the same result every time
My magnetic head is working 'cause if I swipe it i can see the signal after amplification, however I'm unable to transform that signal to a F2F encoded wave :(

any help??

thanks a lot
Title: Re: Magnetic reader
Post by: Grumpy_Mike on Feb 25, 2012, 10:15 am
Quote
comparator has a retro to the (-)input

What does that mean?
The circuits in that PDF had no component parts, so you draw a schematic of what you actually are trying to build with real components.

Quote
I've built it three times from scratch with the same result every time

Looks like you keep making the same mistake then.
Title: Re: Magnetic reader
Post by: chuckcfs on Feb 29, 2012, 05:36 pm
Hi i meant the comparator of the circuit that was posted here on the topic, it's the second post, as far as for the PDF I know it has no components, but I assemble it with real components and it doesn't work, I don't know what can be wrong since it's just amplifiers and comparators, and i test each of the part separately and all is working it's just that it doesn't give the voltages for the steady state that the pdf shows, and I think that i can wire it fine, so I don't know what can be =S

Of the other circuit that i mention (the one posted here) if you check it the comparator has a wire from the (-) input to the output through a resistance, that's what i call retro and on a comparator I have never seen one (at least that I remember)

Thanks again :) 
Title: Re: Magnetic reader
Post by: Grumpy_Mike on Feb 29, 2012, 07:04 pm
Quote
that's what i call retro

Never heard it called that before.
Quote
has a wire from the (-) input to the output through a resistance

Yes it is used to control the hysteresis of the comparator.

Quote
I know it has no components, but I assemble it with real components and it doesn't work,

Yes that is why I was asking for the schematic of what you are trying to make with real components an part numbers to see if you had made a mistake with the conversion into a real circuit. There could be a problem with the type of op amp you are using, the feedback components or anything, but just saying it doesn't work is not very conducive to trying to find out what is wrong.
Basically it is a digital circuit but made with analogue blocks of that anadigm device. So you could just as easily do it in the digital domain.

I suspect however that you are not even getting a signal out of the first amplifier, do you have a scope you can measure things with?
Title: Re: Magnetic reader
Post by: saprodx on Feb 02, 2013, 11:53 am
I've made the schematic and there is the output after i swipe the card:

0
0
8
20
6
11
687
4
14
16
1
6
2
449
667
91
12
642
547
528
179
449
1
2
11
52
485
10
344
3
447
295
7
4
413
14
6
359
477
447
2
280
445
402
476
1
174
325
359
443
406
1
8
1
409
403
3
372
175
251
1
322
8
386
350
296
428
232
419
183
22
400
279
25
322
355
373
347
432
326
1
22
2


is this acurate? and if it is, how can i convert it to binary code?
Title: Re: Magnetic reader
Post by: Grumpy_Mike on Feb 02, 2013, 07:03 pm
Quote
is this acurate?

How can anyone tell? What is the number supposed to be on the card?

Quote
how can i convert it to binary code?

It is already in binary, that is how it is stored in the computer. When you print it out it is converted to decimal.
Exactly what do you want to do with the number? If it is just to print it the look at the serial.print in the reference and see what you need to add to get it to output in binary.
Title: Re: Magnetic reader
Post by: saprodx on Feb 03, 2013, 11:31 am
Do you think that is better to use a ADC IC instead of LM393 comparator?
Title: Re: Magnetic reader
Post by: Grumpy_Mike on Feb 03, 2013, 08:41 pm

Do you think that is better to use a ADC IC instead of LM393 comparator?

for what? you haven't said what circuit you have, generally though no.
Title: Re: Magnetic reader
Post by: saprodx on Feb 03, 2013, 10:54 pm
Using the schematic above, i think is better if i will use a ADC instead of LM393 comparator.
Title: Re: Magnetic reader
Post by: Grumpy_Mike on Feb 04, 2013, 12:18 am
No because what you need here is a comparator to detect a threshold value or not.
All an A/D will give you is a number that you will have to compare against to get a binary value. The same effect can be had by simply varying the gain of the amplifier.