Go Down

Topic: newhaven serial display — HELP NEEDED (Read 2 times) previous topic - next topic

ahhreeyell

Hello,

I need to make an animation that will be displayed on this Newhaven 0220D3Z LCD display: http://media.digikey.com/Photos/Newhaven%20Display%20Photos/MFG_NHD-0220D3Z-NSW-BBW.jpg. Being a noob at this and all, I have a few questions:

1. How do you read the pin connections, exactly? The pin numbers and the function that corresponds to each pin number are listed in the datasheet, but the holes on the board themselves aren't labeled. Here is the datasheet: http://www.newhavendisplay.com/specs/NHD-0220D3Z-NSW-BBW.pdf

2. Why are there two VDD and GND inputs? Do you need to use both?

2. What commands do you use to send bits of data to this thing? Do any of you have experience with this? What do I need to do, code-wise? (I'm a REAL noob with all this).

Thank you so much!

robtillaart

disclaimer, I have no such device.

Quote

1. How do you read the pin connections, exactly? The pin numbers and the function that corresponds to each pin number are listed in the datasheet, but the holes on the board themselves aren't labeled. Here is the datasheet: http://www.newhavendisplay.com/specs/NHD-0220D3Z-NSW-BBW.pdf


On the picture on page 3 the pins 1, 2 , 15 and 16 are mentioned in the drawing. (LEFT)
Sometimes nr 1 connection is a square.

Quote

2. Why are there two VDD and GND inputs? Do you need to use both?

Think not, it gives some freedom to connect it.

Quote

2. What commands do you use to send bits of data to this thing? Do any of you have experience with this? What do I need to do, code-wise? (I'm a REAL noob with all this).

Is stated in the datasheet, page 7 and beyond. Configure it as a serial device first, and connect it to pin 1 (TX) of the Arduino (= hardware serial) to pin 1 of the display (RX)

Code: [Select]

void setup()
{
  Serial.begin(9600);
  Serial.println("Hello World");
}

void loop() {}


Should get you started
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

floresta

Rob types faster than I do and some of our answers are similar....

Quote
but the holes on the board themselves aren't labeled. Here is the datasheet:
They are identified on the 'Mechanical Drawing' on page 3 of the data sheet.

Quote
Do you need to use both?
Good question.  Probably not, you will just have to experiment.

Quote
What commands do you use to send bits of data to this thing?
They are in the data sheet. (I know you didn't want to hear that, but it's the best I can come up with.)

Quote
Do any of you have experience with this?
No, but it looks interesting.

Quote
What do I need to do, code-wise? (I'm a REAL noob with all this).
I would start by setting the jumpers for the Self-test so that you can answer the power supply question.  After you have verified that the device works you will have to determine how you want to communicate with the module.  I would check out the various libraries that are available to help make this decision.  After you decide you will have to set the jumpers appropriately.

Don

ahhreeyell

Okay, thanks a whole lot. I managed to get the device turned on, and I'm able to transmit data by outputting the decimal numbers that correspond to each ASCII code. I also figured out how to get some of the special commands to work.

However, I need to make an animation for this thing. How can I make characters move wherever I want on the screen? Like, suppose I want to make a character jump from cell 1 on row 2 to cell 15 on row 1? How would I do that?

Thanks!

ahhreeyell

Also, are there any special libraries for this thing? It has its own microcontroller, so I figured the LiquidCrystal libraries wouldn't work.

floresta

Quote
However, I need to make an animation for this thing. How can I make characters move wherever I want on the screen? Like, suppose I want to make a character jump from cell 1 on row 2 to cell 15 on row 1? How would I do that?
Look into the 'Set cursor' (AKA Set Cursor Position) command.  You can't really 'move' the character.  You will have to go to the original position of the character and replace it with a space.  Then you will  have to go to the new position and rewrite the character.  If you want to know the relationship between the magic 'hex' numbers and the actual screen position then check out the LCD Addressing link at http://web.alfredstate.edu/weimandn.

Don

ahhreeyell

I tried playing with the "set cursor" command and I haven't really figured it out. If I operate this device in i2c mode, then can't I use the LCDi2cNHD (on this page: http://www.arduino.cc/playground/Code/LCDAPI) library? It says on the datasheet that I need to place a jumper on R1 and put pull-up resistors on R7 and R8 (this is all on page 6 of this datasheet: http://www.newhavendisplay.com/specs/NHD-0220D3Z-NSW-BBW.pdf); however, there are no holes next to them…do I need to solder wires to the board itself? Is there a way to expand my options while still in RS232 mode?

floresta

You shouldn't have to change interface modes (SPI, I2C, RS232) in order to expand your options.  Regardless of how you interface the device the actual commands should be the same.  To send any of the commands you have to first send the command prefix of 0xFE, then the actual command which for setting the cursor is 0x45, and finally you have to send the hex address corresponding to the position you want to go to on the screen.  The table on page 9 gives you eight of the possible values and you can interpolate the rest or follow the link I gave you previously.

Don

ahhreeyell

Yes, but how do you implement a command like the reset cursor position command? This is what I typed:

  Serial.print(254, BYTE);
  Serial.print(69, BYTE);//change cursor position

But then how do you indicate WHERE you want the cursor to go or what character you want to move?
Also, where in the link that you posted does it tell you how to make the ASCII characters move across the screen?

floresta

If you look at the 'Table of Commands' on page 7 you will see that they consist of a sequence of two or more bytes.  The first byte, which is called the 'Prefix' is always 0xFE (which for some mysterious reason you have converted to decimal 254).  The next byte is the 'CMD' which is short for command.  Some commands require more information called a 'Param' which is short for parameter.

Quote
Yes, but how do you implement a command like the reset cursor position command? This is what I typed:

 Serial.print(254, BYTE);
 Serial.print(69, BYTE);//change cursor position

But then how do you indicate WHERE you want the cursor to go or what character you want to move?

You are OK so far, you just need to send the 'Parameter'.  To determine the value for this parameter you have to look at the information for the 20x2 display in the link I sent you to.  Here's a copy:



Lets say you want to go just past the center of the first row.  From the picture above this would be address 0x0A so you should send Serial.print(0x0A,BYTE);.   Remember, when you manually convert hex to decimal the best you can do is get it right.  If there's a way to send data in it's original format that's usually the best choice.

If you want to go to the beginning of the second row you should use:
Serial.print(0xFE,BYTE);  // Prefix
Serial.print(0x45,BYTE);  // Command
Serial.print(0x40,BYTE);  // Parameter


If you want to go to the beginning of the first row you could use:
Serial.print(0xFE,BYTE);  // Prefix
Serial.print(0x45,BYTE);  // Command
Serial.print(0x00,BYTE);  // Parameter


but there is a special command for this because the LCD controller also has a special command to do this:
Serial.print(0xFE,BYTE);  // Prefix
Serial.print(0x46,BYTE);  // Command

This doesn't need a parameter since 'home' is always at address 0x00.


Quote
Also, where in the link that you posted does it tell you how to make the ASCII characters move across the screen?

Nowhere, this is a function of the LCD controller.  Once you set the cursor the next character will be displayed at that new position and the cursor position will then automatically advance to the right for the following character.  

Don

ahhreeyell

Thank you so much, Don. I really appreciate all your help. I have a few questions:

1. In that code that you posted, where do I specify the characters that I want to output? Is there any way you could actually give me a sample program (not too complicated) that works on this particular module?

2. For some reason, whenever I output data to the LCD, there are always a bunch of random bits of data that show up beforehand. For this reason, I cannot output anything static to the LCD, because the random bits just stay there and never go away. Why are those random bits there, and how can I make those go away? In case you don't know what I'm referring to, I attached an image to this message.

3. I was thinking that perhaps the approach I want to take to make this animation is one in which I output a series of static images using custom-made characters--as opposed to moving the cursor around. How do I do this? I put the data in void setup() as opposed to void loop(), so that they would stay still, but then I ran into that annoying problem with the random characters. I was thinking of running through my images using a loop or an array, but how would I do that?

Thanks so much!

floresta

#11
Apr 05, 2011, 04:49 am Last Edit: Apr 05, 2011, 03:34 pm by floresta Reason: 1
Quote
In that code that you posted, where do I specify the characters that I want to output?
After you position the cursor you just send the ASCII codes for the characters you want to display.  You don't have to look the codes up, the compiler does that for you.  Something like Serial.print("Hello, world"); should work.

Quote
Is there any way you could actually give me a sample program (not too complicated) that works on this particular module?
Not really.  I don't have that particular serial module and there are no standards for them, each one has it's own command set.  Also I am fairly illiterate in C, I tinker mostly with assembly language.  I have to look up all the code I send you.  On second thought why don't you try this:
void setup()
{
 Serial.begin(9600);
 Serial.print("Hello world");
}

void loop()
{  
}


If that works then add this to setup:
Serial.print(0xFE,BYTE);  // Command Prefix
Serial.print(0x45,BYTE);  // Set Cursor
Serial.print(0x40,BYTE);  // Start of second line
Serial.print("from ahhreyell");


Quote
For some reason, whenever I output data to the LCD, there are always a bunch of random bits of data that show up beforehand. For this reason, I cannot output anything static to the LCD, because the random bits just stay there and never go away. Why are those random bits there, and how can I make those go away? In case you don't know what I'm referring to, I attached an image to this message.
I would have to know what you are trying to display and how you are trying to display it but offhand I would guess that you are doing stuff in loop that belongs in setup.  Basically as far as the LED is concerned you write stuff that doesn't change in setup and you write stuff that changes in loop.  How about posting some code?

Quote
I was thinking that perhaps the approach I want to take to make this animation is one in which I output a series of static images using custom-made characters...
You are limited to eight custom characters.  Remember, Character LCDs like these are really designed to display short messages although bar graphs aren't too difficult.  Graphical LCDs (which are a bit more difficult to deal with) are more suited to animation.

That ought to keep you out of trouble for a while.  I'll check back tomorrow.


[Edit] It's tomorrow - looking back I see that Rob proposed the same initial sketch back in reply #1 !

Don

floresta

While looking back I saw some unanswered questions.

From reply #3:

Quote
However, I need to make an animation for this thing. How can I make characters move wherever I want on the screen? Like, suppose I want to make a character jump from cell 1 on row 2 to cell 15 on row 1? How would I do that?

Here are the comments, you fill in the code.
void setup()
{

// set Arduino baud rate to 9600

// put the following in loop if you want it to repeat, leave it in setup if you only want to do it once

// position cursor to cell 1 on row 2
// display the character
// delay for as long as you want the character to stay here

// erase the character - this is the generic technique
// position cursor to cell 1 on row 2
// display a blank (0x20)

//   NOTE: you could also have erased the character using the destructive backspace command which may be 
//         unique to the New Haven controller as the LCD controller itself does not inherently do this

// position cursor to cell 15 on row 1
// display the character
// delay for as long as you want the character to stay here

// do more moves using this technique

}

void loop()

}



From reply #4

Quote
Also, are there any special libraries for this thing? It has its own microcontroller, so I figured the LiquidCrystal libraries wouldn't work.

I alluded to this in reply #11.  You are correct about the standard LiquidCrystal library not being appropriate since it is for the native parallel interface.  Each of the various serial LCD modules and/or backpack implementations uses it's own microcontroller.  There's no standardization, each one has it's own command set and hence no library that I know of (but see below).

From reply #6:

Quote
If I operate this device in i2c mode, then can't I use the LCDi2cNHD (on this page: http://www.arduino.cc/playground/Code/LCDAPI) library?

It looks like the answer is yes.  When I initially looked at that page I saw that it talks about a proposed API which is a standard interface.  Now I see that you were referring to a link on that page which does indeed lead to a library written specifically for the New Haven displays. 

My own personal opinion is that it would take me take longer to figure out how to use the library than to implement the actions on my own, but I don't like to use other people's code and I don't like libraries in general.  That comes from my background in education as opposed to one in industry.


Don






DeepBlue

Hello ahhreeyell

To answer your question on the i2c interface, the answer is yes. I bought a similar lcd screen (2x20) with the same driver. All you need to do is solder the 2 pads together where it says "R1" Then use the datasheet to locate the 5v, ground, SCL, and SDA. the library works great, but may need some minor modification. It uses analog pins 4 and 5. analog pin 5 is SLC, and pin 4 is SDA.

Everything else should work. when you initialize the lcd, use (2,16,...) instead of the (4,20,...).

Go Up