-
Notifications
You must be signed in to change notification settings - Fork 148
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
Ultrasonic Distance Sensors #1080
Comments
Are you maybe using a HC-SRO4 library that does not support the modern Attinies and subsequently gets all of its timekeeping wrong? |
Nope, no libraries are included in the sketch. I have also observed the issue with other sensors: Ping, RCWL-1601, and US-100. Thanks for the response. `// Minimal sketch from Arduino "Ping" example void setup() { |
I am getting the same as you. tested with a AT404 You could try this for now. Seems to give correct results in all clockspeeds
|
If pulseIn is broken this bug is double-red critical priority, as pulseIn is one of the most highly analyzed pieces of code in this entire core,and is considered the only 100% reliable way to measure time of an external event. It is used in our calibration routines, everything - but I can't see how this sort of error could happen, as we have tested pulseIn at literally every speed that the internal oscillator of the chip works at since that is how we perform all calibration. Can you get the intermediate values that you're seeing out of this so we can see where this is going off the rails? If pulseIn is not working, until this is confirmed and the fix is implemented (which will be an emergency release), the core should be considered unfit for any application which requires any timekeeping accuracy of any sort. pulseIn should be the iron clad leaves nothing to chance way of timing something, and is used in numerous places in supporting code with the assumption that it will work under all cases other than misleading the chip about it's operating frequency.Hence, if this is not the case, the foundations on which all confidence in the core's ability to keep time are based on a false assumption, and hence cannot be trusted |
Besides the pulseIn duration included in the examples |
I also see the same with AT412 and AT1616 (Adafruit Seesaw board).
…On 04-05-2024 12:45, Hans wrote:
I am getting the same as you. tested with a AT404
The odd thing is that pulsein gives different feedback when you
compile for different clock speeds.
E.g. when I compile at 1MHz, the distance measurement is OK.
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
***@***.***>
Links:
------
[1]
#1080 (comment)
[2]
https://github.com/notifications/unsubscribe-auth/A5CXQ2JDVQL4JH6EY5O2GNTY33PL7AVCNFSM6AAAAABFYOE4VCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBQGMZDMMBQGU
|
I have created a small demonstrator program that requires no external parts The RTC is used to toggle a pin, because the RTC has it's own clock.
The results are:
I ran this on a 204, 404, 1614, 416, 806 and 1626 all with comparable results as above. I have used the Github version of MegaTinycore with a last source fetch date of 29 March 2024 |
I have tested again with an older version of MegaTinycore (2.6.8) and in that version Pulsein works fine. 2.6.9 is not installable, (CRC error), so this regression took place in 2.6.9 or 2.6.10
|
I think this commit caused the regression. When I revert the changes of this commit pulsein works ok again. Though at the cost of breaking millis() as 3 other changes were done that day, but the redefinition of microsecondsToClockCycles smells dangerous, as pulsein() is using it. |
I was able to reproduce the Problem, it's fixable by adding the cast to this line in wiring_pulse.c: In order to optimize millis, I had to remove the casts from the defines, as they were interfering with some Preprocessor defines. EDIT: PR is out |
Agree with you that's by far the best option, or you won't know whose code you are breaking. |
I am experiencing an accuracy problem with all of the MegaTinyCore devices I have tested (ATtiny 402, 1614, 1616, 414, 32xx
). This appears to be a core issue, as the same sketch and hardware works properly with DxCore (DB28, DD14, DD20) and Arduino Uno and Nano. Using a slightly modified example Ping sketch from the Arduino IDE (1.8.13) and a common HC-SRO4 ultrasonic sensor aimed at a flat target about 5 inches distance the ATtiny processors give a distance of about 105 inches while the DxCores correctly measure about 5 inches. All are running at 5 Volts and 20 or 24 MHz with default IDE settings. Any suggestions regarding what I am overlooking, or may this really be an issue with the core?
Basic_Ping_Print.txt
The text was updated successfully, but these errors were encountered: