LCD 16x1 for error codes

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Freaks,

I bought myself this LCD: click me

It's supposed to show error codes and I'd like to play with a LCD and my new scope :) I use a tiny2313 to controll it, which will receive commands from the "to be debugged" controller (application). Now I wonder what to use for communication. UART is comfortable but seldom unused. Since I'm always short on I/O pins I'd like to use only one or two pins of the application µC. My best plan so far is to use a INT input of the tiny2313 and bit bang it with a self made protocol. Something like:

Start signal - "instruction or data?" Bit - payload - checksum

Since that uses a timer on both sides and a lot of programming (sending and receiving routines) I wonder if there are better solutions? (I'll read the USI part in the datasheet tomorrow ... only worked with UART and a self made wired-OR communication so far)

Page 9 of the datasheet shows the pin connections. What do I need to connect to Pin3 V0? Do I need a resistor at pin15 or 16?

PS: maybe I can realize the timing on the application side with a couple of nops

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use an SPI or I2C like interface. Just clock and data. Something that is not sensitive to timing. Either can be bitbanged easily.

Vo is the LCD bias voltage, usually you connect a pot from VCC and GND and the wiper to this input; you set the display contrast with this.

Pin 15 and 16 are for the backlight, if it has it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

does the size matter? I got a couple of 10k pots here.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

10K will be fine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

cool, thanks for your help :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok ... although I read lot of stuff like this, this and that and some more I can't get it going. All it shows are black squares.

The link for the datasheet can be found at the top of my first post. I've read it intensly and just can't find a flaw in my setup.

It's powerd over the ISP from my STK500. The 7805 and the crystal are not mounted. All connections are tripple checked. The pot for brightness works fine.

Here is my schematic:

and here is my minimum code:

//************************************************************************************
//                                includes and subroutines
//************************************************************************************
#include 
#include  
#include "my_bit.h"
#include "my_types.h"

//************************************************************************************
//                                      macros
//************************************************************************************
#define getBit(p,m) ((p) & (m))
#define setBit(p,m) ((p) |= (m))
#define clrBit(p,m) ((p) &= ~(m))
#define flipBit(p,m) ((p) ^= (m))
#define writeBit(c,p,m) (c ? bit_set(p,m) : bit_clear(p,m))
#define Bit(x) (0x01 << (x))
#define LONGBIT(x) ((unsigned long)0x00000001 << (x)) 

//************************************************************************************
//                      global variables, constants and definitions
//************************************************************************************
    #define some_time 50000//nop-wait time
    #define LCD PORTD
    #define DATA PORTB
    #define RS 16
    #define RW 32
    #define E  64
//************************************************************************************
//                                  subroutines
//************************************************************************************
void init (void)
{
//[PortB]
    DDRB  = 0b11111111; //PortB out
    PORTB = 0;
//[PortD]
    DDRD  = 0b01110000; 
    PORTD = 0;
//[Interrupts]

    //sei();
}
//************************************************************************************
void NopWait(uLong nops)
{
    //cli();
    volatile uLong i = nops; 
    for (i; i>0; i--)
    {
        asm volatile("NOP");
    }
    //sei();
}
//************************************************************************************
void LCD_sendcommand(uInt cmd)
{
    NopWait(some_time);     // 50 ms
    clrBit(LCD, RS);
    clrBit(LCD, RW);

    NopWait(some_time);
    setBit(LCD, E);

    NopWait(some_time);
    DATA = cmd;   

    NopWait(some_time);
    clrBit(LCD, E); 

    NopWait(some_time);
    
}
//************************************************************************************
void LCD_init()
{
    LCD_sendcommand(0x30);    
    LCD_sendcommand(0x30);  //three times b/c of datasheet
    LCD_sendcommand(0x30);

    LCD_sendcommand(0x30);  //set to 8bit, 1 line, 5x7 dots
    LCD_sendcommand(0x08);  //display off
    LCD_sendcommand(0x01);  //display clear
    LCD_sendcommand(0x06);  //increase cursor, no shifting
}
//************************************************************************************
//                                     interrups
//************************************************************************************
ISR(TIMER1_OVF_vect)
{ 
    

}
//************************************************************************************
//                                     main
//************************************************************************************
int main()
{
    init();
    LCD_init();

     while(1)
    {
   
    }
} 
/*
    License/Warranty:
    This software is not suitable for any purpose whatsoever.
    The moment it is activated, it can destroy any machine
    it is run on and kill all life in a one kilometer radius or more.
    Have a nice day! 
*/

The macros work fine. Is it OK to always use ~50ms for the delays? Is there a flaw in my schematic I can't find?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You set the display off like your code says.

You might try changing that so the display is turned on, preferably with the blinking cursors to see that it actually works.

You should also try writing some data on screen so you see if it works.

If you only write to the display, and do the display writing with delays, you don't actually need the R/W line, I've usually tied it to GND to save IO pins.

Also your delays are so long that you will want to make it shorter or use the BUSY bit to actually read when the display is ready.

So change that 0x08 to 0x0F or something and it should blink.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wheee, it works!

I had the contrast so high that all squares was black! thanks for the blinking tip, that made me recognize my mistake :):):)