Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HATv3 mixes PWM and GPIO motors #53

Open
Ezward opened this issue Apr 4, 2021 · 2 comments
Open

HATv3 mixes PWM and GPIO motors #53

Ezward opened this issue Apr 4, 2021 · 2 comments

Comments

@Ezward
Copy link

Ezward commented Apr 4, 2021

class HATv3(HATv2):
    _MOTOR_NUM_TO_PINS: Dict[int, MotorPins] = {
        1: MotorPins(10, 9, 8, MotorDirectionControl.PWM),
        2: MotorPins(33, 31, 13, MotorDirectionControl.GPIO)
    }

It appears on motor is controlled via the PCA9685 and one via GPIO. Given that DB21M has 5 RGB LEDs driven by PCA9685, it seem there would be conflicts in addressing the motor and LEDs. So that motor configuration seems wrong.

@tanij
Copy link
Member

tanij commented Apr 5, 2021

The DB21M has 4 LEDs, 2 in the front and 2 in the back. I believe the configuration is correct (although unusual).

@Ezward
Copy link
Author

Ezward commented Apr 5, 2021

This is what I figured out from the code; the pwm value (the third value in the triplet), is always used as the channel on the PCA9685, so in the HATv3 code, motor 1 uses channel 8 on the PCA9685 and motor 2 used channel 13. The difference between the motors is how the two motor direction signals are sent to the motor controller; either via the PCA9685 for MotorDirectionControl.PWM or via a GPIO pin for MotorControlDirection.GPIO. I'm not sure why it was chosen to use GPIO for motor 2 but not motor 1, but I can see now how it works.

class HATv3(HATv2):
    _MOTOR_NUM_TO_PINS: Dict[int, MotorPins] = {
        1: MotorPins(10, 9, 8, MotorDirectionControl.PWM),
        2: MotorPins(33, 31, 13, MotorDirectionControl.GPIO)
    }

So here for motor 1 the first two values of the triplet, 10 and 9 refer to channels/pins on the PCA9685. For motor 2 they represent pin number of the Jetson Nano header.

It's not technically a bug, but it certainly is a little strange and confusing to someone (at least to me) unless they really dig into the code.

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

No branches or pull requests

2 participants