0
\$\begingroup\$

I'm using serial communication to display the the data to my 4x20 lcd display. When I filled up all the lines of course I need to clear it. I've search over the net and found something like Serial.write(27); // ESC command Serial.print("[2J"); // clear screen command Serial.write(27); Serial.print("[H"); // cursor to home command But it doesn't work. I also found a solution like Serial.println(); but that solution(cheat as they called it) will only work on serial monitor. So is there any possible solution to clear the display or delete a single character from it?

\$\endgroup\$
  • \$\begingroup\$ Can you provide the link of the lcd library you are using? Is it the standard arduino library? \$\endgroup\$ – alexan_e Jan 14 '14 at 19:16
  • 1
    \$\begingroup\$ Never mind the library (it is serial communication), we/you need the documentation of that display you use. \$\endgroup\$ – Wouter van Ooijen Jan 14 '14 at 19:20
  • \$\begingroup\$ @alexan_e I think it is the standard library. Because I did not download any thing to successfully launching the serial commands. \$\endgroup\$ – NewInEverything Jan 14 '14 at 19:21
  • \$\begingroup\$ @WoutervanOoijen you mean the specification of the lcd like its schematic diagram right? \$\endgroup\$ – NewInEverything Jan 14 '14 at 19:22
  • \$\begingroup\$ No, the documentation of its serial protocol. The serial displays I know consist of the display proper, and and add-on print with a micro-controller that implements the serial protocol. The firmware of that uC determines how the display reacts to serial commands. Hence you need its documentation. \$\endgroup\$ – Wouter van Ooijen Jan 14 '14 at 19:24
1
\$\begingroup\$

The only relevant info I managed to find is this discussion

According to the last comment from the owner of the board

I tried to print the ascii table from 0 to 255. CR, LF, BS, TAB works. other non printable characters are a no go. other characters are perfect though (well the extended characters are limited).

So I wonder if a CR+LF (carriage return, line feed) sequence has an effect of pushing the printed characters out of the screen, that is

for (int i=0; i < 4; i++) 
{
  Serial.print(13);  // carriage return (CR)
  Serial.print(10);  // line feed (LF)
}

or maybe

for (int i=0; i < 4; i++) 
{
  Serial.write(13);  // carriage return (CR)
  Serial.write(10);  // line feed (LF)
}

If these don't work then the alternative I see is to apply the solution that is described in the start of the linked discussion and send 40 backspace commands:

for (int i=0; i < 80; i++) 
{
  Serial.print(8);  // print 40 times backspace (BS)
}

or you may need

for (int i=0; i < 80; i++) 
{
  Serial.write(8);  // print 40 times backspace (BS)
}
\$\endgroup\$
  • \$\begingroup\$ this code works for (int i=0; i < 40; i++) { Serial.write(8); // print 40 times backspace (BS) }. Thanks, but I don't it's going backwards because on the serial monitor it's going forward which means I cant delete a single character. \$\endgroup\$ – NewInEverything Jan 14 '14 at 21:40
  • \$\begingroup\$ But why did he say it works in the discussion, he had the same board. (?) He said (1) print "backspace" 20*4 times (2) print line 1 (3) print line 2 (4) print line 3 (5) print line 4 By the way 20*40 =80 times so I should edit my code \$\endgroup\$ – alexan_e Jan 14 '14 at 21:44
  • \$\begingroup\$ but this means I'm not deleting any data thrown to the microcontroller. And if I'm right it can consume all the memory of the arduino? Am i right? and what would be the effects of having its memory full? \$\endgroup\$ – NewInEverything Jan 14 '14 at 21:46
  • 1
    \$\begingroup\$ @NewInEverything Each character you send, is received and stored in the display memory (until overwritten or deleted). When you send something using the serial command it doesn't get stored anywhere in the arduino memory. \$\endgroup\$ – alexan_e Jan 14 '14 at 21:49
1
\$\begingroup\$

Summary

You can probably separate the standard parallel LCD from the serial board and use the parallel display directly.

Serial display

The E-Term looks like the display section (top board) has a 16-pin parallel 4x20 character LCD on a board which is attached by a 16-pin connector and standoffs to a parallel to serial adapter (part of bottom board).

enter image description here

If you have no software information on the serial-adapter command-interface, it will be very difficult to use.

Better documented displays

That vendor offers other displays which have much more documentation. Including example Arduino sketches.

You could try these and see if your display interface uses the same or a similar system of commands (using STX and ETX characters to bracket commands within displayable data).

This may end up being a frustrating dead end.

Parallel display portion

There is a good chance the top board uses a standard 16-pin parallel controller and if so, it can be detached from the other board and can be driven using the Arduino LiquidCrystal library.

This library has many functions including ...

  • clear the display - clear()
  • position the cursor - setCursor(column, row)
  • move cursor to top left - home()

Since there are numerous tutorials for this and huge numbers of people using it, you may find this an easier path.

It does use six GPIO pins instead of two. You probably are not (yet) short of GPIO pins on your Arduino clone.

Note that a regular Arduino's A0-A5 (or more) pins can also be used a digital IO pins.

Arduino Megas (and similar clones) have many more GPIO pins which can also be used (so long as you load the relevant "core" into the IDE and then select the right board in the IDE)

Personally, I'd expect this to be the easiest way forward.


Example

This is an old Arduino Duemilanove - it has limited GPIO pins. However it is driving a MIDI shield which has two MIDI ports, 3 pushbuttons and 2 analog potentiometers.

I had no problems finding 6 GPIO pins (plus power and gnd) to connect up a parallel LCD. 4 data (yellow). enable (yellow) RS (blue). Your Arduino-clone has far more GPIO than this and so you shouldn't have much problem.

The mini breadboard is there to make the connections easy and to provide LCD contrast control by potentiometer.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ actually my clone have 4 pins for tx and rx.pins 4-11 is filled up by my keypad, pin for GND and AREF and pins 12 and 13. It has additionnal 10 I/O pins but I don't know if it counts as an GPIO, and 6 unused analog pins. Will there be a problem if i tap the connections of my display to the pins occupied by the keypad? BTW here is the manual of my clone gizDuino \$\endgroup\$ – NewInEverything Jan 14 '14 at 21:07
  • \$\begingroup\$ @New: see updated answer. You have at least GPIO pins 18-23 free - that is enough for a parallel LCD (with offboard contrast control) \$\endgroup\$ – RedGrittyBrick Jan 14 '14 at 21:32
  • \$\begingroup\$ well, I did find a quick solution in one of the answers here in the thread, but I don't think that solution can delete a single character in the display. With your answer do you think I can delete a single character in my display? \$\endgroup\$ – NewInEverything Jan 14 '14 at 21:53
  • \$\begingroup\$ @New: See LiquidCrystal link in answer. You can overwrite any character (e.g. with space) or you can rewrite a line from buffer array. However, if you have serial working, use it. \$\endgroup\$ – RedGrittyBrick Jan 14 '14 at 21:59
  • \$\begingroup\$ I'll still try your solution. Coz I dont think my prof will approve it without deleting a single character. I'll ask again if I encounter any problems. I hope you'll help me again. Thanks \$\endgroup\$ – NewInEverything Jan 14 '14 at 22:03
0
\$\begingroup\$

I don't know the answer to your specific question - but here is how this usually works.

Typically most LCD boards have an "LCD Controller" that only accepts parallel communication - the most common example would be the Hitachi HD44780. Often for a 4 line display, there will be two controllers. For LCDs that accepts serial communication, there is also a companion microcontroller on the LCD controller board. This micro-controller is programmed to accept serial communication and convert it into the proper parallel commands into the LCD controller.

Long story short, I don't believe there are any "standards" and what serial commands are used to clear your display or change the cursor position is dependent on how that microcontroller has been programmed to accept those commands. You will need to see if there is a user guide that explains the details of how to issue those commands.

\$\endgroup\$
  • \$\begingroup\$ actually I'm using a bit similar module. E-term \$\endgroup\$ – NewInEverything Jan 14 '14 at 20:24
0
\$\begingroup\$

On the Newhaven serial displays I've used, the "Clear Display" command is 0x01.

On Parallax displays, the command (called "Form Feed") is 0x0C (12 decimal).

If you have a different type of display, the command may be different again.

\$\endgroup\$
  • \$\begingroup\$ its a bit similar to parallax, but it has an exrta pin for tx. Ill try the command in parallax \$\endgroup\$ – NewInEverything Jan 14 '14 at 20:39
  • \$\begingroup\$ so I assume that this is you command Serial.write(12);, or Serial.println(12);, Serial.print(12);. am I right? if it is. I still can clear the lcd. \$\endgroup\$ – NewInEverything Jan 14 '14 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.