Show Posts
Pages: 1 2 [3]
31  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 20, 2012, 12:31:56 pm
No, I'm just trying to use the Arduino board as a serial interface because I don't have a separate one. The 84's TX pin goes to the RX pin on the Arduino Uno R3 board which makes the TX led blink on the Arduino board. I also connected a 10µF cap between RESET and GND on the Arduino and leave the 4 pins used for programming the 84 connected during testing. The only thing I change during programming is disconnecting the 84's serial line temporarily.
32  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 20, 2012, 12:26:13 pm
@Coding Badly
Now I'm using your library again.
It doesn't seem to matter if I just use the standard
Code:
Serial.begin(9600);
//and so on...

or if I use
Code:
#include <TinyDebugSerial.h>
TinyDebugSerial mySerial = TinyDebugSerial();
mySerial.begin(9600);
//and so on...

the output is always 0xFF with 2.5secs delay in between which I defined to check if it would be far off the expected value
33  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 20, 2012, 12:18:55 pm
The Arduino must get it's power from somewhere else in your setup, otherwise it wouldn't work. Could you post a picture/schematic?

The data I'm receiving ist 0xFF every time if that helps someone to help me. I used a Processing sketch to display the actual binary data because the Arduino serial monitor only prints this character: ÿ
34  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 20, 2012, 10:10:27 am
Maybe you need the updated version mentioned in this thread:

http://arduino.cc/forum/index.php/topic,109081.15.html
I used the current version (15) which should work as well, shouldn't it? But I switched back to http://hlt.media.mit.edu/?p=1695 after it didn't work.

I used an ATTiny85 to send serial data and an Arduino Uno to receive it. First I got some strange gibberish too until I pulled the ATTiny's VCC out by accident. Without VCC on the ATTiny it sent what I wanted, after reconnecting VCC it was gibberish again. There were no pins except Tx, Rx and GND connected.
Not sure how this is supposed to work without power but just to test everything I tried it as well and the AtTiny stopped transmitting after pulling out the VCC cable.
35  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 20, 2012, 08:52:03 am
Hi,

...low baud rates would be fine since the interface will only be used for debugging...

Then I suggest using TinyDebugSerial in the Tiny Core.

I tried the TinyDebugSerial, same problem.

I tried the same thing with an ATTiny85 and for some reason it does only work when VCC is not connected. I haven't tried it with an 84 yet, but I guess it's not that much different. Hope that helps.
What do you mean by not connecting VCC? Two different power supplies for the two microcontrollers? Because at the moment the AtTiny receives power from the Arduino 5V rail.
36  Using Arduino / Microcontrollers / SoftwareSerial with ATTiny84 using ATtiny library on: September 18, 2012, 01:37:42 pm
Hi,

I'm flashing an ATTiny84 using my Arduino Uno and everything works except the SoftwareSerial. I'm using the 8MHz internal clock (not calibrated but low baud rates would be fine since the interface will only be used for debugging). With some baud rates, the Arduino serial interface on my Mac receives some gibberish data and with others nothing at all. The TX led on the Arduino blinks when data is being sent btw.

Here's the important part of my code:
Code:
#include <SoftwareSerial.h>
// Definitions
#define rxPin 2
#define txPin 3

byte pwm = 0;

SoftwareSerial mySerial(rxPin, txPin);

void setup()
{
  // Pin Setup
  pwm = 0;
  mySerial.begin(9600);
}
 
void loop()
{
  /*
    calculates pwm
  */
  mySerial.print(pwm, DEC);
  mySerial.println();
  delay(1000);
}

Can anybody help? Would be greatly appreciated!
37  Using Arduino / Displays / Re: EA DOGXL160-W on Arduino Uno Rev 3 need Tutorial/Help on: September 01, 2012, 05:36:28 am
I've got it working now, the problem was that my Command/Data pin was defined at pin 11 and it's used by the SPI library. I've just defined it somwhere else and everything works!

Thanks for helping, I'll write back once the display does something useful smiley-wink
38  Using Arduino / Displays / Re: EA DOGXL160-W on Arduino Uno Rev 3 need Tutorial/Help on: September 01, 2012, 03:24:57 am
Reset isn't used, so it's essentially tied to 3.3V.

I tried setting the pixels right after the init without using addresses, still doesn't work. Btw, do I have to put the display to sleep before writing data? I couldn't find a workflow for writing data in the manual http://www.lcd-module.de/eng/pdf/zubehoer/uc1610.pdf.


Here's the code for testing without addresses:
Code:
#include <snesController.h>
#include <SPI.h>

#define COMMAND 0
#define DATA 1
//New Controller
//  Latch: Pin 3
//  Clock: Pin 2
//  Data: Pin 5
snesController controller(3, 2, 5);

// Controller
static unsigned long ioReadWriteDelay; // Stores the delay time for ioReads/Writes
int *data;           // States of the controller buttons
boolean buttons[12];
int dataOld[2];        // previous states of the controller buttons

//  Display
const int csPin = 7; // Chip Select pin
const int rstPin = 9; // Reset pin
const int mosiPin = 11; // Mosi Pin
const int cdPin = 12; // Clock/Command Mode pin
const int clkPin = 13; // Clock pin
const int pixels[2] = {160, 104}; // X-Dimension, Y-Dimension


void setup()
{
  // Display Setup:
  // Chip Select pin setup
  pinMode (csPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(csPin, HIGH);  // Normally high

  // Reset pin setup
  pinMode (rstPin, OUTPUT);   // Setting the pin as an output
  digitalWrite(rstPin, HIGH); // Normally high

  // Command/Data pin setup
  pinMode (cdPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(cdPin, HIGH);  // Just to define any state, not necessary
 
  // Clock pin setup
  pinMode (clkPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(clkPin, HIGH);  // Just to define any state, not necessary
 
   // Mosi pin setup
  pinMode (mosiPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(mosiPin, HIGH);  // Just to define any state, not necessary
 
  // OS Setup:
 
  ioReadWriteDelay = micros();
  Serial.begin(9600);
 
  // SPI setup ( http://arduino.cc/en/Reference/SPI )
  SPI.begin();                         // initializing SPI
  SPI.setBitOrder(MSBFIRST);           // MSB is sent first
  SPI.setClockDivider(SPI_CLOCK_DIV16); // 4MHz Clock (16MHz/divider)
  SPI.setDataMode(SPI_MODE3);          // Clock normally hight, data on positive edge.
 
  delay(2500); // The display needs around 5ms to boot, using 20ms just to be safe
 
  display_init(pixels[0], pixels[1]); // Initializes the display
 
}

void loop()
{
 
  if((long)(micros() - ioReadWriteDelay) >= 0)
  {
    ioReadWriteDelay += 16742;  // do it again later [µs].
    // Checks if more than ioReadWriteDelay [ms] has passed since last excecution of the code inside, also works if the timer overflows.
    data = controller.readButtons(); // Read connected controllers
   
    digitalWrite(csPin, LOW);  // Selects the chip
    if (data[0] != dataOld[0])
    {
      /*Serial.write(highByte(data[0])); // Upper 8 bits
      Serial.write(lowByte(data[0]));  // Lower 8 bits
      Serial.write(highByte(data[1])); // Upper 8 bits
      Serial.write(lowByte(data[1]));  // Lower 8 bits
      Serial.println();*/                       // To indicate a completed transmission
      dataOld[0] = data[0];
     
      if((data[0] & 1) == 0)
      {
        lcdWrite(COMMAND, B10100101); // Set all pixels ON
      }
      else
      {
        lcdWrite(COMMAND, B10100100); // reset pixels to stored value
      }
    }
    digitalWrite(csPin,HIGH);  // Deselects the chip
  }
}

void display_init(byte width, byte height)
{
  digitalWrite(csPin, LOW);  // Selects the chip
 
  displayCmd_SET_COM_END(height);       // Defines the dimensions of the display
  displayCmd_SET_LCD_MAPPING_CONTROL(); // Orientation and order of pixels
  displayCmd_SET_SCROLL_LINE(0);        // Disable scrolling
  displayCmd_SET_PANEL_LOADING();       // Sets display capacitance
  displayCmd_SET_LCD_BIAS_RATIO();      // Sets bias ratio
  displayCmd_SET_VBIAS_POTENTIOMETER(); // Sets contrast
  displayCmd_SET_RAM_ADDRESS_CONTROL(); // Sets Auto-Increment
  displayCmd_SET_INVERSE_DISPLAY(false);// Display non-inverse data
  displayCmd_SET_LCD_GRAY_SHADE();      // Set gray shade
  //displayCmd_SET_DISPLAY_ENABLE(true);  // Enable display
  //displayCmd_SET_DISPLAY_ENABLE(false); // Disable display
 
  for(int k = 1; k <= (height / 4); k++)
  {
    //displayCmd_SET_PAGE_ADDRESS(k);
    for(int i = 0; i < width; i++)
    {
     
      //Serial.print(k);
      //Serial.print(" ");
      //Serial.println(i);
     
      //displayCmd_SET_COLUMN_ADDRESS(i);
      lcdWrite(DATA, B11111111); // Write Data to reset
    }
  }
 
  displayCmd_SET_DISPLAY_ENABLE(true);  // Enable display
  //lcdWrite(COMMAND, B10100101); // Set all pixels ON*/
  //delay(300);
  //lcdWrite(COMMAND, B10100100);
  //delay(300);
  digitalWrite(csPin,HIGH);  // Deselects the chip
}

void displayCmd_SET_COM_END(byte height)
{
  /*
  This command programs the ending COM electrode.
  CEN defines the number of used COM electrodes, and it should correspond to the number of pixel-rows in the LCD.
  */
  byte address = height - 1;
  lcdWrite(COMMAND, B11110001); // SET COM END Line 1
  lcdWrite(COMMAND, address);   // Address of last row
}

void displayCmd_SET_LCD_MAPPING_CONTROL()
{
  /*
  This command is used to program LC[2:0] for COM (row) mirror (MY), SEG (column) mirror (MX).
  */
  lcdWrite(COMMAND, B11000110); // SEG (column), COM (row), mirror
  //lcdWrite(COMMAND, B11000000); // This would be used to turn the display upside-down
}

void displayCmd_SET_SCROLL_LINE(byte scroll)
{
  /*
  Set the scroll line number.
  */
  byte lsb = B01000000 | (B00001111 & scroll);        // Combining command and 4 LSB's
  byte msb = B01010000 | ((B01110000 & scroll) >> 4); // Combining command and 3 MSB's
  lcdWrite(COMMAND, lsb);                             // 4 LSB
  lcdWrite(COMMAND, msb);                             // 3 MSB
}

void displayCmd_SET_PANEL_LOADING()
{
  /*
  Set PC[1:0] according to the capacitance loading of LCD panel.
  */
  lcdWrite(COMMAND, B00101011); // Sets Capacitance to 28-38nF
}

void displayCmd_SET_LCD_BIAS_RATIO()
{
  /*
  Bias ratio definition
  */
  lcdWrite(COMMAND, B11101011); // Sets Bias to 1/12
}

void displayCmd_SET_VBIAS_POTENTIOMETER()
{
  /*
  Program VBIAS Potentiometer (PM[7:0]).
  */
  lcdWrite(COMMAND, B10000001); // Command
  lcdWrite(COMMAND, B01011111); // Contrast value
}

void displayCmd_SET_RAM_ADDRESS_CONTROL()
{
  /*
  Program registers AC[2:0] for RAM address control.
  */
  lcdWrite(COMMAND, B10001001); // Set auto-increment
}

void displayCmd_SET_DISPLAY_ENABLE(boolean enable)
{
  /*
  This command is for programming register DC[2].
  When DC[2] is set to 0, the IC will put itself into Sleep mode.
  When any of the DC[2] bits is set to 1, UC1610 will first exit from Sleep Mode, restore the power and then turn on COM drivers and SEG drivers. There is no other explicit user action or timing sequence required to enter or exit the Sleep mode.
  */
  byte command = B10101110;
  if(enable)
  {
    command += 1;
  }
  lcdWrite(COMMAND, command); // Enable/Disable display
}

void displayCmd_SET_COLUMN_ADDRESS(byte column)
{
  byte lsb = column & B00001111;
  byte msb = (column & B11110000) >> 4;
  lcdWrite(COMMAND, (msb | B00010000));
  lcdWrite(COMMAND, (lsb | B00000000));
 
}

void displayCmd_SET_PAGE_ADDRESS(byte page)
{
  page = page & B00011111;
  byte command = page | B01100000;
  lcdWrite(COMMAND, command);
}

void displayCmd_SET_INVERSE_DISPLAY(boolean enable)
{
  /*
  Display the inverse of stored data, this has no effect on the data being stored
  */
  byte command = B10100110;
  if(enable)
  {
    command += 1;
  }
  lcdWrite(COMMAND, command); // Inverse/Regular display
}

void displayCmd_SET_LCD_GRAY_SHADE()
{
  /*
  Program gray scale register (LC[6:5]). This register controls the voltage RMS separation between the two gray shade levels (data “01” and data “10”)
  */
  lcdWrite(COMMAND, B11010011); // 40% gray shade levels
}







void lcdWrite(byte mode, byte data)
{
  //Serial.println("CS Low");
 
  digitalWrite(cdPin, mode); // Selects wether data or command is being sent
  //delayMicroseconds(5);
 
  SPI.transfer(data);        // 1byte of data/command
  //delay(2000);
  //Serial.println("CS High");
 
  //digitalWrite(cdPin, ~mode);
  //delayMicroseconds(5);
}

void resetLcd()
{
  // This function is used to reset the display
  digitalWrite(rstPin, LOW);  // Enabling the reset
  delay(5);                   // 5ms delay just to make sure
  digitalWrite(rstPin, HIGH); // Disabling the reset
  delay(20);                  // The display needs some time to reset, this prevents other code being executed too early
}
39  Using Arduino / Displays / Re: EA DOGXL160-W on Arduino Uno Rev 3 need Tutorial/Help on: September 01, 2012, 12:59:16 am
Moving the CS outside lcdWrite() didn't change the behavior at all, it still doesn't display my data. Any other ideas?

Code:
#include <snesController.h>
#include <SPI.h>

#define COMMAND 0
#define DATA 1
//New Controller
//  Latch: Pin 3
//  Clock: Pin 2
//  Data: Pin 5
snesController controller(3, 2, 5);

// Controller
static unsigned long ioReadWriteDelay; // Stores the delay time for ioReads/Writes
int *data;           // States of the controller buttons
boolean buttons[12];
int dataOld[2];        // previous states of the controller buttons

//  Display
const int csPin = 7; // Chip Select pin
const int rstPin = 9; // Reset pin
const int mosiPin = 11; // Mosi Pin
const int cdPin = 12; // Clock/Command Mode pin
const int clkPin = 13; // Clock pin
const int pixels[2] = {160, 104}; // X-Dimension, Y-Dimension


void setup()
{
  // Display Setup:
  // Chip Select pin setup
  pinMode (csPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(csPin, HIGH);  // Normally high

  // Reset pin setup
  pinMode (rstPin, OUTPUT);   // Setting the pin as an output
  digitalWrite(rstPin, HIGH); // Normally high

  // Command/Data pin setup
  pinMode (cdPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(cdPin, HIGH);  // Just to define any state, not necessary
 
  // Clock pin setup
  pinMode (clkPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(clkPin, HIGH);  // Just to define any state, not necessary
 
   // Mosi pin setup
  pinMode (mosiPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(mosiPin, HIGH);  // Just to define any state, not necessary
 
  // OS Setup:
 
  ioReadWriteDelay = micros();
  Serial.begin(9600);
 
  // SPI setup ( http://arduino.cc/en/Reference/SPI )
  SPI.begin();                         // initializing SPI
  SPI.setBitOrder(MSBFIRST);           // MSB is sent first
  SPI.setClockDivider(SPI_CLOCK_DIV16); // 4MHz Clock (16MHz/divider)
  SPI.setDataMode(SPI_MODE3);          // Clock normally hight, data on positive edge.
 
  delay(2500); // The display needs around 5ms to boot, using 20ms just to be safe
 
  display_init(pixels[0], pixels[1]); // Initializes the display
 
}

void loop()
{
 
  if((long)(micros() - ioReadWriteDelay) >= 0)
  {
    ioReadWriteDelay += 16742;  // do it again later [µs].
    // Checks if more than ioReadWriteDelay [ms] has passed since last excecution of the code inside, also works if the timer overflows.
    data = controller.readButtons(); // Read connected controllers
   
    digitalWrite(csPin, LOW);  // Selects the chip
    if (data[0] != dataOld[0])
    {
      /*Serial.write(highByte(data[0])); // Upper 8 bits
      Serial.write(lowByte(data[0]));  // Lower 8 bits
      Serial.write(highByte(data[1])); // Upper 8 bits
      Serial.write(lowByte(data[1]));  // Lower 8 bits
      Serial.println();*/                       // To indicate a completed transmission
      dataOld[0] = data[0];
     
      if((data[0] & 1) == 0)
      {
        lcdWrite(COMMAND, B10100101); // Set all pixels ON
      }
      else
      {
        lcdWrite(COMMAND, B10100100); // reset pixels to stored value
      }
    }
    digitalWrite(csPin,HIGH);  // Deselects the chip
  }
}

void display_init(byte width, byte height)
{
  digitalWrite(csPin, LOW);  // Selects the chip
 
  displayCmd_SET_COM_END(height);       // Defines the dimensions of the display
  displayCmd_SET_LCD_MAPPING_CONTROL(); // Orientation and order of pixels
  displayCmd_SET_SCROLL_LINE(0);        // Disable scrolling
  displayCmd_SET_PANEL_LOADING();       // Sets display capacitance
  displayCmd_SET_LCD_BIAS_RATIO();      // Sets bias ratio
  displayCmd_SET_VBIAS_POTENTIOMETER(); // Sets contrast
  displayCmd_SET_RAM_ADDRESS_CONTROL(); // Sets Auto-Increment
  displayCmd_SET_INVERSE_DISPLAY(false);// Display non-inverse data
  displayCmd_SET_LCD_GRAY_SHADE();      // Set gray shade
  //displayCmd_SET_DISPLAY_ENABLE(true);  // Enable display
  //displayCmd_SET_DISPLAY_ENABLE(false); // Disable display
 
  for(int k = 1; k <= (height / 4); k++)
  {
    displayCmd_SET_PAGE_ADDRESS(k);
    for(int i = 0; i < width; i++)
    {
     
      //Serial.print(k);
      //Serial.print(" ");
      //Serial.println(i);
     
      displayCmd_SET_COLUMN_ADDRESS(i);
      lcdWrite(DATA, B11111111); // Write Data to reset
    }
  }
 
  displayCmd_SET_DISPLAY_ENABLE(true);  // Enable display
  //lcdWrite(COMMAND, B10100101); // Set all pixels ON*/
  //delay(300);
  //lcdWrite(COMMAND, B10100100);
  //delay(300);
  digitalWrite(csPin,HIGH);  // Deselects the chip
}

void displayCmd_SET_COM_END(byte height)
{
  /*
  This command programs the ending COM electrode.
  CEN defines the number of used COM electrodes, and it should correspond to the number of pixel-rows in the LCD.
  */
  byte address = height - 1;
  lcdWrite(COMMAND, B11110001); // SET COM END Line 1
  lcdWrite(COMMAND, address);   // Address of last row
}

void displayCmd_SET_LCD_MAPPING_CONTROL()
{
  /*
  This command is used to program LC[2:0] for COM (row) mirror (MY), SEG (column) mirror (MX).
  */
  lcdWrite(COMMAND, B11000110); // SEG (column), COM (row), mirror
  //lcdWrite(COMMAND, B11000000); // This would be used to turn the display upside-down
}

void displayCmd_SET_SCROLL_LINE(byte scroll)
{
  /*
  Set the scroll line number.
  */
  byte lsb = B01000000 | (B00001111 & scroll);        // Combining command and 4 LSB's
  byte msb = B01010000 | ((B01110000 & scroll) >> 4); // Combining command and 3 MSB's
  lcdWrite(COMMAND, lsb);                             // 4 LSB
  lcdWrite(COMMAND, msb);                             // 3 MSB
}

void displayCmd_SET_PANEL_LOADING()
{
  /*
  Set PC[1:0] according to the capacitance loading of LCD panel.
  */
  lcdWrite(COMMAND, B00101011); // Sets Capacitance to 28-38nF
}

void displayCmd_SET_LCD_BIAS_RATIO()
{
  /*
  Bias ratio definition
  */
  lcdWrite(COMMAND, B11101011); // Sets Bias to 1/12
}

void displayCmd_SET_VBIAS_POTENTIOMETER()
{
  /*
  Program VBIAS Potentiometer (PM[7:0]).
  */
  lcdWrite(COMMAND, B10000001); // Command
  lcdWrite(COMMAND, B01011111); // Contrast value
}

void displayCmd_SET_RAM_ADDRESS_CONTROL()
{
  /*
  Program registers AC[2:0] for RAM address control.
  */
  lcdWrite(COMMAND, B10001001); // Set auto-increment
}

void displayCmd_SET_DISPLAY_ENABLE(boolean enable)
{
  /*
  This command is for programming register DC[2].
  When DC[2] is set to 0, the IC will put itself into Sleep mode.
  When any of the DC[2] bits is set to 1, UC1610 will first exit from Sleep Mode, restore the power and then turn on COM drivers and SEG drivers. There is no other explicit user action or timing sequence required to enter or exit the Sleep mode.
  */
  byte command = B10101110;
  if(enable)
  {
    command += 1;
  }
  lcdWrite(COMMAND, command); // Enable/Disable display
}

void displayCmd_SET_COLUMN_ADDRESS(byte column)
{
  byte lsb = column & B00001111;
  byte msb = (column & B11110000) >> 4;
  lcdWrite(COMMAND, (msb | B00010000));
  lcdWrite(COMMAND, (lsb | B00000000));
 
}

void displayCmd_SET_PAGE_ADDRESS(byte page)
{
  page = page & B00011111;
  byte command = page | B01100000;
  lcdWrite(COMMAND, command);
}

void displayCmd_SET_INVERSE_DISPLAY(boolean enable)
{
  /*
  Display the inverse of stored data, this has no effect on the data being stored
  */
  byte command = B10100110;
  if(enable)
  {
    command += 1;
  }
  lcdWrite(COMMAND, command); // Inverse/Regular display
}

void displayCmd_SET_LCD_GRAY_SHADE()
{
  /*
  Program gray scale register (LC[6:5]). This register controls the voltage RMS separation between the two gray shade levels (data “01” and data “10”)
  */
  lcdWrite(COMMAND, B11010011); // 40% gray shade levels
}







void lcdWrite(byte mode, byte data)
{
  //Serial.println("CS Low");
 
  digitalWrite(cdPin, mode); // Selects wether data or command is being sent
  //delayMicroseconds(5);
 
  SPI.transfer(data);        // 1byte of data/command
  //delay(2000);
  //Serial.println("CS High");
 
  //digitalWrite(cdPin, ~mode);
  //delayMicroseconds(5);
}

void resetLcd()
{
  // This function is used to reset the display
  digitalWrite(rstPin, LOW);  // Enabling the reset
  delay(5);                   // 5ms delay just to make sure
  digitalWrite(rstPin, HIGH); // Disabling the reset
  delay(20);                  // The display needs some time to reset, this prevents other code being executed too early
}
40  Using Arduino / Displays / Re: EA DOGXL160-W on Arduino Uno Rev 3 need Tutorial/Help on: August 31, 2012, 04:38:35 pm
Yeah, but since I'm just starting with the Arduino I'd rather do it myself to learn a bit more.
I'll test the multibyte thing tomorrow and report back.

Danke schonmal!
41  Using Arduino / Displays / Re: EA DOGXL160-W on Arduino Uno Rev 3 need Tutorial/Help on: August 31, 2012, 04:12:23 pm
Yeah, i thought about doing that later but since every command(i could check via SPI or looking at the display) worked i didn't implement it yet.

Doesn't the display accept multibyte commands if the CS pin goes high in between them? I'll fix that tomorrow and report back.
42  Using Arduino / Displays / Re: EA DOGXL160-W on Arduino Uno Rev 3 need Tutorial/Help on: August 31, 2012, 03:47:03 pm
The reset procedure is not being used, just for testing.

I just checked the data with serial output, but i see nothing wrong there.

Since the commands are accepted, i think the hardware setup is ok. Things like turning all pixels on work.
(I followed the hw setup from EA)
43  Using Arduino / Displays / Re: EA DOGXL160-W on Arduino Uno Rev 3 need Tutorial/Help on: August 31, 2012, 03:30:53 pm
Ok, here's the full source. I just wrote it so there is really nothing optimized smiley-razz
(And I'm new to Arduino)


Code:
#include <snesController.h>
#include <SPI.h>

#define COMMAND 0
#define DATA 1
//New Controller
//  Latch: Pin 3
//  Clock: Pin 2
//  Data: Pin 5
snesController controller(3, 2, 5);

// Controller
static unsigned long ioReadWriteDelay; // Stores the delay time for ioReads/Writes
int *data;           // States of the controller buttons
boolean buttons[12];
int dataOld[2];        // previous states of the controller buttons

//  Display
const int csPin = 7; // Chip Select pin
const int rstPin = 9; // Reset pin
const int mosiPin = 11; // Mosi Pin
const int cdPin = 12; // Clock/Command Mode pin
const int clkPin = 13; // Clock pin
const int pixels[2] = {160, 104}; // X-Dimension, Y-Dimension


void setup()
{
  // Display Setup:
  // Chip Select pin setup
  pinMode (csPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(csPin, HIGH);  // Normally high

  // Reset pin setup
  pinMode (rstPin, OUTPUT);   // Setting the pin as an output
  digitalWrite(rstPin, HIGH); // Normally high

  // Command/Data pin setup
  pinMode (cdPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(cdPin, HIGH);  // Just to define any state, not necessary
 
  // Clock pin setup
  pinMode (clkPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(clkPin, HIGH);  // Just to define any state, not necessary
 
   // Mosi pin setup
  pinMode (mosiPin, OUTPUT);    // Setting the pin as an output
  digitalWrite(mosiPin, HIGH);  // Just to define any state, not necessary
 
  // OS Setup:
 
  ioReadWriteDelay = micros();
  Serial.begin(9600);
 
  // SPI setup ( http://arduino.cc/en/Reference/SPI )
  SPI.begin();                         // initializing SPI
  SPI.setBitOrder(MSBFIRST);           // MSB is sent first
  SPI.setClockDivider(SPI_CLOCK_DIV16); // 4MHz Clock (16MHz/divider)
  SPI.setDataMode(SPI_MODE3);          // Clock normally hight, data on positive edge.
 
  delay(2500); // The display needs around 5ms to boot, using 20ms just to be safe
 
  display_init(pixels[0], pixels[1]); // Initializes the display
}

void loop()
{
 
  if((long)(micros() - ioReadWriteDelay) >= 0)
  {
    ioReadWriteDelay += 16742;  // do it again later [µs].
    // Checks if more than ioReadWriteDelay [ms] has passed since last excecution of the code inside, also works if the timer overflows.
    data = controller.readButtons(); // Read connected controllers
   
   
    if (data[0] != dataOld[0])
    {
      /*Serial.write(highByte(data[0])); // Upper 8 bits
      Serial.write(lowByte(data[0]));  // Lower 8 bits
      Serial.write(highByte(data[1])); // Upper 8 bits
      Serial.write(lowByte(data[1]));  // Lower 8 bits
      Serial.println();*/                       // To indicate a completed transmission
      dataOld[0] = data[0];
     
      if((data[0] & 1) == 0)
      {
       // lcdWrite(COMMAND, B10100101); // Set all pixels ON
      }
      else
      {
       // lcdWrite(COMMAND, B10100100); // reset pixels to stored value
      }
    }
  }
}

void display_init(byte width, byte height)
{
 
  displayCmd_SET_COM_END(height);       // Defines the dimensions of the display
  displayCmd_SET_LCD_MAPPING_CONTROL(); // Orientation and order of pixels
  displayCmd_SET_SCROLL_LINE(0);        // Disable scrolling
  displayCmd_SET_PANEL_LOADING();       // Sets display capacitance
  displayCmd_SET_LCD_BIAS_RATIO();      // Sets bias ratio
  displayCmd_SET_VBIAS_POTENTIOMETER(); // Sets contrast
  displayCmd_SET_RAM_ADDRESS_CONTROL(); // Sets Auto-Increment
  displayCmd_SET_INVERSE_DISPLAY(false);// Display non-inverse data
  displayCmd_SET_LCD_GRAY_SHADE();      // Set gray shade
  //displayCmd_SET_DISPLAY_ENABLE(true);  // Enable display
  //displayCmd_SET_DISPLAY_ENABLE(false); // Disable display
 
  for(int k = 1; k <= (height / 4); k++)
  {
    for(int i = 0; i < width; i++)
    {
     
      //Serial.print(k);
      //Serial.print(" ");
      //Serial.println(i);
      displayCmd_SET_PAGE_ADDRESS(k);
      displayCmd_SET_COLUMN_ADDRESS(i);
      lcdWrite(DATA, B11111111); // Write Data to reset
    }
  }
 
  displayCmd_SET_DISPLAY_ENABLE(true);  // Enable display
  //lcdWrite(COMMAND, B10100101); // Set all pixels ON*/
  //delay(300);
  //lcdWrite(COMMAND, B10100100);
  //delay(300);
}

void displayCmd_SET_COM_END(byte height)
{
  /*
  This command programs the ending COM electrode.
  CEN defines the number of used COM electrodes, and it should correspond to the number of pixel-rows in the LCD.
  */
  byte address = height - 1;
  lcdWrite(COMMAND, B11110001); // SET COM END Line 1
  lcdWrite(COMMAND, address);   // Address of last row
}

void displayCmd_SET_LCD_MAPPING_CONTROL()
{
  /*
  This command is used to program LC[2:0] for COM (row) mirror (MY), SEG (column) mirror (MX).
  */
  lcdWrite(COMMAND, B11000110); // SEG (column), COM (row), mirror
  //lcdWrite(COMMAND, B11000000); // This would be used to turn the display upside-down
}

void displayCmd_SET_SCROLL_LINE(byte scroll)
{
  /*
  Set the scroll line number.
  */
  byte lsb = B01000000 | (B00001111 & scroll);        // Combining command and 4 LSB's
  byte msb = B01010000 | ((B01110000 & scroll) >> 4); // Combining command and 3 MSB's
  lcdWrite(COMMAND, lsb);                             // 4 LSB
  lcdWrite(COMMAND, msb);                             // 3 MSB
}

void displayCmd_SET_PANEL_LOADING()
{
  /*
  Set PC[1:0] according to the capacitance loading of LCD panel.
  */
  lcdWrite(COMMAND, B00101011); // Sets Capacitance to 28-38nF
}

void displayCmd_SET_LCD_BIAS_RATIO()
{
  /*
  Bias ratio definition
  */
  lcdWrite(COMMAND, B11101011); // Sets Bias to 1/12
}

void displayCmd_SET_VBIAS_POTENTIOMETER()
{
  /*
  Program VBIAS Potentiometer (PM[7:0]).
  */
  lcdWrite(COMMAND, B10000001); // Command
  lcdWrite(COMMAND, B01011111); // Contrast value
}

void displayCmd_SET_RAM_ADDRESS_CONTROL()
{
  /*
  Program registers AC[2:0] for RAM address control.
  */
  lcdWrite(COMMAND, B10001001); // Set auto-increment
}

void displayCmd_SET_DISPLAY_ENABLE(boolean enable)
{
  /*
  This command is for programming register DC[2].
  When DC[2] is set to 0, the IC will put itself into Sleep mode.
  When any of the DC[2] bits is set to 1, UC1610 will first exit from Sleep Mode, restore the power and then turn on COM drivers and SEG drivers. There is no other explicit user action or timing sequence required to enter or exit the Sleep mode.
  */
  byte command = B10101110;
  if(enable)
  {
    command += 1;
  }
  lcdWrite(COMMAND, command); // Enable/Disable display
}

void displayCmd_SET_COLUMN_ADDRESS(byte column)
{
  byte lsb = column & B00001111;
  byte msb = (column & B11110000) >> 4;
  lcdWrite(COMMAND, (msb | B00010000));
  lcdWrite(COMMAND, (lsb | B00000000));
 
}

void displayCmd_SET_PAGE_ADDRESS(byte page)
{
  page = page & B00011111;
  byte command = page | B01100000;
  lcdWrite(COMMAND, command);
}

void displayCmd_SET_INVERSE_DISPLAY(boolean enable)
{
  /*
  Display the inverse of stored data, this has no effect on the data being stored
  */
  byte command = B10100110;
  if(enable)
  {
    command += 1;
  }
  lcdWrite(COMMAND, command); // Inverse/Regular display
}

void displayCmd_SET_LCD_GRAY_SHADE()
{
  /*
  Program gray scale register (LC[6:5]). This register controls the voltage RMS separation between the two gray shade levels (data “01” and data “10”)
  */
  lcdWrite(COMMAND, B11010011); // 40% gray shade levels
}







void lcdWrite(byte mode, byte data)
{
  //Serial.println("CS Low");
  digitalWrite(csPin, LOW);  // Selects the chip
  digitalWrite(cdPin, mode); // Selects wether data or command is being sent
  //delayMicroseconds(5);
 
  SPI.transfer(data);        // 1byte of data/command
  //delay(2000);
  //Serial.println("CS High");
  digitalWrite(csPin,HIGH);  // Deselects the chip
  //digitalWrite(cdPin, ~mode);
  //delayMicroseconds(5);
}

void resetLcd()
{
  // This function is used to reset the display
  digitalWrite(rstPin, LOW);  // Enabling the reset
  delay(5);                   // 5ms delay just to make sure
  digitalWrite(rstPin, HIGH); // Disabling the reset
  delay(20);                  // The display needs some time to reset, this prevents other code being executed too early
}
44  Using Arduino / Displays / Re: EA DOGXL160-W on Arduino Uno Rev 3 need Tutorial/Help on: August 31, 2012, 03:17:42 pm
I don't use any lib, wanted to write my own. I use the SPI library @1MHz

Here's the code (no optimization yet, wanted to get it to work first smiley-wink )

void displayCmd_SET_COLUMN_ADDRESS(byte column)
{
  byte lsb = column & B00001111;
  byte msb = (column & B11110000) >> 4;
  lcdWrite(COMMAND, (msb | B00010000));
  lcdWrite(COMMAND, (lsb | B00000000));
 
}

void displayCmd_SET_PAGE_ADDRESS(byte page)
{
  page = page & B00011111;
  byte command = page | B01100000;
  lcdWrite(COMMAND, command);
}

void lcdWrite(byte mode, byte data)
{
  digitalWrite(csPin, LOW);  // Selects the chip
  digitalWrite(cdPin, mode); // Selects wether data or command is being sent
  SPI.transfer(data);        // 1byte of data/command
  digitalWrite(csPin,HIGH);  // Deselects the chip
}

Grüße
45  Using Arduino / Displays / Re: EA DOGXL160-W on Arduino Uno Rev 3 need Tutorial/Help on: August 31, 2012, 03:01:44 pm
Hi,

I connected the EA DOGXL160-W but i can't seem to be able to write data. Commands work just fine, but data isn't being displayed.
My setup for data is something like:

displayCmd_SET_PAGE_ADDRESS(page);
displayCmd_SET_COLUMN_ADDRESS(column);
lcdWrite(DATA, myData); // myData is a byte

For testing purposes, I write all my data that way without using the auto-incrementing addresses(but they are set).
The only thing i see if the display should show myData are some weired random pixels that seem to be some state the buffers are in(always the same pixels).

Can anybody help?
Pages: 1 2 [3]