Multitasking on PIC microcontroller

Thread Starter

cpleng7

Joined Dec 18, 2008
120
Is that possible for a PIC microcontroller work in multitasking?
Which mean that do 2 job in the same time?
 

thatoneguy

Joined Feb 19, 2009
6,359
PICs can do a form of co-operative multitasking using either a library or a programmer's clever use of interrupts and code.

I suggest Boost C w/Novo RTOS Real Time Operating System. The compiler is free to cheap depending on the version, and all but the free version comes with NovoRTOS for 3 tasks simultaneously. It is "coding time decision" multitasking, where the priority and order are set when the program is written.

I've used it a good deal and have had great results with it. Using interrupts gets you far as well. The more one can stay away from using a delay() function, the more "real time" any program will "feel" to a user. Novo RTOS does that easily without the user having to come up with the interrupt scheme and priorities in the interrupts. The code only needs to specify what needs to be done and return control to the RTOS until something else needs to be done. It IS a bit to learn, but worth it.

What sort of multitasking were you looking at doing? I've ran programs on PICs that were rather intensive at first glance to the point I thought of running more than one uC, but didn't need to. Example was a line following and obstacle avoiding robot my kid made that needed to run 2 RC servos, 2 full H-Bridge drivers, and a few IR detectors. Ran without lagging/glitching on the servos or the ranging. If a 14 yr old can learn it, most everybody can.
 

Thread Starter

cpleng7

Joined Dec 18, 2008
120
What sort of multitasking were you looking at doing?
actually I am trying to step down the voltage from the three phase system and feed into the microcontroller. since the three phase system is working so fast as my country is 50Hz voltage, so every cycle is 0.02s. I am using microcontroller act as a zero crossing detector.

so in this case, i have to multitasking to detect the three line.

is that suitable, if i using this.
 

Markd77

Joined Sep 7, 2009
2,806
That's loads of time, with a slow micro you get nearly 20000 (assembler) instructions in 0.02 seconds.
The ADCs on a lot of micros are quite slow so you might have difficulty reading 3 analog voltages fast enough, but a few external components should be enough to find the zero crossing points.
Presumably you will be using transformers to step down the voltage.
Maybe a few more details of what this is for would help us understand better.
 

thatoneguy

Joined Feb 19, 2009
6,359
Zero Crossing Detection Circuits at sound.westhost.com

There are ICs for this as well, but I can't recall any off hand that would be useful for 3 phase, you could use 3 single phase though.

A PIC will have plenty of time to act between phases for minor output and processing, they typically run at 4 MIPS (Million Instructions Per Second) when clocked at 20Mhz.
 

Potato Pudding

Joined Jun 11, 2010
688
If you are using a micro you could almost just aim for syncing to the line frequency unless you have highly reactive circuits that bounce around with lead and lag.
 
Top