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 - simonp54

Pages: [1]
1
Graphic LCDs / Re: NHD-C12864B2Z-RN-FBW Arduino Uno
« on: March 20, 2014, 03:53:45 AM »
Actually I now do have some questions, because the ST7565R documentation is so difficult to follow...

how do i achieve a "Read Data" and a "Read Status" from a point of view of the control lines...

I am not sure how the code you have given relates to the table of commands, because the documents don't show the transitions required on the control pins to achieve them. ( and I am not entirely convinced by the timing diagram because it seems like a general setup?)  Is it just a case of having the WR PIN in the opposite state?  In which case for (7) Display data read I will need A0 to be HIGH, RD LOW, and WR HIGH... we never toggled RD before... should the WriteData and WriteCommand functions now make sure of the state of RD?

Of course... with my unidirectional level shifters...  I wont be able to read the status of the pins...  But I would like to know the correct approach for doing readData and readStatus

2
Graphic LCDs / Re: NHD-C12864B2Z-RN-FBW Arduino Uno
« on: March 19, 2014, 01:37:11 PM »
Hey Michael, just before anything else... I appreciate the help and I am very pleased with your responses so far.  I am however a bit disappointed with the misleading information in the Datasheet document (particularly the example code applying to a scheme that the device doesnt support 8080 vs 6800 i just followed the example thinking it was right and the commented out little bits didn't make that any easier either)...

To answer your question, I have rechecked all the wiring and I have been very aware of the 27 vs 28 pin issue and also if you remember emailed you on the orientation of the connector which I understand is "pins" down towards the board...  (btw yes have offset the ribbon to pin 2 - 28, and checked all connections again).

I had written a long number of questions.... but as I have now got the code and screen working!!!!! I don't need them answered.

The problems were two fold..

1) I hadn't level shifted the control lines... only the DB0-7 lines.... DOH
2) I was debugging the "on off" states of the pins by putting LEDs on the driven side of the level shifter... this dragged the voltages down to an unacceptable level for them to be considered "HIGH" etc...

Thanks so much for all the help... are there any "low level" functions that I can grab to drive the screen to do simple tasks like fill an area (rectangle) etc...  and write text on it????
THANKS again.

and for anyone else...
Code: [Select]
// this code expects an IO expander (MCP23017) on the I2C bus at address 0x20
// two level shifters (74HC4050) are used to migrate the levels from 5v to 3.3v
// pins for the control lines are self explanitory

#include <Wire.h>

#define IO_I2C_ADDR 0x20
#define IO_DIRA_REG 0x00
#define IO_DIRB_REG 0x01
#define IO_ALL_OUTPUTS 0x00
#define IO_ALL_INPUTS 0xFF
#define IO_ADDR_PORT_A 0x12
#define IO_ADDR_PORT_B 0x13

#define RES_PIN 5
#define RD_PIN 4
#define WR_PIN 3
#define A0_PIN 2

void writeCom(byte bits)
{
  digitalWrite( A0_PIN, LOW );     // A0 - set LOW

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_ADDR_PORT_A);              // address port A
  Wire.write(bits);
  Wire.endTransmission();

  digitalWrite( WR_PIN, LOW );    // aka RW - set LOW
  digitalWrite( WR_PIN, HIGH );    // aka RW - set HIGH
}

void writeData(byte bits)
{
  digitalWrite( A0_PIN, HIGH );    // A0 - set HIGH
 
  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_ADDR_PORT_A);              // address port A
  Wire.write(bits);
  Wire.endTransmission();
 
  digitalWrite( WR_PIN, LOW );    // aka RW - set LOW
  digitalWrite( WR_PIN, HIGH );    // aka RW - set HIGH
}



void initScreen()
{
  digitalWrite( RD_PIN, HIGH );      // aka E - set E to HIGH
  digitalWrite( WR_PIN, HIGH );      // aka RW - set RW to HIGH
  digitalWrite( RES_PIN, LOW );      // reset pin set LOW
  delay(150);
  digitalWrite( RES_PIN, HIGH );     // reset pin set HIGH
  delay(150);
 
  writeCom( 0xA2 );    // 1/9 bias
  writeCom( 0xA0 );    // ADC SELECT NORMAL
  writeCom( 0xC0 );    // COM OUTPUT NORMAL
  writeCom( 0x25 );    // INTERNAL RESISTOR RATIO
  writeCom( 0x81 );    // ELECTRONIC VOLUME MODE SET
  writeCom( 0x15 );    // ELECTRONIC VOLUME
  writeCom( 0x2F );    // POWER CONTROLLER SET
  writeCom( 0x40 );    // DISPLAY START LINE SET
  writeCom( 0xAF );    // DISPLAY ON
 
  delay(10);
}

void disp()
{
unsigned int i, j;
        unsigned char page=0xB0;
for(i=0;i<8;i++)           //fill display with checkerboard pattern
{
            writeCom(0x10);        //set column address
            writeCom(0x00);        //set column address
    writeCom(page);        //set page address
            for(j=0;j<64;j++)
            {
               writeData(0xAA);
               writeData(0x55);
            }
            page++;
}
}


//***************************************************
//The setup() function is called
//when a sketch starts. Use it to
//initialize variables, pin modes,
//start using libraries, etc. The
//setup function will only run once,
//after each powerup or reset of the Arduino board.
//***************************************************
void setup()
{
  Serial.begin(9600);

  Wire.begin();

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_DIRA_REG);              // IDDIRA register
  Wire.write(IO_ALL_OUTPUTS);              // set all port A to outputs
  Wire.endTransmission();

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_ADDR_PORT_A);              // address port A
  Wire.write(0x00);
  Wire.endTransmission();
 
  pinMode( WR_PIN, OUTPUT );    // aka RW
  pinMode( A0_PIN, OUTPUT );    // aka RS
  pinMode( RD_PIN, OUTPUT );    // aka E
  pinMode( RES_PIN, OUTPUT );   // aka RESTB

  digitalWrite( WR_PIN, LOW );
  digitalWrite( A0_PIN, LOW );
  digitalWrite( RD_PIN, LOW );
  digitalWrite( RES_PIN, LOW );
 
  initScreen(); 
}


//***************************************************
//the loop() function does precisely what its name suggests,
//and loops consecutively, allowing your program to change
//and respond. Use it to actively control the Arduino board.
//***************************************************
void loop()
{
  disp();
  delay(1000);
}

3
Graphic LCDs / Re: NHD-C12864B2Z-RN-FBW Arduino Uno
« on: March 18, 2014, 06:20:03 PM »
Hi Michael,

Thanks for the response and code.. Yes I know its parallel, and the IO expander I am using is designed to do just this kind of update of all the pins at the same time... so we are ok there.

my code now looks like this
Code: [Select]
#include <Wire.h>

#define IO_I2C_ADDR 0x20
#define IO_DIRA_REG 0x00
#define IO_DIRB_REG 0x01
#define IO_ALL_OUTPUTS 0x00
#define IO_ALL_INPUTS 0xFF
#define IO_ADDR_PORT_A 0x12
#define IO_ADDR_PORT_B 0x13

#define RES_PIN 5
#define RD_PIN 4
#define WR_PIN 3
#define A0_PIN 2

void writeCom(byte bits)
{
  digitalWrite( A0_PIN, LOW );     // A0 - set LOW

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_ADDR_PORT_A);              // address port A
  Wire.write(bits);
  Wire.endTransmission();

  digitalWrite( WR_PIN, LOW );    // aka RW - set LOW
  digitalWrite( WR_PIN, HIGH );    // aka RW - set LOW
}

void writeData(byte bits)
{
  digitalWrite( A0_PIN, HIGH );    // A0 - set HIGH
 
  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_ADDR_PORT_A);              // address port A
  Wire.write(bits);
  Wire.endTransmission();
 
  digitalWrite( WR_PIN, LOW );    // aka RW - set LOW
  digitalWrite( WR_PIN, HIGH );    // aka RW - set LOW
}



void initScreen()
{
  digitalWrite( RD_PIN, HIGH );      // aka E - set E to HIGH
  digitalWrite( WR_PIN, HIGH );      // aka RW - set RW to HIGH
  digitalWrite( RES_PIN, LOW );
  delay(150);
  digitalWrite( RES_PIN, HIGH );
  delay(150);
 
  writeCom( 0xA2 );    // 1/9 bias
  writeCom( 0xA0 );    // ADC SELECT NORMAL
  writeCom( 0xC0 );    // COM OUTPUT NORMAL
  writeCom( 0x25 );    // INTERNAL RESISTOR RATIO
  writeCom( 0x81 );    // ELECTRONIC VOLUME MODE SET
  writeCom( 0x15 );    // ELECTRONIC VOLUME
  writeCom( 0x2F );    // POWER CONTROLLER SET
  writeCom( 0x40 );    // DISPLAY START LINE SET
  writeCom( 0xAF );    // DISPLAY ON
 
  delay(10);
}

void disp()
{
unsigned int i, j;
        unsigned char page=0xB0;
for(i=0;i<8;i++)           //fill display with checkerboard pattern
{
            writeCom(0x10);        //set column address
            writeCom(0x00);        //set column address
    writeCom(page);        //set page address
            for(j=0;j<64;j++)
            {
               writeData(0xAA);
               writeData(0x55);
            }
            page++;
}
}


//***************************************************
//The setup() function is called
//when a sketch starts. Use it to
//initialize variables, pin modes,
//start using libraries, etc. The
//setup function will only run once,
//after each powerup or reset of the Arduino board.
//***************************************************
void setup()
{
  Serial.begin(9600);

  Wire.begin();

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_DIRA_REG);              // IDDIRA register
  Wire.write(IO_ALL_OUTPUTS);              // set all port A to outputs
  Wire.endTransmission();

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_DIRB_REG);              // IDDIRB register
  Wire.write(IO_ALL_OUTPUTS);              // set all port B to outputs
  Wire.endTransmission();
 
  pinMode( WR_PIN, OUTPUT );    // aka RW
  pinMode( A0_PIN, OUTPUT );    // aka RS
  pinMode( RD_PIN, OUTPUT );    // aka E
  pinMode( RES_PIN, OUTPUT );   // aka RESTB
 
  initScreen(); 
}


//***************************************************
//the loop() function does precisely what its name suggests,
//and loops consecutively, allowing your program to change
//and respond. Use it to actively control the Arduino board.
//***************************************************
void loop()
{
  disp();
  delay(10000);
}

But still no joy.
Brings me back to my original question about checking the power supply is operating correctly???

4
Graphic LCDs / NHD-C12864B2Z-RN-FBW Arduino Uno
« on: March 18, 2014, 03:59:49 PM »
Hello again...
After this board has had all its content dropped, I thought I should post again to see if you can help me further.
As you know I am struggling to get this screen to work.  I am now using an I2C I/O expander and two 4050 chips to do the logic conversion to 3.3V I have debugged the outputs using LEDs and I am confident that the code which I attach is sending the correct stuff to the interface (through a NHD-FFC28).  I have checked and double checked everything and still I get nothing from the screen.  When I test without the screen connected it all looks correct, when the screen is inserted into the FFC28 the LEDs dont flash the same way at all...
I am using capacitors from Farnell part number (8126933).

Code is as follows:
Code: [Select]
#include <Wire.h>

#define IO_I2C_ADDR 0x20
#define IO_DIRA_REG 0x00
#define IO_DIRB_REG 0x01
#define IO_ALL_OUTPUTS 0x00
#define IO_ALL_INPUTS 0xFF
#define IO_ADDR_PORT_A 0x12
#define IO_ADDR_PORT_B 0x13

#define RD_PIN 4
#define WR_PIN 3
#define A0_PIN 2

void writeCom(byte bits)
{
  digitalWrite( A0_PIN, LOW );     // A0 - set LOW
  digitalWrite( RD_PIN, HIGH );    // aka E - set HIGH
  digitalWrite( WR_PIN, LOW );     // aka RW - set LOW

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_ADDR_PORT_A);              // address port A
  Wire.write(bits);
  Wire.endTransmission();

  digitalWrite( RD_PIN, LOW );    // aka E - set LOW
  digitalWrite( WR_PIN, LOW );    // aka RW - set LOW
}

void writeData(byte bits)
{
  digitalWrite( A0_PIN, HIGH );    // A0 - set HIGH
  digitalWrite( WR_PIN, LOW );     // aka RW - set LOW
  digitalWrite( RD_PIN, HIGH );    // aka E - set HIGH
 
  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_ADDR_PORT_A);              // address port A
  Wire.write(bits);
  Wire.endTransmission();
 
  digitalWrite( RD_PIN, LOW );    // aka E - set LOW
  digitalWrite( WR_PIN, LOW );    // aka RW - set LOW
}



void initScreen()
{
  digitalWrite( WR_PIN, LOW );      // aka RW - set RW to LOW
  digitalWrite( A0_PIN, LOW );      // aka RS - set RS to LOW
                                    // RESTB ?aka RST? - wired to VDD
                                    // CS1B - wired to VSS
  digitalWrite( RD_PIN, LOW );      // aka E - set E to LOW
  delay(22);                        //wait 22ms

  writeCom( 0xA2 );    // 1/9 bias
  writeCom( 0xA0 );    // ADC SELECT NORMAL
  writeCom( 0xC8 );    // COM OUTPUT REVERSE
  writeCom( 0xA4 );    // DISPLAY ALL POINTS NORMAL
  writeCom( 0x40 );    // DISPLAY START LINE SET
  writeCom( 0x25 );    // INTERNAL RESISTOR RATIO
  writeCom( 0x81 );    // ELECTRONIC VOLUME MODE SET
  writeCom( 0x10 );    // ELECTRONIC VOLUME
  writeCom( 0x2F );    // POWER CONTROLLER SET
  writeCom( 0xAF );    // DISPLAY ON
}

//***************************************************
//The setup() function is called
//when a sketch starts. Use it to
//initialize variables, pin modes,
//start using libraries, etc. The
//setup function will only run once,
//after each powerup or reset of the Arduino board.
//***************************************************
void setup()
{
  Serial.begin(9600);

  Wire.begin();

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_DIRA_REG);              // IDDIRA register
  Wire.write(IO_ALL_OUTPUTS);              // set all port A to outputs
  Wire.endTransmission();

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_DIRB_REG);              // IDDIRB register
  Wire.write(IO_ALL_OUTPUTS);              // set all port B to outputs
  Wire.endTransmission();
 
  pinMode( WR_PIN, OUTPUT );    // aka RW
  pinMode( A0_PIN, OUTPUT );    // aka RS
  pinMode( RD_PIN, OUTPUT );    // aka E
 
  initScreen(); 
}


//***************************************************
//the loop() function does precisely what its name suggests,
//and loops consecutively, allowing your program to change
//and respond. Use it to actively control the Arduino board.
//***************************************************
void loop()
{
  writeCom( B10100110 );
  delay(1000);
  writeCom( B10100111 );
  delay(1000);
}

Pages: [1]