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?

You cannot pr default

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; https://www.robotshop.com/letsmakerobots/node/2890

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

rtfm = read the fine (picaxe) manual :wink:

Overlooked that

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

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

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

"a"

a

#a

%a

- stuff :slight_smile: 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 :slight_smile: And you can send anything as the "letter", or as the #ASCII etc.

The techy formally known as Fritsl!

OMG! Fritsl totally kicks my butt me at interpreting these technical manuals! Respect!

And he nails it. I think. That sneaky word "<control>" in the serlcd manual refers back to the 124. Not to the control key on the keyboard.

Now how about linking the Sparkfun Manual Writers Guild to this page while referring to this little quote from their pdf:

"Please report types, inaccuracies, and especially unclear explanation to us at [email protected]. Suggestion for improvements are welcome and greatly valued."

Of course this means no more artsy rants from you, Frits!

8 :wink:

Rik

As long as it is green and
As long as it is green and has an interesting shape, it can be anything as far as I’m concerned. That goes for anything.

Noticed something!

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

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?

I will never question the Frits again…

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
I demand that you declare med god on your LED! In capitals! :smiley:

Beware …
… for The Fritsl is a wrathful deity!

I like green things
I like green things in interesting shapes…

Yellow CardMike

Yellow Card

Mike

Ok guys heres what I got.

First, to get the 9600 baud, I am using a 8hz external resonator with a setfreq em8.

If I simply use this, I get one capital “H” with 4 blank spaces after it:

setfreq em8

main:

serout 7,N9600_8,(“hello”)

pause 10

end

I have tried T9600_8 --no go

I have tried to send a number instead of letters -no go

I still can’t figure out the “<control>k” crap, but I can’t even seem to send a simple 124 without the display changing --It is my belief that sending 124 should not affect the screen at all unless it is followed by a command. I.e. it is just a heads-up that a command is coming.

Here is what SparkFun said:

The serial LCDs use 8,N,1 serial as stated in the datasheets. You should be able to configure the PICAxe to 8N1 as the PICAxe is just a PIC microcontroller with a BASIC interpreter. Also, there is a backpack on the serial LCDs that contains a PIC, so modifying that code will also work.

I can’t provide support for using PICAxe software as we are only a reseller, but it seems you should be able to configure the PICAxe to output a different serial payload.

 

Have you tried driving the

Have you tried driving the LCD from the serial port on your PC and a terminal emulator? This should be much easier and prove the LCD is OK.

Mike

stumped << 2

I am stumped as to why Sparkfun did not give you any more info or help. Did you give them the same quality (specific) questions we usually to get from you?

And I am stumped as to why “hello” gets translayered into "H ". Did you indeed use a lowercase “h” in your code? I can understand a system that only interprets the first character in a string, but here the system has changed it. And why into the upper case of the input? Would bit #5 not make it through the line? Upper case characters are exactly 2^5=32 places higher in the ascii table. Would a bitwise inversion (hi=lo vv) cause such mayhem?

Would you please check if the Upper Case H is a coincidence? I suggest the following code:

#picaxe40x1
setfreq em8
’ all the ascii codes (decimal) from bang! to tilde~
for b1 = 33 to 126
serout 7,N9600_8,(b1)
debug
pause 3000
next b1

Change the pause to anything that is slow enough for you to read bot the LCD and the debug screen. If these two serial actions even tolerate each other.

Rik

I think your LCD is probably

I think your LCD is probably OK. I say this because you are getting something on the display. At the risk of telling you something that you already know, your problem is most likely the serial link parameters. I had similar symptoms when working with acoustic couplers and teletext based bulletin boards a couple of decades ago.

Can you reset the LCD to the factory settings? It could be that it has interpreted some string of bits as a command to reconfigure itself.

If that doesn’t work, or isn’t possible then try changing the parity flag and the number of stop bits (0, 1 and 2 are usually possible). That’s six different tests.

If you get the same number of characters output as you input (give or take one or two, independent of the number of characters that you sent) then I think the baud rate may be OK - ie one character out => one character in.

A final thing to check may be the serial cable. Are the pins wired correctly? Are all the joints good? Are you getting an intermittent connection? Etc.

I’d still try driving the LCD from a PC, or using the PicAxe to drive a PC. A binary chop of the problem would tell you which end to focus on.

Mike

If this is indeed a translation problem…

If this is indeed a translation problem,

(h to H, e to nothingness), I would love to take a crack at cracking it. That’s why I were so interested in the results of the “33 to 123” test. If we can work out a table of mangled ascii, we might be able to reverse engineer the bug.

if (interested) readon:

Like when all upper case chars are translated to lower case: we’d know something is wrong with bit 5.

Difficulty is that “unprintable characters” are expected to get mangled. The first characters in the table (0 through 31) are such buggers. Number 32 is a space. You already avoided sending 124 (which is aactually a “vertical bar”)because it is supposed to be a control character.

However, the hypothesis is that code gets mangled before the LCD gets a chance to interpret them. So we might as well send the whole bunch and let the chips fall (fail?) were they may. And vice versa: we may be sending a prefectly nice and upstanding piece of ascii like “e” (101) and it might get magled into something really special and weird, like a control char, or a backspace, or an “end of transmission”. Then, all bets are off from that point on. That’s why I suggest to scan a small region of the table at the time, say blocks of 16, until you get back interpretable data. Reset you LCD in between blocks. Reduce blocks’ sizes when it still spews out (mostly) nonsens. Increase when you’re feeling lucky.

Still assuming that we’re chasing that magic retranslation table, with good reason…

else rts:

good luck!

endif

Here you go, rik

Here’s the list, rik. Some of them might be wrong as I had a hard time watching the debug screen and the lcd and writing at the same time. At this point I can write words out such as “HELLO CHRIS!” using this:

setfreq em8

main:
serout 7,N9600_8,(111,117,103,103,97,100,121,111,91,109,89,122)


I guess I could live with doing it this way but I still can’t seem to access the 124 command in any form… i.e. I can’t clear the screen or move the curser. At least at this point we have a full list of what is going in and coming out. --Does this list tell you anything?

 

 

33 o

34 7

35 n

36

37 m

38 6

39 l

40 white square

41 k

42 5

43 j

44 .

45 i

46 4

47 h

48

49 g

50 3

51 f

52

53 e

54 2

55 d

56 white square

57 c

58 1

59 b

60

61 a

62 0

63 '

64 white square

65 _

66 /

67 ^

68

69 ]

70 .

71 a Y with two lines through it

72

73 [

74 -

75 z

76

77 Y

78

79 g

80 X

81 W

82 +

83

84 V

85

86 *

87 T

88

89 S

90 )

91 R

92

93 Q

94 (

95 P

96 white square

97 O

98 '

99 N

100

101 M

102 &

103 L

104 white square

105 K

106 %

107 J

108

109 I

110 $

111 H

112 white square

113 G

114 #

115 F

116

117 E

118 "

119 D

120

121 C

122 !

123 B


 

Interesting!

"cannot move the curser": just get yourself a chair on wheels and kick your table :wink:

I am working on the "translation", if there is one…

8ik