Newb LCD Question

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

K I am trying to compile a LCD test program using Peter Fleury lcd library...I am using the dragon rider 500..

When I compile my code I get this error

make: *** No Rule To Make Target *** '../../../../../Program', needed by 'lcd.o'. Stop.

what do i need to do to fix this

Last Edited: Sat. Dec 20, 2008 - 02:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OKay I somehow fixed the problem but have come across another.....I have downloaded the hex but the lcd will not work...here is my code!!!

#include 
#include 
#include 
#include "lcd.h"

#define F_CPU 8000000UL  //8Mhz

int main(void)
{
	DDRA = 0xFF; //Set port B as Output
	PORTA = 0xAA; //Set Port B Low
	lcd_init(LCD_DISP_ON_CURSOR);
	lcd_clrscr();
	lcd_puts("LCD Test Line 1\n");

	while(1)
	{
		PORTA ^= 0xAA; //Toggle half high then low
		PORTA ^= 0x55; //Toggle Other half high then low
		_delay_ms(100);
		
		
	}
}

And yes I changed the port and pin's in the lcd.h file to match how they are connected to the mcu

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

Have you tried adjusting the contrast of the LCD?

Regards,
Steve A.

The Board helps those that help themselves.

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

Quote:
And yes I changed the port and pin's in the lcd.h file to match how they are connected to the mcu
Which is??? ie if you are using portc with a micro that uses that port for JTAG then it needs to be turned off. (This is a common issue)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

OKay I am using an ATmega32 I have tried adjusting the contrast and have the LCD attached to portD here is the part of the lcd.h that I changed!!

#define XTAL 8000000 
#define LCD_PORT         PORTD        /**< port for the LCD lines   */
#define LCD_DATA0_PORT   LCD_PORT     /**< port for 4bit data bit 0 */
#define LCD_DATA1_PORT   LCD_PORT     /**< port for 4bit data bit 1 */
#define LCD_DATA2_PORT   LCD_PORT     /**< port for 4bit data bit 2 */
#define LCD_DATA3_PORT   LCD_PORT     /**< port for 4bit data bit 3 */
#define LCD_DATA0_PIN    5            /**< pin for 4bit data bit 0  */
#define LCD_DATA1_PIN    6            /**< pin for 4bit data bit 1  */
#define LCD_DATA2_PIN    7            /**< pin for 4bit data bit 2  */
#define LCD_DATA3_PIN    8            /**< pin for 4bit data bit 3  */
#define LCD_RS_PORT      LCD_PORT     /**< port for RS line         */
#define LCD_RS_PIN       4            /**< pin  for RS line         */
#define LCD_RW_PORT      LCD_PORT     /**< port for RW line         */
#define LCD_RW_PIN       2            /**< pin  for RW line         */
#define LCD_E_PORT       LCD_PORT     /**< port for Enable line     */
#define LCD_E_PIN        3            /**< pin  for Enable line     */
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I have tried adjusting the contrast

And what were the results? Did you see anything at all?

Regards,
Steve A.

The Board helps those that help themselves.

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

Koshchi wrote:
Quote:
I have tried adjusting the contrast

And what were the results? Did you see anything at all?

Nothing at all!!!

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

Then it is possible that you have not attached the power correctly. When power is correct (and you have not initialized the LCD) the first line will contain dark boxes (or the first and third line if you have a 4 line LCD).

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
#define LCD_DATA3_PIN    8            /**< pin for 4bit data bit 3  */

How do you get bit 8 in an eight bit port ?

Remember that bit positions are 0..7

1. Edit your lcd.h to reflect the correct bits
2. Adjust your contast potentiometer to about 0V

3. Compile and Run the program.

David.

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

david.prentice wrote:

#define LCD_DATA3_PIN    8            /**< pin for 4bit data bit 3  */

How do you get bit 8 in an eight bit port ?

Remember that bit positions are 0..7

1. Edit your lcd.h to reflect the correct bits
2. Adjust your contast potentiometer to about 0V

3. Compile and Run the program.

David.

I got 8 cause in the comments he is asking for pin number not bit...but I will try and see what happens

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

Koshchi wrote:
Then it is possible that you have not attached the power correctly. When power is correct (and you have not initialized the LCD) the first line will contain dark boxes (or the first and third line if you have a 4 line LCD).

I checked with my meter on top of my solder joints on the lcd and I have 5.02V between pins 2 and 1 like the specs sheets tells me I should have....I will check and see how mu voltage I have at pin three for the contrast!!

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

Kuch wrote:
I got 8 cause in the comments he is asking for pin number not bit...but I will try and see what happens

Yeah but - take a look at the default settings:

#define LCD_PORT         PORTA        /**< port for the LCD lines   */
#define LCD_DATA0_PORT   LCD_PORT     /**< port for 4bit data bit 0 */
#define LCD_DATA1_PORT   LCD_PORT     /**< port for 4bit data bit 1 */
#define LCD_DATA2_PORT   LCD_PORT     /**< port for 4bit data bit 2 */
#define LCD_DATA3_PORT   LCD_PORT     /**< port for 4bit data bit 3 */
#define LCD_DATA0_PIN    0            /**< pin for 4bit data bit 0  */
#define LCD_DATA1_PIN    1            /**< pin for 4bit data bit 1  */
#define LCD_DATA2_PIN    2            /**< pin for 4bit data bit 2  */
#define LCD_DATA3_PIN    3            /**< pin for 4bit data bit 3  */
#define LCD_RS_PORT      LCD_PORT     /**< port for RS line         */
#define LCD_RS_PIN       4            /**< pin  for RS line         */
#define LCD_RW_PORT      LCD_PORT     /**< port for RW line         */
#define LCD_RW_PIN       5            /**< pin  for RW line         */
#define LCD_E_PORT       LCD_PORT     /**< port for Enable line     */
#define LCD_E_PIN        6            /**< pin  for Enable line     */

The 8 bits in a port there are numbered from 0 upwards (in fact he only uses 7 of the 8 bits numbered 0..6)

In fact why not just follow his second diagram on this page:

http://homepage.hispeed.ch/peter...

but wiring to PORTC rather than PORTA and then the ONLY line you need to change in lcd.h is the one defining LCD_PORT

Cliff

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

clawson wrote:
Kuch wrote:
I got 8 cause in the comments he is asking for pin number not bit...but I will try and see what happens

Yeah but - take a look at the default settings:

#define LCD_PORT         PORTA        /**< port for the LCD lines   */
#define LCD_DATA0_PORT   LCD_PORT     /**< port for 4bit data bit 0 */
#define LCD_DATA1_PORT   LCD_PORT     /**< port for 4bit data bit 1 */
#define LCD_DATA2_PORT   LCD_PORT     /**< port for 4bit data bit 2 */
#define LCD_DATA3_PORT   LCD_PORT     /**< port for 4bit data bit 3 */
#define LCD_DATA0_PIN    0            /**< pin for 4bit data bit 0  */
#define LCD_DATA1_PIN    1            /**< pin for 4bit data bit 1  */
#define LCD_DATA2_PIN    2            /**< pin for 4bit data bit 2  */
#define LCD_DATA3_PIN    3            /**< pin for 4bit data bit 3  */
#define LCD_RS_PORT      LCD_PORT     /**< port for RS line         */
#define LCD_RS_PIN       4            /**< pin  for RS line         */
#define LCD_RW_PORT      LCD_PORT     /**< port for RW line         */
#define LCD_RW_PIN       5            /**< pin  for RW line         */
#define LCD_E_PORT       LCD_PORT     /**< port for Enable line     */
#define LCD_E_PIN        6            /**< pin  for Enable line     */

The 8 bits in a port there are numbered from 0 upwards (in fact he only uses 7 of the 8 bits numbered 0..6)

In fact why not just follow his second diagram on this page:

http://homepage.hispeed.ch/peter...

but wiring to PORTC rather than PORTA and then the ONLY line you need to change in lcd.h is the one defining LCD_PORT

Cliff

I see I see it works perfectly now....just very dim(and yes I have cranked the resistor for the contrast) and I think that is because I have the sub reglator installed on the dragon rider 500.

Thanks for all the help

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

Okay new Problem with my LCD and I'm sure it's something simple that I have overlooked.

void LCD_Update(void)
{
	
	if (Update == 1)
	{
		sprintf(Dstring1, "Time: %d:%d", HH, MM); //HH= 5 MM= 15
		sprintf(Dstring2, "PH %f.2 ORP %d", PH, ORP); //PH= 8.02 ORP= 400
		lcd_clrscr();
		lcd_puts(Dstring1);
		lcd_gotoxy(0,1);
		lcd_puts(Dstring2);
		Update = 1;
	}
}

and this is what get's display on my 2X16 LCD..

Time: 5PH ?.2 OR
PH ?.2 ORP 400

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

Hi all,
And for what it is worth just to throw in a few other hardware related problems with which I have seen beginners get unstuck.

1. Would you believe that there is one LCD available from a supplier here in Australia where on the
PIN1 = Vcc & PIN2 = GND, whereas 95% of LCD's have PIN1 = GND & PIN2 = VCC.
Result: Instantly dead LCD panel!

(The great thing about standards is you can have so many to chose from. ':D')

2. Some LCD's require a -ve bias on Vo. If you are recycling a LCD, you may not know its requirements.
Result: LCD looks dead, whilst Vo is in range 0V -> VCC

3. The majority of LCD'S with a 2 X 7 connector have been layed out to have the connector on the LCD side of the board. However, most of the time you want the connector on the back of the board. It will solder there quite nicely, but the catch is that all the
odd & even wires are transposed. ':wink:'
Result: Usually an instantly dead LCD panel as PIN1 & PIN2 are transposed (as in 1 above).

4. When using 4 bit interface make sure that D0-D3 are grounded, not doing so tends to give very intermittant initialisation.

4. If you are really unlucky , you could any of the possible permutations of points 1 - 4 above. Throw in a couple of code issues and LCD's can be very trying! ':roll:'

Lee

Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
Riddle me this...How did the serpent move around before the fall?

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

You need to link in the proper printf library in order to get support for floating point. Search the forum here, it has been discussed many times.

Regards,
Steve A.

The Board helps those that help themselves.

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

Quote:

You need to link in the proper printf library in order to get support for floating point.

And prepare for your binary executable to grow quite some bit. (Search the forum here, it has been discussed many times.)

      sprintf(Dstring1, "Time: %d:%d", HH, MM); //HH= 5 MM= 15
      sprintf(Dstring2, "PH %f.2 ORP %d", PH, ORP); //PH= 8.02 ORP= 400 

Quote:

and this is what get's display on my 2X16 LCD..

Time: 5PH ?.2 OR
PH ?.2 ORP 400


Apartf from the "?" in the second line (that's due to floating point support missing), in the first line of output you have gotten a part of the second line of output. It seems to me that you have overlapping, or not large anough, buffers. Could we see a little more code? How is DString1 and DString2 defined?

Lastly:

sprintf(Dstring2, "PH %f.2 ORP %d", PH, ORP); 

I think you want a slightly different format specifier for the float:

sprintf(Dstring2, "PH %.2f ORP %d", PH, ORP); 

The general form for a format tag is

%[flags][width][.precision][length]specifier

always starting with "%" and ending with the "specifier" (like 'u', 'i', 'f' etc).

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

OKay I increased the size of Dstring1 and Dstring2 to [16]
but am still searching on how to get full float support.....my code allready bloated by 2000 bytes just when I add one double declaration and added the sprintf()

so it all works now other then the fact that it's not showing my float number....will keep ready on how to support float numbers, or if someone wants to post it here that works two...

#include 
#include 
#include  
#include 
#include 
#include 
#include "lcd.h"
#include "i2cmaster.h"
#include "uart.h"

[/code]

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

Yes, reading the compiler documentation is a good idea.

Rethinking the calculations and algorithms so you don't need floating point data types and printf support is a better idea.

Stealing Proteus doesn't make you an engineer.

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

I need the Floating point data....I did some reading and I have added the following to my make file

-Wl,-u,vfprintf -lprintf_flt -lm

I have added the libm.a, and libprintf_flt.a and it still isn't working proper....what else am i missing

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

From the fragments I see here I don't think you need floating point. But it's your problem, not mine, so I don't care if you aren't open to advice.

Stealing Proteus doesn't make you an engineer.

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

I fixed the problem and it all works fine now....I was putting -Wl,-u,vfprintf -lprintf_flt, in the wrong spot....I wasn't clicking on linker options before adding that line...thnx all for the help!!

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

ArnoldB wrote:
From the fragments I see here I don't think you need floating point. But it's your problem, not mine, so I don't care if you aren't open to advice.

The reason I need it as a float is because it's industry standard to display PH levels in this format specially since you PH is measured in values between 0 and 15!

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

OK, so how many decimal places of accuracy are you planning to display? If 3 or less then how about multiplying everything internally up by 1,000 (that is 3 decimal places) so now you 00..15 becomes 00000..15000. Say the value you calculate is 11207. Now, just at the last minute, before you write it to the display/output you always insert a decimal point character 3 from the right so that is displayed as "11.207". So now you can display 0.000 to 15.999 and nehind the scenes you are only really using uint16_t's (maybe going to uint32_t's for intermediate calculation results).

This way there's no floating point involved. Your program is 1K..2K smaller and runs about 10,000 times faster.

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

How do you insert a decimal into the number like that....whenever I try I end up replacing one of the numbers with a decimal??

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

This won't work for all occasions (currently only when 5 digits) but it's a start:

char buff[10], copy[10], *p, *q;
uint8_t dp_pos;
uint16_t x = 11207;
itoa(buff, x, 10); // buff[] ="11207"
dp_pos=strlen(buff); // so it starts at 5
p = buff;
q = copy;
while(*p) {
 *q++ = *p++; // keep copying from one to other
 if (3 == dp_pos) {
  *q++ = '.';
 }
 dp_pos--;
}
*q = 0; // make sure string has 0 terminator
//print copy[] to output device

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

clawson wrote:
This won't work for all occasions (currently only when 5 digits) but it's a start:

char buff[10], copy[10], *p, *q;
uint8_t dp_pos;
uint16_t x = 11207;
itoa(buff, x, 10); // buff[] ="11207"
dp_pos=strlen(buff); // so it starts at 5
p = buff;
q = copy;
while(*p) {
 *q++ = *p++; // keep copying from one to other
 if (3 == dp_pos) {
  *q++ = '.';
 }
 dp_pos--;
}
*q = 0; // make sure string has 0 terminator
//print copy[] to output device

When I copy and paste this code I get 2 warnings

../DragonRider500.c:139: warning: passing argument 1 of 'itoa' makes integer from pointer without a cast
../DragonRider500.c:139: warning: passing argument 2 of 'itoa' makes pointer from integer without a cast

and it displays what looks to be a P

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

Hmmm... typecast needed?
edit: On second thought, no. What if you try to pass the value of the variables instead of their address?

itoa((char *)(int)buff,*x, 10);

Where does that get you?

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

I suspect that you have not #included to give the correct prototype for itoa().

Please do not try extraneous casting. Just declare prototypes correctly.

David.

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

Kuch,

I think you misunderstood the motive of my post. I wasn't giving you a piece of working code on a plate. I was simply pointing you in roughly the right direction (first use itoa to stringify the number then do a bit of processing to insert a character (a '.' in this case) in roughly the right place.

I didn't expect the code to actually work I only threw it together as I typed the post in a couple of minutes.

It's time for you to do a bit of thinking yourself and possibly use the idea for your own implementation. In my code is x was 325 (meaning 0.325) then it wouldn't work at all. So you probably want to post process the itoa() output first to 0 pad all numbers out to 5 digits before you start (even when x=0)

Cliff

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

Problem solved

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

Great!! Amazing what one can do in 7 months. :?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly