Jump to content

All multiplexed devices using TCA9548A stopped working


Recommended Posts

Posted

Hi all

during conversion to RS485 I have discovered that all of my multiplexed OLED sketches that use the TCA9548A multiplexer have stopped functioning. This includes nont DCS Bios ones as well. 

Using the I2C scanner I can see that it is is detected on addresses 0x3c and 0x70 and these are indeed the callouts on my sketches. If just one stopped working I would suspect hardware, but all four? I think something has changed, either in the libraries or the Ide

To check I have used different PC's, different Nano's, different USB cables but am drawing a blank, both figuratively and literally. On my VHF AM radio panel using USB I can still get the rotary encoders to function, but nothing I do will make the displays show anything. I modified one of the sketches slightly to just display a 5 and a 6 in place of the in game data, but even that doesn't show - here's the code

//#define DCSBIOS_DEFAULT_SERIAL
#define DCSBIOS_IRQ_SERIAL

#include <DcsBios.h>
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
//#include "er_oled.h"

#define TCAADDR 0x70
void tcaselect(uint8_t i) {
  if (i > 7) return;

  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();
}

U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R3, /* clock=*/SCL, /* data=*/SDA, /* reset=*/U8X8_PIN_NONE);  // All Boards without Reset of the Display R3 refers to 270 deg text rotation
//U8G2_SSD1306_64X32_1F_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);


void setup() {

  /* void DisplayInit() {
     for (int i = 0; i < 7; i++)
       tcaselect(i);*/
  DcsBios::setup();

 for (int i = 0; i <= 7; i++) {
    tcaselect(i);
    u8g2.begin();
    //Wire.begin();
  }
}


void onVhfamPresetChange(char* newValue) {
  tcaselect(3);  //multiplex the required OLED
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_logisoso38_tr);
  u8g2.drawStr(0, 80, newValue);  // 0 left, 0 top max appx 100
  u8g2.sendBuffer();
  //delay(1000);
}
DcsBios::StringBuffer<2> vhfamPresetStrBuffer(0x118a, onVhfamPresetChange);

void onVhfamFreq4Change(char* newValue) {
  tcaselect(4);  //multiplex the required OLED
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_logisoso38_tr);
  u8g2.drawStr(0, 80, newValue);  // 0 left, 0 top max appx 100
  u8g2.sendBuffer();
  //delay(1000);
}
DcsBios::StringBuffer<2> vhfamFreq4StrBuffer(0x1192, onVhfamFreq4Change);


void onVhfamFreq3Change(char* newValue) {
  tcaselect(5);  //multiplex the required OLED
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_logisoso38_tr);
 //u8g2.drawStr(0, 80, newValue[0]);   // 0 left, 0 top max appx 100
  u8g2.drawStr(0, 80, "5");  // 0 left, 0 top max appx 100
  u8g2.sendBuffer();
  //delay(1000);
}
DcsBios::StringBuffer<2> vhfamFreq3StrBuffer(0x118e, onVhfamFreq1Change);




void onVhfamFreq2Change(char* newValue) {
  tcaselect(6);  //multiplex the required OLED
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_logisoso38_tr);
  //u8g2.drawStr(0, 80, vhfamFreq2);   // 0 left, 0 top max appx 100
  u8g2.drawStr(0, 80, "6");  // 0 left, 0 top max appx 100

  u8g2.sendBuffer();
  //delay(1000);
}
DcsBios::StringBuffer<2> vhfamFreq2Buffer(0x118e, onVhfamFreq1Change);


void onVhfamFreq1Change(char* newValue) {
  tcaselect(7);  //multiplex the required OLED
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_logisoso38_tr);
  u8g2.drawStr(0, 80, newValue);  // 0 left, 0 top max appx 100
  u8g2.sendBuffer();
  //delay(1000);
}
DcsBios::StringBuffer<2> vhfamFreq1StrBuffer(0x1190, onVhfamFreq1Change);


DcsBios::RotaryEncoder vhfamFreq1("VHFAM_FREQ1", "DEC", "INC", 4, 3);
DcsBios::RotaryEncoder vhfamFreq2("VHFAM_FREQ2", "DEC", "INC", 8, 7);
DcsBios::RotaryEncoder vhfamFreq3("VHFAM_FREQ3", "DEC", "INC", 10, 9);
DcsBios::RotaryEncoder vhfamFreq4("VHFAM_FREQ4", "DEC", "INC", 5, 6);
DcsBios::RotaryEncoder vhfamPreset("VHFAM_PRESET", "DEC", "INC", 12, 11);
DcsBios::RotaryEncoder vhfamVol("VHFAM_VOL", "-3200", "+3200", 17, 16);

void loop() {
  DcsBios::loop();

  
}

Is anyone able to shed some light on this? Does anyone have a TCA9548A based sketch that they can test to see if it still works?

Cheers

Les

Posted (edited)

Hi Les,

try the linked example to see if your devices come up (TCA9548 I2CScanner.ino). Use USB connection to read out serial communication.

https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/arduino-wiring-and-test#example-multiplexing-2115002

 

Regards, Vinc

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

I worked out what it is; something has changed in either the u8g2 library, or SSD1306 because now in the constructor you have to have the display frame buffer set to F. If you set it to 1 or 2, which I had done in my original sketches, it simply won't display anything. However on the VHF radio panels (see link) I had set the buffer to the lower rate because when used on the same Nano as the rotary encoders, it would push the dynamic memory to nearly 100%, and stop the OLEDs from being displayed.

In order for the sketch to work I have to comment out the rotary encoders, so I can have either the OLEDs or the encoders, but not both. With the full frame buffer just the OLEDs take 87% of the dynamic memory 

 

And I also still cannot get the Freq3 displaying correctly, I have it statically set at displaying ".0". I would still like to resolve that.

So unless I can get hold of some Nano's that have more memory I will have to redesign my VHF radios to break out the encoders

Cheers

 

Les

 

  • Like 1
Posted

I ran the sketch on a Mega, and I was correct that the memory issue was what was giving the problems. With the sketch at full frame buffer, and all the rotary encoders in there too I was using 25% of the memory and it worked fine (apart from Freq3 - can't shift that problem yet)

I believe that I can use more than one multiplexer from one Arduino so potentially I can run both the AM and FM iterations of the VHF radio from one Mega. However I am not at all happy about how the u8g2 library is playing up, and so am going to do some tests with a simple Adafruit SSD1306 library to see if that is less tricky

Les

  • Like 1
Posted

I have managed to knock together an SSD1306 based sketch, which includes all the encoders, and it uses 38% of the Nano dynamic memory. It works, and best of all, the Freq3 issue is resolved.

One minor issue is that it seems to not respond very well to text placement - changing the cursor position appears to have no effect unless you put in a stupid number. It seems to be more noticeable after application of the set.rotation command.

The only other minor quibble is that the largest font I can use is 24 point, where my u8g2 sketch was using a 38 point font. I may end up making my own font (if I can remember how)

Cheers


Les 

  • Like 1
Posted (edited)

👍

but too bad that nobody uses your setup and may contribute to your need.

I personally use the Max7219 that uses a very different approach.

Regards, Vinc

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

I know what you mean Vinc - it's sometimes hard to accept that you have spent a day working to improve something that no-one in the world needs!

Still, never ask why a hobby gives you enjoyment, just accept it and move on (and tell the wife it's essential to your wellbeing)

Les

  • Like 1
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...