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

servo frequency NOT set properly for ATtiny1616 #98

Closed
tracton opened this issue Mar 20, 2024 · 2 comments
Closed

servo frequency NOT set properly for ATtiny1616 #98

tracton opened this issue Mar 20, 2024 · 2 comments

Comments

@tracton
Copy link

tracton commented Mar 20, 2024

  • Hardware: ESP32 to ATtiny1616 over I2C; ATtiny is supposed to output PWN (with 5-10% duty cycle) on pin 11 to Motor driver that drives a Servo SM-S2309S. Oscilloscope on pin 11.
  • Arduino version: 2.3.2

BUG: Adafruit_seesaw.cpp appears to have a bug in that the chip is not identified in the Adafruit_seesaw::setPWMFreq function, and so legit pins can not have their PWM frequency set; the call is prematurely returned.

SOLUTION: The setPWMFreq function should look like the analogWrite function which tests each Hardware ID Code to determine which pins support PWM per chip. I think it should look a bit like this:

  int8_t p = -1;
  if (_hardwaretype == SEESAW_HW_ID_CODE_SAMD09) {
    switch (pin) {
    case PWM_0_PIN:
      p = 0;
      break;
    case PWM_1_PIN:
      p = 1;
      break;
    case PWM_2_PIN:
      p = 2;
      break;
    case PWM_3_PIN:
      p = 3;
      break;
    default:
#ifdef SEESAW_I2C_DEBUG
      Serial.printf("SEESAW: PWM not supported on Pin %d for hardware %d\n", pin, _hardwaretype);
#endif
      break;
    }
  } else {
    p = pin;
  }

@tracton tracton changed the title servo servo frequency NOT set properly for ATtiny1616 Mar 20, 2024
@caternuson
Copy link
Contributor

Hmm. Agree. Looks like that logic needs updating for the ATtiny variants, like you mention - similar to what's in analogWrite.

Thanks for changing the issue title.

@caternuson
Copy link
Contributor

Closing. Should be fixed with #99.

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