Cannot get PWM 33 to work.

AdamMiltonBarker
AdamMiltonBarker New Member Posts: 20

Has anyone worked with MRAA on UP2 (Python) PWM pins are suppose to be 33,32,16. I have three MG996R servos connected, I can move the servos on pins 32 and 16, but 33 seems to be unresponsive. These are powered off the 5v (No external) but it makes no difference when removing one or both of the other servos so I don't think it is power issue.

Advice would be awesome, stuck on releasing some code due to this :)

Comments

  • AdamMiltonBarker
    AdamMiltonBarker New Member Posts: 20

    Ugh, cannot edit post. mraa-gpio list:

    03     I2C_SDA: GPIO I2C
    05     I2C_SCL: GPIO I2C
    07       GPIO4: GPIO
    08     UART_TX: GPIO UART
    10     UART_RX: GPIO UART
    11    UART_RTS: GPIO UART
    12     I2S_CLK: GPIO
    13      GPIO27: GPIO
    15      GPIO22: GPIO
    16        PWM3: GPIO PWM
    18      GPIO24: GPIO
    19   SPI0_MOSI: GPIO SPI
    21   SPI0_MISO: GPIO SPI
    22      GPIO25: GPIO
    23    SPI0_CLK: GPIO SPI
    24    SPI0_CS0: GPIO SPI
    26    SPI0_CS1: GPIO SPI
    27       ID_SD: GPIO I2C
    28       ID_SC: GPIO I2C
    29       GPIO5: GPIO
    31       GPIO6: GPIO
    32        PWM0: GPIO PWM
    33        PWM1: GPIO PWM
    35     I2S_FRM: GPIO
    36    UART_CTS: GPIO UART
    37      GPIO26: GPIO
    38     I2S_DIN: GPIO
    40    I2S_DOUT: GPIO
    
  • DCleri
    DCleri Administrator, AAEON Posts: 1,213 admin
    edited May 2020

    Hi @AdamMiltonBarker

    I think you have already tried to use only PWM on pin 33 without the others. Do you confirm that this approach doesn't work?

    In general, powering 3 servos from the mainboard is not a good idea. I would suggest to use an external power source.

  • AdamMiltonBarker
    AdamMiltonBarker New Member Posts: 20

    Thank you for the reply, yes it makes no difference if I have 1 or 3 servos attached. We may be able to add an additional power supply but it changes our design and not really something we want to do at this stage.

  • DCleri
    DCleri Administrator, AAEON Posts: 1,213 admin
    edited May 2020

    Regarding your design, you should consider that the pins are connected to a MAX10 FPGA.
    As the pins are TTL, they are not supposed to be used to drive servos directly, but they can at most power an LED.

    They have a maximum output current per pin of 25mA and voltage level of 3.3V.
    If the servos you are using exceed those values, it is not fine, you may have damaged the FPGA and experience unexpected behavior or non-working pins.

  • AdamMiltonBarker
    AdamMiltonBarker New Member Posts: 20

    Thanks for the info we are using https://www.electronicoscaldas.com/datasheet/MG996R_Tower-Pro.pdf we are very far into this project, what would your suggestions be? The entire project is based around UP2 boards, published code is working fine with the hardware with exception to this pin. We needed 6 servos really but settled for 3, with only 2 working.

    https://github.com/COVID-19-AI-Research-Project/EMAR-Mini
    https://github.com/COVID-19-AI-Research-Project/EMAR-Mini/blob/master/Devices/2/Documentation/Installation/Installation.md

    There is another question I would like to ask, we are using OpenVINO and NCS2 for depth measurements for the robot, this requires non root execution of the program (Long story), I have managed to get udev rule set up for GPIO allowing non root control, what rules would work for PWM?

    What I have tried so far:

    /etc/udev/rules.d/80-gpio-noroot.rules

    # /etc/udev/rules.d/80-gpio-noroot.rules
    # Corrects sys GPIO permissions so non-root users in the gpio group can manipulate bits
    # Change group to gpio
    SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chown -R root:gpio /sys/devices/soc.0/*pinctrl/gpio'"
    # Change user permissions to ensure user and group have read/write permissions
    SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chmod -R ug+rw /sys/devices/soc.0/*pinctrl/gpio'"
    
    SUBSYSTEM=="pwm*", PROGRAM="/bin/sh -c '\
            chown -R root:gpio /sys/class/pwm && chmod -R 770 /sys/class/pwm;\
            chown -R root:gpio /sys/bus/pci/devices/0000\:00\:19.*/pxa2xx-spi.*/spi_master/spi1/spi1.0/pwm/pwmchip0 && chmod -R 770 /sys/bus/pci/devices/0000\:00\:19.*/pxa2xx-spi.*/spi_master/spi1/spi1.0/pwm/pwmchip0\
    '"
    

    !/bin/sh -e

    chown -R root:gpio /sys/class/gpio
    chmod -R ug+rw /sys/class/gpio
    chown -R root:gpio /sys/class/pwm
    chmod -R ug+rw /sys/class/pwm
    
  • AdamMiltonBarker
    AdamMiltonBarker New Member Posts: 20

    I resolved the issue above with non-root GPIO, the rule was:

    SUBSYSTEM=="pwm*", PROGRAM="/bin/sh -c '\
            chown -R root:gpio /sys/class/pwm && chmod -R 770 /sys/class/pwm;\
            chown -R root:gpio /sys/devices/pci0000:00/0000:00:1a.0/pwm/pwmchip* && chmod -R 770 /sys/devices/pci0000:00/0000:00:1a.0/pwm/pwmchip*;\
    '"
    

    Issue still remains with the PWM pin. I will try with another powersupply for the servos, but still it does not work on it's own.

  • AdamMiltonBarker
    AdamMiltonBarker New Member Posts: 20

    I moved to another device as even with the rules above still had permission errors. On this device all pins are working. I will debug when I get some time and try and see what the issue was. Will take into account your suggestions about the external power. With external power do you see any other issues. This robot is our prototype of a larger robot, it is not meant for heavy lifting etc, just to show how it is controlled by our open source network.

Privacy Policy