PDA

View Full Version : Multi-tasking



malc-c
- 11th July 2006, 21:27
Hi,

Firstly, thanks to Alain and Steve for their help on the "Dr Who" pulse light.. the "client" is really happy !

I was just out in the garden doing a spot of weeding, and watched a plane go over (we live on the flight path of Luton airport) and noticed (as it was an older type of plane) that it had a red beacon under its belly, mid way between the wings. This beacon pulsed in the same way...

Now I have in the past managed to write some code that runs through a loop double flashing three ports on a 12F675 that gives a nice strobe effect for model aircraft when using ultra-bright LEDs.

Now here is the question... how simple would it be to get a PIC like the 12F675 to multi-task and run both loops at the same time, without waiting for either to finish. I've not written any code yet, especially as the original double flash routine was my baptisum (sp) of assembly, and effectivley I ended up just typing what I was told to !!

I don't want you guys to spend hours writing sample code, as Im still working on other projects so it may be a while before I'll get started on this project, but just wanted to understand the complexity, if any, of multi-tasking.

Jerson
- 12th July 2006, 05:47
If you consider co-operative multi-tasking. I have seen some projects where the main loop calls several functions repeatedly. Each function performs a certain function and returns. When many functions are put together, you will see a kind of multi-tasking, but mind you; the key word here is 'co-operation'. Any function hogging the CPU will kill all the others.

Pre-emptive multi-tasking should be a nightmare, I guess, on the PIC with its limited stack levels.

Jerson

mister_e
- 12th July 2006, 05:50
if i understand correctly, you may want to run a timer in background, read the value of it and do action with x,y or z value... or use the Darrel Taylor Multi_SSPWM routine.
http://www.pbpgroup.com/modules/wfsection/article.php?articleid=12

mister_e
- 12th July 2006, 05:55
and multi tasking is an kind of impossible task... it give the impression of but it's not a real multi tasking... worst on 12F series.

Fluent on 18Fs with their tons of great gadget.

Acetronics2
- 12th July 2006, 08:49
Hi, Malc

First, you have a look to THIS :

http://www.mes-avions-rc.net/2nd%20video%20samples.wmv

The "lightshow" heart is a simple 16C84 !!! whithout any multitasking ...


Second, let's have a closer look to what you want to do

Alain

malc-c
- 12th July 2006, 08:59
Hi,

Yup seen that vid.. that's one nice model !

Acetronics2
- 12th July 2006, 09:06
" Yup seen that vid.. that's one nice model !"

Hi,

I Know it more than well ... ( Laughs )

It took me a little more time to find this second link ...

http://www.mes-avions-rc.net/light%20test%201.wmv

Alain

malc-c
- 12th July 2006, 22:57
Those landing lights are bright !!

picster
- 13th July 2006, 02:02
You could use an incrementing, looping counter/timer that counts up to a number that is evenly divisible by all "timing" constants. After each increment, divide the counter total by the number of counts desired for each independent light (i.e. - 10 for one, 11 for another, 6 for a third). Check the modulus, and if it's 0, then set the associated countdown byte to turn on an output for the proper number of count cycles. Check your next constant and do the same. When you've done all 3, then decrement the countdown bytes and go to a routine to turn each output on if its associated countdown byte is non-zero. Rinse and repeat.

Picster

Luciano
- 13th July 2006, 18:50
Hi,

See these links:

AN585 - A Real-Time Operating System for PICmicro™ Microcontrollers
http://ww1.microchip.com/downloads/en/AppNotes/00585b.pdf

AN585 Source Code
http://ww1.microchip.com/downloads/en/AppNotes/00585.zip

Best regards,

Luciano