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

example of using servo? #148

Closed
zoooofu opened this issue Jan 9, 2017 · 6 comments
Closed

example of using servo? #148

zoooofu opened this issue Jan 9, 2017 · 6 comments

Comments

@zoooofu
Copy link

zoooofu commented Jan 9, 2017

I have known firmata.js providing servoWrite(pin, degree) and servoConfig(pin, min, max) to control a servo, can anyone give an example of using servoConfig api? On the other hand, why there is no any api of reading servo's degree, like servo.read() function provided in Arduino? Thanks.

@soundanalogous
Copy link
Member

The is an example in the examples directory: https://github.com/firmata/firmata.js/blob/master/examples/servo-config.js.

Regarding servo.read(), I'm soliciting feature requests for a new Firmata Servo 2.0 api here: firmata/protocol#78. So please add a request there.

@zoooofu
Copy link
Author

zoooofu commented Jan 12, 2017

@soundanalogous Thanks for your comment. I have commented something of Servo 2.0 api under your request, hopefully it would make sense.

@rwaldron
Copy link
Collaborator

servo.read() doesn't actually read the servo hardware, all it does is return the present position computed in terms of the latest tick in microseconds. The present position is always whatever your program last told it to be, so your code always knows exactly what it last wrote to the servo.

@zoooofu
Copy link
Author

zoooofu commented Jan 13, 2017

@rwaldron Thanks for pointing out my misunderstand of servo.read(). Here is the description of it from Arduino official site.

@soundanalogous
Copy link
Member

There is no guarantee the value returned by read() is correct. The servo could have been obstructed or some other reason that caused it not to move the full amount expected per the last call to write(). However returning the read() value from the firmware (the Servo library) would be more accurate than relying on the last write() value from the Firmata client, but that also comes with the cost of increased latency.

@rwaldron
Copy link
Collaborator

Here is the description of it from Arduino official site.

My summary was based on a review of Servo library source, to determine how it implemented read()

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

3 participants