Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

PCA9685ServoExample not working #402

Open
luke-ff opened this issue Feb 11, 2018 · 1 comment
Open

PCA9685ServoExample not working #402

luke-ff opened this issue Feb 11, 2018 · 1 comment

Comments

@luke-ff
Copy link

luke-ff commented Feb 11, 2018

I've tried to test the PCA9685 servo examples. They don't work, and I managed to figure out, where the problem might be located:

Taking a look at com.pi4j.component.servo.impl.GenericServo.setPositon():

public void setPosition(float position) {
this.position = validatePosition(position);
pwmDuration = calculatePwmDuration(position);
servoDriver.setServoPulseWidth(pwmDuration);
}

  • calculatePwmDuration does not return a duration, but a value between 0 and 4096
  • setServoPulseWidth calls setPwm(Pin, int duration) (where duration is microseconds)

this results in wrong signals...

@Sciss
Copy link

Sciss commented Jun 12, 2021

A work around is to use setServoPulseWidth directly, all you need to do is interpolate between minimum and maxium pulse-width in microseconds, e.g. 500 to 2500 which might correspond to 0 to 180 degrees.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants