Arduino-FOC icon indicating copy to clipboard operation
Arduino-FOC copied to clipboard

_micros() accuracy

Open Polyphe opened this issue 4 years ago • 1 comments

Hello @askuric, When I use _micros(), I get 75us for the loop of FOC:

t0=_micros(); motor.loopFOC(); motor.move(); t2=_micros(); Serial.print("..."); Serial.println(t2-t0);

The result is t2-t0 = 94 with a time distribution of loopFOC() @75 + a move() @19 = 94us.

And, then, when I use this, I get 20us with an oscilloscope:

GPIOA->BSRR = GPIO_BSRR_BS15; motor.loopFOC(); GPIOA->BSRR = GPIO_BSRR_BR15;

I think there is an accuracy issue with _micros(). Maybe, use a Timer for a best accuracy as for the Atmega328, and increase the accuracy of all others measures of timing, velocity, and so on.

Best regards.

Polyphe avatar Dec 24 '20 10:12 Polyphe

It looks like in GPIO example you have ommited motor.move(); call which is doing a lot of things, depending on controller type.

KaSroka avatar May 30 '21 22:05 KaSroka