C-Code to interface ACM1604B SERIES LCD MODULE to P1
gregfox
Posts: 68
in Propeller 1
Hello, I’m looking for C-Code to interface an
ERM1604SBS-1 (ACM1604B SERIES LCD MODULE) with the P1 (propeller). If anyone
has code for this, Great! If not, does anyone have any C-Code for any series
LCD interface that I might modify to work with the propeller? I have nothing against Spin, in fact, I like it, but it's not transferable, and all my other stuff in in C. . The ERM1604 connections
are below, THANKS!;
INTERFACE
PIN CONNECTIONS HD44780
LCD
Pin No. Symbol Level Pin Description Function
1 VSS - Ground OV
2 VDD - Supply voltage for logic +5V
3 VO - LCD contrast adjust By user
4 RS H/L Register select H: Data; L:
Instruction code
5 R/W H/L Read / write H: Data read, L: Data
write
6 E H, H4L Enable Start signal for data
read/write
7 DBO H/L Data bit 0 8-bit interface
S DB1 H/L Data bit 1 8-bit interface
9 DB2 H/L Data bit 2 8-bit interface
10 DB3 HA Data bit 3 8-bit interface
11 DB4 HA Data bit 44-bit or 8-bit interface
12 DB5 H/L Data bit 5 4-bit or 8-bit
interface
13 DB6 H/L Data bit 6 4-bit or 8-bit
interface
14 DB7 H/L Data bit 7 4-bit or 8-bit
interface
15 A - Anode for LED backlight Power supply
for LED/EL backlights
16 K - Cathode for LED backlight Power supply
for LED/EL backlights
ERM1604SBS-1 (ACM1604B SERIES LCD MODULE) with the P1 (propeller). If anyone
has code for this, Great! If not, does anyone have any C-Code for any series
LCD interface that I might modify to work with the propeller? I have nothing against Spin, in fact, I like it, but it's not transferable, and all my other stuff in in C. . The ERM1604 connections
are below, THANKS!;
INTERFACE
PIN CONNECTIONS HD44780
LCD
Pin No. Symbol Level Pin Description Function
1 VSS - Ground OV
2 VDD - Supply voltage for logic +5V
3 VO - LCD contrast adjust By user
4 RS H/L Register select H: Data; L:
Instruction code
5 R/W H/L Read / write H: Data read, L: Data
write
6 E H, H4L Enable Start signal for data
read/write
7 DBO H/L Data bit 0 8-bit interface
S DB1 H/L Data bit 1 8-bit interface
9 DB2 H/L Data bit 2 8-bit interface
10 DB3 HA Data bit 3 8-bit interface
11 DB4 HA Data bit 44-bit or 8-bit interface
12 DB5 H/L Data bit 5 4-bit or 8-bit
interface
13 DB6 H/L Data bit 6 4-bit or 8-bit
interface
14 DB7 H/L Data bit 7 4-bit or 8-bit
interface
15 A - Anode for LED backlight Power supply
for LED/EL backlights
16 K - Cathode for LED backlight Power supply
for LED/EL backlights
Comments
The HD44780 object in PropWare will work wonderfully for you. Be sure to configure the dimensions as 16x4.
PropWare::HD44780 source code
PropWare::HD44780 example (written for a 16x2 lcd, so make sure you change the 2 to a 4 )
I would seriously consider Parallax's serial LCDs, with one wire serial interface. They cut down on pin usage and there is C example source code on the LEARN portion of their website. After using one in my current project, I will never use another HD44780 for another Propeller project.
I looked at the links and it is confusing to me because it’s
written in C++ (I know a little C but not C++). If I could understand how to
compile the object I would. I guess I’ll try to understand the method of
compiling and the use of makefile. Not exactly what I’m looking for (C would be
better as I could learn from the code) but it’s a start. My goal is to learn
how to program the LCD in C.
and yes they are simple to use…But
1.
They cost 9 times more than the HD44780,($5.38
vi $47.00)
2.
The Demo is written in spin, and I want to use
C.
3.
Although it would be very easy to go down that
road, I want to see the code in C so that I may learn something. It’s the hard way, but in the end the better way.
I will re-create the demo project in a SimpleIDE project for you tonight so that you have a demo that is easier for you to understand. No need to mess with Makefiles - using PropWare objects does not require using the PropWare build system
maybe some snippets are helpful
--Edit--See my post below for the attached zip.
I would expect an error like that if your file name ended in ".c" instead of ".cpp"
Can you show the entire contents of the compilation window?
it received the following error;
Project Directory:
C:/GREG/Parallax/
SimpleIDE
Version 1.0.2
C:/Users/greg/Documents/SimpleIDE/Learn/Simple
Libraries/
C:/GREG/Parallax/
Updated on: 2015-05-06
propeller-elf-gcc.exe
-v GCC 4.6.1 (propellergcc_v1_0_0_2408)
propeller-elf-c++
-I . -L . -o cmm/HD44780_Demo.elf -Os -mcmm -m32bit-doubles -fno-exceptions
-fno-rtti HD44780_Demo.cpp -ltiny -ltiny -ltiny
HD44780_Demo.cpp:5:30:
fatal error: PropWare/hd44780.h: No such file or directory
compilation
terminated.
Done.
Build Failed!
I have a
folder named PropWare, and in it hd44780.h and printer.h. The file path is;
C:Program Files
(x86)SimpleIDEpropeller-gccpropeller-elfinclude.
I think this is correct, Y/N?
"I have a folder named PropWare"Where is that folder located? Do you mean you have a folder "C:Program Files (x86)SimpleIDEpropeller-gccpropeller-elfincludePropWare"? If so, that would be incorrect. The PropWare folder should be in the same directory as the .side file.
I just triple checked on my own machine and that zip still works from Ubuntu Linux. I check on my Windows virtual machine as well
- Download SimpleIDE installation file
- Install SimpleIDE, accepting all defaults
- Download zip as attached above
- Extract zip somewhere (I extracted to my desktop)
- Open SimpleIDE, accept default workspace
- Click "Project" menu at the top of the window
- Select "Open" in the menu, navigate to the extracted folder named "HD44780"
- Select "HD44780_Demo.side" and click "Open" in the bottom right
- Click the hammer icon to build
- Rejoice
This worked both for Windows and Linux identically. I was also able to then program my board and it ran successfully, from both OSes.Thanks.
That'd be perfect. Knowing now that it works as such, I assume you can figure out how to change the code to fit your hardware if it is already wired up.
But... if I output on line 29 the folowing;lcd.puts("abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWZYZ");
I get;
line 1: VWZYZfghijklmnop line 2 blankline 3: FGHIJKLMNOPQRSTU line 4 blankWhat might I be doing wrong?I tried all the other iterations 16x1,20x1,20x2 etc. sometime I get all four lines but out of order.Thank you again!
And let me know what it outputs. That will tell me how the module maps the physical location of characters to its memory addresses. It clearly isn't normal and if I were to believe the datasheet 100%, it would actually not be an HD44780 controller. But.... I find it hard to believe that someone would so closely mimic HD44780 but then change the DDRAM so that no one could use it easily.
SimpleIDE Version 1.0.2C:/Users/greg/Documents/SimpleIDE/Learn/Simple Libraries/C:/GREG/Parallax/ Updated on: 2015-05-06
propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2408)propeller-elf-c++ -I . -L . -o lmm/HD44780_Demo.elf -Os -mlmm -Wall -m32bit-doubles -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections HD44780_Demo.cppIn file included from PropWare/hd44780.h:33:0,from HD44780_Demo.cpp:5:./PropWare/printer/printer.h:393:38: warning: variadic templates only available with -std=c++0x or -std=gnu++0x [enabled by default]./PropWare/printer/printer.h:394:70: warning: variadic templates only available with -std=c++0x or -std=gnu++0x [enabled by default]./PropWare/printer/printer.h: In member function 'void PropWare::Printer::printf(const char*, T, const Targs ...) const':./PropWare/printer/printer.h:449:40: warning: variadic templates only available with -std=c++0x or -std=gnu++0x [enabled by default]HD44780_Demo.cpp: In function 'int main()':HD44780_Demo.cpp:31:23: error: 'lt' was not declared in this scopeHD44780_Demo.cpp:31:35: warning: for increment expression has no effect [-Wunused-value]HD44780_Demo.cpp:31:36: error: expected ')' before ';' tokenHD44780_Demo.cpp:31:40: error: name lookup of 'c' changed for ISO 'for' scoping [-fpermissive]HD44780_Demo.cpp:31:40: note: (if you use '-fpermissive' G++ will accept your code)HD44780_Demo.cpp:31:41: error: expected ';' before ')' token
So I input:lcd.puts("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+9876543210");the display read:3210EFGHIJKLMNOPOpqrstuvwxyz0123QRSTUVWXYZabcdef456789!@#$%^&*()
What I will do is create a special HD44780 object just for the 16x4 format. Unfortunately, I don't have a 16x4 LCD and don't really want to pay $15 for something I'll never use (and the ones from china won't be here for three weeks). So... I'm going to have to ask you to test it for me. I'll try to get it perfect the first time around... but, please forgive me if takes a few back-and-forths.
I think I’m beginning to understand; 16X4 is a bit uncommon and 20X4 is more common. Would it not be advisable to just obtain some 20X4?Also I would be happy to test whatever comes my way.Again thank you for your time.
If you want to purchase a 20x4, go for it. I don't have a class that communicates with these LCDs over I2C though, so you'll have to look for code from other people or write your own. If you choose a 20x4 parallel LCD, then the code you already have should work great.
If you want to stick with your 16x4, that is no problem. I'm more than happy to create simple objects like that when requested. And... it's a gaping hole in the HD44780 class that is going to bother me until I fill it.