Shop OBEX P1 Docs P2 Docs Learn Events
C-Code to interface ACM1604B SERIES LCD MODULE to P1 — Parallax Forums

C-Code to interface ACM1604B SERIES LCD MODULE to P1

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


 
«1

Comments

  • This is a standard HD44780 LCD (the Toshiba HD44780 is the LCD controller itself).
    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 :) )
  • gregfox
    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.
  • Thanks SwimDude0614!


    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.
  • Thanks you Idbruce, I’ve looked at the single line serial,
    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.
  • Good news Greg! You have an example in another thread that just popped up:http://forums.parallax.com/discussion/161786/serial-lcd-not-updating#latest

    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
  • gregfoxgregfox Posts: 68
    edited 2015-07-31 12:39
    Many thanks for all you time and effort.
  • years ago I did a interface for propgcc to this lcd module
    maybe some snippets are helpful
     
     
    c
    c
    1K
    h
    h
    315B
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-07-31 23:36
    Sorry about not doing this last night. Since I'm not at home now, I can't test it on a Propeller to be sure, but I would give it a 90% confidence rating - since it compiles, it should run fine.
    --Edit--See my post below for the attached zip.
  • Thank you Swimdude, this could be just what I'm looking for. I'll try it out tomorrow as I'm out of town tonight.
  • Thank you Reinhard I sure will try out your code, looks good!
  • Just tested that example code - it does in fact work. And, here's the attached zip.
  • Swimdude, I tried compiling HD4478_Demo with simple IDE, and received an error "namespace PropWare {".Are you sure it compiled for you? 
  • did you open the .side file that is attached in the 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?
  • gregfoxgregfox Posts: 68
    edited 2015-08-01 19:51

  • SwinDude, I was finally able to open the .side and when I compiled
    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?
  • sure is odd that "-ltiny" shows up three times.
    "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
  • Worked perfectly for me on Windows too. Here's the steps I took:
    1. Download SimpleIDE installation file
    2. Install SimpleIDE, accepting all defaults
    3. Download zip as attached above
    4. Extract zip somewhere (I extracted to my desktop)
    5. Open SimpleIDE, accept default workspace
    6. Click "Project" menu at the top of the window
    7. Select "Open" in the menu, navigate to the extracted folder named "HD44780"
    8. Select "HD44780_Demo.side" and click "Open" in the bottom right
    9. Click the hammer icon to build
    10. 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.
  • It compiled, I am now rejoicing! Thank you.Tomorrow I'll hook up the LCD and give it a try.
  • gregfoxgregfox Posts: 68
    edited 2015-08-02 13:16

    Thanks.
  • SwimDude, a quick look, and am I right to connect D0 of the LCD to pin P19, D1 to pin P20 ... D7 of the LCD to pin P26?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.
  • THE HARDWARE WILL BE HOOKED UP TODAY OR TOMORROW, LOOKING FOR SOME PARTS, i'LL REPORT BACK. THANKS
  • Almost there, I changed line 18 to read;const HD44780::Dimensions DIMENSIONS = HD44780::DIM_16x4;

    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!
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-08-06 20:53
    Set the dimensions to DIM_40x2 and write 80 unique characters to it. This would be most easily accomplished with
    for (char c = 33; c < (33 + 80); ++c) {
    lcd.put_char(c);
    }
    

    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.
  • I put you code and got the following error:Project Directory: C:/Users/greg/Desktop/LCD/HD44780/HD44780/
    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!@#$%^&*()
  • Ugh, sorry lol. The forums translated "<" into "&lt;"
  • I was curious about that...
  • gregfoxgregfox Posts: 68
    edited 2015-08-03 04:02
    It then compiled but the display was blank. I should check all connections...
  • Okay, this makes sense now and matches exactly what this website describes for 16x4. Unfortunately, 16x4 is a pain and will require some very odd logic. Because that odd logic is not required for any other form factor, I am not going to include it in the standard HD44780 object. If I did, it would only waste valuable code space for most users.
    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.
  • gregfoxgregfox Posts: 68
    edited 2015-08-03 15:45
    Very kind of you to offer, but if I may ask, is this display so different from the others? Is there a different 4 line display using the HD44780 that would conform more to the norm?I found several 20X4 on ebay, some are I2C some not.

    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.
  • 20x4 would be much better because it organizes the rows in a normal fashion. Why oh why somebody decided to organize the rows in 16x4 as they did, I will never know!
    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.
Sign In or Register to comment.