Pages: [1]   Go Down
Author Topic: pulsein() function read from magnetic head  (Read 364 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello!

I've made the circuit from that page: http://arduino.cc/forum/index.php?topic=92518.0 and i had connected the output from the 393 to arduino.
Using the pulsein function, when i swipe the card, the results are the folloving:

0
0
0
67
1
1
1
579
3
2
18
620
12
296
2
699
1
1
1
565
581
6
18
628
598
1
610
666
757
455
22
1
725
8
665
889
3
526
827
930
11
12
718
1
1
10
680
359
12
1
1285
1
25
0
0

Is this accurate?
And also, how can i transform this measurements of wave width into binary code?

Thank you.
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 211
Posts: 13469
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Big chance you missed a number of bits &| bytes. pulsein() waits for low, times a pulse. If in the time you are processing the pulses there is another pulse you will miss it.

Better connect the reader to the interrupt pin, fill an array with values and parse these.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12520
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

when i swipe the card, the results are the folloving:

...

Is this accurate?

Yes, I believe those are the results you saw. Whether those results match what was on the card, I don't suppose it would be possible to say unless you knew what data was on the card. Why don't you look at the source data, look at the encoding scheme and work out what the expected results ?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Big chance you missed a number of bits &| bytes. pulsein() waits for low, times a pulse. If in the time you are processing the pulses there is another pulse you will miss it.

Better connect the reader to the interrupt pin, fill an array with values and parse these.


This is my code :

Code:
int pin = 7;
unsigned long duration;
void setup() {
  Serial.begin(9600);
  pinMode(pin, INPUT);
}

void loop() {
duration = pulseIn(pin, HIGH);
Serial.println(duration);
delay(5);
}

Can you give me an example using interrupts?

Thank you both for replyes!
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 211
Posts: 13469
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


a starter,
- http://arduino.cc/en/Reference/AttachInterrupt -
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for your reply!

Also, if someone knows another schematic for transforming the analog signal to digital signal using lm393 comparator, plase reply me, because the schematic above is not good.

Thank you!
Logged

Pages: [1]   Go Up
Jump to: