Waveshare 4 inch TFT Touchscreen with SPI

Hi,

We've been using the Waveshare 4 inch TFT shield with the following library GitHub - MHotchin/Waveshare4InchTftShield: Graphics and touchscreen drivers for Waveshare 4" shield via the SPI interface.

We're running the display on Arduino Mega 2560. The Mega also has an Ethernet 2 Shield attached, and therefore we've been using the following pins for the display:

	constexpr unsigned int LCD_CS = 7; //  LCD Chip Select
	constexpr unsigned int LCD_BL = 14;  //  LCD Backlight
	constexpr unsigned int LCD_RST = 6;  //  LCD Reset
	constexpr unsigned int LCD_DC = 5;  //  LCD Data/Control
	constexpr unsigned int TP_CS = 3;
	constexpr unsigned int TP_IRQ = 2;
	constexpr unsigned int TP_BUSY = 1;
	constexpr unsigned int SD_CS = 53;

When testing the display with short breakout wires it seems to work fine (and also when used as shield), however we need a slightly longer cable (shielded sVGA type), and when using a longer cable we've found that the SD card doesn't want to initialize anymore - failing with error 1 (while it initializes normally when using short wires) using the normal Sd2Card class, even though the display works fine. We've also found that in our production environment the display sometimes blanks (whites) out permanently (this has never happened during testing in controlled environment). Has anybody had similar problems when using Display in combination with SD?
To emphasize, everything works until we replace wires with cable (VGA or CAT-5 just relaying wires). MISO/MOSI,CLK, SS is 50,51,52, 53 respectively. We've tested the cable and at least electrically it seems fine.

Any thoughts appreciated.

It sounds like the cable is either picking up outside signals (like an antenna) or the capacitance won't run at the speed the library specifies.

The first thing to try would be to run things at a lower frequency. In the CPP file for the library, change:

SPISettings _tftSpiSettingsWrite(20000000, MSBFIRST, SPI_MODE0);

to a lower value, like 1000000 (1 million rather than 20 million). If that works, then the cable is likely the issue.

Cat 5 is twisted pair, so putting two signal lines on one pair may cause problems. With only eight wires (4 pairs), it would be hard to separate things properly. Do you have a ribbon cable you could try?

Also, that code has now been folded into the original library for the shield - any future fixes or changes will happen there instead.

It works the same, the class name is

Waveshare_ILI9486

instead of

Waveshare4InchTftShield

.

MHotchin:
Also, that code has now been folded into the original library for the shield - any future fixes or changes will happen there instead.

GitHub - ImpulseAdventure/Waveshare_ILI9486: Arduino library for Waveshare ILI9486 supporting the Waveshare 3.5" & 4" TFT Touch Shields for Arduino. Includes GFX-compatible API and touchscreen driver

It works the same, the class name is

Waveshare_ILI9486

instead of

Waveshare4InchTftShield

.

Thanks for your response. Yes, I've noticed this, but also noticed that there was changes weren't significant. I think you're right wrt. the wiring.

MHotchin:
It sounds like the cable is either picking up outside signals (like an antenna) or the capacitance won't run at the speed the library specifies.

The first thing to try would be to run things at a lower frequency. In the CPP file for the library, change:

SPISettings _tftSpiSettingsWrite(20000000, MSBFIRST, SPI_MODE0);

to a lower value, like 1000000 (1 million rather than 20 million). If that works, then the cable is likely the issue.

...

I've lowered the frequency significantly (even up to 250kHz). The SD was still not initialized. I might be wrong, but I'm very surprised that the cable would still be picking up outside signals. What did you mean when you said...

or the capacitance won't run at the speed the library specifies

... did you mean that rising edge harmonics might be causing the problem? Would you add a cap between MISO/MOSI/CLK and ground?

Thanks