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

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
DragonSkyRunner
 
Posts: 17
Joined: Tue Sep 23, 2014 1:59 pm

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

Post by DragonSkyRunner »

The project I have in mind (TFT display eyes on a costume head with pupils/irises controlled with a 9-DOF Accel/Mag/Gyro and a analog light sensor) should be in theory relatively straight forward, with only simple hardware accelerated shapes being drawn to the screen. But I cannot find anything detailing using more than one driver board at a time. Over SPI, as far as I can tell, it should be possible, but there's nothing detailing how to go about wiring such a setup.

So if it does work, would bottle necking be a major issue if it's only hardware accelerated shapes?, and would current draw be a major concern as well?, and would a Uno (and by extension Pro Trinket) have enough pins for this?

Sorry for the million questions, but I'd rather not go ahead and get the parts and find out I need to wear a eye-patch.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

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

Post by adafruit_support_rick »

Wire both display's SCLK, MOSI, and MISO to 13, 12, and 11.
Wire the first board's CS to 10 and RST to 9
Wire the second board's CS and RST to two different pins - let's say CS to 8 and RST to 7.

INT is only used for touch - sounds like you're not using that, so you can ignore it.

Declare two instances of Adafruit_RA8875 objects in your code

Code: Select all

// 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_CS_1 10
#define RA8875_RESET_1 9

#define RA8875_CS_2 8
#define RA8875_RESET_2 7

Adafruit_RA8875 tft_left = Adafruit_RA8875(RA8875_CS_1, RA8875_RESET_1);   //left "eye"
Adafruit_RA8875 tft_right = Adafruit_RA8875(RA8875_CS_2, RA8875_RESET_2);  //right "eye"

User avatar
DragonSkyRunner
 
Posts: 17
Joined: Tue Sep 23, 2014 1:59 pm

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

Post by DragonSkyRunner »

Thank you! Here I was worried I was going to have to muck about with 2 or more microcontrollers communicating over serial to pull it off.

Although, after researching even more, I'm starting to get the feeling that between the code to run the screens, making a AHRS out of the Accel/Mag/Gyro combo and the calculations for the pupil position and iris size/rotation (Fun fact: snakes, crocodiles and certain species of reptile with slitted pupils can rotate the entire eyeball to compensate for head position relative to the horizon.), the 32K/28K flash would get chewed up really quickly. So in your humble professional opinion, would that be a valid concern?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

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

Post by adafruit_support_rick »

Well, first off, two instances of the RA8875 don't take up any more flash space than one instance. That's just the way class libraries work.

Without knowing what you really have to do, it's hard to say. But I'm going to guess that you won't have a problem with flash space. If it gets to be a problem, you might give Arduino 1.5.7 a try - I understand that the code it generates is quite a bit more compact than earlier versions.

User avatar
DragonSkyRunner
 
Posts: 17
Joined: Tue Sep 23, 2014 1:59 pm

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

Post by DragonSkyRunner »

All of the necessary code, in theory, is just the drivers for both the RA8875 & the LSM9DS0, plus the code to run the animation on the eyes. Which include calculating the various triangle coordinate positions and the circle locations between any point A and point B that they get drawn to, including curved interpolation between said points, rotating a bunch of points relative to other points, while also drawing all of this to the screens, and getting input from the rotational sensors and modifying the raw sensor data to something slightly more useful, and the analog input from the light sensor to top it all off.

If it was just the code itself, I don't think it would be too much of a issue. But, I have no idea how much the driver overhead eats into useable memory for code.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

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

Post by adafruit_support_rick »

Hack up a quick'n'dirty sketch that instantiates two RA8875's and the LSM9DS0. You don't need all of the code, and you don't need the hardware. The compiler will tell you how much flash space is used just for that, and you can include the freeRam() function from here to tell you how much SRAM is used.

https://learn.adafruit.com/memories-of- ... ree-memory

User avatar
local_dani_21
 
Posts: 128
Joined: Sun Apr 19, 2009 3:10 pm

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

Post by local_dani_21 »

I'm also working on a project with several 5" TFT's with RA8875-drivers. For a start I'm trying to wire up only two displays. The first display goes without saying (SCK, MISO, MOSI, CS1, RESET) and your Arduino 1.0.6-RA8875-textmode-example. The problem I encounter is that as soon as I connect the second RA8875 to the setup (SCK as above, MISO as above, MOSI as above, CS2, RESET as above), the setup stops working. Having both RA8875s wired up, I get the «RA8875 not found» error during setup(tft.begin(RA8875_800x480)).

What do I do wrong?
Have you yourself every tried two RA8875 on one microcontroller? I read at different places in your forum that «it should work» (and bought 7 of them), but now I'm starting to wonder if RA8875 is correctly implementing an SPI slave.

Thanks for your help, Dani
Last edited by local_dani_21 on Sun Nov 09, 2014 6:00 pm, edited 1 time in total.

User avatar
local_dani_21
 
Posts: 128
Joined: Sun Apr 19, 2009 3:10 pm

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

Post by local_dani_21 »

Funny thing is: When I connect the first RA8875 as described above («hardware»-SCK, «hardware»-MISO, «hardware»-MOSI, «hardware»-SS, RESET1) and connect the second RA8875 alike leaving out MISO (only SCK as above, MOSI as above, CS2, RESET2) and try (using the textmode-default-example of your Adafruit_RA8875-library) to write text to the first display, I get the exact same content of both displays - even if nowhere in the code anything is written about CS2 or RESET2.
Image
That seems very strange to me. Thanks for your help, Dani

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

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

Post by adafruit_support_rick »

local_dani_21 wrote:I get the exact same content of both displays
That is not so strange. If your CS2 is set low, that's exactly what I'd expect. Make sure to set CS2 and RESET2 to output and set them both high, and see if the same thing still happens.
local_dani_21 wrote:The problem I encounter is that as soon as I connect the second RA8875 to the setup (SCK as above, MISO as above, MOSI as above, CS2, RESET as above), the setup stops working. Having both RA8875s wired up, I get the «RA8875 not found» error during setup(tft.begin(RA8875_800x480)).
Can you post your code?

User avatar
local_dani_21
 
Posts: 128
Joined: Sun Apr 19, 2009 3:10 pm

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

Post by local_dani_21 »

Sure! When using the following code, I get in the terminal:
RA8875 start
RA8875-2 Not Found!
Setup (Arduino Yun, 32u4, two RA8875 on 5" TFT):
Arduino SCK --> both RA8875 SCK
Arduino MISO --> both RA8875 MISO
Arduino MOSI --> both RA8875 MOSI

Arduino 10 --> RA8875#1: CS
Arduino 9 --> RA8875#1: Reset

Arduino 8 --> RA8875#2: CS
Arduino 7 --> RA8875#2: Reset

Both RA8875 are powered with 5V from the Arduino Yun, which itself is USB-powered from a MacBook Pro.
Thanks for having a look into it!

Dani

Code: Select all

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

// Library only supports hardware SPI at this time
// Connect SCLK (Hardware SPI clock)
// Connect MISO (Hardware SPI MISO)
// Connect MOSI (Hardware SPI MOSI)

#define RA8875_CS 10
#define RA8875_RESET 9
#define RA8875_CS2 8
#define RA8875_RESET2 7

Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
Adafruit_RA8875 tft2 = Adafruit_RA8875(RA8875_CS2, RA8875_RESET2);
uint16_t tx, ty;

void setup() 
{
  Serial.begin(57600);
  while (!Serial){} // Yun: Wait for serial connection to not miss the output

  pinMode(RA8875_CS, OUTPUT);    digitalWrite(RA8875_CS, HIGH);
  pinMode(RA8875_RESET, OUTPUT); digitalWrite(RA8875_RESET, HIGH);
  pinMode(RA8875_CS2, OUTPUT);   digitalWrite(RA8875_CS2, HIGH);
  pinMode(RA8875_RESET2, OUTPUT);digitalWrite(RA8875_RESET2, HIGH);
  
  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);
  }
  if (!tft2.begin(RA8875_800x480)) {
    Serial.println("RA8875-2 Not Found!");
    while (1);
  }

  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);
  tft.fillScreen(RA8875_BLACK);

  /* Switch to text mode */  
  tft.textMode();
  
  tft2.displayOn(true);
  tft2.GPIOX(true);      // Enable TFT - display enable tied to GPIOX
  tft2.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
  tft2.PWM1out(255);
  tft2.fillScreen(RA8875_BLACK);

  /* Switch to text mode */  
  tft2.textMode();

  
  /* Set a solid for + bg color ... */
  
  /* ... or a fore color plus a transparent background */

  
  /* Set the cursor location (in pixels) */
  tft.textSetCursor(10, 10);
  
  /* Render some text! */
  char string[15] = "Hello, World! ";
  tft.textTransparent(RA8875_WHITE);
  tft.textWrite(string);

  /* Set the cursor location (in pixels) */
  tft.textSetCursor(10, 10);
  
  /* Render some text! */
  char string2[16] = "Helloo, World!";
  tft2.textTransparent(RA8875_WHITE);
  tft2.textWrite(string2);


  tft.textColor(RA8875_WHITE, RA8875_RED);
  tft.textWrite(string);
  tft.textTransparent(RA8875_CYAN);
  tft.textWrite(string);
  tft.textTransparent(RA8875_GREEN);
  tft.textWrite(string);
  tft.textColor(RA8875_YELLOW, RA8875_CYAN);
  tft.textWrite(string);
  tft.textColor(RA8875_BLACK, RA8875_MAGENTA);
  tft.textWrite(string);

  /* Change the cursor location and color ... */  
  tft.textSetCursor(100, 100);
  tft.textTransparent(RA8875_RED);
  /* If necessary, enlarge the font */
  tft.textEnlarge(1);
  /* ... and render some more text! */
  tft.textWrite(string);
  tft.textSetCursor(100, 150);
  tft.textEnlarge(2);
  tft.textWrite(string);
}

void loop() 
{
}
Last edited by local_dani_21 on Mon Nov 10, 2014 10:58 am, edited 1 time in total.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

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

Post by adafruit_support_rick »

What happens if you comment out this bit:

Code: Select all

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

User avatar
local_dani_21
 
Posts: 128
Joined: Sun Apr 19, 2009 3:10 pm

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

Post by local_dani_21 »

No:

Code: Select all

RA8875 start
RA8875-2 Not Found!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

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

Post by adafruit_support_rick »

OK, then there's something wrong with your wiring to TFT 2. I have run my RA8875 with CS=8 and RST=7, and it works.

User avatar
local_dani_21
 
Posts: 128
Joined: Sun Apr 19, 2009 3:10 pm

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

Post by local_dani_21 »

Dear Rick

I have checked my wiring ten times - each of my RA8875s works perfectly as long as it is the only one on the SPI bus. As soon as I stick in a second one, the program hangs as described. Can you please confirm that you have two running RA8875s at the same time on the same microcontroller? Thank you very much, Dani

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

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

Post by adafruit_support_rick »

I can't confirm that. I only have one RA8875. I'll have to get another one. It will take a few days.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”