32
of 76
TEP , The Engineering Projects , Image

syedzainnasir

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon
PIC microcontroller and LCD
TEP , The Engineering Projects , Calender Question: 20-Feb-2017
TEP , The Engineering Projects , Category In: PIC Microcontroller Projects
Hi, I've been working on this issue for days now and I'm not a programmer but I've been trying to make my pic (PIC24HJ12GP201) communicate with my LCD (Matrix Orbital LK204-25). When I connect to output on hyperterm the code works great it shows what it is suppose to show, however I cannot seem to make it work on LCD which is using the serial RS-232 interface. Can anyone please give me an idea as to how to make it work?

Here is the code that I have: [code] #define FCY 25000000 #define BAUDRATE 19200 #define BRGVAL ((FCY/BAUDRATE)/16)-1 void initUART(void) { PORTBbits.RB4 = 1; ///*************************** // Assign U1Rx To Pin RP0 //*************************** RPINR18bits.U1RXR = 0; //*************************** // Assign U1CTS To Pin RP1 //*************************** RPINR18bits.U1CTSR = 1; //*************************** // Configure Output Functions // (See Table 9-2) //*************************** //*************************** // Assign U1Tx To Pin 11 //*************************** RPOR4bits.RP8R = 3; //*************************** // Assign U1RTS To Pin 12 //*************************** RPOR4bits.RP9R = 4; //UART Initialization// PLLFBD=38; // M=40 CLKDIVbits.PLLPOST=0; // N1=2 CLKDIVbits.PLLPRE=0; // N2=2 RCONbits.SWDTEN=0; // Disable Watch Dog Timer while(OSCCONbits.LOCK!=1) {}; // Wait for PLL to lock U1MODEbits.STSEL = 0; // 1-stop bit U1MODEbits.PDSEL = 0; // No Parity, 8-data bits U1MODEbits.ABAUD = 0; // Autobaud Disabled U1MODEbits.BRGH = 0; // Low Speed mode U1BRG = BRGVAL; // BAUD Rate Setting for 19200 U1STAbits.UTXISEL1 = 0; U1MODEbits.UARTEN = 1; // Enable UART U1STAbits.UTXEN = 1; // Enable UART Tx } /////////////////////////////////////////////////////////////////// int main () { unsigned int place1,place2,place3; int STX,ETX,sign,unit_num; int temperature; initADC(); // initialize the ADC initUART(); // initalize the UART LCDinit(); OutStr(">"); The LCDinit(); Is a function from a header. I didn't included it here, but what the LCD requires to perform tasks is to have decimal values sent to it. For instance in order to clear the screen which I've been trying to do, the following must be done (this is excerpt from LCD manual); Clear Screen Syntax Hexadecimal 0xFE 0x58 Decimal 254 88 ASCII 254 ?X? Description This command will immediately clear all of the contents of the display. so what I've done is make the following commands WriteUART1(254); WriteUART1(88); [/code] I do not know why it does not work by sending this, I have the LCD to it's default setting to 19200 baudrate and that's how i set software too. Please, any help with be greatly appreciated
TEP , The Engineering Projects , Icon Answer: 5 TEP , The Engineering Projects , Icon Views: 150 TEP , The Engineering Projects , Icon Followers: 85
Small Bio
TEP , The Engineering Projects , Image

syedzainnasir

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon

RE:

PIC microcontroller and LCD
TEP , The Engineering Projects , Calender Comment: 20-Feb-2017
TEP , The Engineering Projects , Category In: PIC Microcontroller Projects
I did more research and it seems that PICs function as TTL, so one of the things I needed to do is change the LCD protocol to TTL. Unfortunately nothing works and I don't see any communication with it :(

Someone who knows how to resolve this..it really is boggling me
TEP , The Engineering Projects , Tick Correct Answer
Comment Bio
TEP , The Engineering Projects , Image

syedzainnasir

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon

RE:

PIC microcontroller and LCD
TEP , The Engineering Projects , Calender Comment: 20-Feb-2017
TEP , The Engineering Projects , Category In: PIC Microcontroller Projects
[quote=Isabelle post_id=58 time=1487581586 user_id=67] Hi, I've been working on this issue for days now and I'm not a programmer but I've been trying to make my pic (PIC24HJ12GP201) communicate with my LCD (Matrix Orbital LK204-25). When I connect to output on hyperterm the code works great it shows what it is suppose to show, however I cannot seem to make it work on LCD which is using the serial RS-232 interface. Can anyone please give me an idea as to how to make it work?

Here is the code that I have: [code] #define FCY 25000000 #define BAUDRATE 19200 #define BRGVAL ((FCY/BAUDRATE)/16)-1 void initUART(void) { PORTBbits.RB4 = 1; ///*************************** // Assign U1Rx To Pin RP0 //*************************** RPINR18bits.U1RXR = 0; //*************************** // Assign U1CTS To Pin RP1 //*************************** RPINR18bits.U1CTSR = 1; //*************************** // Configure Output Functions // (See Table 9-2) //*************************** //*************************** // Assign U1Tx To Pin 11 //*************************** RPOR4bits.RP8R = 3; //*************************** // Assign U1RTS To Pin 12 //*************************** RPOR4bits.RP9R = 4; //UART Initialization// PLLFBD=38; // M=40 CLKDIVbits.PLLPOST=0; // N1=2 CLKDIVbits.PLLPRE=0; // N2=2 RCONbits.SWDTEN=0; // Disable Watch Dog Timer while(OSCCONbits.LOCK!=1) {}; // Wait for PLL to lock U1MODEbits.STSEL = 0; // 1-stop bit U1MODEbits.PDSEL = 0; // No Parity, 8-data bits U1MODEbits.ABAUD = 0; // Autobaud Disabled U1MODEbits.BRGH = 0; // Low Speed mode U1BRG = BRGVAL; // BAUD Rate Setting for 19200 U1STAbits.UTXISEL1 = 0; U1MODEbits.UARTEN = 1; // Enable UART U1STAbits.UTXEN = 1; // Enable UART Tx } /////////////////////////////////////////////////////////////////// int main () { unsigned int place1,place2,place3; int STX,ETX,sign,unit_num; int temperature; initADC(); // initialize the ADC initUART(); // initalize the UART LCDinit(); OutStr(">"); The LCDinit(); Is a function from a header. I didn't included it here, but what the LCD requires to perform tasks is to have decimal values sent to it. For instance in order to clear the screen which I've been trying to do, the following must be done (this is excerpt from LCD manual); Clear Screen Syntax Hexadecimal 0xFE 0x58 Decimal 254 88 ASCII 254 ?X? Description This command will immediately clear all of the contents of the display. so what I've done is make the following commands WriteUART1(254); WriteUART1(88); [/code] I do not know why it does not work by sending this, I have the LCD to it's default setting to 19200 baudrate and that's how i set software too. Please, any help with be greatly appreciated [/quote]
A quick scan of the LCD manual indicates that there are two modes of communicating with it. RS-232 and I2C. The RS-232 interface signal levels are defined for input voltages in the range where a low is less than -3V and a high is greater than +3V.

The I2C interfaces is indeed a 0V to 5V signal interface but the serial data definition is different from the RS-232 serial data definition.

You could get your hands on a MAX232 device. This device runs on 5V but is capable of translating from the 0 to 5V logic levels used by the microcontroller to the typical -10V to +10V signal levels required by RS-232.
TEP , The Engineering Projects , Tick Correct Answer
Comment Bio
TEP , The Engineering Projects , Image

syedzainnasir

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon

RE:

PIC microcontroller and LCD
TEP , The Engineering Projects , Calender Comment: 20-Feb-2017
TEP , The Engineering Projects , Category In: PIC Microcontroller Projects
[quote=Junaid_Shahid post_id=60 time=1487581735 user_id=48] [quote=Isabelle post_id=58 time=1487581586 user_id=67] Hi, I've been working on this issue for days now and I'm not a programmer but I've been trying to make my pic (PIC24HJ12GP201) communicate with my LCD (Matrix Orbital LK204-25). When I connect to output on hyperterm the code works great it shows what it is suppose to show, however I cannot seem to make it work on LCD which is using the serial RS-232 interface. Can anyone please give me an idea as to how to make it work?

Here is the code that I have: [code] #define FCY 25000000 #define BAUDRATE 19200 #define BRGVAL ((FCY/BAUDRATE)/16)-1 void initUART(void) { PORTBbits.RB4 = 1; ///*************************** // Assign U1Rx To Pin RP0 //*************************** RPINR18bits.U1RXR = 0; //*************************** // Assign U1CTS To Pin RP1 //*************************** RPINR18bits.U1CTSR = 1; //*************************** // Configure Output Functions // (See Table 9-2) //*************************** //*************************** // Assign U1Tx To Pin 11 //*************************** RPOR4bits.RP8R = 3; //*************************** // Assign U1RTS To Pin 12 //*************************** RPOR4bits.RP9R = 4; //UART Initialization// PLLFBD=38; // M=40 CLKDIVbits.PLLPOST=0; // N1=2 CLKDIVbits.PLLPRE=0; // N2=2 RCONbits.SWDTEN=0; // Disable Watch Dog Timer while(OSCCONbits.LOCK!=1) {}; // Wait for PLL to lock U1MODEbits.STSEL = 0; // 1-stop bit U1MODEbits.PDSEL = 0; // No Parity, 8-data bits U1MODEbits.ABAUD = 0; // Autobaud Disabled U1MODEbits.BRGH = 0; // Low Speed mode U1BRG = BRGVAL; // BAUD Rate Setting for 19200 U1STAbits.UTXISEL1 = 0; U1MODEbits.UARTEN = 1; // Enable UART U1STAbits.UTXEN = 1; // Enable UART Tx } /////////////////////////////////////////////////////////////////// int main () { unsigned int place1,place2,place3; int STX,ETX,sign,unit_num; int temperature; initADC(); // initialize the ADC initUART(); // initalize the UART LCDinit(); OutStr(">"); The LCDinit(); Is a function from a header. I didn't included it here, but what the LCD requires to perform tasks is to have decimal values sent to it. For instance in order to clear the screen which I've been trying to do, the following must be done (this is excerpt from LCD manual); Clear Screen Syntax Hexadecimal 0xFE 0x58 Decimal 254 88 ASCII 254 ?X? Description This command will immediately clear all of the contents of the display. so what I've done is make the following commands WriteUART1(254); WriteUART1(88); [/code] I do not know why it does not work by sending this, I have the LCD to it's default setting to 19200 baudrate and that's how i set software too. Please, any help with be greatly appreciated [/quote]
A quick scan of the LCD manual indicates that there are two modes of communicating with it. RS-232 and I2C. The RS-232 interface signal levels are defined for input voltages in the range where a low is less than -3V and a high is greater than +3V.

The I2C interfaces is indeed a 0V to 5V signal interface but the serial data definition is different from the RS-232 serial data definition.

You could get your hands on a MAX232 device. This device runs on 5V but is capable of translating from the 0 to 5V logic levels used by the microcontroller to the typical -10V to +10V signal levels required by RS-232. [/quote]
thank you for replying to my troubles :)

And as a matter of fact, I do have that chip!! I connected it and like said before it works for hyperterminal but it does not work for my LCD. This is my first time ever programming a PIC, I'm sure something about my code is weird. Any other suggestions? :confused:
TEP , The Engineering Projects , Tick Correct Answer
Comment Bio
TEP , The Engineering Projects , Image

syedzainnasir

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon

RE:

PIC microcontroller and LCD
TEP , The Engineering Projects , Calender Comment: 20-Feb-2017
TEP , The Engineering Projects , Category In: PIC Microcontroller Projects
[quote=Isabelle post_id=62 time=1487581848 user_id=67] [quote=Junaid_Shahid post_id=60 time=1487581735 user_id=48] [quote=Isabelle post_id=58 time=1487581586 user_id=67] Hi, I've been working on this issue for days now and I'm not a programmer but I've been trying to make my pic (PIC24HJ12GP201) communicate with my LCD (Matrix Orbital LK204-25). When I connect to output on hyperterm the code works great it shows what it is suppose to show, however I cannot seem to make it work on LCD which is using the serial RS-232 interface. Can anyone please give me an idea as to how to make it work?

Here is the code that I have: [code] #define FCY 25000000 #define BAUDRATE 19200 #define BRGVAL ((FCY/BAUDRATE)/16)-1 void initUART(void) { PORTBbits.RB4 = 1; ///*************************** // Assign U1Rx To Pin RP0 //*************************** RPINR18bits.U1RXR = 0; //*************************** // Assign U1CTS To Pin RP1 //*************************** RPINR18bits.U1CTSR = 1; //*************************** // Configure Output Functions // (See Table 9-2) //*************************** //*************************** // Assign U1Tx To Pin 11 //*************************** RPOR4bits.RP8R = 3; //*************************** // Assign U1RTS To Pin 12 //*************************** RPOR4bits.RP9R = 4; //UART Initialization// PLLFBD=38; // M=40 CLKDIVbits.PLLPOST=0; // N1=2 CLKDIVbits.PLLPRE=0; // N2=2 RCONbits.SWDTEN=0; // Disable Watch Dog Timer while(OSCCONbits.LOCK!=1) {}; // Wait for PLL to lock U1MODEbits.STSEL = 0; // 1-stop bit U1MODEbits.PDSEL = 0; // No Parity, 8-data bits U1MODEbits.ABAUD = 0; // Autobaud Disabled U1MODEbits.BRGH = 0; // Low Speed mode U1BRG = BRGVAL; // BAUD Rate Setting for 19200 U1STAbits.UTXISEL1 = 0; U1MODEbits.UARTEN = 1; // Enable UART U1STAbits.UTXEN = 1; // Enable UART Tx } /////////////////////////////////////////////////////////////////// int main () { unsigned int place1,place2,place3; int STX,ETX,sign,unit_num; int temperature; initADC(); // initialize the ADC initUART(); // initalize the UART LCDinit(); OutStr(">"); The LCDinit(); Is a function from a header. I didn't included it here, but what the LCD requires to perform tasks is to have decimal values sent to it. For instance in order to clear the screen which I've been trying to do, the following must be done (this is excerpt from LCD manual); Clear Screen Syntax Hexadecimal 0xFE 0x58 Decimal 254 88 ASCII 254 ?X? Description This command will immediately clear all of the contents of the display. so what I've done is make the following commands WriteUART1(254); WriteUART1(88); [/code] I do not know why it does not work by sending this, I have the LCD to it's default setting to 19200 baudrate and that's how i set software too. Please, any help with be greatly appreciated [/quote]
A quick scan of the LCD manual indicates that there are two modes of communicating with it. RS-232 and I2C. The RS-232 interface signal levels are defined for input voltages in the range where a low is less than -3V and a high is greater than +3V.

The I2C interfaces is indeed a 0V to 5V signal interface but the serial data definition is different from the RS-232 serial data definition.

You could get your hands on a MAX232 device. This device runs on 5V but is capable of translating from the 0 to 5V logic levels used by the microcontroller to the typical -10V to +10V signal levels required by RS-232. [/quote]
thank you for replying to my troubles :)

And as a matter of fact, I do have that chip!! I connected it and like said before it works for hyperterminal but it does not work for my LCD. This is my first time ever programming a PIC, I'm sure something about my code is weird. Any other suggestions? :confused: [/quote]
Just to make sure that I am clear on the details, you have added a MAX232 device to your PIC design so you clearly have the correct RS-232 level being generated by your PIC board. You are feeding these RS-232 signal levels to your LCD but the LCD is not responding to any of the commands or data.

You also indicated (I believe) that the RS-232 output of your PIC design generates the correct characters on the computer monitor (running hyperterminal) in response to the characters you send it.

All of the above understanding being true then a few things to check are that the LCD is set to the correct bit-per-second data rate and that the LCD is set to RS-232 mode and not I2C data mode. Do you have the correct pinout so that you are sending the data to the LCD on its receive input pin and not accidentally on its transmit output pin?

Can you post a copy of the schematic of your PIC board so that we can have a look at the hardware connections you are using.
TEP , The Engineering Projects , Tick Correct Answer
Comment Bio
TEP , The Engineering Projects , Image

syedzainnasir

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon

RE:

PIC microcontroller and LCD
TEP , The Engineering Projects , Calender Comment: 20-Feb-2017
TEP , The Engineering Projects , Category In: PIC Microcontroller Projects
[quote=Junaid_Shahid post_id=63 time=1487581912 user_id=48] [quote=Isabelle post_id=62 time=1487581848 user_id=67] [quote=Junaid_Shahid post_id=60 time=1487581735 user_id=48]

A quick scan of the LCD manual indicates that there are two modes of communicating with it. RS-232 and I2C. The RS-232 interface signal levels are defined for input voltages in the range where a low is less than -3V and a high is greater than +3V.

The I2C interfaces is indeed a 0V to 5V signal interface but the serial data definition is different from the RS-232 serial data definition.

You could get your hands on a MAX232 device. This device runs on 5V but is capable of translating from the 0 to 5V logic levels used by the microcontroller to the typical -10V to +10V signal levels required by RS-232. [/quote]
thank you for replying to my troubles :)

And as a matter of fact, I do have that chip!! I connected it and like said before it works for hyperterminal but it does not work for my LCD. This is my first time ever programming a PIC, I'm sure something about my code is weird. Any other suggestions? :confused: [/quote]
Just to make sure that I am clear on the details, you have added a MAX232 device to your PIC design so you clearly have the correct RS-232 level being generated by your PIC board. You are feeding these RS-232 signal levels to your LCD but the LCD is not responding to any of the commands or data.

You also indicated (I believe) that the RS-232 output of your PIC design generates the correct characters on the computer monitor (running hyperterminal) in response to the characters you send it.

All of the above understanding being true then a few things to check are that the LCD is set to the correct bit-per-second data rate and that the LCD is set to RS-232 mode and not I2C data mode. Do you have the correct pinout so that you are sending the data to the LCD on its receive input pin and not accidentally on its transmit output pin?

Can you post a copy of the schematic of your PIC board so that we can have a look at the hardware connections you are using. [/quote]
yes, I have it so it is on RS232 as opposed to TTL and I2C because it is on it's defualt setting. So, that being said the baud rate is set to 19200 as well. Everything you stated on your last post is absolutely correct :D
TEP , The Engineering Projects , Tick Correct Answer
Comment Bio
TEP , The Engineering Projects , Tags
PLC
Robot
STM32
Arduino
AI
ESP32
Ladder Logic
PLC Projects
Programming
Communicates STM32
PLC Projects
Communicates PLC
Font Style
Alignment
Indenting and Lists
Insert Media
Insert Items

Want to leave an answer!

Word Count :0 Draft Saved at 12:42 am.