Picaxe to serial LCD via firmware chip

jst3712

Member
Hi, I'm not all that experienced with Picaxe but have learnt the basics, and now tackling with LCD's. I am programming my Picaxe to transmit messages to my serial LCD via a *firmware chip* (i.e. using 1 single Picaxe output pin). I am very new to this. I have tackled how to send a message to the LCD using firmware commands, but there's 2 things I am stuck on....
1) I have quite a few different messages to send to the LCD depending on the various inputs. Not a lot of memory to play with, a lot of the code is repetition (like clear line command, pauses, etc) and I thought about using variables, but I find the Picaxe manual explaining 'variables' hard to understand. How can I set a number of variables to store some text. Hope I'm clear enough here. e.g. lcdmsg1 = "This is line 1 for the LCD".
2) This question is more LCD Firmware related: How can I make the top line scroll but keep the bottom line still? (or vice versa). I worked out how to scroll text but it scrolls both lines at the same time! :confused:
 

Technical

Technical Support
Staff member
understand. How can I set a number of variables to store some text. Hope I'm clear enough here. e.g. lcdmsg1 = "This is line 1 for the LCD".
You can't - each variable can only store 1 'letter' (ascii character). However you could preload the eeprom data memory (eeprom command) and then read back strings using the read command within a loop. Seach in the forum for some examples.

You can 'fake' scrolling by re-drawing the top line only, moving a character each time ie you always send 16 new characters, but the position of the desired text within the 16 characters changes.
 

jst3712

Member
Ok thanks. About the scrolling, I understand what you are saying, but I still need bit of help! (The EEPROM part of my question I will look more into it).

Here is the code I am currently using. Perhaps something is in the wrong order? :rolleyes: I have been playing around with it for way too long. Both lines are scrolling but only top line should be.

Code:
serout 6,T2400,(254,1)   'clear LCD screen
pause 100
serout 6,T2400,(254,192,"This is line 2 LCD long text")   'Bottom line (to be steady)
pause 2000
  for b3 = 0 to 16
    serout 6,T2400,(254,24)   'scroll right to left
    serout 6,T2400,(254,128,"This is line 1 LCD long text")   'Top line (to scroll)
    pause 220
  next b3
pause 2000
goto home   'when finished, go to Home
 

hippy

Technical Support
Staff member
Yes, the Scroll command will scroll all lines of your display. You have two options -

1) Use the Scroll command then rewrite the text which shouldn't have been scrolled. This is probably easiest for a PICAXE.

2) Do not use any scrolling commands but write the text starting from the character you want. This is easier if the text messages are held in the Eeprom Data aea.

You are nearly doing (1), but you first write the bottom line so it then scrolls while always re-writing the top line after the scroll so it hasn't scrolled.

Write the top line first, issue the scroll command, then rewrite the bottom line and you should be okay.
 

Technical

Technical Support
Staff member
Please look at the advanced LCD examples in part 3 of the manual. This explains how the 254,24 command works - this is where your confusion is. It actually moves the whole display 'window'

Imagine 2 lines of 40 characters written on a piece of paper. Then cut a piece of card with a window in it, so that only 2 lines x 16 characters can be seen through the card window. Now pull the piece of paper under the card - the text will scroll but you can only see 16 characters at a time. That is how the LCD works - the 'scroll' command moves the paper one place left or right. Therefore using this command you can never scroll just one line!

To add to Hippys comments you will need to re-write the second line at address, 192, then 193, then 194 etc, as the whole display 'window' has moved each time (ie the first charcter in the card window has moved).
 
Last edited:

kevrus

New Member
If you have a lot of repetion in your code, then possibly you could optimise with subroutines.

Repetitive messages can be stored in eeprom as advised by technical...I put this at the start of the program i.e.

eeprom 0, ("my message here!")

if using a 16x2 display and the first eeprom address started at eeprom 0, the next eeprom address for the next message should start at eeprom 16 i.e.

eeprom 16, (" next text line ")
and so on until you run out of eeprom space.
to recall eeprom messages, I load the eeprom addresses into a variable and then serout the contents of that variable i.e.

for b0=0 to 16
readb0, b1
serout 7,t2400,(b1)
next b0

hope this helps
 

jst3712

Member
hi hippy, yeah I think I already tried that. Are you able to change the order for me (ammend it to the way you think it should be) and repost it? I would really appreciate that. Thanks.


Yes, the Scroll command will scroll all lines of your display. You have two options -

1) Use the Scroll command then rewrite the text which shouldn't have been scrolled. This is probably easiest for a PICAXE.

2) Do not use any scrolling commands but write the text starting from the character you want. This is easier if the text messages are held in the Eeprom Data aea.

You are nearly doing (1), but you first write the bottom line so it then scrolls while always re-writing the top line after the scroll so it hasn't scrolled.

Write the top line first, issue the scroll command, then rewrite the bottom line and you should be okay.
 

jst3712

Member
Thanks kevrus. Not quite what I was asking (maybe I wasn't explaining myself properly) but at least I learnt something from your response! Now I know how to store up to 256 bytes worth of LCD messages into the eeprom! That will definately come in handy for my project because it will save some "memory" for other commands. Thanks again.


If you have a lot of repetion in your code, then possibly you could optimise with subroutines.

Repetitive messages can be stored in eeprom as advised by technical...I put this at the start of the program i.e.

eeprom 0, ("my message here!")

if using a 16x2 display and the first eeprom address started at eeprom 0, the next eeprom address for the next message should start at eeprom 16 i.e.

eeprom 16, (" next text line ")
and so on until you run out of eeprom space.
to recall eeprom messages, I load the eeprom addresses into a variable and then serout the contents of that variable i.e.

for b0=0 to 16
readb0, b1
serout 7,t2400,(b1)
next b0

hope this helps
 

jst3712

Member
ok ta. I played around with it more, still can't figure it out :(
I think I might just leave it for now... it's not all that important at this stage... I can always come back to this. Just didn't realize how tricky it is to do (with minimal code, that is). But thanks!


Please look at the advanced LCD examples in part 3 of the manual. This explains how the 254,24 command works - this is where your confusion is. It actually moves the whole display 'window'

Imagine 2 lines of 40 characters written on a piece of paper. Then cut a piece of card with a window in it, so that only 2 lines x 16 characters can be seen through the card window. Now pull the piece of paper under the card - the text will scroll but you can only see 16 characters at a time. That is how the LCD works - the 'scroll' command moves the paper one place left or right. Therefore using this command you can never scroll just one line!

To add to Hippys comments you will need to re-write the second line at address, 192, then 193, then 194 etc, as the whole display 'window' has moved each time (ie the first charcter in the card window has moved).
 
Top