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

sonar sensor problem(hcsr04) - time_pulse_us #26

Closed
crouse12 opened this issue Nov 22, 2020 · 11 comments
Closed

sonar sensor problem(hcsr04) - time_pulse_us #26

crouse12 opened this issue Nov 22, 2020 · 11 comments
Milestone

Comments

@crouse12
Copy link

crouse12 commented Nov 22, 2020

The following code for hcsr04 can work on microibit v1, but it cannot work on microbit v2.
Python editor version for my test is 2.1.0-beta.7.
I think time_pulse_us or sleep_us has some bugs.

image

@microbit-carlos
Copy link
Contributor

What's the result you get in a v1 vs v2?

@crouse12
Copy link
Author

microbit v1 show distance on led screen.
However, microbit v2 does not show anything.
I found that makecode has the same issue.

microsoft/pxt-microbit#3731

@crouse12
Copy link
Author

crouse12 commented Dec 7, 2020

I find v0.2.23 of codal-microbit-v2 now released.
It solves pulse problem.
Does micropython update, too?

microsoft/pxt-microbit#3731

@dpgeorge
Copy link
Collaborator

Yes MicroPython is now updated to codal v0.2.23.

@jaustin
Copy link
Contributor

jaustin commented Dec 14, 2020

@crouse12 could you please test with the build from https://github.com/microbit-foundation/micropython-microbit-v2/actions/runs/419939816 (this is an automatically built version from a commit on master, so isn't exactly what the next release will look like, but does have the updated CODAL).

@crouse12
Copy link
Author

I test time_pulse_us on microbit v2 using the following two MicroPython Versions.
However, they cannot work.
I think there are something wrong on time_pulse_us.

image

image

@jaustin
Copy link
Contributor

jaustin commented Jan 20, 2021

@dpgeorge does the patch from @xmeow look okay to you? Would be great to close this off with the next release if so?

@microbit-carlos microbit-carlos changed the title sonar sensor problem(hcsr04) sonar sensor problem(hcsr04) - time_pulse_us Feb 1, 2021
@microbit-carlos
Copy link
Contributor

microbit-carlos commented Feb 5, 2021

Looks like PR #58 is adding the CODAL method to the MicroPython pin API. I think ultimately what we need is to make sure machine.time_pulse_us works on V2.

MakeCode also had an issue in this area, and the feature was originally implemented in the MakeCode code too, so the functionality has been moved to CODAL.
It'd be good to use CODAL in this case as well to unify the implementation.

@dpgeorge
Copy link
Collaborator

dpgeorge commented Feb 8, 2021

machine.time_pulse_us() has been fixed by b7a76e4 . So this function should now work the same as on V1.

It'd be good to use CODAL in this case as well to unify the implementation.

If the built-in MicroPython one works, is it ok to just keep that the way it is?

@jaustin
Copy link
Contributor

jaustin commented Feb 12, 2021

I think if it's not a trivial switch over, I'm happy to leave things as they are with the V2 implementation.

@microbit-carlos
Copy link
Contributor

Great, closing this as fixed. 🎉

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

Successfully merging a pull request may close this issue.

4 participants