SX1509 LED blink issue

I’ve designed the sx1509 into a system of mine and am having issue with io.blink().

Regardless of what ms parameters I pass I always get something that appears to be a 50% on/off duty cycle blink on my LED outputs. I obviously have I2C working, addressing working, etc. because I can address individual LEDs and correctly get them blinking, but always at what appears to be the same duty cycle. I am able to increase the divisor and slow the blink rate down - but always at a ~50% duty cycle.

I’ve tried the sparkfun blink demo example… same thing.

Anyone have any ideas what might be going on?

Thanks in advance!

Share the code being used and a photo of the wiring/setup, and finally which MCU is being used too and maybe we can get it figured out

TS-Russell:
Share the code being used and a photo of the wiring/setup, and finally which MCU is being used too and maybe we can get it figured out

TS-Russell,

Thanks for the reply! Here’s the snipped of the schematic showing the SX1509 part:

https://lh3.googleusercontent.com/pw/AM … authuser=0

The code is quite literally the sparkfun blink demo, the only modification being the pin of the LED. For the purposes of this post I’m trying to blink the OFFHOOK pin [3]. And indeed it blinks. But not at the 2:1 ratio that the code should exhibit. Again, I can plug in anything for ms and the rate of blinking will vary, but not from a 50/50 time base.

The computer being used the Arduino MKR NB 1500 with LTE modem. Hence OFFHOOK. :slight_smile:

#include <Wire.h>           // Include the I2C library (required)
#include <SparkFunSX1509.h> //Click here for the library: http://librarymanager/All#SparkFun_SX1509

// SX1509 I2C address (set by ADDR1 and ADDR0 (00 by default):
const byte SX1509_ADDRESS = 0x3E; // SX1509 I2C address
SX1509 io;                        // Create an SX1509 object to be used throughout

// SX1509 Pin definition:
const byte SX1509_LED_PIN = 3; // Changed from 15 to 3

void setup()
{
  Serial.begin(115200);
  Serial.println("SX1509 Example");

  Wire.begin();

  // Call io.begin(<address>) to initialize the SX1509. If it
  // successfully communicates, it'll return 1.
  if (io.begin(SX1509_ADDRESS) == false)
  {
    Serial.println("Failed to communicate. Check wiring and address of SX1509.");
    while (1)
      ; // If we fail to communicate, loop forever.
  }

  // Set up the SX1509's clock to use the internal 2MHz
  // oscillator. The second parameter divides the oscillator
  // clock to generate a slower LED clock. 4 divides the 2MHz
  // clock by 2 ^ (4-1) (8, ie. 250kHz). The divider parameter
  // can be anywhere between 1-7.
  io.clock(INTERNAL_CLOCK_2MHZ, 4);

  io.pinMode(SX1509_LED_PIN, OUTPUT); // Set LED pin to OUTPUT

  // Blink the LED pin -- ~1000 ms LOW, ~500 ms HIGH:
  io.blink(SX1509_LED_PIN, 1000, 500);
  // The timing parameters are in milliseconds, but they
  // aren't 100% exact. The library will estimate to try to
  // get them as close as possible. Play with the clock
  // divider to maybe get more accurate timing.
}

void loop()
{
  // Relax! The SX1509's got this...
}

SX1509::calculateLEDTRegister() and SX1509::calculateSlopeRegister() are declared incorrectly. The SparkFun library sends milliseconds into those two function as a uint8_t. Changing the declarations as described below got things working.

Change two declarations from:

uint8_t calculateLEDTRegister(uint8_t ms);

uint8_t calculateSlopeRegister(uint8_t ms, uint8_t onIntensity, uint8_t offIntensity);

to:

uint8_t SX1509::calculateLEDTRegister(uint16_t ms);

uint8_t SX1509::calculateSlopeRegister(uint16_t ms, uint8_t onIntensity, uint8_t offIntensity);

On another issue, the timebase calculated by SX1509::configClock() seems wonky. It’s running twice as fast as anticipated with the internal clock divided by 4 and altering the divisor yields different blink rates when my understanding is that configClock() should compensate for that, but I haven’t dug into this issue yet.