Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

QT PY Can't output PWM on Pins 7, 8, 9 & 10 simultaneously
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

QT PY Can't output PWM on Pins 7, 8, 9 & 10 simultaneously

by BoardsNSource on Sat May 08, 2021 5:31 am

In the documentation, it dictates that the QT PY can output PWM on all 4 of these pins.

Individually it is true, however, when trying to use all at the same time, the wrong pins get activated and they stutter.

I have tested this on the Seeeduino Xiao, and that works as expected, however with the QT PY it does not seem possible.

Here is an extremely basic example which only shows this specific problem.

Code: Select all | TOGGLE FULL SIZE
#include <Arduino.h>

// Macro: PWM Output Pins
#define PWM_OUTPUT_MOTOR_1_A 9
#define PWM_OUTPUT_MOTOR_1_B 10
#define PWM_OUTPUT_MOTOR_2_A 8
#define PWM_OUTPUT_MOTOR_2_B 7

void setup(void)
{
  pinMode(PWM_OUTPUT_MOTOR_1_A, OUTPUT);
  pinMode(PWM_OUTPUT_MOTOR_1_B, OUTPUT);
  pinMode(PWM_OUTPUT_MOTOR_2_A, OUTPUT);
  pinMode(PWM_OUTPUT_MOTOR_2_B, OUTPUT);
}

void loop(void)
{
  for (size_t j = 0; j < 4; j++)
  {
    for (size_t i = 0; i < 5; i++)
    {
      analogWrite(PWM_OUTPUT_MOTOR_1_A, j == 0 ? (i + 1) * 51 : 0);
      analogWrite(PWM_OUTPUT_MOTOR_1_B, j == 1 ? (i + 1) * 51 : 0);
      analogWrite(PWM_OUTPUT_MOTOR_2_A, j == 2 ? (i + 1) * 51 : 0);
      analogWrite(PWM_OUTPUT_MOTOR_2_B, j == 3 ? (i + 1) * 51 : 0);
      delay(1000);
    }
  }
}


You can see this in effect by setting some of the defined pins to 0/removing them.

This works as expected with pins 8,9 and 10, but with 7, 9 and 10, or 7, 8, 9 or 7,8, 9, 10, it does not work at all. It does not matter which pins are chosen, only that more than 2 are selected.

It is possible I am missing something but I cannot find any explanation for this and can confirm that it works as expected on a different microcontroller with the same wiring and same code.

I can provide a video if necessary.

If it is of any use, I am trying to make a self balancing vehicle, using a DRV8833, hence the 4 PWM outputs simultaneously.


Edit:

Even weirder, it seems that the PWM signal which is for pin 7 (the last in the loop), also is duplicated to Pin 9, which has no output when its supposed to have output

So the expected order is Pin 9 loops up, then pin 10, then pin 8, then pin 7, however, instead, it is nothing, then pin 10, then pin 8, then pins 7 and 9 at the same time, which isn't supposed to happen at any point in the program.

Further Edit:

As a sanity test, I double checked by running the exact same code on the Xiao again, and it ran as expected.

BoardsNSource
 
Posts: 1
Joined: Sat May 08, 2021 2:56 am

Please be positive and constructive with your questions and comments.