lookup table for LCD driving

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

Hi, I want to use an AVR to recieve data from an ADC, and then drive an LCD to display this data. I was told the best way to do this is to use a look-up table, but I have no idea what this is or how to use it.

I couldn't find anything online, so I was hoping someone could give me a breif explanation, or point me to an introductory text on it.

Thanks alot

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

First up, what LCD? As for using a look up table, it depends on what you want to look up or translate. You also don't mention what language you intend to use. Just like Google, if you ask a more precise question, you'll most likely get a more precise answer. So tells us what LCd, what you intend to measure with the ADC and whether you intend to use the AVR's internal ADC. It could be you want to measure a thermistor and need to linearise the value in order to get Celcius. In this instance a lookup table would be the usual solution. If this is the case you could search on "thermistor avr table" in which case you'll get more meaningful hits. This issue has also been discussed a lot on this forum.

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

Kartman wrote:
First up, what LCD? As for using a look up table, it depends on what you want to look up or translate. You also don't mention what language you intend to use. Just like Google, if you ask a more precise question, you'll most likely get a more precise answer. So tells us what LCd, what you intend to measure with the ADC and whether you intend to use the AVR's internal ADC. It could be you want to measure a thermistor and need to linearise the value in order to get Celcius. In this instance a lookup table would be the usual solution. If this is the case you could search on "thermistor avr table" in which case you'll get more meaningful hits. This issue has also been discussed a lot on this forum.

I'm intending to drive a HD44780 based two line LCD module, as part of a SMPS I'm designing. The first line will display voltage, the second, current limit. The voltage reading will come from an external 12bit ADC, which will probably be transmitted serially to the USART.

Ignoring the current reading for now, I need a look-up table for the voltage reading. However I have no idea what this entails. I thought it was something to do with storing ASCII data for a given reading at successive locations in memory (2^12 readings), and then addressing them with the ADC output?

I assumed there would be a generic explanation available for "what is a lookup table?"...surely though a lookup table may have different applications, there is some kind of basic explanation for what it is and does? Looking on google, the problem is that all the hits are too specific, and none specific to what I'm doing.

Thanks for your reply, apologies for repeating this question if it has been asked.

Foget to mention, I want to write this in assembler

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

A look up table in this instance would be a 'brute force' solution.
Since the voltage measurement is linear, you can scale the ADC result by using multiplies/divides. Conversion into the ascii representation used by the LCD is a standard algorithm and interfacing to the LCD has been done to death.

Your perception of the lookup table is correct - but consider the amount of flash memory - 2^12 (4096) times 4 characters gives you 16k of flash - just for the lookup table. Using code to translate would only amount to a few 100 bytes of flash. So, I'd forget about using a lookup table in this application.

A 12bit aDC will most likely not use the usart for interface - more like SPI or a few port pins.

Most of the code you'll need is available both here and on the web. Have a look at the projects section for a project that is similar to what you're doing.

I'd also suggest you look at using 'C' to write the code. It will most likely save a lot of time. For example, converting the binary value to ascii for display on the LCD is a standard function in C.