Go Down

Topic: pulsein() function read from magnetic head (Read 481 times) previous topic - next topic

saprodx

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.

robtillaart


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.
Rob Tillaart

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

PeterH


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 ?
I only provide help via the forum - please do not contact me for private consultancy.

saprodx



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: [Select]
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!

robtillaart


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

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

saprodx

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!

Go Up