Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - andywb

Pages: [1]
Character LCDs / Re: NHD-0420D3Z - Arduino I2C Address 0x28 SOLVED
« 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

Character LCDs / 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,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
  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(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)));
  val++;        // increment value
  if(val == 84) // if reached 64th position (max)
    val = 41;    // start over from lowest value

Pages: [1]