Move servo with speed and hold position #6641
Replies: 1 comment
-
Posted at 2022-05-30 by TheLogan I found a "workaround", not perfect at all, but it sort of does what I want.
Posted at 2022-06-07 by @gfwilliams You might just be able to use:
It feels a bit hacky though! Maybe the servo library should provide a function for it Posted at 2022-06-07 by TheLogan That would be the best solution. Posted at 2022-06-08 by @gfwilliams Great! https://github.com/espruino/EspruinoDocs/blob/master/devices/Servo%20Motors.md https://github.com/espruino/EspruinoDocs/blob/master/devices/servo.js Posted at 2022-06-08 by TheLogan So this is the actual servo script? I thought it was just part of the documentation, I didn't think to look for the file in the EspruinoDocs repo xD Posted at 2022-06-08 by @gfwilliams Yes, that's it! Yes, pretty much all the module source is also in EspruinoDocs! Posted at 2022-06-08 by TheLogan I think this is the first pull request I've ever done between forks and the first one on GitHub for that sake. I hope I did it correctly xD Posted at 2022-06-09 by @gfwilliams Looks great! Just merged! It won't be live immediately, but give it a few days :) Posted at 2022-06-09 by TheLogan Great, looking forward to it :) Posted at 2022-06-19 by GermanWarez Tbh, I'm not a fan of the merge: In line line 116 in devices/Servo Motors.md was changed to use software PWM instead of hardware PWM, besides the fact that the description above says 'You can also use a hardware timer to produce the pulse...'. And in line 119 in devices/Servo Motors.md only the comment was modified, now it includes '... devices/Servo Motors.md'. I'd say '// move to position 0.5 over 1 second' would be correct. Posted at 2022-06-21 by TheLogan I can totally see your point, I may have misunderstood what is happening.
Where what I actually saw was: How would you suggest the change be implemented? :) Posted at 2022-06-21 by GermanWarez Oh yeah, the soft option, and the analogWrite that is actually a PWM - it's not self-explaining. As a quick hack something like this:
It would be possible to add the option 'hold' to the 'connect' function, then there's no need to include it in every call to 'move'. The code is not tested. Posted at 2022-06-21 by TheLogan I'll look it over and test it tomorrow :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2022-05-30 by TheLogan
I am playing around with a servo.
I get that I can do
This will move the servo to position 0.5 over 3 seconds, however, it doesn't hold the position, so in this case, I am opening a chest, and once the chest is open the weight of it makes the lid slowly close again which is not what I want.
I also get that I can do
This will move the servo to the position taking 1 second and will hold the position, but I can't seem to find a way to set the speed/time by which it moves.
I've tried with interval and moving it a set amount but that results in jaggery movement (I set it with an interval of 20ms, that should not be perceptible, but it was)
Does anyone have any ideas of what I should do to get both the speed/time control, and get it to hold the position once it reaches it? :)
Beta Was this translation helpful? Give feedback.
All reactions