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

If two 74HC595 shift registers are used they need unique addresses #1291

Closed
fivdi opened this issue Feb 15, 2017 · 1 comment
Closed

If two 74HC595 shift registers are used they need unique addresses #1291

fivdi opened this issue Feb 15, 2017 · 1 comment

Comments

@fivdi
Copy link
Contributor

fivdi commented Feb 15, 2017

This issue was reported on the J5 gitter channel.

If two 74HC595 shift registers are used like this:

  var expander_1 = new five.Expander({
    controller: "74HC595",
    pins: {
      data: 6,
      clock: 7,
      latch: 8
    }
  });

  var expander_2 = new five.Expander({
    controller: "74HC595",
    pins: {
      data: 9,
      clock: 10,
      latch: 11
    }
  });

  var virtual_1 = new five.Board.Virtual(expander_1);
  var virtual_2 = new five.Board.Virtual(expander_2);

  var ledsGroup_1 = new five.Leds({
    pins: [0, 1, 2, 3, 4, 5, 6, 7],
    board: virtual_1
  });

  var ledsGroup_2 = new five.Leds({
    pins: [0, 1, 2, 3, 4, 5, 6, 7],
    board: virtual_2
  });

The following error will be thrown:

Although a 74HC595 shift register isn't an I2C device, the Expander class treat it as one. This only becomes visible when two or more 74HC595 shift registers are used as they all end up having the same I2C address. It's possible to work around the issue by giving each shift register a unique address:

var expander_1 = new five.Expander({
    controller: "74HC595",
    pins: {
      data: 6,
      clock: 7,
      latch: 8
    },
    address: 0x01
  });

var expander_2 = new five.Expander({
    controller: "74HC595",
    pins: {
      data: 9,
      clock: 10,
      latch: 11
    },
    address: 0x02
  });

Perhaps this is only a documentation issue.

@rwaldron
Copy link
Owner

Yikes, that's a totally real bug. Expander controller definitions will need to include some flag that indicates that they are I2C and therefore subject to I2C address constraints, or "normalization" step that automatically adds an address for those that shouldn't require an address from the user. I'll add this to my more immediate "to do" list

rwaldron added a commit that referenced this issue Mar 30, 2017
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
rwaldron added a commit that referenced this issue Mar 30, 2017
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
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