Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

micros() function missing in Arduino.h #54

Closed
oscaropenness opened this issue Jan 14, 2020 · 6 comments
Closed

micros() function missing in Arduino.h #54

oscaropenness opened this issue Jan 14, 2020 · 6 comments

Comments

@oscaropenness
Copy link

For using ultrasonic sensors, accurate (microsecond) time measurements are necessary.
The micros() function seems currently not implemented in the board definition for the ArduinoIDE.
Using the implemented millis() function is unfortunately not precise enough.

Can the micros() function be implemented in Arduino.h as well?

@heyderpaez
Copy link

I have the same issue. I have not even been able to execute the basic examples for HTCC-AB01 due to the error of the micros () function.

@lnlp
Copy link

lnlp commented Jan 31, 2020

This appears to be a bug and really should be fixed for compatibility with the basics of the Arduino framework.

@OstertagM
Copy link

I have same problem

@dbuggz dbuggz mentioned this issue Feb 27, 2020
@kkalbaugh
Copy link

kkalbaugh commented Mar 11, 2020

Also having the same issue with Lorawan example getting the error in Adafruit_NeoPixel.h and using a dallas DS18B20. I have Adafruit NeoPixel v1.3.5 installed.

In file included from C:\Arduino\hardware\CubeCell\ASR650x-Arduino\libraries\LoRa\src\LoRaWan_APP.cpp:3:0:

C:\Arduino\libraries\Adafruit_NeoPixel/Adafruit_NeoPixel.h: In member function 'boolean Adafruit_NeoPixel::canShow() const':

C:\Arduino\libraries\Adafruit_NeoPixel/Adafruit_NeoPixel.h:234:58: error: 'micros' was not declared in this scope boolean canShow(void) const { return (micros()-endTime) >= 300L; }

@Heltec-Aaron-Lee
Copy link
Collaborator

Just added two examples: micros and millis.

micros
The micros function uses the internal system ticker (48MHz timer), this timer of ASR6501 is not accurate, as tested, it has 1.7% error.
image

The delay in the example is 1000ms, ideally, the output value here should be 1000000.

But look at the printed time stamp, each print have 20 - 22ms error. It means the actual delay(1000); spend 1020 - 1022ms. Because the delay uses internal system ticker too.

So the error is (1020000 - 1002735) / 1020000 ≈ 1.7%

That’s why I didn’t use system ticker for LoRaWAN operations. Another problem is the system ticker can’t run during the deep sleep period, wake up from deep sleep will make the micros back to 0.

millis
image

The millis function uses external 32.768KHz RTC clock, it a very accurate timer, and can run during the deep sleep period. As the picture has shown, it’s the same with the delay time.

But the minimum period is 1/32768 ≈ 30us, can’t be the source of micros.

@Heltec-Aaron-Lee
Copy link
Collaborator

This problem also talk here:
http://community.heltec.cn/t/cubecell-micros-function/985/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants