[SOLVED ] topway lcd interfacing using rs232 communication protocol

I recently purchased (https://www.topwaydisplay.com/product/smart-lcd/smart-lcd-module-HKT050ATA-C) HKT050ATA-C topway display LCD. I am trying to interface it with Arduino using UART protocol. I used the same connections as shown in their manual (check the attached screenshot). I used RS232 converter to TTL level to connect the LCD with the Arduino Uno. They mentioned that there are only 3 pins needed to be connected which are(Tx, Rx, GND) and I connected them to their respective pins in the DB9 connector. I tried it with this configurations and it didn't work. I also tried including the RTS(request to send) pin and it still didn't work.
I used the same code found in their YouTube tutorial.(TOPWAY Smart LCD - interface with Arduino UNO - YouTube)
NOTE: Their software (RGtools V1.70) for some reason doesn't include my LCD model(HKT050ATA-C) as shown in the attached screenshot.
My problem now is that I can't communicate between the LCD and the Arduino. I created 2 variables on the smart LCD. The Arduino requests to read one of them(by targeting it's specific address) that I change with simple mathematical operations (as shown in attached screenshot). Then the Arduino is supposed to send the same value again to the LCD and place it in the other variable to confirm that the Arduino read the first variable and sent it and updated the second variable. As shown in the screenshot, the variable on the LCD is changed but the variable that is controlled by the Arduino is not which means there's a communication problem surely but I don't know why.
Thanks in advance

int temp_h=0;
int temp_1=0;
int writeback_h=0;
int writeback_1=0;
int packet_0K=0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while(!Serial){;}//wait for serial port to connect.Needed for native USB port only
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.write(0xaa);//packet head
  Serial.write(0x3e);// VP_N16 read command
  Serial.write(0x00);// VP_N16 address
  Serial.write(0x08);
  Serial.write(0x00);
  Serial.write(0x00);
  Serial.write(0xcc);//packet tail
  Serial.write(0x33);//packet tail
  Serial.write(0xc3);//packet tail
  Serial.write(0x3c);//packet tail
  
  while(!Serial.available()){}
  if(Serial.read()==0xaa){                  // packet head
    packet_0K=1;
    Serial.println("Packet head received");
    while(!Serial.available()){}
    if(Serial.read()==0x3e){                // packet command
      while(!Serial.available()){}
      temp_h=Serial.read();                 // read back value high byte
      while(!Serial.available()){}
      temp_1=Serial.read();                 // read back value low byte
      while(!Serial.available()){}
      if(!(Serial.read()==0xcc)){packet_0K=0;}  //packet tail
      while(!Serial.available()){}
      if(!(Serial.read()==0x33)){packet_0K=0;}  //packet tail
      while(!Serial.available()){}
      if(!(Serial.read()==0xc3)){packet_0K=0;}  //packet tail
      while(!Serial.available()){}
      if(!(Serial.read()==0x3c)){packet_0K=0;}  //packet tail
      }
      else
      {packet_0K=0;}
      
    
    }
    else
    {packet_0K=0;}

 if (packet_0K){
  writeback_h=temp_h;
  writeback_1=temp_1;
  Serial.write(0xaa);//packet head
  Serial.write(0x3d);// VP_N16 write command
  Serial.write(0x00);// VP_N16 address
  Serial.write(0x08);
  Serial.write(0x00);
  Serial.write(0x02);
  Serial.write(writeback_h);  // VP_N16 data high byte
  Serial.write(writeback_1);  // VP_N16 data low byte
  Serial.write(0xcc);//packet tail
  Serial.write(0x33);//packet tail
  Serial.write(0xc3);//packet tail
  Serial.write(0x3c);//packet tail
  }
  for(int i=0; i <= 20; i++){delayMicroseconds(1000);}
}

db9.jpg

db9.jpg

Looks like fun! RS232 connects Rx to Tx, and Tx to Rx. The video shows connections that appear to go to pins 0 and 1, that will not work without some additional steps taken. Please post your schematic, not a frizzy thing and we should get you there. You should also post your code.

Thanks for replying
First, I already attached the code I used on the Arduino Uno which is just a series of bytes that defines the commands I need to write or read from certain addresses on the smart LCD.It is exactly the same as the tutorial that Topway posted.
If you're talking about the code on the LCD, there's nothing much there. Their software enables us to implement our UI designs without any coding.

As for the schematic:-
NOTE : I powered the LCD with an external 12 volt power supply
imagine the connection as a chain as follows: LCD --> DB9 male connector --> DB9 female connector of RS232(MAX232) module --> to the Arduino finally
If you look at my previously attached screenshot, their instructions said to connect as follows:
RX(LCD) ---> TX(Female DB9 of RS232 module)
TX(LCD) ---> RX(Female DB9 of RS232 module)
GND(LCD) --> GND (Female DB9 of RS232 module)
RTS(LCD) ---> RTS (Female DB9 of RS232 module)

then I connected the 4 pins of RS232 module to Arduino
Vcc --> 3.3 volt of Arduino
GND --> GND of Arduino
TX --> RX of Arduino
RX --> TX of Arduino

kit_max232_newV.jpg

Schematic.pdf (84.6 KB)

kit_max232_newV.jpg

Okay I fixed it with the help of some E_mails from their technical support
This is the diagram they sent me
I connected it exactly like this without needing an intermediate male DB-9 cable to fit into the female DB-9 of the RS232 module
I also knew exactly what the LCD sent and traced it byte by byte with the help of this video and their handbook

Also in case of the configuration setup here's another screen shots they sent me for my model which was
HKT050ATA-C
So I'll attach the code I used to check for the touch key response example which is in this video

So what this code does is use the Arduino's LED on pin 13 to validate that the LCD sent certain values to the Arduino
This only takes action on the last 2 icon touch keys which are ( 00 ) and ( FF )
If you click on 00 , the LED in the Arduino turns on
If you click on FF , the LED in the Arduino turns off

/*                                        
This code is used to check for the last 2 touch keys only, the ones that send certain values acompanied by the address of the VP_16 variable used in the process
which is in this case 0x 00-08-00-00
So when I click on the icon touch key that says 00, the LED turns on
when I click on the icon touch key that says FF or 256 , the LED turns OFF
                                       */
/**********************LCD variables******************************************/
int temp;
/****************************************************************/
void setup() {
  Serial.begin(115200);//don't forget to set it on your LCD configuration setup in RGtools
  pinMode (13,OUTPUT);//arduino LED set as OUTPUT
  digitalWrite(13,LOW);//LED initially OFF
  while(!Serial){;}//wait for serial port to connect.Needed for native USB port only
}
void loop() {
   Serial.read();//0xaa head
   Serial.read();//0x77 touch command
   Serial.read();//0x00 start address
   Serial.read();//0x08
   Serial.read();//0x00
   Serial.read();//0x00end address
   Serial.read();//0x00//valuebyte1
   temp=Serial.read();//valuebyte0 but i know anyway that the lcd display project on RGtools changes only the first byte so I ignored the other byte
   Serial.read();//tailbyte0
   Serial.read();//tailbyte1
   Serial.read();//tailbyte2
   Serial.read();//tailbyte3
    if(temp==0x00){
      digitalWrite(13,HIGH);
          }
    if(temp==0xFF){
      digitalWrite(13,LOW);
          }

  for(int i=0; i <= 20; i++){delayMicroseconds(1000);}
}

1 Like

This topic was automatically closed after 43 days. New replies are no longer allowed.