PDA

View Full Version : Newhaven Serial COG 2X16 LCD



Neosec
- 19th March 2013, 17:55
Has anyone ever used one of these serial displays before? Obviously LCDOUT wont work and neither will SEROUT nor I2CWRITE, etc. There's example code on the Data sheet at the product page (http://www.newhavendisplay.com/nhdc0216czfswfbw3v3-p-1828.html), but since I'm a noob and it's not in PICBASIC I don't understand it. The display is a 4 line serial interface:

2* RS* MPU* Register*Select*Signal.**RS=0:*instruction;*RS=1:* data*
3* CSB* MPU* Active*LOW*Chip*Select*signal*
4* SCL* MPU* Serial*clock
5* SI* MPU* Input*data

The included sample code looks pretty intimidating to me I'm just wondering if it would be much smaller In PICBasic or if I should abandon this display for now until I get more experience and go back to the tried and true parallel LCD.
I bought this display on a whim because of its very low current ~1mA and 3 volt supply as my project is battery powered.

I haven't even hooked up the display yet (mostly due to the 1.5mm pitch, connector on order) and tried to make it work so I'm not necessarily looking for code, just advice from the experienced here If this is not worth the effort for a noob.

TIA
Neo

http://media.digikey.com/Photos/Newhaven%20Display%20Photos/MFG_NHD-C0216CZ-FSW-FBW-3V3.jpg

Sample code:

Example*Initialization*Program*
void init()
//initialize the LCD
{
P3 = 1;
P1 = 1;
RST = 0; //RESET
delay(2);
RST = 1; //end reset
delay(20);
Writecom(0x30); //wake up
delay(2);
Call writecom(0x30); //wake up
Call writecom(0x30); //wake up
Call writecom(0x39); //function set
Call writecom(0x14); //internal osc frequency
Call writecom(0x56); //power control
Call writecom(0x6D); //follower control
Call writecom(0x70); //contrast
Call writecom(0x0C); //display on
Call writecom(0x06); //entry mode
Call writecom(0x01); //clear
delay(10);
}
void writecom(int d)
{
CS = 0; //CS
RS = 0; //A0 = Command
for(serialcounter = 1; serialcounter <= 8; serialcounter++) //send 8 bits
{
if((d&0x80)==0x80) //get only the MSB
SI=1; //if 1, then SI=1
else
SI=0; //if 0, then SI=0
d=(d<<1); //shift data byte left
SCL = 0;
SCL = 1;
SCL = 0; //SCL
}
CS = 1;
}
void writedata(int d)
{
CS = 0; //CS
RS = 1; //A0 = Data
for(serialcounter = 1; serialcounter <= 8; serialcounter++) //send 8 bits
{
if((d&0x80)==0x80) //get only the MSB
SI=1; //if 1, then SI=1
else
SI=0; //if 0, then SI=0
d=(d<<1); //shift data byte left
SCL = 0;
SCL = 1;
SCL = 0; //SCL
}
CS = 1;
}

HenrikOlsson
- 19th March 2013, 19:48
Hi,
The PBP command to use with that display is SHIFTOUT.
Pull the Chip Select line low, set the RS line high or low depending on if it's a command or data you're sending, the use SHIFTOUT to send the actual command (or data) to the display.

Make sure to read up on the SHIFTOUT command in the manual, the instruction set for the LCD is in the datasheet. If you get stuck post the code and details on which chip etc you're using and I'm sure someone will be able to help.

It looks to be a 3.3V unit, make sure you doublecheck that before trying to connect it to 5V!

/Henrik.

Neosec
- 19th March 2013, 20:56
Excellent! Thank you.

I got this LCD because it was a 3 volt unit as I have other 3 volt components in the project and I didn't want to have to resort to translators (plus I'm running out of pins on my 18 pin PIC). Which leads me to another question is "3 volt" and "3.3 volt" considered to be the same? I've actually seen data sheets use both on the same data sheet. I've also read the everything is 3 volt now and that 3.3 is older term that just keeps on going like "110 volt" household AC, which is actually all 120 volt now.

wdmagic
- 20th March 2013, 02:35
Just a note, if your running your PIC at 5 volts, just use a resistor with zener diode to this display, you can get away with a tiny 3.3v zener and say a 510ohm resistor, the display uses such little amount of power its not worth it to have a seperate supply.

Neosec
- 20th March 2013, 04:44
Good tip 'Magic, thanks. Is 3.3 Volts and 3 Volts interchangeable?

HenrikOlsson
- 20th March 2013, 06:09
Always read the datasheet for the device/part in question.
For this display it quite clearly states that Vdd can be between 2.7 and 4.5V so 3 or 3.3V are both well within spec.

/Henrik.