3
$\begingroup$

i need your advice if someone experienced something similar. I try using digital servo but when i tried to connect it to board by this tutorial https://blogs.oracle.com/hinkmond/entry/connect_robot_servo_to_rpi3
servo motor only shakes for first ten cycles but after that turns normally. I have no idea why is that but in every article i read that controlling digital servo is same as analog with no need to program them after unboxing. Thanks for any idea

$\endgroup$
1
$\begingroup$

The tutorial is using software pwm from java code. If the PI is otherwise busy or the jvm pauses for garbage collection, the pwm signals to the servo will be erratic. Which could be causing your problems.

I have to admit to only looking at the first page of the tutorial.... The other problem I encountered which was very confusing was erratic behaviour caused by the servo drawing more powerr than the PI can supply... Yes I was powering my servo from the pi's 5 volt rail.

By far the most likely answer is that java does lots of small garbage collections for a while until it adjusts its settings and settles into a much longer garbage collection cycle causing your program to pause repeatedly.

When java does a garbage collection your code stops, therefore so does the pwm and this would cause the strange behavior your are describing.

For my servos I'm using the adafruit 16 Channel pwm board, it has it's own clock, you talk to it via i2c and it leaves your code free to do other stuff.

You should probably do some reading about java garbage collection, java and real-time processing don't go together so well. As long as you understand that you can only get near to real-time processing out of java, all is good.

$\endgroup$
  • $\begingroup$ Thanks for answer. I used external power source (+5V) with no effect. What baffles me is that shaking stops after cca minute and after that works great. So my question was about digital/analog servo differences cause it looks like the servo cannot process the signal at first (maybe weak signal for digital processer) and i cannot find reason for it anywhere $\endgroup$ – dukatmar Sep 16 '13 at 8:56
  • $\begingroup$ I've edited my original answer $\endgroup$ – Robert Sutton Sep 16 '13 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.