Plotting a Sin wave form on an MSP2807 ILI9341 TFT Display

I am trying to plot a sine wave form on an MSP2807, 2.8 inch TFT SPI, 240x320 display being driven by an ESPWROOM32 development module. I know that the sketch is calculating the correct pixel values for the sine wave form and associated axes and tic marks.

But when the sketch reaches the draw line and draw string commands it does not plot onto the MSP2807 screen.

The pin out labels on the MSP2807 are as follows:

 Pin #        Pin Label
    1                VCC
    2                GND
    3                CS
    4                RESET
    5                DC
    6                SDI(MOSI)
    7                SCK
    8                LED
    9                SDO(MISO)
  10                T_CLK
  11                T__CS
  12                T_DIN
  13                T_DO
  14                T_IRQ

The sketch is:

Trig_Sin_Plot_Var_on_ILI9341_10-10-23.ino (11.7 KB)

I am using s set of specifically focused Bodmer setup and configuration files:

ESP32_MSP2807_User_Setup_Select.h (17.0 KB)

ESP32_MSP2807_User_Setup.h (20.3 KB)

Setup42_ILI9341_ESP32.h (2.1 KB)

What have I failed to correctly initiate?

Could it have run out of memory (probably not)? Have you tried a minimal "line draw only" sketch?

I compiled your files and had a lot of re-definition warnings about CS, DC and RST, and on multiple pins. Maybe it is my setup causing the warnings.

XFPD: Thank you for looking at this sketch. I don't get any error messages. It just seems that when the sketch is directed to draw graphics, it doesn't do them even thought the variables to be plotted and drawn have a calculated value.

These kind of graphs require all your mathematical skills and that you are willing to think differently when we talk about the vertical axis. In TFTs the vertical axis is upside down, so you must always consider that this situation turns what you know about graphics on its head. All the libraries I know have started from the Adafruit libraries, their approach is simple but effective, the use of DMA is something that we must thank many enthusiasts who have designed very advanced libraries.

Look at this example, which you can easily transfer to the instructions of the library you are using for your screen. I just programmed it on a MEGA with an ILI9488-SPI very similar to the one you have in your project.

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <ILI9488.h>
#define TFT_RST  8
#define TFT_DC   9
#define TFT_CS  10
ILI9488 myGLCD = ILI9488(TFT_CS, TFT_DC, TFT_RST);

float Xi= 40, Yi= 20, Xf= 479-Xi, Yf= 319-Yi, Ym= 319/2;

void setup() {
  myGLCD.begin();
  myGLCD.setRotation(3); 
  
  myGLCD.fillScreen(ILI9488_GREEN);
  myGLCD.setTextSize(2);
  myGLCD.setCursor(130, 140); myGLCD.setTextColor(ILI9488_RED);  myGLCD.println("  ILI9488 3.5''");
  delay(1500);
  myGLCD.setTextSize(2);
  myGLCD.fillScreen(ILI9488_BLACK);

  //border
  myGLCD.drawRect(0, 0, 479, 319, ILI9488_RED);
  
  // XY  axes
  myGLCD.drawLine(Xi, Ym, Xf, Ym, ILI9488_GREEN);
  myGLCD.drawLine(Xi, Yi, Xi, Yf, ILI9488_GREEN);
  
  //Sin function plot
  SIN();
}

void loop(){}

void SIN(){
  for ( long  i = 0 ; i<=359 ; i++)
    {  
       myGLCD.drawPixel((Xi+i), (Ym-(90*sin(3*i*PI/180))), ILI9488_YELLOW);
    }
}

Try to divide the project into small parts at a time, after you have mastered each part very well, put them together into what you want to show on the TFT.

TFTLCDCyg: Thank you for your very useful help in interfacing an Arduino Uno uProcessor to an MSP2807, 2.8 inch TFT SPI 240 x 320 display. With your help, I was able plot a simple sine curve on this display:

Uno Sine Wave Plot.pdf (25.5 KB)

I enclose a copy of my sketch for same:

Very_Simple_Uno_Sin_Plot_10-12-23.ino (3.6 KB)

As you may note, my display is slightly smaller than the one you used:

     X_max= 320,  Y_max= 240

I was also able to plot this same simple sine curve on the MSP2807 display when driven by an ESP32 and an Arduino Nano uProcessor.

Thanks once again for this valuable help.

Jerry Renken

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.