PDA

View Full Version : LCD Display Formatting



jimtreg
- 9th October 2015, 08:01
Hi,

I am a newbie to PBP3.0 and have studied the LCDOUT statement in the reference manual for some time without much enlightenment. (Examples in very short supply). Anyway, what I believe I want to do is to measure a voltage level with a ADC input, convert the output of the A/D to an actual voltage by scaling, store the result in memory, and then later read memory and insert this data into an LCDOUT statement as follows

LCDOUT $FE, $80, B0,B1,".",B3,"VOLTS"

Is this form of formatting OK?

HenrikOlsson
- 9th October 2015, 09:51
Hi,
That depends on HOW you scale the values and what's actually stored in B0, B1 and B2. As written the LCDOUT statement will send whatever is stored in B0 to the LCD meaning that if the B0 holds the value 65 you'll get the letter 'A' on the screen because the ASCII code for 'A' is 65. So, if you have ALREADY converted the value to ASCII and stored the first digit in B0 and the second in B1 then what you have is correct.

What I suspect you want is something like


Voltage VAR WORD
Voltage = ADResult */ 125 'Convert 0-1023 to 0-500 (roughly)
LCDOUT $FE, $80, DEC Voltage / 100, "." DEC Voltage // 100


/Henrik.

grahamg
- 9th October 2015, 09:52
Yes your formatting looks good.

jimtreg
- 9th October 2015, 10:36
Hi Henrick,

Yep, goes without saying that (a) the data stored would be in ASCII format and (b) I don't do stupid things like using B0,B1, etc instead of labels :-(. Geez, I am getting old................ As well as getting old, I'm getting lazy. Thank God for much early programming experience because the PBP manual ain't exactly forth coming :-)

Thanks for coming back

best regards
Jim


Hi,
That depends on HOW you scale the values and what's actually stored in B0, B1 and B2. As written the LCDOUT statement will send whatever is stored in B0 to the LCD meaning that if the B0 holds the value 65 you'll get the letter 'A' on the screen because the ASCII code for 'A' is 65. So, if you have ALREADY converted the value to ASCII and stored the first digit in B0 and the second in B1 then what you have is correct.

What I suspect you want is something like


Voltage VAR WORD
Voltage = ADResult */ 125 'Convert 0-1023 to 0-500 (roughly)
LCDOUT $FE, $80, DEC Voltage / 100, "." DEC Voltage // 100


/Henrik.

Heckler
- 9th October 2015, 15:40
Have you set up the circuit and tested any of your code?

If not then that is what I would do...

noting like the instant feedback of seeing the minor changes to your code and the effect on what is displayed on the LCD.