4

I use my Arduino with Adafruit PCA9685 servo controller. To set PWM signals I use the provided library: https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library

It allows easily set PMM signal and works good. But how can I "unset" PWM signal for a certain pin?

If a PWM siganl is active, the servo stucks on the current position and can't be moved by hand, but only by setting other pulse length. So I need to move servo and then "free" it.

  • I'm not really into servos... do they "release" when just the duty cycle is 0% or 100% (this can easily be done with your PCA9685)? If not, the only way is switching off the power supply for that servo. – mic Jun 09 '17 at 08:45
  • Did you find a solution? I'm having the same problem. – Miguel Jun 25 '20 at 10:05

5 Answers5

3

You can try to send no "ON" time to your output pin on the PCA9685. So, you start the "ON" at 0 and stop the "OFF" at 0.

void freeServo(uint8_t servoIdx)
{
  pwm.setPWM(servoIdx, 0, 0 );
}
0

You could try changing the corresponding pin from output to input. To be sure not to disturb other comfigurations you could do direct port manipulation.

void servo_off() {
  DDRD &= ~(1<<PD5);
}

void servo_on() {
  DDRD |= (1<<PD5);
}

This assumes you use pin PD5 for the pwm signal. Adjust the "D" in DDRD and PD5 so it matches the port in use as well as the pin number.

Of course, you need some additional user input like a button to trigger calls to those functions.

Sim Son
  • 1,859
  • 12
  • 18
  • PCA9685 is controlled over I2C and the question is about the Adafruit library for the PCA9685 module – Juraj Dec 08 '21 at 04:45
0

Are your servo's control pins active high or active low?

From the library code at https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library/blob/d265f74fc0e66632e6dafc787c95b008f3245550/Adafruit_PWMServoDriver.cpp#L242 it looks like there are special on&off values of setPWM(pin,on,off) that turn the servo fully on or fully off, and how they work they depends on whether the servo pin is active high or active low.

unsigned byte idle = CertainPin;

servoController01.setPWM(idle, 0, 4096); // fully off Active high // servoController01.setPWM(idle, 4096, 0); // fully off Active low

or with the better documented setPin():

servoController01.setPin(idle,0,false); // Active high
//servoController01.setPin(idle,0,true); // Active low
Dave X
  • 2,332
  • 14
  • 28
-1

Unluckily, AFAIK, the servo powers the motor even when the PWM signal is not applied. So "removing" the PWM is useless.

You will have to "turn off" the servo by removing the power. To do this, use a transistor (usually servos are more current-hungry than arduino can bear). When you want to "free" the servo, remove the power and it will be "free".

frarugi87
  • 2,721
  • 10
  • 19
  • you are wrong if I connect servo to my assembly it is "free" until I havent PWM set aslo I can free all servos by sending reset command to PCA9685 but my task is to "free" just one particular servo: there is the problem – Sergey Kravchenko Jun 09 '17 at 21:47
-1

I got same problem, searched around but found no answer, so I looked into the source code and found that you simply have to set the angle of the servo to 'None' to stop sending PWM pulses to the servo. For example, if your servo uses channel 14 on the PCA9685 board:

kit.servo[14].angle = None

  • It sounds like you're talking about python, or something like it, and maybe some other library and not anything to do with the question. – timemage Feb 27 '21 at 19:48