Close
Flash Forge Inventor II Spring Promotion



Page 1 of 3 123 LastLast
Results 1 to 10 of 25
  1. #1
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,414
    Add printbus on Thingiverse

    Recovery from garbled Marlin LCD display

    How prevalent is the problem of the Marlin LCD panel displaying garbled data? My MakerFarm 8-inch i3v does it once in a while - often enough to just be annoying.

    Having written LCD interface code before, I've looked at what is supposed to be displayed and the actual garbled display. Turns out the screen effect is very predictable once it gets into this garbled mode. I have an idea for a firmware change that would recover from this, but I don't want to futz with it if this isn't a common problem.

    EDIT: My reluctance to futz with this is simply that I'm new to looking at the Marlin software and it would take me some time to figure out how the LCD interface is implemented. If there's someone out there that already understands the interface, I could share what I think we could do to fix this so that person could give it a whirl.

    Last edited by printbus; 05-02-2015 at 08:32 PM. Reason: migrated to offsite image storage due to 3DPrintBoard issues

  2. #2
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,153
    Unfortunately for you.... I don't have an LCD Panel or I would jump in and help you! There are a lot of different modules and communication methods for the different panels. It might make sense to see which panels are 100% reliable and compare their interface code against what you have. If you can get consensus on what the most reliable one is... I'll take a look. It might be they have pushed the timing or something a little bit too far and warming over the interface code makes things better. But that is pure speculation.

  3. #3
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,664
    Quote Originally Posted by Roxy View Post
    But that is pure speculation.
    That is a whole lot more than speculation, it is years of hands on experience.

  4. #4
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,414
    Add printbus on Thingiverse
    What I've seen so far in the code is pretty generic, thanks to the Hitachi controller chip and clones that pretty much every LCD uses. The Marlin code quickly leverages Arduino library stuff for the LCD functions.

  5. #5
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,414
    Add printbus on Thingiverse
    Oh, what the heck. I have a firmware change uploaded to test. I'll post details after I run this a while to make sure there are no ramifications of the change and after I witness the display recovering from "garbled mode".

    The fix is oriented around LCD interfaces that leverage the 4-bit or nibble mode to send data to the displays. As best I can interpret the possibly dated code base from MakerFarm that I'm working with, this will be the case for those with a configuration.h file that has #define statements for ULTIPANEL, REPRAP_DISCOUNT_SMART_CONTROLLER, G3D_PANEL, or ULTIMAKERCONTROLLER. These in turn will invoke the ULTRA_LCD stuff that is important here.

    In the 4-bit data mode, two transfers to the LCD display are required for most commands and data characters. The problem is that if we miss a transfer or double-clock one due to static, noise, firmware timing, or whatever, the data being sent to the display gets out of sync. For display characters, data gets displayed that is say the last four bits in one character and the four bits from the next character. This out-of-sync error will remain until the Arduino board is restarted or reset.

    There's an easy way to prove this theory for those running the printer from a host like Repetier that allows you to send G-code commands in real time. If you see the display garbled, send this to the printer without the quotes: "M117 ccccccccc" (be sure it is lower case). When things are working properly, this should cause the string of c's to be written to the status line at the bottom of the screen. In garbled mode, a string of 6's will be printed somewhere instead. Why 6's? The character address code for "c" is binary 01100011, and is sent to the display in two transfers consisting of 0110 and 0011. When things get out of sync the LCD will read these repetitive transfers in as 0011 and 0110 instead, or 00110110 combined. That's the character address code for the number 6. The location of the 6's may be somewhere other than the bottom row; it's likely that command messages can get messed up just like the character address messages.

    The display modules support 8-bits of character codes. The predefined character sets in the display modules supplement the normal 7-bit ASCII alpha-numeric character set with 128 Greek and other symbols. Once the character data transfers get messed up, it doesn't take much for characters to be selected from the extra symbols. If you have a font table for one of the Hitachi-based LCD modules and the display is garbled, you can use the M117 command to play around with how different "intentional" characters get misinterpreted as stuff in the extended character set, etc. You could even use the font table to reverse things and decode what a garbled display is trying to tell you.

    What I've uploaded to test is a one-line code change that reinitializes the LCD interface whenever the display will revert back to the main status screen. When the garbled display occurs, simply letting the display timeout should restore things. If the main display itself is what's garbled, pressing the panel knob and then waiting for the timeout that returns to the main status display should restore things.
    Last edited by printbus; 08-24-2014 at 02:59 AM.

  6. #6
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,153
    Quote Originally Posted by Mjolinor View Post
    That is a whole lot more than speculation, it is years of hands on experience.
    OK.... I believe its real.... But it might not be the interface code... I'm just making stuff up... If there is a stack overflow condition or a bad pointer being de-referenced in a loop, you can make all kinds of data corruption happen.... My guess is they are pushing some I^2C timing or something too hard. What happens a lot of time is people make firmware based timing loops and when the processors speed up, the timing doesn't work any more. I really don't know at this point. The good news is, I don't have an LCD Panel to look at... I can just sit here and speculate! What a sad world!

  7. #7
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,414
    Add printbus on Thingiverse
    To clarify for the interested, the interface involved with at least these display panels consists of six dedicated pins on the Arduino processor. i2c isn't involved. SPI is ran to the panel on at least the RepRapDiscount smart controller, but it is used with the SD card, not the LCD module. The six pins consist of an enable, a register select, and four parallel data lines. Low level operations involved with setting the data lines and toggling the enable and register select pins are accomplished through Arduino LiquidCrystal library functions. Marlin code takes care of higher level stuff like menu structure.

    It could be there's more than one thing going on, but static discharge is definitely a way I've seen my display mess up.

  8. #8
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,153
    Quote Originally Posted by printbus View Post
    To clarify for the interested, the interface involved with at least these display panels consists of six dedicated pins on the Arduino processor. i2c isn't involved. SPI is ran to the panel on at least the RepRapDiscount smart controller, but it is used with the SD card, not the LCD module. The six pins consist of an enable, a register select, and four parallel data lines. Low level operations involved with setting the data lines and toggling the enable and register select pins are accomplished through Arduino LiquidCrystal library functions. Marlin code takes care of higher level stuff like menu structure.

    It could be there's more than one thing going on, but static discharge is definitely a way I've seen my display mess up.
    I don't remember why I was thinking i^2c was used. I think I was looking at some of the smaller Arduino boards that had less I/O pins and that ended up being how a given LCD Panel worked with it. Your explanation about each character being transferred as 2 nibbles is helpful. I think what you are saying is there is no signalling to the LCD Panel to tell it which 1/2 of the character it is receiving. It just starts in the right state and every other nibble that is transferred to it is the start of another character. That seems like it is just asking to get out of phase if anything unexpected happens.

    It would seem they should have some way to reset the panel and get it to a known state???

    Another question is this: Since a lot of the LCD Panels use the same support chip, does this happen equally often with all of them? Or does it mostly happen with specific Arduino boards? Is there some combination that is more prone to the display getting out of sync? Is it at all related to how clean the power is? I know my PrintrBoard had trouble powering the Servo for Auto Bed Leveling. Do the LCD Display boards grab a lot of power from the Arduino board?

    The reason for the questions is if the root cause of the LCD Panel getting out of sync is because of missing or double clocking of the nibbles... It would seem slowing that down and making sure there are nice clean edges to the Enable and Select lines after the data is stable would help. Right? But if the corruption happens because of noisy power or something else, the solution will be doing things to clean that up.

    UPDATE: And the more I look at this, the more I don't know. Pulling up this link: http://www.reprap.org/wiki/RAMPS_LCD it shows how to build the LCD Panel and it claims it is enabled by taking the comments off of the #define ULTRA_LCD line. But when you look at their directions, they are saying the LCD Panel has 8 data lines and they only hook up 4 of them???? It would seem they should have some 'illegal' combination of RS, R/W and Enable that causes the display chip to reset????

    Oh and here is at least one example of an LCD Panel using i^2c: Check out: http://blog.reprap.org/2008/10/new-b...oller-v10.html That must be why I was thinking they were using i^2c in general for this stuff.
    Last edited by Roxy; 08-22-2014 at 10:08 AM.

  9. #9
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,414
    Add printbus on Thingiverse
    Quote Originally Posted by Roxy View Post
    ...Pulling up this link: http://www.reprap.org/wiki/RAMPS_LCD it shows how to build the LCD Panel and it claims it is enabled by taking the comments off of the #define ULTRA_LCD line. But when you look at their directions, they are saying the LCD Panel has 8 data lines and they only hook up 4 of them???? ...
    The display modules DO have 8 data lines, but the controller chip supports a data transfer mode that only uses four of them. The modules also have a read/write signal, but common applications don't need to read anything back from the display so they're hardwired for write-only. Using the 4-bit mode saves Arduino pins. (I'll get to i2c savings later)

    Quote Originally Posted by Roxy View Post
    It would seem they should have some way to reset the panel and get it to a known state??? ...It would seem they should have some 'illegal' combination of RS, R/W and Enable that causes the display chip to reset????
    One would think, but no. "Initialization" involves sending a particular sequence of commands to the display module, with specific timing constraints on the transfers. That's all my "fix" is doing - periodically reinitializing the display by going through that command sequence again. There's a bit of delay in doing this, but I don't notice it on my printer. If I understand Marlin right, any printing going on should be handled in interrupts, so the additional time spent reinitializing the display shouldn't affect anything.

    Quote Originally Posted by Roxy View Post
    Since a lot of the LCD Panels use the same support chip, does this happen equally often with all of them? Or does it mostly happen with specific Arduino boards? Is there some combination that is more prone to the display getting out of sync? Is it at all related to how clean the power is? I know my PrintrBoard had trouble power the Servo for Auto Bed Leveling. Do the LCD Display boards grab a lot of power from the Arduino board?
    I think there's too many variables here. I've had static issues on non-printer and non-Arduino designs using the modules, minimized by simply putting the display behind a bezel. They don't all use the same Hitachi HD44780 controller chip. There are clone chips out there. Older boards have discrete chips. Newer boards have the substrate right on the board and coated over. They just all support the same command set as the original HD44780 chips. Then, there's different module circuit board layouts that could lead to differences - maybe trace routing differs, different ground distribution, or maybe some include decoupling capacitors, who knows. Also, maybe some of the Arduino clone boards are better quality than others. Cleanliness of the power supply could make a difference. Wire routing in the printers could make a difference.

    The core of the LCD modules I've used only need a couple of milliamps of power. If used, a backlight will draw more, but displays with the typical LED backlighting will still be relatively low. I would assume that those reprap displays with the rotary encoder and SD card still draw minimal power.

    ---------------

    Rather than ramble on here, I'll touch on i2c in another post.
    Last edited by printbus; 08-27-2014 at 01:33 PM.

  10. #10
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,414
    Add printbus on Thingiverse
    On to the i2c or i^2c stuff. For the unfamiliar reader, a simple overview first.

    The larger Atmel AVR microcontrollers support a serial transfer over what Atmel calls the two-wire interface, or TWI. You can read about TWI in the AVR ATMEGA datasheet of your choosing. This is compatible with the Inter-Integrated Circuit (i2c or i^2c) interface. Read about THAT on wiki or other resource. It's a slick interface that allows support chips to interface with a microcontroller through serial data transfers and device addressing. Communication only requires a couple of pins, and addressing means you share the same signal pins for multiple devices. The Arduino world took this a step farther. The Wire library allows you to perform i2c communication but without committing to having or using the TWI function in the ATMEGA chip, albeit with a substantial amount of software overhead.

    Functionally, there's no reason why you couldn't use TWI/i2c for the LCD interface. In fact, there are i2c "LCD backpacks" from sources like Adafruit and Sparkfun that solder directly onto the pins of the LCD module and turn it into an i2c node. The one's I've seen of these still require you to use the LCD in 4-bit mode. Why? The i2c adapters use a shift register chip that decodes the serial data stream into the parallel lines needed to drive the display. This chip can only accept a number of bits at a time. In addition to data lines, the RS signal, E signal, and usually a backlight on/off signal have to be sent. There aren't enough shift register bits to send 8 bits of data, so only 4 get sent. RS and E aren't passed over discrete wires subject to noise and static, so maybe this is still an improvement with regards to the garbled display issue with nibbles getting out of sync. I don't know.

    Personally, however, I think it is hard to have an LCD interface that is efficient over i2c, and incredibly so with the Arduino library if it is used. Remember that we need to be setting data lines and toggling RS and E pins to send data and commands to the display. The flexible bit-bang nature of Arduino means everything is being done in software (ie, the ATMEGA TWI hardware isn't used), and there's also i2c overhead involved in setting up each transfer. Send an i2c command to confirm the bus is available. Send i2c commands to address a specific device and set up a data transfer with it. Send four of the display data bits with RS set to the desired level and E not asserted. Resend the same data bits but with E now asserted. Resend the data bits but now toggle E back to inactive. Send the next four data bits with E de-asserted. Send them again with E asserted. Again with E now toggled off. This is coming from dated memory and might not be totally correct, but this should convey a sense of the number of transfers required to send simple messages to the display. BTW, then when done with the transfer, send an i2c command to relinquish the i2c bus. And if I recall my dated research into the Arduino Wire library, acquisition of the i2c bus and addressing a device occurs on every byte or display character sent over the Wire library. Keep in mind that software is dealing with all this one serial bit at a time. Yes, one bit at a time. Very inefficient from a software overhead perspective. I've never used the Wire library, but I've read how this leads to a really slow update for anything but the smallest size display.

    FOLLOWUP COMMENT: To be fair, not all of my concerns are with the Arduino Wire library. The software-intensive effort in handling i2c is exasperated by the need to toggle control pins on the LCD display - that's driven by the nature of the LCD modules, not the Wire library. After knocking the dust off more brain cells, I also now remember that the i2c bus acquisition on every character was something done in sample software provided by AdaFruit for their i2c LCD backpack board. The Wire library wouldn't likely require every byte to be handled individually.
    Last edited by printbus; 08-27-2014 at 01:31 PM.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •