Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - write into the LCD 20x4 with ldmicro I2C

(you are viewing a thread; or go back to list of threads)

write into the LCD 20x4 with ldmicro I2C (by John)
Hi JoSé
I see LDmicro support LCD 20x4 via I2C
Can you help : how to calculate the cursor like 16x2.
Example: show '0' at line 3, column 20? I have read the lcdi2clib text file but still don't understand.
Thanks you so much.
Fri Jul 17 2020, 10:50:36
(no subject) (by José)
Yes it should work, if you have the right version of the libraries.
To move to line 3 column 20 you should use 1 10 10011 in binary
= 0xD3 in hexadecimal

PS:
1 = Move
10= 2= line 3 -1
10011= 19= col 20 -1
Mon Jul 20 2020, 13:44:54
(no subject) (by John)
Hi José
I do as your instruction, send 0xD3 to LCD but it only correct column and row was wrong. It only show at line 1 and line 2, can't not show at line 3-4. I have checked the library at below:
// Ligne 1
if(y == 1) {
adresse = LCD_LIGNE_1 + (x - 1);
}
// Ligne 2
else if (y == 2) {
adresse = LCD_LIGNE_2 + (x - 1);
}
// Ligne 2
else if (y == 3) {
adresse = LCD_LIGNE_3 + (x - 1);
}
// Ligne 2
else {
adresse = LCD_LIGNE_4 + (x - 1);
}

LCD_I2C_SendCommand(LCD_CMD_SET_DDRAM | adresse);
And
#define LCD_CMD_SET_DDRAM 0x80 // Commande d'affectation de l'adresse DDRAM
#define LCD_LIGNE_1 0x00 // Adresse ligne 1
#define LCD_LIGNE_2 0x40 // Adresse ligne 2
#define LCD_LIGNE_3 0x14 // Adresse ligne 3
#define LCD_LIGNE_4 0x54 // Adresse ligne 4
#define LCD_CMD_SET_CGRAM 0x40 // Commande d'affectation de l'adresse CGRAM

But issue still happen, my LDmicro is ver. 5404
Can you help check this library again?


}
Fri Jul 24 2020, 01:13:06, download attachment test.ld
(no subject) (by José)

I can't test since I'm in holidays.

But I think that the pb may come from version 5.4.0.4 ?
Please try my own build ldmicro32 5.5 available at:

https://github.com/joegil95/LdMicro32

Download zip file, extract the executable you want and the libraries. You must replace the libraries in LIBRARIES_FOR and in your project /lib folder where they are copied automatically.

Best regards
José
Sun Jul 26 2020, 11:54:43
(no subject) (by OnosTech)
Hi José,

The same problem was reported in the comment section of my youtube page. https://youtu.be/vbq3zlObp7c

There is no difference between version 5.4.0.5 and LdMicro32.

In addition to what John observed above, I also observed this other problem in line 243 of "I2CLib.c"
y = ((val & 60) >> 5) + 1; // y sur 2 bits => 0 < y < 5 lignes


It is an omission of 0x before 60 which I think should be 0x60 as shown below


y = ((val & 0x60) >> 5) + 1; // y sur 2 bits => 0 < y < 5 lignes

This I have tested and it seems to work fine. Please you and Ihor should verify and update with a new version.


Many thanks for your great work.

Onos
Tue Jun 15 2021, 04:44:04
(no subject) (by José)
Hi Onos

Yes, you're right, there's a little bug in I2CLib.c, for all targets:

y = ((val & 60) >> 5) + 1 must be replaced by:
y = ((val & 0x60) >> 5) + 1

I'll publish a new release of ldmicro32 with my new Ladder to C translater as soon as possible.

Thank's for this information !

José
Thu Jun 17 2021, 14:58:36
(no subject) (by José)
PS:

To use a 20 x 4 lcd display, LCD_I2C_MoveCursor() must also be modified in LcdI2cLib.c by replacing:

if((y < 1) || (y > 2) || (x < 1) || (x > 16)) ...

by:

if((y < 1) || (y > 4) || (x < 1) || (x > 20)) ...

I'll also modify it in next release.
Thu Jun 17 2021, 15:05:17
(no subject) (by OnosTech)
Hi José,

Glad I can help.

I have one request. Is it possible to include Modbus RTU library for LDmicro. This will make it easy to communicate with other commercial PLC and automation product.

Best Regards
Onos
Fri Jun 18 2021, 18:21:15
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):