ADC result on LCD

Thread Starter

Shagas

Joined May 13, 2013
804
Well if I just connect the 5V and ground + the backlight then I get a blank LCD .
If I put the contrast up to full then I get 16 white squares (full display)
(btw my LCD works opposite to normal I think . It uses polarization to open up the pixels instead of closing them )
 

Thread Starter

Shagas

Joined May 13, 2013
804
http://www.gme.cz/lcd-displej-mc1601a-red-negativ-p513-142

"NEGATIV"

EDIT:

It's a URL and it scrolls. But I can only see the first 8 chars .
I know the chars 9-16 work because If I make the LCD display some character without cleaning screen then it displays them on all boxes.

Maybe the reason that this happens is because the chars 1-9 are on the first 'ROW" and the 9-16 are on the second 'ROW"
 

donpetru

Joined Nov 14, 2008
185
Maybe the reason that this happens is because the chars 1-9 are on the first 'ROW" and the 9-16 are on the second 'ROW"
Is that possible.

By the way, when you powered LCD with +5 V and ground and contrast to maximum, then show 16 black squares OR only 8 black squares I as shown below?
 

Attachments

Thread Starter

Shagas

Joined May 13, 2013
804
Is that possible.

By the way, when you powered LCD with +5 V and ground and contrast to maximum, then show 16 black squares OR only 8 black squares I as shown below?
LCD with +5v and ground and full contrast I can see all 16 squares.
I don't know if it's possible but it's the only explanation that I can give for it .
Because I know that all the squares work , but if I send a single string then only the first 4 chars are displayed
 

donpetru

Joined Nov 14, 2008
185
Ok, test LCD with the next hex file attached below.
I changed so that the first row 8 characters to be written and on the second row to be written other characters. In reality the two rows to display on a single line.
You should see on the LCD: 1234567890123456. Tell me if you see this.

LATER EDIT:
I modified the initial configuration of LCD to the following form (Atmega32):
RS ---> PORTD2
EN ---> PORTD3
D4 ---> PORTD4
D5 ---> PORTD5
D6 ----> PORTD6
D7 ----> PORTD7
When try test hex below, using the above configuration for connecting LCD.
 

Attachments

Last edited:

Thread Starter

Shagas

Joined May 13, 2013
804
Ok, test LCD with the next hex file attached below.
I changed so that the first row 8 characters to be written and on the second row to be written other characters. In reality the two rows to display on a single line.
You should see on the LCD: 1234567890123456. Tell me if you see this.

LATER EDIT:
I modified the initial configuration of LCD to the following form (Atmega32):
RS ---> PORTD2
EN ---> PORTD3
D4 ---> PORTD4
D5 ---> PORTD5
D6 ----> PORTD6
D7 ----> PORTD7
When try test hex below, using the above configuration for connecting LCD.

Yes I now see 1234567890123456
The whole 16 squares .
What did you do?

EDIT: Oh yeah you explained above , so How Can I use this now
 
Last edited:

donpetru

Joined Nov 14, 2008
185
LCD is good, now tell me what software you want to do? Or what you want to do software? You said you wanted to read ADC value and then ... ? Explain in more detail.
 

Thread Starter

Shagas

Joined May 13, 2013
804
First of all , thanks alot for the help above.
So what row should I write my data so I can display on the 9-16 characters?
****
I know how to program the ADC
I just wanted to do a simple test where I use 10bit ADC to display 0-1023 on the display using a Resistor and LDR. I already did this using some code that I wrote and some LCD code that I copy pasted.

I now downloaded a library from Peter Fleury and configured it with the help of this website
http://maxembedded.com/2011/06/16/lcd-interfacing-with-avr/

Now the LCD works fine but still doesn't display characters 9-16 when I give it a long string.
 

mitko89

Joined Sep 20, 2012
127
I checked the comments of your code... Did you read the documentation of the LCD display you are using? This project has no educational value if you just copy-paste some code.. Preview the attached document and you will understand what are your commands doing...
 

Attachments

Thread Starter

Shagas

Joined May 13, 2013
804
I checked the comments of your code... Did you read the documentation of the LCD display you are using? This project has no educational value if you just copy-paste some code.. Preview the attached document and you will understand what are your commands doing...
I didn't copy paste the code . I studied it and almost fully understood it , then wrote my own code based on it .
Problem is that my code was giving me problems and after being tired of starting at the screen for 3 hours in frustration I decided to copy/paste to see if it works .

!!! where did you find that datasheet?
I could only find the pin configuration . Thanks alot !

EDIT: Also I know what all those commands did but I didn't know the exact values of delay due to lack of datasheet.
Also is there any other way to make a small delay without using ASM 'nop"?
 

mitko89

Joined Sep 20, 2012
127
When you search for a datasheet of a display always search with "programming" suffix in google, don't use just the part number. Most of the displays have standard commands, but delays are different and the only source you can get this information from is such specification. It took me less than a minute to acquire this one. I don't blame you for anything, just read the materials that I and donpetru provided to you and hopefully you will be fine. Good luck!
 

donpetru

Joined Nov 14, 2008
185
If you wish write characters from 9-16, you have to write the data in row 2, first character.
And if you want to make a soft to write on LCD discrete values ​​of ACD from channel 0 atmega 32, you can do it like this (I used mikroC):
Rich (BB code):
// LCD module connections
sbit LCD_RS at PORTD2_bit;
sbit LCD_EN at PORTD3_bit;
sbit LCD_D4 at PORTD4_bit;
sbit LCD_D5 at PORTD5_bit;
sbit LCD_D6 at PORTD6_bit;
sbit LCD_D7 at PORTD7_bit;

sbit LCD_RS_Direction at DDD2_bit;
sbit LCD_EN_Direction at DDD3_bit;
sbit LCD_D4_Direction at DDD4_bit;
sbit LCD_D5_Direction at DDD5_bit;
sbit LCD_D6_Direction at DDD6_bit;
sbit LCD_D7_Direction at DDD7_bit;
// End LCD connection

unsigned int adc, k;
unsigned char ch1, ch2, ch;

void display_LCD() {
ch1 = adc /1000u;               // extract 10.00 U digit
     if (ch1==0)
           {
           LCD_Chr(k,1, 32);   // write white space if ch=0
           }
      else
           {
           LCD_Chr(k,1,48+ch1);
           }
ch2 = (adc / 100u) % 10u;     // extract 01.00 digit
     if (ch2==0 && ch1==0)
           {
           LCD_Chr(k,2, 32);   // write white space if ch=0
           }
      else
           {
           LCD_Chr(k,2,48+ch2);
           }
ch = (adc / 10u) % 10u;      // extract 00.10 digit
   LCD_Chr_CP(48+ch);
ch = adc % 10u;              // extract 00.01 digit
   LCD_Chr_CP(48+ch);
}

void main() {

DDA0_bit = 0;  // ADC input ch0 Atmega32 (PA0)

ADC_Init();    // Init ADC

Lcd_Init();                        // Initialize LCD
Lcd_Cmd(_LCD_CLEAR);               // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off

adc = 0;

do  {
    for(k=1;k<=2;k++)
        {
         adc = ADC_Read(0);    // get ADC value from 0th channel (PA0)
         if(k==2){ adc = 1023 - adc;}
         display_LCD();
         Delay_ms(100);
        }
} while(1);
}
And I attached hex file below.
Good luck.
 

Attachments

Last edited:
Top