supasorn
Posts: 6
Joined: Thu Feb 19, 2015 8:21 pm

PWM output does not stop

Sat Apr 25, 2015 6:41 pm

I'm able to generate PWM output to my servo with different libraries: RPIO and wiringPi2 using these snippets:
https://pythonhosted.org/RPIO/pwm_py.html and http://raspi.tv/2013/how-to-use-wiringp ... nd-pwm#pwm

I'm able to control the position of the servo just fine. And after I'm done, I'm calling
RPIO:
servo.stop_servo(18)
or
wiringPi2:
wiringpi.pwmWrite(18,0)
wiringpi.pinMode(18,0)

But the servo still retains its position, which seems like PWM is still being generated. I'm using an A+ model.
Does anybody know how to completely shut the signal, so the servo becomes free?

User avatar
joan
Posts: 14394
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: PWM output does not stop

Sat Apr 25, 2015 7:04 pm

The servo will stay in the last commanded position unless a force is acting upon it.

supasorn
Posts: 6
Joined: Thu Feb 19, 2015 8:21 pm

Re: PWM output does not stop

Sat Apr 25, 2015 7:06 pm

Yes, but there shouldn't be any force retaining its position, and that's what I'm experiencing.

User avatar
joan
Posts: 14394
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: PWM output does not stop

Sat Apr 25, 2015 7:29 pm

supasorn wrote:Yes, but there shouldn't be any force retaining its position, and that's what I'm experiencing.
I wonder if they are just retaining the last position as they are still powered? It may well depend on the make/model of the servo as to what they do when they aren't receiving pulses.

You'd need a 'scope on the line to check for pulses, but I'm pretty confident that there won't be any.

supasorn
Posts: 6
Joined: Thu Feb 19, 2015 8:21 pm

Re: PWM output does not stop

Sat Apr 25, 2015 7:35 pm

Thanks Joan!

When I first turn on Pi, the servo is free -- no resisting motion. After I run the code, finish execution, the resisting motion is still there. I tried running python in interactive and non-interactive, both giving the same result and servo isn't free once PWM has be setup. I can't find anyway to stop PWM except reboot.

Edit-- the model is sub-mirco Tower Pro SG51R. I'm using hardware PWM at pin 18.

User avatar
joan
Posts: 14394
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: PWM output does not stop

Sat Apr 25, 2015 7:44 pm

supasorn wrote:Thanks Joan!

When I first turn on Pi, the servo is free -- no resisting motion. After I run the code, finish execution, the resisting motion is still there. I tried running python in interactive and non-interactive, both giving the same result and servo isn't free once PWM has be setup. I can't find anyway to stop PWM except reboot.

Edit-- the model is sub-mirco Tower Pro SG51R. I'm using hardware PWM at pin 18.
You can stop PWM on gpio 18 by changing the mode from ALT5 to any other mode, say INPUT or OUTPUT.

As I say I'm fairly sure there won't be pulses. If you want to make sure you could use my piscope to see activity on the gpios.

charmcity
Posts: 4
Joined: Tue Mar 31, 2015 9:15 pm

Re: PWM output does not stop

Sat Apr 25, 2015 7:46 pm

Hey,

I had a few thoughts -- for me, using wiringpi2
wiringpi.pwmWrite(18,0)

Works for me. Stops the PWM and I can see it on the scope. If you don't have a scope why not hook up an LED to the signal and see if its on or not - could help debug.

Also RPI.GPIO --> pwmOBJ.stop() is what I use for soft-pwm.

Good luck!
Tom

User avatar
joan
Posts: 14394
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: PWM output does not stop

Sat Apr 25, 2015 7:51 pm

charmcity wrote: ...
If you don't have a scope why not hook up an LED to the signal and see if its on or not - could help debug.

Also RPI.GPIO --> pwmOBJ.stop() is what I use for soft-pwm.
...
Good idea about using a LED (plus resistor) to see servo pulses.

I think the OP is using RPIO.GPIO (not RPi.GPIO). RPIO.GPIO generates hardware timed servo pulses.

supasorn
Posts: 6
Joined: Thu Feb 19, 2015 8:21 pm

Re: PWM output does not stop

Sat Apr 25, 2015 8:24 pm

Thanks everyone!
PWM does indeed stop (checked with LED), but SG51R still retains the position.
This is weird considering the fact that if you haven't fed PWM to it, it stays free. But once you send PWM at least once, and stop PWM, it never stops retaining its position.

I'm looking for a solution to save power when this servo is not in used. Any ideas?

Greystone
Posts: 9
Joined: Fri Jan 03, 2014 3:38 pm

Re: PWM output does not stop

Sat Nov 04, 2017 7:01 pm

I am experiencing the same thing. Did you ever resolve this?

Return to “Troubleshooting”