PICAXE 18M2 a disappointment?

ncoplin

Member
Somehow I thought this chip was to be a replacement for the 18A and 18X chips, yet none of my 18A/18X projects work!!!

I'm struggling to find anything in one place that would describe how to change your old programs to work either.

* Seems like port B needs to be told its output before anything leaves the chip
* bit inputs seem unreliable, ADC ok
* "standard" LCD program/subroutines from Hippy which worked one the 18A and 18X don't

You'd think there was a directive to make the new chip run like the older ones its meant to replace, or a guide if you had to make the changes manually.

So far, the only thing I find these chips share is that they all have 18pins!

I held out so much hope for this chip's process power, that I'm hoping I can be set straight on how to make it work.

Sorry for my post being such a downer...

PS:Using program editor 5.3.1
 

westaust55

Moderator
On every recent PICAXE (ie X2 and M2 parts), all pins are generally inputs until changed in software.

Have you had a read of the 18M2 briefing on how IO pins are addressed?
http://www.rev-ed.co.uk/docs/picaxe18m2.pdf

Have you tried the X2 (yes I know it is X2 and not M2 specific – may be also M2 now don’t have PE on this machine) conversion wizard within the PE to automatically apply the DIRS commands etc to set port B as outputs as appropriate.
 

ncoplin

Member
Thanks for your reply Westaust55...

Figured the output thing, and after a couple more hours of hair-pulling the conversion requirement looks like:

#ifdef 18m2
dirsB = %11111111
dirsC = %00000000 'optional, not really needed
setfreq m4 'optional, not really needed
#endif

Still can't get all previous programs to work....

What I haven't been able to figure out is how to make RESET active again without coding an interupt or something.

And here's a doozey, previously the one pin could be used as both a binary input and as a ADC (so you could for example have a resistor ladder) or just check that one of the switches was pressed. NOT ANY MORE it would seem. Using the READADC command stops the pin from being a regular input. Not sure if this is an implementation bug or feature....
 

hippy

Ex-Staff (retired)
It's can sometimes be a bit of an up-hill struggle with a new PICAXE which supersedes other; one usually gets enhanced features, often lower cost, but things can be slightly different. We tried to make migration as easy as possible with under-the-hood intelligent translation of pre-18M2 pin numbering to 18M2 port.pin convention, accepting pre-18M2 commands as well as 18M2, so older programs run unchanged; the majority should but not all programs will.

Having to use "dirsB=$FF" is the most noticeable change if using "pinsB=" commands as all B.x pins default to input after download and on reset. This is described in the PICAXE18M.PDF. Programs which use HIGH and LOW etc will still automatically make the B.x outputs as required.

The C.5 pin, which was previously Reset on 18-pin PICAXE, is now a digital input only. To utilise that pin as if it were a reset function it will be necessary to poll it or interrupt and activate the RESET command.

Though it is possible to use a pin for reading analogue and digital input it is most common to use a pin for one or the other. The Microchip datasheets carry cautions against applying analogue signals to digital input pins and the 18M2 follows Microchip's guidelines and automatically configures the pin for analogue when READADC is activated and leaves it as analogue when completed. The silicon design means that subsequent digital reads of the analogue input pin will always return zero. This can be overridden by manipulation of the 'adcsetup' variable to return a pin to digital usage.

I'm surprised my LCD code does not run on an 18M2 after adding "dirsB=$FF", but when I get the time I'll check that.
 

ncoplin

Member
I'm surprised my LCD code does not run on an 18M2 after adding "dirsB=$FF", but when I get the time I'll check that.
Thanks for the background. Appreciate its a challenge to move forward, and maintain compatibility, but a small section in the manuals to help transition/conversion is missing.

Solved the LCD code issue. In addition to dirsB=%11111111 one needs to change the routines output lines to be "pinsB=...." rather than simply "pins=...".

A compiler directive could have sorted this out in a hassle free way by making the power on default less like a PIC and more like a PICAXE.

Now on to all those new features!

:)
 
Top