Sign in

username:

password:



Not a member?

Search Comp.Arch.Embedded



Search tips

embedded by Keywords

68HC11 | 68HC12 | 8051 | 8052 | ARM | ARM7 | Asic | AT91 | AT91RM9200 | Atmel | AVR | AVRStudio | Bootloader | CFP | CompactFlash | Cygnal | Cypress | Dataflash | DSP | eCos | EEPROM | Embedded Linux | Emulator | Endian | Ethernet | Firewire | FPGA | Freescale | GCC | GNUARM | GSM | H8 | HDLC | I2C | Infineon | Interrupts | Java | JTAG | LCD | LED | LPC2000 | MCU | Microchip | MMC | MPLAB | MSP430 | PC104 | PCB | PCI | PCMCIA | PowerPC | Rabbit | RS232 | RS485 | RTOS | SBC | SDRAM | Sensor | SPI | STK500 | UART | UML | USART | USB | Verilog | VHDL | VxWorks | Xilinx

Ads

Discussion Groups

Discussion Groups | Comp.Arch.Embedded | Displaying real-time data through LCD

There are 4 messages in this thread.

You are currently looking at messages 0 to 4.

Displaying real-time data through LCD - sani_figs - 23:44 29-07-08

Hi,

As of now, I can display text through a 4x20 LCD ("Hello World!").
However, I need to display real-time data which is computed every 2secs.

In the sample codes that I have seen (and have used), the character is
sent one at a time:

          lcd_puts(const char *s){
                while(*s)
                lcd_write(*s++);
          }

and the input is a predefined string:

         in main function:
                lcd_puts("Hello World!");

My question is, how can I modify my code to display real-time data (int or
float)? 

I'm thinking of something like the printf function which will be called
everytime data needs to be displayed:
 
          printf("Reading: %d",data);

But how can I implement this if the data is a predefined string and if the
data is sent one char at a time?

Thank you!




Re: Displaying real-time data through LCD - Neil - 01:51 30-07-08

sani_figs wrote:
> Hi,
> 
> As of now, I can display text through a 4x20 LCD ("Hello World!").
> However, I need to display real-time data which is computed every 2secs.
> 
> In the sample codes that I have seen (and have used), the character is
> sent one at a time:
> 
>           lcd_puts(const char *s){
>                 while(*s)
>                 lcd_write(*s++);
>           }
> 
> and the input is a predefined string:
> 
>          in main function:
>                 lcd_puts("Hello World!");
> 
> My question is, how can I modify my code to display real-time data (int or
> float)? 
> 
> I'm thinking of something like the printf function which will be called
> everytime data needs to be displayed:
>  
>           printf("Reading: %d",data);
> 
> But how can I implement this if the data is a predefined string and if the
> data is sent one char at a time?
> 
> Thank you!
> 
sprintf();  itoa();  math to break the number down to characters.

Re: Displaying real-time data through LCD - Meindert Sprang - 03:21 30-07-08

"sani_figs" <a...@yahoo.com> wrote in message
news:_s...@giganews.com...
> Hi,
>
> As of now, I can display text through a 4x20 LCD ("Hello World!").
> However, I need to display real-time data which is computed every 2secs.

<snip>

> I'm thinking of something like the printf function which will be called
> everytime data needs to be displayed:
>
>           printf("Reading: %d",data);
>
> But how can I implement this if the data is a predefined string and if the
> data is sent one char at a time?

Either use sprintf() to create a string which you can send character by
character or check your compiler manuals how to implement your own
putchar(). Most compilers allow you to create your own putchar() function,
tailored to your hardware. All other standard C functions that print
something, like puts(), printf() etc., will eventually call putchar().

Meindert



Re: Displaying real-time data through LCD - Paul Carpenter - 05:14 30-07-08

In article <_s...@giganews.com>, 
a...@yahoo.com says...
> Hi,
> 
> As of now, I can display text through a 4x20 LCD ("Hello World!").
> However, I need to display real-time data which is computed every 2secs.
> 
> In the sample codes that I have seen (and have used), the character is
> sent one at a time:
> 
>           lcd_puts(const char *s){
>                 while(*s)
>                 lcd_write(*s++);

Hopefully lcd_write has all the correct handling for the delays
for writing to the lcd, and more importantly a TIMEOUT and error 
return. So that if the LCD fails or its connector 'falls off'
the code does not get stuck there!

If you have a spare timer consider using a timer interupt to
o/p the next character from a buffer to the display.
           }
> and the input is a predefined string:
> 
>          in main function:
>                 lcd_puts("Hello World!");
> 
> My question is, how can I modify my code to display real-time data (int or
> float)? 

Do you need full float capability for the data that will be displayed?
Do you really need on a small display to show 6 or more decimal places?

Are the figures you are going to display going to have a maximum number
of digits (integer and/or fraction part)? If so consider rolling your
own integer conversion and doing a fixed point over function to display
two effective 'integers'.
 
> I'm thinking of something like the printf function which will be called
> everytime data needs to be displayed:
>  
>           printf("Reading: %d",data);

Know the positions of your data numbers and exactly their min/max sizes.
Always get data to print on certain boundaries.
 
> But how can I implement this if the data is a predefined string and if the
> data is sent one char at a time?

Others have said how you can create your own put_char() and using 
functions like sprintf and itoa as well.

Do some tests for your library and target, as I remember you saying
you are using some form of Zilog mcu, do you have enough Flash/RAM
space to use printf/sprintf functions?

printf/sprintf functions and associated functions are large users
of memory on most compliers as they have the ability to display
a lot more formats than you will require on a 4 x 20 LCD.

In some cases you will not have room on the display anyway.

Look at a HD44780 data sheet also for how to address the display
RAM so you ONLY update the data portion of a line with the
new numbers, not rewrite the whole line or display.

If you hunt around the GNUH8 site mentioned below there is a 'C'
LCD example (written for a different micro), that may well help.

-- 
Paul Carpenter          | p...@pcserviceselectronics.co.uk
<http://www.pcserviceselectronics.co.uk/>;    PC Services
<http://www.pcserviceselectronics.co.uk/fonts/>; Timing Diagram Font
<http://www.gnuh8.org.uk/>;  GNU H8 - compiler & Renesas H8/H8S/H8 Tiny
<http://www.badweb.org.uk/>; For those web sites you hate