0

Driving 2X RA8875 off of one microcontroller, can it be done
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Driving 2X RA8875 off of one microcontroller, can it be

by local_dani_21 on Mon Nov 10, 2014 12:42 pm

I would be SOO thankful! Of course in the meantime I'll rewire the thing. But since so far I've ever only heard that it «should theoretically be possible», there is a chance that it actually doesn't work with two on the same bus (which would be too bad since I bought so many displays to work together).

Thanks for getting another one! Best regards, Dani

local_dani_21
 
Posts: 126
Joined: Sun Apr 19, 2009 3:10 pm
Location: Zürich, Switzerland

Re: Driving 2X RA8875 off of one microcontroller, can it be

by local_dani_21 on Thu Nov 13, 2014 3:46 am

Hi Rick

Were you able to get another RA8875 with display? Are you able to drive two at the same time? Thank's for helping! Dani

local_dani_21
 
Posts: 126
Joined: Sun Apr 19, 2009 3:10 pm
Location: Zürich, Switzerland

Re: Driving 2X RA8875 off of one microcontroller, can it be

by adafruit_support_rick on Thu Nov 13, 2014 2:29 pm

Got it this morning. I might not have time to check it out until tomorrow. Pretty tied up today.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Driving 2X RA8875 off of one microcontroller, can it be

by local_dani_21 on Thu Nov 13, 2014 5:13 pm

Great! I have an almost free weekend for thinkering!

local_dani_21
 
Posts: 126
Joined: Sun Apr 19, 2009 3:10 pm
Location: Zürich, Switzerland

Re: Driving 2X RA8875 off of one microcontroller, can it be

by adafruit_support_rick on Fri Nov 14, 2014 1:01 pm

OK, I tried it out. It came right up and worked for me. I wired it all up and verified that the first RA8875 worked all by itself, then I verified that the second RA8875 worked all by itself, then I verified that they both worked together.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Driving 2X RA8875 off of one microcontroller, can it be

by adafruit_support_rick on Fri Nov 14, 2014 1:02 pm

BTW - here's the code I hacked up for testing:
Code: Select all | TOGGLE FULL SIZE
/******************************************************************
 This is an example for the Adafruit RA8875 Driver board for TFT displays
 ---------------> http://www.adafruit.com/products/1590
 The RA8875 is a TFT driver for up to 800x480 dotclock'd displays
 It is tested to work with displays in the Adafruit shop. Other displays
 may need timing adjustments and are not guanteed to work.
 
 Adafruit invests time and resources providing this open
 source code, please support Adafruit and open-source hardware
 by purchasing products from Adafruit!
 
 Written by Limor Fried/Ladyada for Adafruit Industries.
 BSD license, check license.txt for more information.
 All text above must be included in any redistribution.
 ******************************************************************/

#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"


// Library only supports hardware SPI at this time
// Connect SCLK to UNO Digital #13 (Hardware SPI clock)
// Connect MISO to UNO Digital #12 (Hardware SPI MISO)
// Connect MOSI to UNO Digital #11 (Hardware SPI MOSI)
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9
#define RA8875_INT_2 2
#define RA8875_CS_2 8
#define RA8875_RESET_2 7

Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
Adafruit_RA8875 tft2 = Adafruit_RA8875(RA8875_CS_2, RA8875_RESET_2);
uint16_t tx, ty;

void tftSetup(Adafruit_RA8875 *tft)
{
  tft->displayOn(true);
  tft->GPIOX(true);      // Enable TFT - display enable tied to GPIOX
  tft->PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
  tft->PWM1out(255);

  // With hardware accelleration this is instant
  tft->fillScreen(RA8875_WHITE);

  // Play with PWM
  for (uint8_t i=255; i!=0; i-=5 )
  {
    tft->PWM1out(i);
    delay(10);
  } 
  for (uint8_t i=0; i!=255; i+=5 )
  {
    tft->PWM1out(i);
    delay(10);
  }
  tft->PWM1out(255);
 
  tft->fillScreen(RA8875_RED);
  delay(500);
  tft->fillScreen(RA8875_YELLOW);
  delay(500);
  tft->fillScreen(RA8875_GREEN);
  delay(500);
  tft->fillScreen(RA8875_CYAN);
  delay(500);
  tft->fillScreen(RA8875_MAGENTA);
  delay(500);
  tft->fillScreen(RA8875_BLACK);
 
  // Try some GFX acceleration!
  tft->drawCircle(100, 100, 50, RA8875_BLACK);
  tft->fillCircle(100, 100, 49, RA8875_GREEN);
 
  tft->fillRect(11, 11, 398, 198, RA8875_BLUE);
  tft->drawRect(10, 10, 400, 200, RA8875_GREEN);
  tft->fillRoundRect(200, 10, 200, 100, 10, RA8875_RED);
  tft->drawPixel(10,10,RA8875_BLACK);
  tft->drawPixel(11,11,RA8875_BLACK);
  tft->drawLine(10, 10, 200, 100, RA8875_RED);
  tft->drawTriangle(200, 15, 250, 100, 150, 125, RA8875_BLACK);
  tft->fillTriangle(200, 16, 249, 99, 151, 124, RA8875_YELLOW);
  tft->drawEllipse(300, 100, 100, 40, RA8875_BLACK);
  tft->fillEllipse(300, 100, 98, 38, RA8875_GREEN);
  // Argument 5 (curvePart) is a 2-bit value to control each corner (select 0, 1, 2, or 3)
  tft->drawCurve(50, 100, 80, 40, 2, RA8875_BLACK); 
  tft->fillCurve(50, 100, 78, 38, 2, RA8875_WHITE);

}

void setup()
{
  Serial.begin(9600);
  Serial.println("RA8875 start");

  /* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
  if (!tft.begin(RA8875_800x480)) {
    Serial.println("RA8875 Not Found!");
    while (1);
  }

  Serial.println("Found RA8875");

  Serial.println("RA8875 2 start");

  /* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
  if (!tft2.begin(RA8875_800x480)) {
    Serial.println("RA8875 2 Not Found!");
    while (1);
  }

  Serial.println("Found RA8875 2");

  tftSetup(&tft);
  tftSetup(&tft2);
 
  pinMode(RA8875_INT, INPUT);
  digitalWrite(RA8875_INT, HIGH);
 
  tft.touchEnable(true);
   
  Serial.print("Status: "); Serial.println(tft.readStatus(), HEX);
  Serial.println("Waiting for touch events ...");
}

void loop()
{
  float xScale = 1024.0F/tft.width();
  float yScale = 1024.0F/tft.height();

  /* Wait around for touch events */
  if (! digitalRead(RA8875_INT))
  {
    if (tft.touched())
    {
      Serial.print("Touch: ");
      tft.touchRead(&tx, &ty);
      Serial.print(tx); Serial.print(", "); Serial.println(ty);
      /* Draw a circle */
      tft.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 4, RA8875_WHITE);
    }
  }
}

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Driving 2X RA8875 off of one microcontroller, can it be

by local_dani_21 on Fri Nov 14, 2014 1:16 pm

Thank you so much!
I feel of course completely stupid and am very relieved to know that it can be done. I'll try it tonight. Again.
Best regards, Dani

local_dani_21
 
Posts: 126
Joined: Sun Apr 19, 2009 3:10 pm
Location: Zürich, Switzerland

Re: Driving 2X RA8875 off of one microcontroller, can it be

by adafruit_support_rick on Fri Nov 14, 2014 1:20 pm

Good luck!

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Driving 2X RA8875 off of one microcontroller, can it be

by local_dani_21 on Fri Nov 14, 2014 4:04 pm

So far I only get the same results as ever. I try to write down what I do - hopefully you'll find a detail I have overseen.

Wiring:
Code: Select all | TOGGLE FULL SIZE
Arduino Yun | RA88751 | RA88752
-------------------------------
5V          | VIN     | VIN
GND         | GND     | GND
10          | CS      |
9           | RST     |
3           | INT     |
8           |         | CS
7           |         | RST
2           |         | INT
SCK         | SCK     | SCK
MOSI        | MOSI    | MOSI
MISO        | MISO    | MISO


Uploading your code, I get
Code: Select all | TOGGLE FULL SIZE
RA8875 start
RA8875 Not Found!


However, if I take RA8875-2 out of the breadboard (leaving all the cables in it's places) and comment out all references to RA88752, the frist display works flawlessly.

On the other side, if I put RA88752 back onto the breadboard an remove the first RA8875 and comment out all references to RA88751 (again leaving all cables in place), the second displays works well.

Image

They do not work well as long as the three SPI-wires connect both the RA8875s - it seems.

Is there a speciality in your wiring? Do you wire something differently compared to me? Thanks for helping, Dani

local_dani_21
 
Posts: 126
Joined: Sun Apr 19, 2009 3:10 pm
Location: Zürich, Switzerland

Re: Driving 2X RA8875 off of one microcontroller, can it be

by adafruit_support_rick on Fri Nov 14, 2014 5:32 pm

The only difference is that I'm using a Uno and you're using a Yun. That shouldn't make a difference, but do you have a Uno to try it with?
RA8875x2.png
RA8875x2.png (889.09 KiB) Viewed 1337 times

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Driving 2X RA8875 off of one microcontroller, can it be

by local_dani_21 on Sat Nov 15, 2014 5:33 am

I can't believe it: Using an UNO, the setup with two RA8875's works perfectly, using a YUN, it doesn't work. Does anyone have an explanation for this? What is different with the two processors? I assume something with the SPI-port, but I of course don't know? Timing?

local_dani_21
 
Posts: 126
Joined: Sun Apr 19, 2009 3:10 pm
Location: Zürich, Switzerland

Re: Driving 2X RA8875 off of one microcontroller, can it be

by local_dani_21 on Sat Nov 15, 2014 6:28 am

PS: I've tried the two-display setup over SPI with Arduino Yun (Atmel 32u4), Teensy++ 2.0 (Atmel AT90USB1286), Teensy 3.1 (MK20DX256), they all work when only 1 RA8875 is connected.

Only when I use a Atmel 328P (Arduino UNO), I can use 2 RA8875's at the same time. You might want to add this information to your product-website https://www.adafruit.com/product/1590.

Is there any chance that you would consider digging into the timing of the SPI library to find out where the bug lies?
Should I post this as a problem at the http://www.arduino.cc-website?
Last edited by local_dani_21 on Sat Nov 15, 2014 7:09 pm, edited 1 time in total.

local_dani_21
 
Posts: 126
Joined: Sun Apr 19, 2009 3:10 pm
Location: Zürich, Switzerland

Re: Driving 2X RA8875 off of one microcontroller, can it be

by adafruit_support_rick on Sat Nov 15, 2014 10:37 am

Are you using Arduino 1.5.8? We've seen some strange timing problems with that, and I believe they have rewritten the SPI library for that release. Have you got an earlier version you can try this with?

If you think it's a bug in the SPI library, then the Arduino forums would be the place to post about this problem.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Driving 2X RA8875 off of one microcontroller, can it be

by local_dani_21 on Sat Nov 15, 2014 11:26 am

I tried it with Arduino IDE 1.5.7 as well as with Arduino IDE 1.5.7 -> no difference.

local_dani_21
 
Posts: 126
Joined: Sun Apr 19, 2009 3:10 pm
Location: Zürich, Switzerland

Re: Driving 2X RA8875 off of one microcontroller, can it be

by tdicola on Sat Nov 15, 2014 3:44 pm

Are you still powering everything off a USB connection to a laptop/computer? If so try switching to an external power supply--I have a feeling it might be a power issue with both displays and the Yun taking a little more power than the USB port can provide. Remember the Yun has a full Linux processor with WiFi and an ATmega processor so it can pull much more current than a normal Arduino Uno with just the ATmega (in my testing the Yun pulled about about 250-300 mA of current alone).

As far as powering the Yun goes, it's a little trickier since it doesn't have any onboard voltage regulator. You'll want to use a 5V USB power source, like you might use to charge a phone, and plug a micro USB cable into the Yun's programming port and the power supply.

Give using an external power supply a try and let's see if it runs both displays.

tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Please be positive and constructive with your questions and comments.