esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
420 stars 26 forks source link

SX1509 Allow setting PWM frequency and debounce #1899

Open intermittech opened 2 years ago

intermittech commented 2 years ago

Describe the problem you have/What new integration you would like

Please describe your use case for this integration and alternatives you've tried:

Additional context

Part of this request is linked to a prior request in making the SX1509 integration within ESPhome more useful to be used in hardware projects. The SX1509 is quite a capable chip but currently it's functionality can't be fully utilized within ESPhome.

The Sparkfun Arduino Library describes very well what options are possible with the chip.

SeByDocKy commented 4 months ago

Ho yes :) would be great !!!!!!!!!!! I am exactly on this problem try to understand why I can't control perfectly my SSR (a LSA-H3P90YB).... Via a logic analyser here a screenshot of the SX1509 generated signal:

img_04

In practice, the foscout frequency is not the fOsc value.. We are around 130Hz vs (fOsc=2Mhz)

When you are looking the sx1509.cpp code, you have

  temp_byte |= (1 << 6);   // Internal 2MHz oscillator part 1 (set bit 6)
  temp_byte &= ~(1 << 5);  // Internal 2MHz oscillator part 2 (clear bit 5)
  this->write_byte(REG_CLOCK, temp_byte);

  this->read_byte(REG_MISC, &temp_byte);
  temp_byte &= ~(1 << 7);  // set linear mode bank B
  temp_byte &= ~(1 << 3);  // set linear mode bank A
  temp_byte |= 0x70;       // Frequency of the LED Driver clock ClkX of all IOs:
  this->write_byte(REG_MISC, temp_byte);|

fOSC is effectively set to 2Mhz but the foscout = fosc/2^(REG_MISC[6:4]-1). Here REG_MISC[6:4] is set to 0b111=8 via temp_byte |= 0x70;. It means that foscout = 2.10^6/(2(8-1)). So at the lowest speed clock !!!! I agree with you it should be great to add the option to change this default 0x70 value....