18M2 as LCD serial firmware chip

joely87

Member
Hello all,

With the release of the Picaxe 18M2 at a ridiculously low price ($6 in Aus) I was tempted to update my skill in picaxe ready to start teaching design and technology next year.

I have played around with LCD and in the past mostly using the sparkfun serial enabled backpack as it h been simple to use but cost around $18 AUS.
http://www.sparkfun.com/commerce/product_info.php?products_id=258

So here is what I am thinking (member ncoplin) resolved the 18M2 compatibility http://www.picaxeforum.co.uk/showthread.php?t=16165&highlight=LCD+18m2 to work with Hippy's Picaxe LCD interfacing code http://www.hippy.freeserve.co.uk/picaxelc.htm#Output_Pin_Definition.

So I now have A 16 pin LCD working and displaying " Hello World" and I can communicate between two picaxe chips.

I was thinking of trying to write some code to one 18M2 as a serial firmware back pack with 6 wire communication. Then you could use any picaxe chip using 2 wire serial communication to the 18M2 which could encode the text and send it to the LCD.

Sounds simple but I don't think I'm ready to start this project without some extra support from the picaxe community.

The way I see it is rather than paying $15 - $20 for a serial backpack. Anyone could use a $6 18M2 download this program to it and integrate the 18M2 into there circuit. Then use simple picaxe to picaxe communication such as serout, pin, baudmode, ("Hello World").

Thanks all,

Joel
 

MFB

Senior Member
Ron Hackett covers the design of a serial-to-LCD module in his recent book "PICAXE Microcontroller Projects for The Evil Genius". Also, well worth purchasing for other information like using timers and interrupts etc.
 

Dippy

Moderator
Why not have a go?

A firmware chip is simply a uC which accepts serial and converts.
All you have to do is set a desired EOD and pop off to the desired routine.

This Forum ,as you have discovered, has loads of info on driving an LCD (hardware conenctions and code examples).

And just think, one of the students here may be unwittingly help his 'next-year' teacher write code... ;)
Let us know if that's the case it would be a strange irony.
 

hippy

Ex-Staff (retired)
It should be possible; I did the same with a PICAXE-18. The main issue is that the 18M2 has limited HSERIN without full background receive and a SERIN loop on the 18 had severe limitations on baud rate. With faster 18M2 speeds things should be better but there probably will be limitations.

The technique used for the 18 was to read bytes into SFR ( used like scratchpad ) until a terminating byte was found, then churn that buffer out to the LCD. It was how quickly the 18 could store the byte, increment the buffer pointer, and be back at SERIN ready for the next byte which was the limitiation.
 

joely87

Member
Succsess!

Thanks to all three of you. I found some of hackets code for 14m on his site and modified it for 18m2. Because the 18m2 has twice as many variables I was able to use serin pin, T4800_8, b0.....b16. This allowed one variable for an instruction and 16 to fill one line on a 16x2.

I will post the code so far when I get some more time.

My question now is from hippys comment... As the 18M2 can run multiple programs at once would it be possible to have one program monitoring serin and a second program writing the data to the LCD? Would this resolve any problems with not getting back to serin in time?

I'll need to read up on running multiple programs in the manual.

Thanks for your help.
 

John West

Senior Member
As I understand it the 18M2 clock cycles are sequenced through each of the programs in turn. Time management would still have to be treated as though you were running all your code as one program.

This new structure can allow for one program to get locked up while looking for an input that never occurs, while still running the other 3 functioning programs. That could come in handy for things like robotics. Keep the flaps working when the motor control is locked up and such.

But the programs are only functionally isolated - not actually separate internally. The clock still only works one process at a time - not 4.
 
Last edited:

Dippy

Moderator
That's roughly how I read it too.
The 18M2 does not do genuine parallel processing.

I wouldn't complicate things unneccessarily.
The simplest variation:-
1. Sit there waiting for input *
2. Has all the input finished?
3. What's the command and parameters.
4. Oooh, I'm meant to do such&such.
5. Do it
6. Return to waiting.

Options include; doing something and waiting for a serial interrupt + stashing data (which some PICAXEs do for you) and setting a 'busy' pin.
 

hippy

Ex-Staff (retired)
As above, it's 'round-robin scheduling' rather than true parallel processing on the M2's. When a task encounters a SERIN ( or other blocking commands ) it sits there until data arrives or it times out, no other tasks can run.

In some ways multi-processing would be bad for this application ( though it does depend on how it's done ). If you were reading a byte, buffering it, getting the next byte, you'd want to be back in SERIN as quick as possible. With multi-tasking, as soon as SERIN completes, the other tasks get executed, so you end up adding delays between SERIN's. You could SUSPEND other taks but then you may as well be running a non multi-tasking program.
 

John West

Senior Member
Hippy, you're saying the round robin processing would not continue on to the next process if one process was waiting for a SERIN, or similar command?
 

westaust55

Moderator
I found some of Hackett's code for 14m on his site and modified it for 18m2. Because the 18m2 has twice as many variables I was able to use serin pin, T4800_8, b0.....b16. This allowed one variable for an instruction and 16 to fill one line on a 16x2.
I think that you missed MFB’s point about Ron Hackett’s NEW book.(see here: http://www.jrhackett.net/)

In that book, Ron uses the -20X2 in Chapter 10 to create a serial interface for and LCD module.
The 14M approach was an older method.

About half way down the web page on Ron’s site you will then find a link to the PICAXE programs for all of Ron’s projects.
Would not be too hard I should think to adjust for the 18M2.
 

joely87

Member
Thanks westaust55. It seems I did miss the points in hackets new book. Since my last post I have found updated info on his website and found the code he wrote for the 20x2. I agree I can't see any major issues tweaking the code for 18m2. I am going to buy the book today and have another shot next weekend.

Thankyou all for your help this far.
 
Top