Serial LCD with 08M

Dave E

Senior Member
I am trying to get a serial LCD (Parallax 2x16 with backlight) to work with a 08M. See below for code. The data sheet for the display is attached. It looks like I need to use a baud mode of N2400 but all I get is trash all over the display. Using T2400, I do get some correct numbers but only two at a time and sometimes in the wrong order. I am new to PICAXE and would appreciate any help.


SETFREQ M4
HIGH 1
SEROUT 1, T2400, (22) 'TURN LCD ON
PAUSE 100
SEROUT 1, T2400, (17, 12) 'TURN BACKLIGHT ON AND CLEAR SCREEN
PAUSE 100

MAIN:
HIGH 2 'TURN LED ON
B3 = 123
SEROUT 1, T2400, (130, " ", 130, #B3) 'SET CURSOR AT POSITION 130, PRINT B3 TO LCD
PAUSE 500
LOW 2 'TURN LED OFF
GOTO MAIN
 

Attachments

nzdragme

New Member
Try a resistor on the serial in line going to either ground or +5v depending on whether you decide to stick with "t" or "n". You will find more info about this in the picaxe manual (the part on interfacing to lcd displays) and also if you search the forum here for "serial lcd". I had a similar problem last week and this is what fixed it. Good luck!
 

Dave E

Senior Member
Thanks for the reply nzdragme. I tried a 10K, 1K and a 330 ohm resistor in both +5 and gnd with both T2400 and N2400 but had no effect. Any other ideas?
 

westaust55

Moderator
Have you set the LCD module switches (on the back) to SW1 to ON and SW2 to OFF as indicated in the datasheet for the Baud Rate of 2400 ?
 

Dave E

Senior Member
Thanks for the reply westaust55.
Yes, I checked the switches several times. Cycled power several times.
I assume that I need to use the control codes for the LCD that I am using such as decimal 22 to turn the display on, decimal 12 to clear screen and decimal 17 to turn backlight on. The manual for the AXE033 LCD shows a different set of control codes.
I am most familiar with the Basic Stamp 2 modules and do not have any problems with these LCDs. Do the PICAXE chips require a decimal designator or require HEX for control charactors? I read over the manual for the AXE033 LCD but did not find anything that may help.
I am sure that I have overlooked something. I have been using the BS2 modules for about 2 years now but just received my first PICAXE 5 days ago.

Any other ideas?

Thanks for the help.
 

Dippy

Moderator
Never used this module so going blindly from Parallax Data Sheet.

It says:-
"You should also set the serial port pin on the BASIC Stamp to HIGH before the 100 ms start-up delay, as this is the normal state of a serial port when it isn’t sending any data."

and Stamp Example:-
HIGH TxPin ' Set pin high to be a serial port
PAUSE 100 ' Pause for Serial LCD to initialize
SEROUT TxPin, Baud19200, ["Hello, this text will wrap."]

Whereas, you've done a HIGH followed immediately by a Serout.
Should there be a pause 100 between High 1 and Serout 1, .. ?

And you're sure the power supply is OK when everything powered up?
No nasty dips.
Grounds commoned?
 

westaust55

Moderator
Dave,

I do not have the same LCD module as you but havce a Rev-Ed AXE033 and a 4x20 LCD display (with backlight) from the local Aust Parallax agent.
Both use the command:

SEROUT 1, N2400, (varables or text within brackets)

Which board are you using with the 08M?
Are you connecting direct to the PICAXE pin or going via a transistor which would invert the signal "sense".

I had a few problems with a serial keyboard I built due to the non-invert / invert issue and with the wrong sense I could still see about half of the data. SO don't think that just because you can see a few characters with the T2400 that it is right and not try the N2400 option further.
 

Dave E

Senior Member
Thanks everyone for the help.
Dippy, I made the change in code but no help.
westaust55, I am using a breadboard with a breadboard adapter for programming.

I thought it would be something I overlooked but could not find anything so I programmed a BS2 with the same code and it worked fine. At this point I decided to bring out the oscilloscope and found that to match the idle high of the BS2 I needed to use T2400. The only problem is that the trace from the 08M is the SAME as from the BS2. The only difference I see is a slight (about 0.2 ms) pulse width change in a couple of pulses. But the overall pulse train is the same and I don't think that the slight mismatch in some of the pulse widths will make a difference. I could be wrong though.

Any help will be greatly appreciated.

Dave
 

hippy

Ex-Staff (retired)
Hopefully those 200uS variances are for inter-byte gaps ( changes in the lengths of the +V period ). At 2400 baud each bit should be about 416uS and most serial devices will tolerate +/-6% before getting corruption.

I don't know of any "T2400 doesn't work" problems beyond setting HIGH and a PAUSE 100 or so before the first SEROUT so it should be working as you'd expect.

The only other thing I can thing of is what voltage is the 08M signal ? Is it lower than that coming from the Basic Stamp ?
 

Dave E

Senior Member
Thanks hippy.
I even tried another 08M to no avail. Even the start up commands do not work most times. I have not been able to turn the backlight on with code 17. I still only get 2 digits that seem to be a random mixture of 1, 2 and 3.
 

Dave E

Senior Member
WORKING!!
I decided to play with the CALIBFREQ command. At CALIBFREQ 2, the LCD started working. The display works with a CALIBFREQ factor of 2 to around 15. Any factor outside that range and the display goes back to the problem described above.
Here is what I found: At the default factor of 0, the SEROUT command listed in my first posting lasts about 40.1 mS. With a factor of 2, the pulsetrain lasts about 39.9 mS.

Thanks everyone for the help.

Dave
 

westaust55

Moderator
Dave,

at a loss for too many further suggestions here.

Try adding a pause (PAUSE 1000) before the first instruction to the LCD. a long short but maybe the LCD is taking a bit longer to initialise and missing the first instruction. But then, you say you do get some characters occasionally.

EDIT:
Ahh now explained.
Yes the AXE033 has a jumper on it to permit some calibration (frequency adjustment) in case there is a speed discrepancy.
 
Last edited:

Dave E

Senior Member
Thanks again for the suggestions westaust55.

This does bring up a couple of questions.
1) What exactly does CALIBFREQ do?
2) If the chip is running at 4 MHz at default (CALIBFREQ 0), what is the freq at CALIBFREQ 1.....?
2) How much of a freq change do you get with temperature change? In other words, will the display stop working if I have a circuit with LCD outside (20 degF - 100 degF)?

Dave
 

Dippy

Moderator
Hi Dave,

The PIC internal resonator is not a accurate/precise/stable as an external crystal.

Check out the Basic Manual for a description of Calibfreq.
Then if you feel like a long read get the Microchip PIC data sheet and search on OSCTUNE. It is a register where you can make small adjustments to the internal register which adjusts the internal resonator fequency.
You can have a POKE of the values to see how the frequency changes - if you have a 'scope.

While you are wrestling with the PIC data sheet you can also see (in some Data Sheets) graphs of frequency(stability) against temperature.
This will be new to you (but educational) as I think all Stamps have a crystal(?).

And bing able to POKE and PEEK registers is an area where PICAXE scores over Stamp (though, in fairness, I haven't bothered looking at Stamps for donkey's so it may have changed dunno.)

This example shows Int Osc stability against Vsupply and temperature for 16F88x (28X1), for 16F88 (18X) it is not so good, so it depends on the device:-
 

Attachments

hippy

Ex-Staff (retired)
Seems the oscillator was just a little too out of spec. The AXE033 had problems specifically with the PICAXE-18A where the internal oscillator has a very wide tolerance (+/-25%) but the 08M/18X have much tighter tolerance, +/-2% under most circumstances.

As mentioned earlier, serial is usually workable up to +/-6% and I've never encountered any problems with an 08M but maybe the LCD is more sensitive than most other serial.
 

Dippy

Moderator
Yes, it's a funny old world.

I was doing some PIC code a while back to read Serial from PICAXE.
I used the 'recommended' BRG for 2400 baud. (Yes, I actually read the Data Sheet)
My practice runs from PC terminal fine, but were awful from an 18X.
Had to adjust 16bit BRG vals quite a lot off-calc to make it work well.

If you looped the code (for a range of BRG vals) you could plot a range of reliable BRG values and get a disitribution. Similarly with PC to PIC serial. So, I plumped for 'in the middle' and everything was happy hippy.
 

sandy

New Member
Thank you guys so much for having this discussion about the picaxe and the serial LCD. I need to get it up and running tomorrow, so this was INFINITELY helpful. Hugs and kisses.
 

Dave E

Senior Member
Footnote:
The serial LCD still works fine and I have since set up a basic stamp BS2px and an 08M with a direct serial link and all is working fine without adjusting the freq of the 08M.

Dave
 
Top