-
Notifications
You must be signed in to change notification settings - Fork 39
Add support for Servo #16
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
Comments
This waits until a pulse has just been completed to change the compare register values. This attempts to solve isse #16. servoWrite could cause the signal to be inverted if/when the compare registers were changed at the same time that they matched the timer. This attempts to wait until the timer value is below the smaller compare register to make any changes.
@nseidle caught the moment of inversion on a logic analyzer. You can see that the timing between servo frames was 21.9 ms consistently. You can also see regular 15 ms spacing between short blips toward GND after the inversion. You will find that these two frequencies meet perfectly at the E1 marker - GND zero. The test code was waiting 15 ms between each call to servoWrite(). When that delay collided with the asynchronous timer comparison bad things happened (* insert some explanation for what happened in the bowels of the silicon * ) and the signal was inverted. Commit 82089ed tries to solve this in a stateless manner by ensuring that the timer value is less than the smaller of the two compare values. Initial testing looks promising, however it's still possible that the servoWrite() function tries to change the register values right when ctimer_val == cmpr0_val. I don't know what will happen in that case. This solution is nice because it avoids the need for an 'is initialized' array for analog output pins. |
Closing until we hear more... |
Add support for the Arduino library Servo. Owen's already got the analogWrite() function examples that show how to do this. We just need to build out the other parts of the library API.
The text was updated successfully, but these errors were encountered: