I'm using the PIC 18F4550 to write to an LCD 16x4. I used MikroC Pro for PIC to write the code and the Proteus to simulate. I'm using the library Lcd and Lcd_Constants already present on the MikroC Pro for PIC. I'm just modifying a pre existed code that was originally designed for a 20x4 LCD, but I didn't find any declaration about the type of the LCD (16x4 or 20x4 ) in the code. As a example I tried to wrote the following messages:
Lcd_Chr(1,1,'F');
Lcd_Chr_Cp ('I');
Lcd_Chr_Cp ('R');
Lcd_Chr_Cp ('S');
Lcd_Chr_Cp ('T');
Lcd_Chr_Cp (' ');
Lcd_Chr_Cp ('L');
Lcd_Chr_Cp ('I');
Lcd_Chr_Cp ('N');
Lcd_Chr_Cp ('E');
Lcd_Chr(2,2,'S');
Lcd_Chr_Cp ('E');
Lcd_Chr_Cp ('C');
Lcd_Chr_Cp ('O');
Lcd_Chr_Cp ('N');
Lcd_Chr_Cp ('D');
Lcd_Chr_Cp (' ');
Lcd_Chr_Cp ('L');
Lcd_Chr_Cp ('I');
Lcd_Chr_Cp ('N');
Lcd_Chr_Cp ('E');
Lcd_Chr(3,2,'T');
Lcd_Chr_Cp ('H');
Lcd_Chr_Cp ('I');
Lcd_Chr_Cp ('R');
Lcd_Chr_Cp ('D');
Lcd_Chr_Cp (' ');
Lcd_Chr_Cp ('L');
Lcd_Chr_Cp ('I);
Lcd_Chr_Cp ('N');
Lcd_Chr_Cp ('E');
Lcd_Chr(4,2,'F');
Lcd_Chr_Cp ('O');
Lcd_Chr_Cp ('U');
Lcd_Chr_Cp ('R');
Lcd_Chr_Cp ('T');
Lcd_Chr_Cp ('H');
Lcd_Chr_Cp (' ');
Lcd_Chr_Cp ('L');
Lcd_Chr_Cp ('I');
Lcd_Chr_Cp ('N');
Lcd_Chr_Cp ('E');
But, in the simulation, appeared the third and fourth lines shifted by 6 columns positions. So, does someone know why it is happening ? Below is a print of a part of the schematics and simulation:
[EDITED]
I programmed a device here and the same happened. I think that, probably, the problem is on the library.
I did the following modification of th code above:
Lcd_Out(1, 1, "First Line");
Lcd_Out(2, 2, "second Line");
Lcd_Out(3, -2, "Third Line");
Lcd_Out(4, -2, "Fourth Line");
It worked. Is not a elegant way, but worked. I needed to shift the column number negatively.