Jump to content
TCSCOUT

Picaxe & Lcd's

Recommended Posts

It just amazes me how brilliant some people are to be able put it all together and make it work. Whether you learned it on your own or went to school, you still have to have it between the ears to have a finished working product.

Share this post


Link to post
Share on other sites
 
 

I have never done a picaxe to picaxe serial communication, but looks like I'm going to give it a go. Setting everything up to test is a pain, sure could use one of those super bread boards like in the video :lol: .

Share this post


Link to post
Share on other sites
 

Yeah, the serial LCDs run between 20-25 bucks, actually the LED ones were cheaper. I figured it's the only way I would figure one out. Starting from scratch wasn't an option for my brain. Now that I have them going I can see how it works and it makes sense to build them from scratch like you are.

If anyone just wants an easy way to get into using one then it's a very good option to buy the serial ones and you will have it spitting out words in no time. You just have your power contacts and one data line to a picaxe, then you just serout your info to it. What's also nice is you can run the power through the controller chip so you can kill the display to save juice when not in use. You can also send code to turn the display off as well.

 

 

Share this post


Link to post
Share on other sites
 

Sounds Cool KZ3. I'm almost ready to try this. :lol: I better check the smoke detectors first and see if they are working. :o

Share this post


Link to post
Share on other sites
 
 

Got some of it working. I have a 14M sending serial text to the 14M on the LCD. What I put in there comes up on the LCD, but so does some random stuff after that. I have the baud set at 4800 on both. Break time :lol: Getting hungry!

Share this post


Link to post
Share on other sites
 

I'm not sure on your serial code, but it could have a start up message in the program and you are over writing it with your message. I had that same problem once. Longer pause at start to get that message through, clear screen, then send your message. If it's random characters it could be pause time or baud rate. Try increasing you rate once and see what happens. It could also be in your code too. This is why I aged quite a bit doing this.

 

Example of what I run on the 20x2

 

For the 20m2 it doesn't run as fast and doesn't have 9600 baud rate, so I had to use t4800 and run the chip faster or I would get garbage on the screen or nothing at all. For the LED I could run the same baud rate on either chip.

 

 

Initialize_LCD:
pause 5000 ' Warm up
serout B.7,T9600,(254, 128)    'Sets line 1 position 1

pause 20
serout B.7,T9600,("Hello")  ‘line 1 hello 

pause 20

serout B.7,T9600,(254, 192)    'Sets line 2 position 1

pause 20
serout B.7,T9600,("Begin Setup now")  ‘line 2 Begin Setup now

pause 5000

serout B.7,T9600,(254, $01) 'Clear Screen
return

Edited by KZ3

Share this post


Link to post
Share on other sites
 

I have it working pretty well, just have two messages that I can select a high on the one picaxe that sends the information to the second which sends the text to the LCD. I can mount the one picaxe on back of the LCD and that should work well. I'm using 4800 baud and it's a tad slow but not too bad. I'll post up a video if the video turned out OK?

Share this post


Link to post
Share on other sites
 

Pics of how you have this all wired up would be nice for a dummy like me along with some explanation please. I have been looking over some material on this today but it doesn't take much to get me confused. :D

Share this post


Link to post
Share on other sites
 

I'm confused too :blink: I'll put something together showing what I have now. I don't want to know all there is to know about LCD's, just would like to do a few simple things with it. Not sure how it's going to work out?

 

Here is my 2 message test video.

Share this post


Link to post
Share on other sites
 

Looks like you are making good progress there Roger. That is cool. Can't wait til mine arrives to start playing with but I may get frustrated pretty quick.

Share this post


Link to post
Share on other sites
 
Need to build me one of these :lol: !

 

!

I am sure that guy has way to much time on his hands, imagine if he built cameras

Share this post


Link to post
Share on other sites
 
 
Need to build me one of these :lol: !

 

!

I am sure that guy has way to much time on his hands, imagine if he built cameras

 

 

I know what you mean, it's hard enough for me to follow what they have already figured out.

 

Here is the way I wired mine. The other picaxe is wire as any other picaxe, just use the same common ground on both picaxe's (tied together) and then use the serial out output 0 to the input 4 on the one connected to the LCD.

Just 2 wires between the 2 picaxe's needed. Actually one and the power grounds from each going to the power supply ground.

 

post-5460-1329793472_thumb.jpg

 

This the code on the picaxe connected to my LCD, I changed it a little, set the baud in the code instead of having the plug change it, baud set @ 4600. Most of this is not my work, cannot take neither credit or fault for it.

 

'
' NOTE:
'     In order for the LCD to function correctly, the master processor must
'     send serial data in "packets" of nine characters. The first char must
'     be a command that specifies the display location at which printing
'     should begin. The remaining 8 characters can be text or commands.


' *** Constants *********

    symbol baud   = input0            ' used to set Baud (hi=4800/lo=2400)
    symbol hi     = 1                    ' used to set Baud (hi=4800/lo=2400)
    symbol cmd    = 0                    ' used to set up for cmd/txt byte        
    symbol txt    = 1                    ' used to set up for cmd/txt byte
    symbol enable = 1                    ' LCD enable pin = PICAXE output1
    symbol RSin   = outpin0            ' LCD RegSel pin = PICAXE output0


' *** Variables *********

    symbol char  = b10                ' character to be sent to LCD
    symbol index = b11                ' used as counter in For-Next loops
    symbol RSbit = b12                ' used to set  for cmd/txt byte
    symbol temp  = b13                ' used to manipulate char


' *** Directives ********

                                    ' AXE027 Green cable
    #picaxe14M                            ' set compiler mode


' *** Begin Main Program *******************************************************

setfreq m8
gosub Init

do
    'if baud = hi then    
        serin 4,N4800_8,b0,b1,b2,b3,b4,b5,b6,b7,b8
;else        
        'serin 4,N2400_8,b0,b1,b2,b3,b4,b5,b6,b7,b8
;endif

    char = b0
    gosub OutByte

    char = b1
    gosub OutByte

    char = b2
    gosub OutByte

    char = b3
    gosub OutByte

    char = b4
    gosub OutByte

    char = b5
    gosub OutByte

    char = b6
    gosub OutByte

    char = b7
    gosub OutByte

    char = b8
    gosub OutByte
loop


' *** End Main Program - Subroutines Follow ************************************


' *** Init Subroutine ***
Init:
    pins =  0                            ' clear all output lines
    pause 200                            ' pause 200 mS for LCD initialization

    pins = 12                            ' (48/4=12) set to 4-bit operation
    pulsout enable,1                    ' send data
    pause 10                                ' pause 10 mS

    pulsout enable,1                    ' send again
    pulsout enable,1                    ' send again (necessary in 4-bit mode)

    pins =  8                            ' (32/4=8) set to 4-bit operation
    pulsout enable,1                    ' send data.
    pulsout enable,1                    ' send again (necessary in 4-bit mode)

    pins = 32                            ' (128/4=32) set to 2 line operation

    pulsout enable,1                    ' send data

    char = 12                            ' turn off cursor
    gosub OutByte                        ' send instruction to LCD

    return


' *** OutByte Subroutine ***

OutByte:
    if char<32 OR char>127 then
         RSbit = cmd                    ' set up for command byte
    else
         RSbit = txt                    ' set up for text byte
    endif

    temp = char / 4                    ' because we're using DB5...DB2
    temp = temp & %00111100            ' mask for  DB5...DB2
    pins = temp                            ' place high nibble of char onto pins
    RSin = RSbit                        ' RSin = 0 for command or 1 for text
    pulsout enable,1                    ' send data

    temp = char * 4                    ' because we're using DB5...DB2
    temp = temp & %00111100            ' mask for  DB5...DB2
    pins = temp                            ' place low nibble of char onto pins
    RSin = RSbit                        ' RSin = 0 for command or 1 for text
    pulsout enable,1                    ' send data

    return

 

I'll put the sending picaxe code in the next post in case you want to test it. Just jump input 1 and 0 to change the message back and forth.

Share this post


Link to post
Share on other sites
 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×