Go Down

Topic: PulseIn don't work well (Read 2 times) previous topic - next topic

alejandroerickson

#5
Feb 13, 2011, 12:55 am Last Edit: Feb 13, 2011, 12:58 am by alejandroerickson Reason: 1
noted.  thanks for the tips!

my thought would be run loop for a while and gather "gap"s in a buffer.  when the buffer is full, report the values and quit.  that way you wouldn't risk missing as much stuff while you are printing "gap" and disabling interrupts.

I guess in the code I posted, you would do

Code: [Select]

cli();//disable interrupts
uint32_t printgap = gap;
sei();//enable interrupts
Serial.print(printgap);

Coding Badly


retrolefty

Or you could use the Arduino predefined way:

Quote
noInterrupts();  //disable interrupts
uint32_t printgap = gap;
interrupts();     //enable interrupts
Serial.print(printgap);


Lefty

kurama

Hey guys,
   Alejandro, thx for the code and explanation, i'm integrating it in a school project, just one question, can your code be addapted for pulses from HALL sensors?, and measure the time between pulses?

Go Up