Interference Issues with Arduino Mega + 2xSPI devices - Page 1
Forum section: electronics / general

author: frusciante89
author_rank: Newbie
timestamp: October 19, 2024, 08:57:05 pm
content: Hello everyone!I’m currently working on a project using an Arduino Mega, where I have two devices connected via SPI: a BB-ADS1220 (for reading 2 strain gauges) and an LSM6DSO (accelerometer/gyroscope). I was able to connect both sensors separately and read data out of each of them with no issue. Yay! :slight_smile:However, I’m experiencing some interference issues when trying to read them together (on the same SPI bus).Although I can read both, when I touch the accelerometer, it seems to introduce noise + fluctuations in the readings from the strain gauge circuit (which should not read anything as it is far from the accelerometer).Has anyone encountered similar issues when using multiple devices on the same SPI bus? Any suggestions on how to mitigate this interference? I should mentioned that I'm switching between two SPI modes in my code (SPI mode 0 for the LSM6DSO and SPI mode 1 for the ADS1220). I fear this might be the issue?Here’s a quick overview of my setup:Microcontroller: Arduino MegaSensors: BB-ADS1220 (strain gauge) and LSM6DSO (accelerometer)Level shifter: PiHut TXB0104Connections: Both devices are connected via SPI with appropriate wiring and grounding (see attached schematic)Any advice or insights would be greatly appreciated!Code:#include <SPI.h>#include "Protocentral_ADS1220.h"//TODO: bug. If I move the accelerometer, the load cell signal is affected. How come?// LSM6DSO Configuration#define LSM6DSO_CS_PIN 10#define WHO_AM_I_REG 0x0F#define CTRL1_XL 0x10#define CTRL2_G 0x11#define OUTX_L_A 0x28#define OUTX_H_A 0x29#define OUTY_L_A 0x2A#define OUTY_H_A 0x2B#define OUTZ_L_A 0x2C#define OUTZ_H_A 0x2D#define OUTX_L_G 0x22#define OUTX_H_G 0x23#define OUTY_L_G 0x24#define OUTY_H_G 0x25#define OUTZ_L_G 0x26#define OUTZ_H_G 0x27// ADS1220 Configuration#define PGA 4 // Programmable Gain = 1#define VREF 2.048 // Internal reference of 2.048V#define VFSR (VREF / PGA)#define FULL_SCALE (((long int)1<<23) - 1)#define ADS1220_CS_PIN 9#define ADS1220_DRDY_PIN 8Protocentral_ADS1220 pc_ads1220;int32_t adc_data;void setup() {Serial.begin(115200);// Initialize SPISPI.begin();// Initialize LSM6DSOpinMode(LSM6DSO_CS_PIN, OUTPUT);digitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect LSM6DSOconfigureLSM6DSO();// Initialize ADS1220pinMode(ADS1220_CS_PIN, OUTPUT);digitalWrite(ADS1220_CS_PIN, HIGH); // Deselect ADS1220configureADS1220();}void loop() {// Read data from LSM6DSOreadLSM6DSO();// Read data from ADS1220readADS1220();}// Function to configure LSM6DSOvoid configureLSM6DSO() {Serial.println("Configuring LSM6DSO...");digitalWrite(LSM6DSO_CS_PIN, LOW); // Select LSM6DSOSPI.setDataMode(SPI_MODE0); // Set SPI mode to 0// Send initialization commandswriteRegister(CTRL1_XL, 0x60); // Enable accelerometerwriteRegister(CTRL2_G, 0x60); // Enable gyroscopedigitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect LSM6DSO}// Function to read data from LSM6DSOvoid readLSM6DSO() {digitalWrite(LSM6DSO_CS_PIN, LOW); // Select LSM6DSOSPI.setDataMode(SPI_MODE0); // Ensure SPI mode is set to 0int16_t accelX = read16bitRegister(OUTX_L_A, OUTX_H_A);int16_t accelY = read16bitRegister(OUTY_L_A, OUTY_H_A);int16_t accelZ = read16bitRegister(OUTZ_L_A, OUTZ_H_A);Serial.print(accelX); Serial.print(" ");Serial.print(accelY); Serial.print(" ");Serial.print(accelZ); Serial.print(" ");digitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect LSM6DSO}// Function to configure ADS1220void configureADS1220() {Serial.println("Configuring ADS1220...");digitalWrite(ADS1220_CS_PIN, LOW); // Select ADS1220SPI.setDataMode(SPI_MODE1); // Set SPI mode to 1// Send initialization commands// ... (Initialize ADS1220 settings)// Initialize ADS1220 with Chip Select and Data Ready pinspc_ads1220.begin(ADS1220_CS_PIN, ADS1220_DRDY_PIN);// Configure ADS1220 settingspc_ads1220.set_data_rate(DR_330SPS); // Data rate of 330 samples per secondpc_ads1220.set_pga_gain(PGA_GAIN_1); // PGA gain set to 1pc_ads1220.set_conv_mode_single_shot(); // Set to single-shot conversion modedigitalWrite(ADS1220_CS_PIN, HIGH); // Deselect ADS1220}// Function to read data from ADS1220void readADS1220() {digitalWrite(ADS1220_CS_PIN, LOW); // Select ADS1220SPI.setDataMode(SPI_MODE1); // Ensure SPI mode is set to 1// Read data from ADS1220// ... (Implement ADS1220 read logic)// Read from channel 0adc_data = pc_ads1220.Read_SingleShot_SingleEnded_WaitForData(MUX_SE_CH0);float ch0 = convertToMilliV(adc_data);// Read from channel 1adc_data = pc_ads1220.Read_SingleShot_SingleEnded_WaitForData(MUX_SE_CH1);float ch1 = convertToMilliV(adc_data);// Calculate the differential voltage (half-bridge value)float differentialVoltage = 40000*(ch1 - ch0);// Print the differential voltage for the Serial PlotterSerial.println(differentialVoltage);digitalWrite(ADS1220_CS_PIN, HIGH); // Deselect ADS1220}// Function to write to a registervoid writeRegister(byte regAddress, byte data) {digitalWrite(LSM6DSO_CS_PIN, LOW); // Select deviceSPI.transfer(regAddress & 0x7F); // Send register address (write mode)SPI.transfer(data); // Send the data to writedigitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect device}// Function to read a 16-bit registerint16_t read16bitRegister(byte regL, byte regH) {byte lowByte = readRegister(regL);byte highByte = readRegister(regH);return (int16_t)((highByte << 8) | lowByte);}// Function to read a single registerbyte readRegister(byte regAddress) {digitalWrite(LSM6DSO_CS_PIN, LOW); // Select deviceSPI.transfer(regAddress | 0x80); // Send register address with read bit (0x80)byte regValue = SPI.transfer(0x00); // Send dummy byte and read responsedigitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect devicereturn regValue; // Return the register value}// Function to convert raw ADC data to millivoltsfloat convertToMilliV(int32_t i32data) {return (float)((i32data * VFSR * 1000) / FULL_SCALE);}Thanks in advance!

author: nctnico
author_rank: Super Contributor
timestamp: October 19, 2024, 10:06:51 pm
content: This is the point where I would use an oscilloscope with SPI protocol decoding to simply see what is going on. Actually, it is good custom to check SPI busses anyway just to verify settings and timing even if it appears they are working correctly.

author: xvr
author_rank: Frequent Contributor
timestamp: October 20, 2024, 02:25:47 pm
content: Remove manipulation with *_CS_PIN in all functions, except writeRegister and readRegister. This manipulation only produce spurious clock cycles (because of SPI mode changes), real CS performed in read/writeRegister and class members of pc_ads1220

author: Ian.M
author_rank: Super Contributor
timestamp: October 20, 2024, 02:43:07 pm
content: Seehttps://www.eevblog.com/forum/projects/odd-instabilities-with-level-shifter-5v-lt-gt-3-3v-for-spi/A photo of your setup would be good, to confirm you have all the modules close together on a carrier board with no long wires. If you try to drive long wires with a TXB0104 (or any other push-pull auto-direction sensing level converter), you will believe your circuit is cursed!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 20, 2024, 06:27:43 pm
content: For reference, this question was also posted at:https://electronics.stackexchange.com/questions/728414/interference-issues-with-arduino-mega-2xspi-devices

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 20, 2024, 07:05:04 pm
content: Quote from: T3sl4co1l on October 20, 2024, 06:27:43 pmWhere the first comment clearly indicates the root of the problem.The LSM6DSO is not suited for multiple devices on a single SPI bus. The manual indeed shows that when CS is one, the device is in I2C / I3C mode, and with both interfaces sharing the same clock and data input it might inadvertently get addressed by data intended for the other device on the bus.Scoping the signal lines might show this resulting in wrong data, but it would be hard to determine that it is due to some sort of bus collision.The solution would indeed be to incorporate another type of level shifter that allows disabling the SPI signals to the LSM6DSO.

author: frusciante89
author_rank: Newbie
timestamp: October 20, 2024, 09:36:44 pm
content: Quote from: pcprogrammer on October 20, 2024, 07:05:04 pmYes, this might be exactly what I'm seeing: when I move the accelerometer board, the signal of the strain gauge gets affected (it shouldn't).The nuclear solution will be to change accelerometer, but is there maybe a different level shifter I can use to eliminate this effect?I should also point out that when I flex the strain gauge, the accelerometer signals are not affected

author: Benta
author_rank: Super Contributor
timestamp: October 20, 2024, 09:57:46 pm
content: The problem is your TXB0104. It can't three-state the MISO_5V output (which is drawn as an input).Bad schematic, BTW, hard to read. Learn how to use KiCAD.

author: Peabody
author_rank: Super Contributor
timestamp: October 20, 2024, 10:50:42 pm
content: If you're running both SPI devices at 3.3V, the solution may be to not level shift MISO at all. That's the method used by the Adafruit microSD card adapter, and it works well and plays well with others. The 3.3V high output of the device will be read as high by the Mega without any shifting. Then you can depend on both devices to put MISO into tristate when their respective CS lines are not asserted, which they should do automatically.Also, the other three lines are not bidirectional lines, and don't need a bidirectional level shifter. You could use something like the 74LV1T34, or 74LVC125A to shift the 5V lines down to 3.3V. They will probably be a lot faster than the bidirectional shifter.

author: nctnico
author_rank: Super Contributor
timestamp: October 21, 2024, 06:02:57 am
content: Quote from: frusciante89 on October 20, 2024, 09:36:44 pmChanging the accelerometer to one with a real SPI interface would be a good option (some people are smoking too much weed at ST). Also ditch the bi-directional level shifter and make all logic levels 3.3V.

author: frusciante89
author_rank: Newbie
timestamp: October 21, 2024, 09:08:15 am
content: Thanks for the reply! Do you have any susggestion? I've chosen the LSM6DSO as it is it relatively small and cheap (the final PCB needs to be extremely tiny), but happy to consider other better solution as this is still a prototype.Also, what do you mean with "make all arduino logic levels 3.3V"? The SPI levels coming from the Arduino are 5V if I'm not mistaken

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 21, 2024, 11:25:51 am
content: Quote from: frusciante89 on October 21, 2024, 09:08:15 amI'm not to familiar with the ATmel MCU's but most likely the clock and the mosi lines are push pull driven and as such yes have 5V levels.An input on the Arduino mega will work when presented with 3.3V logic levels.The problem is with an output on the Arduino mega. When it is open drain (open collector) it is not a problem when the signal is pulled up to 3.3V, but when it is a push pull output the high level will be near 5V. This can cause 3.3V logic to die.But for these signals you don't need a bidirectional level translator. A buffer from the74LVC125range will do in this case.

author: Ian.M
author_rank: Super Contributor
timestamp: October 21, 2024, 01:27:16 pm
content: You could use T.I'sTXU0304level translator. It has three channels A to B and one B to A + an active high output enable pin, and independent A and B Vcc pins, so apart from the OE polarity is ideal for SPI. The ADS1220 can work at 5V Vcc so that connects direct to the 5V Arduino. The LSM6DSO needs 3.3V supply and signals, so connect it to the B side of the TXU0304. It will also need some pullups on CS, SCL and SDA so when the TXU0304 outputs are disabled, it drops back to I2C mode cleanly and doesn't get accessed. Drive the TXU0304 OE pin from the /SS to the ADS1220, so the LSM6DSO is isolated while accessing the ADS1220.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 21, 2024, 01:50:40 pm
content: Quote from: frusciante89 on October 21, 2024, 09:08:15 amMany Arduino boards, including Mega, can run at either 3.3V or at 5V; it's just a matter of voltage regulator used, and observing the particular voltage/frequency limits of the specific microcontroller variant uses. Yours runs at 5V, so its logic levels are 5V.Edit: Ian.M already posted about this while I was writing mine. Please ignore the repetition –– although mine is slightly different (non-minimal/excessive compared to Ian.M's). See attached schematic for details.If I were you, I'd use a pair ofTXU0304's, with inverted Chip Select logic (i.e. HIGH activates, LOW deactivates), connected to each TXU0304 OE pins. Connect one of A1-A3 to GND, and its output to the SPI device chip select, with a pull-up resistor (say 10k) to the SPI device VCC.Whenever TXU0304 OE pin is low, its outputs are high impedance, and thus that SPI device won't affect your Arduino.If you need to save one pin, use a logic inverter, like 74LVC1G04 (say,74LVC1G04GV,125in SOT23-5/SOT753 package, hand-solderable with 0.95mm pitch), with its A input connected to the SPI CS pin on your Arduino, and Y output to one of the TXU0304's OE pins. That way, when it is low, this TXU0304 is selected; when SPI CS is high, the other TXU0304 (with SPI CS directly to OE) is selected.I keep these and TXU0102 (for UART RX+TX) and TXU0204 (for UART RX+TX+CTS+RTS) always at hand; they're that useful. For maximum reliability and robustness, add 100nF X7R supply bypass capacitors between VCCA and GND, and between VCCB and GND, on each TXU chip.These are unidirectional voltage level translations that can do 200 MHz or more at 3.3V-5V logic levels, and can handle logic levels all the way down to 1.1V. The GND pin is shared for both sides, but each side needs to provide a voltage supply at the desired voltage level. In your case, you'd use 5V for the Arduino side, and 3.3V for the SPI device side. (It does not matter which is VCCA or which is VCCB. The voltage on the OE pin is referenced to the lower one.)I often create quick carrier boards in the free onlineEasyEDAeditor, because it directly interfaces to JLCPCB's PCB manufacturing. I'm a cheapskate, so I buy my components from LCSC or Mouser, and solder the components to the PCBs myself.

author: Peabody
author_rank: Super Contributor
timestamp: October 21, 2024, 02:24:48 pm
content: That just seems like total overkill to me. Here's Adafruit's microSD breakout board for using SD cards (3.3V) with 5V Arduinos. It works great. Notice that MISO just goes straight through with no translation. Why would this not work for the OP? What does a pair of TXU0304s add?

author: Ian.M
author_rank: Super Contributor
timestamp: October 21, 2024, 03:19:44 pm
content: A pair of TXU0304 adds *nothing* useful as the ADS1220 supports 5V Vcc and its DOUT goes hi-Z properly when its /CS goes high. However asingleTXU0304 can both level translate the LSM6DSO SPI bus both ways and isolate it so its I2C mode doesn't cause problems when accessing the ADS1220. Ideally you'd add an inverter to turn Arduino LSM6DSO /CS out into active high OE for the TXU0304, but I suggested above using the Arduino ADS1220 /CS out as it doesn't really matter if the LSM6DSO goes into I2C mode while neither is being accessed, provided MOSI and SCLK are kept high while both /CS signals are high.

author: nctnico
author_rank: Super Contributor
timestamp: October 21, 2024, 03:30:12 pm
content: Quote from: Peabody on October 21, 2024, 02:24:48 pmMaybe that could be because the designer didn't care or that SD cards might be 5V tolerant. Without checking the specifications you won't know whether it works by accident or by design. I'd be cautious.

author: Ian.M
author_rank: Super Contributor
timestamp: October 21, 2024, 05:06:41 pm
content: I'd bet that *FAR* more of Adafruit's customers are 'makers' (i.e. 🙈 🐵 followers of the Instructables 'Cargo Cult' and similar) than are electronics design professionals or even amateurs who aspire to professional quality or are willing to learn!Also Vih(min) for most pins of an ATmega2560 is 70% of Vcc for Vcc>2.4V. A 3.3V level is *NOT* certain to read as logic 1 on a 5V Arduino Mega2560. You need >3.5V + whatever extra allowance you judge suitable for ground bounce and noise immunity. The chances that it won't read as logic 1 are pretty small as the switching point is usually fairly near Vcc/2 but except for one-off hobby projects where you can test the input threshold of the specific individual MCU chip you are using, its a *BAD* idea as it leaves you with insufficient or no noise margin so it can stop working or become intermittant if you look at it wrong or are wearing the wrong color underwear!A 5V MCU with specifically TTL compatible inputs is a different matter as all bipolar TTL has Voh(min)<3V, so 3.3V CMOS can drive a 5V TTL compatible input.

author: Peabody
author_rank: Super Contributor
timestamp: October 21, 2024, 05:26:17 pm
content: You could solve any noise margin problems on MISO by lowering the Mega's Vcc to 4.5V or so. Anyway, would it be possible to just run the LSM6DSO on I2C, with the usual single mosfet bidirectional level translators? Or would that be too slow?

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 21, 2024, 05:32:59 pm
content: Quote from: Ian.M on October 21, 2024, 03:19:44 pmSure! I thought I made it clear that mine is excessive?You see, I am of the opinion that if one is going to make a break-out board, even for prototyping, it's worth making it work for any pair of SPI devices. In my schematic, they may even use completely different voltages. It fits comfortably within 1" × 1" two-layer board (with components on both sides), too.A more minimalistic option would to use just three 74LVC1T45's (SCK, MOSI, MISO), and a P-channel logic-level MOSFET like DMP2120U, DMP2045U, et cetera to control the Arduino-side 5V supply to the 1T45's. When either supply drops to 0V, 1T45 will tri-state its outputs.Edit: See attached schematic.

author: Ian.M
author_rank: Super Contributor
timestamp: October 21, 2024, 05:50:51 pm
content: Is this yours at OSHWlab?https://oshwlab.com/nominalanimal/txu0304-spi-translator-boardI'd have done it a bit different - with pads to fit a pullup or pulldown for B side MOSI and SCLK, and a pullup for B side SS to guarentee their state when EN is inactive, and provision to drive EN from inverted A side SS, maybe just an unpopulated footprint for a 74LVC1G132 Schmidt NAND as an inverter driven by A SS with a small RC delay on one of its inputs to stretch the EN pulse slightly so B SS drives high before the outputs tristate and the pullup takes over. Alternatively, populate it but with a solder jumper pad to connect its output to EN. That would make it a truely universal SPI level shifter usable for upwards and downwards level shifting in a mixed voltage SPI bus.I agree there is a case for designing with second sourced 74LVC parts rather than T.I.'s propritary level shifter. Don't forget you need a fourth 74LVC1T45 to translate SS.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 21, 2024, 06:53:31 pm
content: Quote from: Ian.M on October 21, 2024, 05:50:51 pmYep! Designed in 2022, not related to the discussion at hand.Quote from: Ian.M on October 21, 2024, 05:50:51 pmYes, that would be much better. The pullup/downs make a lot of sense. I should also add a 2.5mm mounting hole for a M2.5 nylon standoff, with 5mm diameter safe area for the nylon screw head.(I use this one with EN jumpered to one of the supplies with a wire link, so I didn't even think about the inactive case.)To disconnect the B side from the SPI bus, why not connect A side SS to GND, B side SS with a pullup to VCCB, MOSI and SCLK to VCCB or GND?That way, when EN is high, B side SS is low, and B side connected to the A side. When EN is low, B side is isolated from A side.Ah, but the timing of it all, and transition glitches..Might be easier to use SS on A side, with an RC delay to a logic inverter to EN. That way, when SS is released, there is a slight delay before the TXU0304 outputs turn high-Z; but by that time, the data lines should already be idling, and there should be no glitches.Quote from: Ian.M on October 21, 2024, 05:50:51 pmI do prefer the TXU0n0m over 74LVC1T45/2T45/8T245/16T245, because the TXU0n0m have Schmitt trigger inputs.But I don't see why the LSM6DSO would need an SS? The LSM6DSO would always have its CS asserted continuously, as that selects the SPI mode.The LSM6DSO_SCL and _SDA (SCK and MISO) should have weak pull-downs (SPI mode 0) or pull-ups (SPI mode 3), though, so that when the 1T45 outputs are high-Z, they are pulled to the idle state.

author: nctnico
author_rank: Super Contributor
timestamp: October 21, 2024, 06:58:40 pm
content: Quote from: Nominal Animal on October 21, 2024, 06:53:31 pmYes and no. A nice feature of using a select pin is that it -ideally- resets the statemachine dealing with the SPI interface. SPI can be prone to false clock pulses (think ESD and other strong electric fields) and without a select pin resetting the interface, the data could be incorrect forever. Ofcourse it may be possible to correct this through software but it is an extra hassle.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 21, 2024, 07:30:50 pm
content: Right, so perhaps something like attached? I omitted the pull-up/pull-down resistors from LSM6DSO_SCL and LSM6DSO_SDA lines, as they depend on the SPI mode used.Arduino /SS is active low, and is connected to both theDMP2045UP-channel MOSFET gate and U1 input. Note that U1 is powered from 5V, not from the DMP2045U-switched 5V. When /SS is high, LSM6DSO_CS is high (not asserted, thus SPI idle or I3C mode), SPI_5V is 0V, and the data lines are high-Z. When /SS is low, LSM6DSO_CS is low (asserted), SPI_5V is 5V, and the data lines are connected.In hand-solderable SOT23-3/SOT23-6 footprints, you can get a hundred 74LVC1T45W6-7 for 10€ from Mouser, and 25 DMP2045U-7 for 3.80€, so this is also quite cheap an option.I have not simulated or tested this, so I'm not exactly sure the transitions will be glitch-free.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 21, 2024, 07:37:01 pm
content: The CS pin of the LSM6DSO is meant to be used as a regular CS in SPI mode - so you're supposed to keep it at a idle level of 1 between SPI commands. (See datasheet.)I'm not sure connecting it permanently to a low level would even work. Is it able to interpret several different commands while CS is low? Not sure. That's not what I read in the DS. I would say no, as read and write commands of registers can read/write multiple bytes - not knowing how many in advance - so it can't possibly know a new command is incoming unless CS goes high and back low.What that means is that the chip is in I2C mode while CS is high and thus "idle", even when using SPI, from what I understand. That's not fully ideal I guess, but the probability you'd inadvertently toggle SCL/SDA pins to make a valid I2C frame while using SPI looks very low.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 22, 2024, 03:08:35 pm
content: Dammit, I'm an idiot for not realizing this earlier. Apologies to the OP for not seeing the trivial, obvious solution.Quote from: frusciante89 on October 19, 2024, 08:57:05 pmTXB0104 can definitely three-state the pins: it's got the OE pin for exactly this purpose. When it is low (OP has it tied high), all signal pins are in high-impedance state, as if they were disconnected.However, TXB0104datasheetnotes that VCCA ≤ VCCB; VCCA = 1.2V to 3.6V, VCCB = 1.65V to 5.5V. OP has it the exact wrong way in the schematic, but since the acceptable voltages are silkscreened on the board, I assume they have them right.The simplest option is to connect the CS1_5V pin (the active-low select for the ADS1220) ALSO to the TXB0104 OE. That way, whenever the ADS1220 is enabled (CS1_5V is LOW), the TXB0104 is disabled and all its pins in high impedance state ("disconnected"). No other changes are needed.(While OE pin is powered by VCCA, it is safe for voltages up to 5.5V, so it is perfectly okay to use VCCA=3.3V, VCCB=5V, and connect OE to a 5V I/O pin. The 3.3V VCCA simply means that on the OE pin, LOW is below 1.2V, and HIGH is above 2.2V.)

author: Ian.M
author_rank: Super Contributor
timestamp: October 22, 2024, 03:40:09 pm
content: Well spotted. Assuming the TXB0104 is the right way round, it still probably needs some mods, namely 100K pullup resistors on LSM6DSO CS, SDA and SCL pins to keep it deselected when the the TXB0104 outputs are tristated.Also I still have concerns about the construction as I raised in reply#3 - if the modules are patched together with long duPont jumpers its unlikely to work well if at all, as the TXB0104 cant tolerate much load capacitance. If its on an Arduino Mega proto shield with minimum length jumpers tracks between modules, or other compact minimum connection length construction, this is far less of a concern.

author: nctnico
author_rank: Super Contributor
timestamp: October 22, 2024, 03:49:11 pm
content: IIRC the bi-directional level shifters have pull-up on the pins. Somewhere around 10k Ohm.

author: Ian.M
author_rank: Super Contributor
timestamp: October 22, 2024, 04:06:37 pm
content: Quote from: nctnico on October 22, 2024, 03:49:11 pmThat's not what theTXB0104 datasheetsays in 6.5 Electrical Characteristics:IOZ- High impedance state output current - max. +/- 2 uAIf there *is* an internal pullup, it must be either >2.5 Meg not to breach that spec @5V supply or be disconnected when OE is low.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 22, 2024, 04:46:35 pm
content: Quote from: Ian.M on October 22, 2024, 03:40:09 pmRight. TXB0104 does not have internal pull-ups, and any external ones must be at least 50k. (The board is actuallyAdafruit 1875, indicated by the ThePiHut ADA1875 product identifier.)Quote from: Ian.M on October 22, 2024, 03:40:09 pmDefinitely agreed.Here, too, TXU0304 is better with higher drive strength (12mA max at 5V), so it would have been a better choice from the get go – if only anyone sold suitable breakout boards. (While I have my own design – in CC0-1.0/Public Domain –, Ian.M had some great ideas on how to make it much more betterer. As it is now, it just fit my immediate needs.. Also, I noticed that the TXU0304 datasheet explicitly states it will not glitch during VCCx < 0.1V high-Z ("glitch-free power supply sequencing" in any order), without even any specific ramp order or rate.)While 74LVC1T45 has even higher drive strength (24mA max), it lacks the Schmitt triggers the TXU0304 has, so voltages between the low and high thresholds may cause excess current draw.