Go Down

Topic: Large button/led board. Multiple SCL-SDA connections (Read 858 times) previous topic - next topic

Moris526


Hi.

I made a 32 Adafruit Neotrellis units large board. Conected i2c with Arduino Mega.

At large speed of data tranfer it freezes or misses steps. It doesnt happen if I use half the boards, for example.

My question is : Would it help if I make multiple conections of the SCL and SDA cables at differente point

around the board?


PerryBebbington

I like the board but I don't understand the question.
Please provide a drawing to illustrate what you mean.
Or, better still, why are you ever asking? What is stopping you from just trying it?

Wawa

Each module has level shifters with 10k pull up resistors, plus the one from the Mega,
that's a combined pull up of ~300 ohm...

My question is : Would it help if I make multiple conections of the SCL and SDA cables at differente point
More wiring is more wire capacitance, so I think a bad idea.

What speed is the TWI at. default 100kHz or high-speed 400kHz.
Does the code allow you to lower the I2C speed.
Leo..

raschemmel

#3
Oct 06, 2020, 07:51 am Last Edit: Oct 06, 2020, 07:53 am by raschemmel
I2C Pullup Resistor Calculation

Quote
A strong pullup (small resistor) prevents the I2C pin on an IC from being able to drive low
What happens to the pullup value when you put 32 of them in parallel ?

Watcher


Wawa

The Mega should be able to pull 300 ohm low enough.

Try adding this at the end of setup()

Wire.setClock(50000); // half speed

Leo..

raschemmel

#6
Oct 06, 2020, 08:44 am Last Edit: Oct 06, 2020, 08:45 am by raschemmel
Quote
The Mega should be able to pull 300 ohm low enough.
Not sure how that relates.

The standard I2C pullup (I2C is open collector) is 4.7k ohms.

RT=1/[(1/4700ohms) *32)]
    RT  = 146.875 ohms  

(1/4700= 2.127659e-4)
,(2.127659e-4*32=0.0068085)
1/0.0068085= 146.875 ohms


Wawa

The 32 boards OP is using have 10k pull up resistors, plus a 10k set on the Mega.
That's 10000/33 = 303 ohm = 16.5mA.

Default I2C is 100kHz/400pF/3mA.
A 5volt Arduino can do the newer FM+ (FastMode) I2C standard, which is 400kHz/4000pF/30mA.

Rise times might be compromised by bus capacitance, so OP should try lowering the default I2C speed first.
Leo..

Paul__B


raschemmel

#9
Oct 06, 2020, 05:10 pm Last Edit: Oct 06, 2020, 05:12 pm by raschemmel
Quote
Remove three quarters of the pullups!
I2C is open collector. I don't think you want to short the collector directly to the SCL & SDA lines do you ?

That doesn't souind like a good idea .

Quote
Open collector outputs require a pull-up resistor (R in the image above) for the output to be able to properly "output high". The pull-up resistor is connected between the output pin and the output voltage (Vcc in the image above) that is desired for a high state.Nov 9, 2017
LINK

Moris526

#10
Oct 06, 2020, 06:19 pm Last Edit: Oct 06, 2020, 06:24 pm by Moris526
Thanks for the answers.

I tried adding Wire.setClock(50000);  to Setup with no luck.

Give you more info.  I send data from Max/MSP. Im sure this part of the proyect is not the problem because

I try already sending data directly from the arduino code with the same result.


The problem its either with the Arduino code ( I think the code is pretty clean) or the comunication whit the

boards.

It at high speed when I press a button the data seems to be messed up, changing colours and missing steps.

I leave the Arduino code and attach a video with the behaviour.


Code: [Select]
#include "Adafruit_NeoTrellis.h"


#define Y_DIM 16
#define X_DIM 32
#define INT_PIN 10



Adafruit_NeoTrellis t_array[Y_DIM/4][X_DIM/4] = {

  

 { Adafruit_NeoTrellis(0x35), Adafruit_NeoTrellis(0x3A), Adafruit_NeoTrellis(0x4A), Adafruit_NeoTrellis(0x33),Adafruit_NeoTrellis(0x4B), Adafruit_NeoTrellis(0x45), Adafruit_NeoTrellis(0x4C), Adafruit_NeoTrellis(0x42) },
 
{ Adafruit_NeoTrellis(0x4D), Adafruit_NeoTrellis(0x3E) , Adafruit_NeoTrellis(0x40), Adafruit_NeoTrellis(0x38),Adafruit_NeoTrellis(0x31), Adafruit_NeoTrellis(0x3D), Adafruit_NeoTrellis(0x3B), Adafruit_NeoTrellis(0x49) },

{ Adafruit_NeoTrellis(0x2F), Adafruit_NeoTrellis(0x2E), Adafruit_NeoTrellis(0x3C), Adafruit_NeoTrellis(0x47),Adafruit_NeoTrellis(0x32), Adafruit_NeoTrellis(0x36), Adafruit_NeoTrellis(0x48), Adafruit_NeoTrellis(0x3F)  },

  { Adafruit_NeoTrellis(0x34), Adafruit_NeoTrellis(0x44), Adafruit_NeoTrellis(0x39), Adafruit_NeoTrellis(0x41), Adafruit_NeoTrellis(0x30), Adafruit_NeoTrellis(0x37), Adafruit_NeoTrellis(0x43), Adafruit_NeoTrellis(0x46) }
,
};


Adafruit_MultiTrellis trellis((Adafruit_NeoTrellis *)t_array, Y_DIM/4, X_DIM/4);


TrellisCallback blink(keyEvent evt){
  
  if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_RISING)
  
     Serial.println (evt.bit.NUM);

      
  else if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_FALLING)
    
   Serial.println(evt.bit.NUM + 1000);

    
 
  return 0;
}

inline uint32_t rgbColor(uint32_t r, uint32_t g, uint32_t b)
{
  return ((r << 16) | (g << 8) | b);
}
  
  
const byte numChars = 32;
char receivedChars[numChars];
char tempChars[numChars];      
      

int a = 0;
int b = 0;
int c = 0;
int d = 0;

boolean newData = false;
  
  
////////////////////////////////////////////////////////
  
  
   void setup() {
  Serial.begin(9600);
  

  Wire.setClock(50000);

  pinMode(INT_PIN,INPUT);
  
  
  !trellis.begin();
  
  
  for(int y=0; y<Y_DIM; y++){
    for(int x=0; x<X_DIM; x++){
      
      trellis.activateKey(x, y, SEESAW_KEYPAD_EDGE_RISING, true);
      trellis.activateKey(x, y, SEESAW_KEYPAD_EDGE_FALLING, true);
      trellis.registerCallback(x, y, blink);
  
    }
  }
    
/////////////////////////////////////////////////////////////////////////////////

}

void loop() {
 

  if(!digitalRead(INT_PIN)){
    trellis.read();
  }
  
 

  recvWithStartEndMarkers();
    if (newData == true) {
        strcpy(tempChars, receivedChars);
            
        parseData();
        
        newData = false;
    }

  

}

    
/////////////////////////////////////////////////////////////////////

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;

    while (Serial.available() > 0 && newData == false) {
        rc = Serial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0';
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

///////////////////////////////////////////////////////////////////

void parseData() {

    
    
    
    char * strtokIndx;

    strtokIndx = strtok(tempChars," ");    
    
  
    
  
    a = atoi(strtokIndx);    

    strtokIndx = strtok(NULL, " ");
    b = atoi(strtokIndx);    


    strtokIndx = strtok(NULL, " ");
    c = atoi(strtokIndx);    

    strtokIndx = strtok(NULL, " ");
    d = atoi(strtokIndx);    

      
  
  
   trellis.setPixelColor(a,  rgbColor(b,c,d));
    

  trellis.show();  
  
    
      
    
    
    

  
}




     
     
     
     
     
     
     

 


raschemmel

Did you debounce the button ?
If not you're probably seeing button bounce

Moris526

Did you debounce the button ?
If not you're probably seeing button bounce
But with a smaller board the behaviour is normal.


raschemmel

Do you know what debouncing is and how it relates to buttons ?

Wawa

How long/messy is the wiring between I2C master and LED board.
Leo..

Go Up