Go Down

Topic: How can i measure 0.5 micro second pulse width with pulse in function (Read 211 times) previous topic - next topic

rahulkp1986

Hello all
I need to measure a pulse width up to .5 micro second resolution im using the below 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);
}
See also


I tried using arduino uno, STM32F103C8T6, and Lolin NodeMCU ESP8266 CP2102  all are giving resolution of 1 micro second, and there is an error of +- 2 micro second

i have heard STM32F103C8T6, and Lolin NodeMCU ESP8266 CP2102 are faster than uno.. so it should give much higher accuracy right? but in my case all are same

can anyone help?

AWOL

"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


Go Up