-
Notifications
You must be signed in to change notification settings - Fork 92
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
[Question] Weird Servo Motor Movement #108
Comments
Hi @d-graz , This problem is caused by some limitations of the PWM implementation in simavr (used by PICSimLab to simulate AVRs). |
Hi @lcgamboa, thank you for the very clear explanation. |
Hi @d-graz , PICSimLab currently uses a fork of simavr with some modifications compared to the original. In the future (when I have time) I intend to use the original version in PICSimLab. Comparing the PWM of the two versions, the original version no longer has the "wobble" but has the same position error. Setting the input voltage to 2.5v results in an angle of 89 degrees and an output pulse of 1.371 ms instead of 1.5 ms (1.4833 to be exact). In a real Arduino Uno board, the pulse has the correct value, so the problem is in the simulator and not in the code and library. I believe it is more appropriate for you to collaborate with the original fork, if you can solve the problem there, I just copy the solution into the fork used by PICSimLab. In the original project, there is more support and reviewers. |
I will in advance admit that I'm not a pro user of this very nice piece of software (as i started using it 2 weeks ago). I have noticed the following using
Servo.h
library:myservo.write(0)
works great and brings the motor to the correct anglemyservo.write(180)
works great and brings the motor to the correct anglemyservo.write(90)
does not works as expected as the motor reaches approximately 75 degrees and seems to wobble a bit while doing so.At the start i tough that there was a problem in my code or my installation of the simulator but then i checked out also the online one to find that the same problem persisted.
For example here in one of the example available on the wiki if you set the potentiometer to 2.5V (half of his 0V-5V range) the servo motor should reach 90 degrees but as you can see this does not happen.
I'm not marking this as a bug because maybe it's a simulator limitation or I'm not aware of some physics law the simulator is applying.
I would be happy if someone could give me an explanation for this behavior.
Thank you in advance.
The text was updated successfully, but these errors were encountered: