Do "X2" chips "multi-task"?

lforbes

New Member
Apologies if this has been discussed b/f but I've searched and cannot find an answer. I have read the docs on the new X2 micro-controllers and the program "slots" available seem to imply some sort of multitasking ability. To be more specific, if I have a "pause" or "count" instruction in a program in one slot and the same in another slot, can they both be configured to operate "simultaneously" i.e. correct timing in each case? An example would be simultaneous counting of pulses on two separate inputs (or any other type of concurrent operations).

TIA for any assistance.........
 

BeanieBots

Moderator
Unfortunately, only one slot can run at any one time.

There may be alternative methods to do as you require.
(eg. simulataneous reading of inputs using a polling method)
If you can be more specific, then somebody might be able to suggest a more specific method.
 

MartinM57

Moderator
if I have a "pause" or "count" instruction in a program in one slot and the same in another slot, can they both be configured to operate "simultaneously" i.e. correct timing in each case?
Not that I know of, but the new 18M2 (out this quarter) can.
No, but the new 18M2 (out this year, maybe) might be able to - the details of its multitasking capability, especially when there is a 'blocking' command (e.g. PAUSE or COUNT) in one thread, are not yet released
 

hippy

Ex-Staff (retired)
I don't have a spec for the full capabilities of the M2's so can only guess but it would seem unlikely that simultaneous commands which are timing critical would be possible, simply because switching tasks would mean that one or both tasks would lose all timing accuracy rendering them meaningless. If it can be done then you can be sure Rev-Ed will look at that possibility. It's probably best to consider it more as time-slicing; 'execute one command from one task, execute another in a different task, then back again'.

For lower resolution timing commands such as PAUSE it is more likely that some switching within commands should be possible with the caveats that blocking may affect timing or commands are deferred until they can execute without affecting timing commands.

This is however pure speculation on my part and not any official statement by Rev_Ed.

Some multi-tasking can be done with current PICAXE such as background counting which can run in parallel with program polling and it may always be possible to use multiple PICAXE's each handling separate tasks. The relatively low-cost of the "M" parts can make that a viable option in some cases.
 

lforbes

New Member
Thanks all for your responses. I sort of thought that would be the case (no multi-tasking) but am wondering now what particualrly useful purpose the program "slots" otherwise serve (I suppose though it might be useful for breaking long programs into more manageable pieces(?))?
 

MartinM57

Moderator
I don't have a spec for the full capabilities of the M2's
Ooh - looks like there might be whole series of them ;)

Thanks all for your responses. I sort of thought that would be the case (no multi-tasking) but am wondering now what particualrly useful purpose the program "slots" otherwise serve (I suppose though it might be useful for breaking long programs into more manageable pieces(?))?
Yep:
- giving more program space
- being able to run programs from external i2c EEPROM
- plus being able to update the internal program by copying a new program from an external i2c EEPROM (see booti2c command)
 

womai

Senior Member
As long as you don't want to execute the separate task very fast (meaning with very fine timing control), the "elapsed time" counter the 18M2 will have can probably be used even if e.g. a pause command in one task would block the other tasks. That way, instead of relying on pause commands to insert delays, each tasks waits in a loop until the elapsed time matches the desired delay, resulting in non-blocking operation for all tasks. For faster operation one could maybe use the internal timer (have to see how much of that functionality will be exposed by the M2).

On the X1 and X2 parts, you can use the timer interrupt feature to create your very own multitasking system. See this previous thread for some further discussion as well as some code snippets:

http://www.picaxeforum.co.uk/showthread.php?t=8541&highlight=multitasking

Just make sure each task finishes in less than the interrupt period.

From the preliminary description the M2 part looks like a very powerful yet very beginner-friendly device (while the X2 parts are probably a bit more daunting for a true beginner, but give even more capability). E.g. "elapsed time" counter is definitely less challenging than timer interrupts. Can't wait to get a hold of some M2's so I can play with the new features. (Are we there yet? :)
 
Last edited:
Top