Author Topic: NHD-0420D3Z - Arduino I2C Address 0x28 SOLVED  (Read 420 times)

andywb

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
NHD-0420D3Z - Arduino I2C Address 0x28 SOLVED
« on: August 07, 2018, 02:05:55 AM »
I have a project which uses these displays and was originally based on a Stamp BS2pe. The display worked well at address 0x50 using the BS2. I now have the display working with the Arduino Uno. I have reduced the clock rate to 50kHz and made sure the pull ups are above 10k as mentioned in post https://www.newhavendisplay.com/NHD_forum/index.php/topic,8660.0.html.

I2C Scanner is reporting the display at address 0x28 which is one bit shifted from 0x50 and it seems one bit is being dropped on the wake up signal from the bus.

The display responds to commands sent to address 0x28 but not to those sent to 0x50.

Is this an Arduino issue or a display problem?

I am addressing the display directly using the Wire library.

#include <Wire.h>

byte val = 41;
byte val2 = 0xFE;
byte val3 = 0x45;
byte val4 = 0x00;
int Millis1;
int Millis2;
int Millis3;

void setup()
{
  Wire.begin(); // join i2c bus
  Wire.setClock(50000);
  Serial.begin(9600);
  Millis1 = micros();
  Millis2 = micros();
  Millis3 = (Millis2 - Millis1);//Measure time taken for the maths
}

void loop()
{
  Wire.beginTransmission(0x28); // transmit to device
                              // device address is specified in datasheet
 char myString[] = "This is the first line ";

 
 Wire.write(val2);
 Wire.write(val3);
 Wire.write(val4);
 Wire.write(myString);
 Wire.write(val);             // sends value byte
 Millis1 = micros();
 Wire.endTransmission();     // stop transmitting
 Millis2 = micros();
 Serial.print(Millis2 - Millis1 - Millis3);//Print time taken for 252 clock pulses in microseconds
 Serial.print(" - ");
 Serial.print((252000/(Millis2 - Millis1 - Millis3)));
 Serial.println("Khz");
 
  val++;        // increment value
  if(val == 84) // if reached 64th position (max)
  {
    val = 41;    // start over from lowest value
  }
  delay(500);
}
« Last Edit: August 11, 2018, 01:17:34 AM by andywb »

andywb

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: NHD-0420D3Z - Arduino I2C Address 0x28 SOLVED
« Reply #1 on: August 11, 2018, 01:24:36 AM »
If you read the NHD data carefully it does imply 0x50 is an 8 bit value with the lowest bit set to zero:-

"The default I2C address is 80 (50 hex). The I2C address can be changed to any 8-bit value by command
function, with the exception that the LSB (least significant bit) must always be '0'."


0x68 on the DS3231 is a seven bit address to which you have to add the read or write bit. You can use this directly in the Wire library as Wire adds the read/write bit.

The I2C call on the Parallax stamp uses an 8 bit address, Wire on the Arduino uses a 7 bit address and shifts it left.

On the Arduino you therefore have to convert the 8 bit NHD display address 0x50 given in the data sheet to 0x28 before you send it to the wire library. Wire will restore the address to 0x50 for transmission.

I should have realised this because when I looked carefully into my old PBasic Code I declared all the addresses in set up but on the call to the sub routine which reads the clock I found a shift left with a comment about this.

Other tips to save you reading additional threads - The NHD display cannot be powered from the Arduino 5v when the Arduino is powered from USB as the 5v supply falls to 4.69v. Maximum clock rate has been de-rated by Newhaven to 50KHz. Use Wire.setClock(50000L) after Wire.begin to reduce the clock rate. If you do not reduce the clock rate the display misses characters.

Update 14/08/2018 - The Wire page has a note about the 7 bit and 8 bit addresses which somehow I missed https://www.arduino.cc/en/Reference/Wire
« Last Edit: August 14, 2018, 01:25:39 AM by andywb »

 

Arduino LCD library not working with newhaven display NHD‐0420H1Z‐FL‐GWB-3V3

Started by c2hollowBoard Character LCDs

Replies: 9
Views: 15651
Last post July 10, 2014, 08:46:06 AM
by Michael_L
MOVED: 320x240 sunlight readable dispaly to arduino + library

Started by Michael_LBoard Customer Projects

Replies: 0
Views: 4714
Last post October 23, 2015, 11:45:28 AM
by Michael_L
Arduino demo code for running the NHD-0420DZW-AB5 OLED display via SPI

Started by llameroBoard OLEDs

Replies: 1
Views: 1912
Last post May 21, 2018, 11:28:30 AM
by Ted_M
How do I stack a DAC shield between a 4.3" LCD Display and an Arduino Mega 2560?

Started by wa6htpBoard Customer Projects

Replies: 1
Views: 346
Last post September 19, 2018, 09:14:45 AM
by Ted_M
320x240 sunlight readable dispaly to arduino + library

Started by vonz66Board Graphic LCDs

Replies: 1
Views: 6008
Last post October 23, 2015, 11:46:04 AM
by Michael_L