This project involves interfacing a New Haven Display
to an Arduino NANO PCB. It's for use reading process variables from an RS485 link. The specific LCD is P/N NHD-0420D3Z-NSW-BBW-V3
. This LCD includes an SPI interface which allows commands to be sent using SS (slave select), SCK (SPI clock) and MOSI (Master Out Slave In). The LCD is a write to only device. Including ground and +5VDC make just 5 wires required to use the LCD. This makes wiring the LCD easier. Both Digikey
carry these displays. Mouser carries the Arduino NANO V3
PCB. Digikey also carries the Arduino NANO V3
The LCD uses a MicroChip PIC16F690 processor to handle the serial (SPI, I2C and RS232) communications and general housekeeping. Controlling the LCD is accomplished via sending command bytes prefixed by 0xfe. The absence of this 0xfe byte tells the LCD to interpret the byte as an ASCII character. Which displays at the current cursor position. Consult the SPECIFICATIONS
for technical details on the LCD (commands, configuring and pinouts). Selecting communication mode is accomplished by closing (leaving open) solder pads R1 and R2. For SPI mode, close R2 which requires soldering a wire across the R2 pads. Leave R1 open. This is delicate soldering and requires a small soldering tip.
The NANO V3 PCB uses an Atmel ATMEGA328P processor running at 16 MHz. Its SPI engine allows dividing the FOSC frequency by 128 for an SPI SCK of 125KHz (slowest possible). The LCD's maximum SPI SCK is 100KHz. So it isn't possible to use the NANO's SPI engine which would make life easier. The work around is to write a bit bang function that simulates the SCK and MOSI pulse train required by the LCD. Writing in C on the NANO V3 brings the SPI SCK frequency down to 25KHz which is fast enough for most applications. The C function presented here is based on the PIC16F690 DATASHEET
page 184. Figure 13-5 shows the timing expected for SPI slave mode (CKE=0, CKP=1). Input bits are sampled on the rising edge of each clock pulse. Any function written to accomplish this will work fine. I used a Tektronix 465B dual trace scope to check pulse timing. The C function here places the data bit pulse width just about in the middle of the rising edge of the SPI SCK. The helps with any timing jitters to avoid data transmission errors. LCDs are typically slow devices with a few instructions requiring 4mS to execute and most in the 100 uS range. The specs have all this data. At 25KHz (SCK), there is a reasonable amount of wiggle room on timing.