different chip versions - choosing/tips

KTarke

Senior Member
PROLOG: (TRYING to keep it short)

Less than two months ago I first "found" Picaxe chips, and saw the potential: here is the means to do the projects I have had in mind (with Picaxe, do-able with my skills,which do not include assembler code).
BEFORE really starting to learn Picaxe coding, I had to decide, which chip(s) to use. Then I saw it this way: the chip has to have certain features: 1-wire support , several adc's with good resolution, and enough memory/program lines.
So. I ended up with 28 X1/X2.

Did 7 successful (upcoming commercial) projects (same time learning Picaxe coding) and was ,in a way, satisfied w/ my choice.
Carefully reading the old threads, I saw that Hippy liked to use 20X2, and FINALLY I understood the real potential of that chip (X2 features,low price,pin configuring most versatile)

TODAY I got 10 bare 20X2 chips ,and built a few pcb's on veroboard, myself.
And was happy! Explanation:earlier used ready-built 28X-boards, but those were not any easier to connect. If I use DS1820 sensors, have to strip away the 10K resistor set, usually do not need the ULN-chip for anything, the plug-in cables look nice, but I still have to solder all the external parts to THEM (it's the same ,if I solder to the veroboard...)

So, my NEW choice is 20X2 (BIG thank to Hippy)


What else I have understood in two months:
I have earlier worked with industrial electronics, and using SEVERAL uP:s is quite strange way of thinking to me! With Picaxe (NOW I understand) it is a very good idea to use another (smaller) Picaxe for interfacing (or even several!)


NOW to the real thing. I want to raise discussion of potential/using different models. AND if possible, rise new thoughts on the more experienced guys minds (if my stupid idea's might lead to something new...)

some thoughts:
-28 and 40 X2 has several "places" for programs. How really could those places be utilized? Any way of chancing program "on the fly"?
-20X2 seems to be the most versatile model, but having a little less program memory than other X2:s. (Hippy has shown exellent ways in program optimizing,but is there other ideas? Maybe "deviding code" between several Picaxe's)
-There has been discussion of the COMING 18-model, and it's new features.
As Hippy said, a single core does not bring multitasking...
I am interested to have more knowledge about the existing background tasking (understood, that atleast some comms can work in the background) and could there be possibilities to put some other task to back?? (for example watching buttons, with interrupt, etc.)
-The idea of modular programming (which is introduced in manual, but is not yet here) is really something. Earlier have introduced myself little to Python and even the original LOGO, and understand the potential of building your own procedures, and re-using them in programs. It is NEARLY the same as using sub.procedures, but modules can re-use variables, and in some matter, "act in their own".

At least starting programs by name (as now subs) would help...

Think, that these things are merely connected with the PE ,than the firmware of the chips...?

Does anyone find any useful thoughts here?
 

hippy

Technical Support
Staff member
In most cases choosing a chip will primarily be based on number of I/O pins and firmware capabilities with physical size and cost being secondary, or being a limiting factor on choice. The two extremes are to choose a chip with 'everything' 40X2) or to choose the minimum capable of achieving the requirements.

In truth, many people probably do tend towards choosing a PICAXE because it is cheapest. That's not necessarily wrong but one sometimes has to question the potentially 'false economy' of such a move when it's then necessary to add additional hardware and write complicated code to achieve what a slightly more expensive PICAXE could do easily.

I like the 20X2 because it is a nice mid-range chip, reasonably priced, large memory, extremely fast, and conveniently has all I/O consecutively numbered sequentially down each side; very handy for throwing things together when testing. That in many way does distort my preference and I expect it's the same for everyone, all having our favourites for some particular reason or other.

I have to admit that I may sometimes appear to neglect some of the PICAXE range, but that simply comes from the work I do, 20X2 and 28X2 being the natural choices for that work, though it doesn't mean they are better than another PICAXE for a specific task. It does perhaps highlight the two roles which PICAXE plays; in product or project or for experimenting with hardware and software concepts and most of my work is in the later.

For development work I'd say 'more of everything' is the better so 20X2, 28X2, 40X2, but for actual projects to be built either, one of those for familiarity and ignore the cost, or the PICAXE which best fits the project as per opening paragraphs remarks. Ultimately there is no best PICAXE only better matches with the task in hand.

On the specific questions ...

Additional program slots - It's easy to choose a slot with RUN ( and BOOTI2C ). There are a number of uses for slots, initialising Eeprom values or restoring defaults ( the main program can be in one slot and calibration in another ), running two different programs ( a Centigrade and Fahrenheit temperature monitor, or different games which use the same buttons and LED's ) or even having a fall-back program or test program to switch to when experimental code doesn't work as expected.

Dividing code between PICAXE, multi-PICAXE networks - Entirely possible with any of the PICAXE and more a question of system design than something else. Some things are more easily modularised than others, good cases are front-ends which can receive 433MHz wireless without blocking the rest of the program ( also useful for serial and IR ), baud rate conversions, serial-to-something controllers, LCD, LED expansion, printers and so on. A PC serial to 16-LED controller could be implemented with a single 28X2, two 18M or sixteen 08's, each having particular advantages and disadvantages. What's an advantage to one may be a disadvantage to another so there's no 'this is the way to do it'. Complicated systems will likely be complicated no matter how they are done but modularisation can help, particularly if using the traditional 'input-process-output' model of data flow.

On modularisation of code - This is a more tricky issue as it depends on how you view it and approach it. On one hand it's brilliant for big projects on processors which have huge amounts of program and variable space where one doesn't care how much 'waste' there is, on the other, that's not so good when limited memory is available. In most cases where I've re-used code from a PICAXE project cut and paste has achieved that and one usually wants something slightly different anyway. There's also the issue of market where someone wants to see the 'bare metal' of the PICAXE and others who want a completely abstracted view of the hardware and how one ties that together without disadvantaging the other is not easy. Invariably people want both and that can lead to complications. The approach has been to make PICAXE more 'bare metal' and leave abstraction and modularisation to be implemented how the user wants to achieve that, though the PICAXE is in some ways more abstracted and modularised than other systems just that one doesn't always immediately see it; most PICAXE I/O commands are abstracted views of the hardware; READADC, READTEMP etc.

On background tasking - The PICAXE has very little background tasking, pure hardware background tasking such as PWMOUT and PWM and software assisted hardware tasking such as servo pulse generation, moving high-speed serial received into scratchpad, I2C Slave, hardware interrupts and timers. Tasks such as monitoring for button pushes can appear to be done in the background when used for interrupt but these are really things which are checked for between PICAXE commands and for current PICAXE it's only really interrupts handled in this way. I doubt this will fundamentally change but the M2's will offer the ability to run multiple tasks which appear to execute simultaneously so while one program loop is flashing a LED another can be looping and checking the state of a button input. When a button push is detected that can set a variable which can affect the LED loop and thus can achieve the apparent background processing. The same can be achieved with the current PICAXE's but usually makes for more complicated code. For example a PICAXE-18M may need to generate a signal on pin 1 when a button is pressed and another signal on pin 2 if a button is not pressed within one second -

Code:
#Picaxe 18M

Do
  If pin1 = 1 Then
    High 1
    w0 = 0
  Else
    w0 = w0 + 10
    If w0 = 1000 Then
      High 2
    End If
  End If
  Pause 10
Loop
For the 18M2 something like this would achieve the same task -

Code:
#Picaxe 18M2

Task1:
  Do
    If pin1 = 1 Then
      High 1
      w0 = 0
    End If
  Loop

Task2:
  Do
    Pause 10
    w0 = w0 + 10
    If w0 = 1000 Then
      High 2
    End If
  Loop
The advantage of this type of multi-tasking is that it makes it easier to define the program in terms of the distinct tasks it does - Task 1 : Set output when button pushed and clear the timeout flag (w0), Task 2 : Increment the timeout flag and set output when the timeout expires - and to put those two tasks together within a program.

To go back to multi-PICAXE networks this is also a good example for such use. Rather than have your single PICAXE monitoring button pushes, checking for timeout, you can off-load all that work into a separate PICAXE-18M2 and simplify your main PICAXE program which will either get a signal when the button is pushed or another signal when a timeout occurs. As we saw, the existing 18M can do the same job so would make an equally good candidate in a multi-PICAXE network.

As said before it's a question of system design and having the vision to see where a system can be sub-divided easily. For a temperature display it may be a case of -

Read temperature
Average temperatures
Convert from Centigrade to Fahrenheit
Convert to display format
Send to LCD

All that would normally be done in a single PICAXE but there's no reason not to run each task on its own PICAXE, send its data to the next by serial, though it may not make sense to do so. A good design practice I find is to make each of those steps a GOSUB to a subroutine for each of those steps, and those steps make the main loop. The subroutines themselves then become very simple, and they are easy to test separately; set the input variables, GOSUB the routine, see what the result is. Plus you look at the main loop and you can see what it does even if you don't understand each individual step, you can study one step without having to understand what the other steps are actually doing.

You may ultimately optimise the code to turn this into a sequence of commands in the main loop itself, but I've found it's a good design approach and clearly shows how optimisation may gain in speed and code space but loses other information which may be very useful for others to understand the code.
 

westaust55

Moderator
I probably differ from many in that I have my main “experimenters” box based on a PICAXE 40X1 (went for max IO) with extra EEPROM, F-RAM, DS1338 RTC, uM-FPU, SPE030, i2c IO chips, speaker, LEDs, 3x16key keypads (as a 48 key keyboard with shift function) and a range of other bits such as 4x20 LCD (with backlight), LDR, DS18B20, IR LED, pot, mag field senor, etc for general development work. Bpc also includes a DA-15 pin connector (larger brother of DB-9) with 8 digital IO, i2c comms pins and analog input and power available for specific expansion modules and breadboard work

Then I can select smaller PICAXE chips such as 08M, 14M, 18X, 20M, 28X1 etc depending on more specific and permanent project requirements based upon facets such as number/type of IO required, program size, etc. Have not had a specific need for an X2 part to date.
 

KTarke

Senior Member
Thank You for your comments!

Hippy:
You again gave me a huge amount of data (and idea's).

About the buttons:
I rose that up, because in two experiments had problems with button-sub-procedure ;button press ought to be detected immediately (detecting does not consume time from other operations) but it maybe hard to "spread" actions (caused by pushing button) so, that those actions does not slow down the main procedure too much... It is possible (but hard) to do the "actions" a few lines in a row, and jump back to the main routine in the middle... and so on...
In those cases, I now consider a slave processor to handle those input-actions.

Westy:
You have a real PRO development gear! I do not wonder, why You haven't needed the X2-features...


My thinking has been formed during decades in business-world and industrial environment. So, in Picaxe's ,too, I first wanted to make a single choice, that is enough for my needs, but is not too expensive... Now later I have come to understand, that 20X2 meets better my needs, than my first choice, 28X2.(20X2 is in a way more flexible, and that makes pcb as simple as it can be)
And that it is really a good idea to share tasks between several Picaxes, which keeps the "main" board VERY small and simple.(veroboard seems to be good enough, since on the main board I only need to have the programming socket and a few pull- up/down resistors. All other components can very well be attached somewhere else ,for example output transistor in the same place, where the relay is...)
 

manuka

Senior Member
There are of course now 17 PICAXEs, but the phasing out of older ones and the arrival of the "4 in 1" 18M2 will bring this down to ~10. In fact the 18M2 looks as if it may well blow the 20X2 out of the water - designers are recommended hence to keep their options open !

In spite of the wide choice I'm continually telling folks that the "baby" 08M is still capable of all manner of magic, & I for one have yet to fully plumb their e-depths! It's not so much a PICAXE cost issue (as they're all cheap enough!), but the ability for the 08M to get proof of concept ideas up & running quickly. Much time is often wasted with the bigger "sledgehammer" PICAXEs just cracking nuts.

It's "horses for courses", & I use a variety of PICAXEs (most initially bread boarded) rather than any single one, only migrating to more powerful ones & PCBs when limits are reached or designs are tamed. To take a Finnish analogy I guess there's little point in rushing out to buy an iPad to only send texts when just a plain Nokia would do! Stan.
 
Last edited:

KTarke

Senior Member
There are of course now 17 PICAXEs, but the phasing out of older ones and the arrival of the "4 in 1" 18M2 will bring this down to ~10. In fact the 18M2 looks as if it may well blow the 20X2 out of the water - designers are recommended hence to keep their options open !
I am very interested in the new model, and will keep a "opening" for that.
Only, some things make me wonder...
-Until now, only X2 parts have had a bunch of "special" features.
Naming the new baby "M2" points to the direction, that it lacks some of those X2-features, and brings something more. A new pile of "post-it's" to remeber, which commands work differently as in X2's, what is missing, which pins do not work the same way as in X2... and so on.
-Anyway, 18 has 2 pins less than 20... means in some cases lack of ports.

These are the things, that me make me a little skeptic for the expression. "18M2 looks as if it may well blow the 20X2 out of the water".
In my opinion, if something better is done, the old (good) features should remain!

It's "horses for courses", & I use a variety of PICAXEs (most initially bread boarded) rather than any single one, only migrating to more powerful ones & PCBs when limits are reached or designs are tamed. To take a Finnish analogy I guess there's little point in rushing out to buy an iPad to only send texts when just a plain Nokia would do! Stan.
Yes, true. And more true, if one is designing/experimenting with, "separate" projects.
My use is alittle different:
I DO a lot of "hobby" projects too, but trying also to find a "hole" from the market = try to develop small, reasonably priced gadgets for the need of my customers. When either:
- I see a pricy device, I might right away see, that it can be done other way with Picaxe, and I could make a few $ because there is a "need" for a cheaper version.
-My client tells me of a device, that ha has not found, but needs. I might see that it is doable.

This is my profession and living: "problem solving" by some little gadgets/modifications/products.

A example: Have sold a good deal of gsm- alarm/remote controllers. Simple and cheap (only one alarm/ one control /device, but usually that is enough! and customer does not want to pay for unneeded features)
The design is very harsh:an old phone is hard-wired, and the only external components needed, are one relay, one opto-isolator, one push button.


That brings me to the point:
To be able to act fast (in designing and bringing up a new product) I HAVE remember "by heart", what I can do with the uP, I have home waiting...
and when prototyping, have "chart in my head" about what pins have used to do what (makes code-writing a lot faster)

There is the reason for being skeptic about jumping to a new model
 

hippy

Technical Support
Staff member
Naming the new baby "M2" points to the direction, that it lacks some of those X2-features, and brings something more.
That's probably a fair summary.

It would be nice if Microchip produced a PICmicro which had the same abilities, memory size and on-chip peripherals across all its variants and we could produce an '08X3' through '40X3' which varied only in the number of pins available but they don't. Thus it has to be compromise with the result that one PICAXE may be slightly different to another, some have one thing another may lack and vice-versa. It's the same for most microcontroller products.

The PICAXE also serves two very different markets; from experts who want their PICAXE to do everything, not only have bells, whistles and kitchen sinks but have them in abundance, and students who are being exposed to electronics and programming for the first time who need to do simple things as easily as possible. For education the view is probably "08M" then choose upwards as necessary, for experts it's probably the opposite, "40X2" and go down to find the best fit for the job. Many fall mid-way, no longer novices but not calling themselves experts, so the choice and decision can appear a little more difficult.

I too wouldn't say the 18M2 will blow the 20X2 out of the water, more that it takes the 18X and 18M to the next level and sits alongside the 20X2. For some an 18M2 may be a best fit, for others the 20X2. Ultimately there will likely be better convergence to M2 parts for the education sector and towards X2 for more advanced use. How well converged, how small we can make the differences for each group ( and as a whole ), and which parts become naturally obsoleted as a result, only time will tell. We will almost certainly continue to support older parts no matter what.
 

KTarke

Senior Member
I agree with You, Hippy.

Producing Picaxes are a matter of Microchips choices. And therefore too, all the the older models can be kept is sale/support-list (usually new products are updates to old one's, which vanish from market. just seen that with Maxim's 1-wire products...)
Because the work (firmware) for Picaxe-models is done, and Pics are available, it is wise to keep them all.

I just don't understand the logic in Microchips way in bringing new models...
Maybe, some of those are "ordered"? (some mass-users of chips might dictate, which things they need, and which can be dropped)
I would like, if there were some "updates" ,too (upgrades to existing models ,with new features , at least the old features and commands intact!) Quite certainly that would mean going to a model with more legs... but still there would be a clear series of "one chip" with different feature levels. (like in cars... same model, 3 to 5 levels of features)

Now, when Pic's are so different, it affects greatly on the Picaxe-commands.

Just begun my Picaxe-using with 28X1 and 28X2, and was several times annoyed ,why so many commands work differently/need different kind of parameters, when the chip is "just" a variant of the same brand (28X1 and 28X2)
That was the expression I got about the naming of Picaxe's!
Had to dig deeper ,download the Pic-datasheets, and to find out how different are the chips behind those quite similar names.

Seems really, that every Picaxe has it's own place and use, and there is no need to compare chips.
Maybe, I will in the future use 18M2 to something, but do not now believe, that it could replace 20X2.

In my eyes, the most important thing is, how much will using the old commands differ from the X2-parts! Really wouldn't again like to bump into things, that give errors in PE, because the command is used another way, or I have to write the parameters in a different way...
Learning totally new commands/features is always a necessity, and nothing against that.
Changing the way how old commands work, is like, if in every new version of MS Windows, all the drop-down menus were different...
 

MartinM57

Moderator
KT - if any of your "commercial" projects uses serial comms then I would suggest a PICAXE with an external crystal/resonator to ensure accurate baud rates at all times (yes, you can maybe tweak the OSCAL register on a homemade project but that's not the way to do it properly). That means 18M2 and 20X2 are out of the equation.

Seems really, that every Picaxe has it's own place and use, and there is no need to compare chips.
Agreed.
 

KTarke

Senior Member
KT - if any of your "commercial" projects uses serial comms then I would suggest a PICAXE with an external crystal/resonator to ensure accurate baud rates at all times (yes, you can maybe tweak the OSCAL register on a homemade project but that's not the way to do it properly). That means 18M2 and 20X2 are out of the equation.

Agreed.
Thank You for the warning.
Not yet there is on the list any device, that needs comms, but have to keep in mind if that kind of situation comes.
Reading old posts from the forum (earlier) I saw some talk about internal resonator being a bit unstable, but forgot that when "re-choosing" the Picaxe-model to use.
On stand-alone gadgets, 20X2 is nice ,because of the internal resonator: high speed,but no need to solder a crystal = simpler pcb
 

hippy

Technical Support
Staff member
Just begun my Picaxe-using with 28X1 and 28X2, and was several times annoyed ,why so many commands work differently/need different kind of parameters, when the chip is "just" a variant of the same brand (28X1 and 28X2)
I didn't think there were that many differences in commands between X1 and X2 though there are some changes from pre-X1 mainly because commands can do something different or have more capabilities.

Having written code using #ifdef conditional compilation I haven't run into many problems writing code which will run on 28X, 28X1 or 28X2. The main issue is in I/O definition due to pin naming changes but the commands and parameters are generally the same across the range. Using something only available for one will present problems. If using PEEKSFR and POKESFR there can be issues as Microchip sometimes inconveniently moves things around.
 
Top