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

Add PulseIn Implementation #396

Closed
wants to merge 1 commit into from

Conversation

stevemcquaid
Copy link

Add support for implementing the arduino pulseIn method and exposing that thru Firmata. Specifically needed for ultrasonic ranging sensors that use a pulse to measure distances. Polling the pin state over the network using a firmata client to take measurements is too noisy. The network latency is never going to be fast or stable enough to get any sort of accuracy for these timing-based sensors.

The time differential needed to compute measurements on these type of sensors, I believe, really needs to be done on the hardware itself. Network latency can add +-10 full milliseconds even under the best conditions. (Plus it would stink to have measurements change as a function of distance from wifi router.)

This code was taken from: @jgautier 's arduino fork,
Architectural approach from: @NeoPolus - pyFirmata#45
Relevant threads with gobot client:

@soundanalogous
Copy link
Member

The problem with this implementation is it contains long blocking delays. This is fine if the only thing the user needs is pulsein support in Firmata for a given application, but if combining with other general features such as digital I/O, analog in, PWM, I2C, UART, etc the user may experience unexpected behavior due to the blocking delays. That is why I do not want to accept this PR for the general purpose. Come up with a non-blocking implementation and I will consider it.

@mircobabini
Copy link

Hi there! I need the same thing.

First question: is it good to use the 0x74 for the feature?

Second question: @soundanalogous are you referring to the delayMicroseconds usage? Due to the fact that Arduino is not multithreaded, how is it possible to make it non-blocking?

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 this pull request may close these issues.

3 participants