Let's Make Robots!

Help with Picaxe and serial LCD

Ok Picaxe Basic Gurus... I think I need some code snippits...

My new serial enabled LCD just arrived and I can't seem to get it up and running. I am using what I think is the standard picaxe basic commands but I am only getting white blocks, x's and some other random symbols. To be honest, I am confused with a lot of the serial commands in general, the whole ASCII thing and anything written as 0x7C or 0x14 or whatever.

Here is the display.

Here is the PDF

For instance, I first need to change the baud rate. The instructions tell me to send 124 followed by "<control>k" . Now it seems the picaxe standard is 2400 baud. What is the actual command? Do I send the "change baud" command at 2400 baud when the display is at a default of 9600? and then the command number is 124 and also 0x7C so what do I do?

In my mind (and to show I have no idea what I am doing) here are all the options I can see:

serout 7,N2400, (124, "<control>K")

-or-

serout 7,N2400,(124)

pause 5

serout 7,N2400,("<control>K")

-or-

serout 7,N2400,($7c, "<control>k")

I could go on and on with my guessing but nothing is working.

In general, I assume my major problem is with the baud rate, I hope and assume that after I get that fixed I should be able to return to the standard serout 7,N2400,("Hello") sorta commands.

Would anyone be so kind as to give me a crash course on what you think I should know?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
I like green things in interesting shapes...

They are green and come in VERY interesting shapes!!!!!

Orion_slave_girls.jpg

It is a 40x1 by the way...

...And I did check the manual, the Good manual that is:

Capacitor 3:24 states:

And the Lord saw the Frits, and the Lord saw that the Frits was right, and it was Good. Thou shall check thy baud rates as one would check thy polarity of thy servo connectors.

Who would have known it was there all the time!

 

 

I demand that you declare med god on your LED! In capitals! :D
... for The Fritsl is a wrathful deity!

Wow, you guys are great...

I did try to change my freq. to 9600 with better but not complete results. When using serout 7,N9600_8,("hello") on my diplay I got an "H". However, as I usally do in these situations, I decided to check everything step by step which is when I found I am using a 16hz resonator so the "_8" is probably throwing a wrench (spanner) into the works. According to the manual,

On devices with fixed external resonators this command cannot be used - the
value of the external resonator must be changed to alter the clock frequency. 

My assumption was that the external resonator was used for reference -i.e. the picaxe would see the 16hz resonator and just devide (or mulitply) by 2 to get the 8hz I was asking for. This, I guess, is not the case. I have an extra 8hz which I think I will swap out and/or I will try N9600_16 along with the setfreq.

And I can't help think Frits is right about the 124 command. It probably doesn't matter what form the decimal "124" is sent I think I just need to send it at the right baud rate. --I still am a little concerned with the lack of start bit, but I am starting to think this just might be a baud rate issue after all. If nothing else, you guys have given me a lot of stuff to try -I'll keep you informed if I get anywhere.

WTF? If I am right? Of course I am right! Comon!

And of course it is a baud-rate-issue! However, you did not say which Picaxe you are using, so how can we help on that? 

You cannot pr default communicate at 9600 through a picaxe.

The baudrate on the  display needs 9600 .. even to change to another rate.

So - you'll need to change the Picaxe's speed to 8 or 16 mhz's, rtfm, the serout command.

Speed can be changed by SW: rtfm: setfreq

- or HW; http://letsmakerobots.com/node/2890

Finaly; You may want to use T instead of N on the serout command.

rtfm = read the fine (picaxe) manual ;)

I completely overlooked that part of the manual. Just saw a bunch of speeds available and assumed too much. The highest speed available on a 28X1 at 4 MHz is 2400. For lesser Picaxes it's 2400. That probably explains the 2400 default for all picaxes. You need to change the Picaxe's frequency as Frits describes for anything above that.

Once you get you Picaxe in N9600_8 or T9600_8 mode, you have to choose whether to keep working in "overclocked" mode, or to tell the serlcd to accept input at a lower speed. Then optionally switch the picaxe back to good old 4 MHz.

I've been looking at that funny "<control>k" business. That would probably work on computers that actually have a keyboard that also has a "Ctrl" key on it. But your Picaxe does not. And your program editor eats up any <control>k combo for itself. I checked on a more flexible system (linux) where the combo is usually printed as ^K. The combos ^K, ^L, ^M, ^N, ^O and ^P turn out to be these characters from the ascii table:

Oct   Dec   Hex   Char
-------------------------------------------
013   11    0B    VT  '\v' (vertical tab) 
014   12    0C    FF  '\f' (form feed)    
015   13    0D    CR  '\r' (carriage ret) 
016   14    0E    SO  (shift out)         
017   15    0F    SI  (shift in)          
020   16    10    DLE (data link escape)   

So, in order to write the two bytes (124 decimal) and (^K) out the serial backdoor, you would program:

serout 7, N9600_8, (124,11)
   or
serout 7, T9600_8, (124,11)

 

Methinks...
8ik

Erh, when the manual refers to "control / command charaters", it is refering to "254" & "124" :) Those can indeed be sendt from the Picaxe!

rtfm Picaxe manual on the serial output, all the sending in

"a"

a

#a

%a

- stuff :) And so send 124 or 0x7C or 254 or 0xFE as you want, that will be the "control character".See the LCD-manual for more on which for what.

Summary; Any letter sendt in the right baud-rate etc will be printed on the display. Only, there are 2 characters that can be sendt that does not print (among many others) - and sending one of these will make the LCD-module listen to what comes after it, and take that as a command.

You can also send other commands, I am sure, such as "new line", which I think is 110, 113 is top or whatever, cant remember it, but it is all very standard ASCII-language :) And you can send anything as the "letter", or as the #ASCII etc.