Pumpkin, Inc.

Pumpkin User Forums

Delayed start of a task

If you can't make Salvo do what you want it to do, post it here.

Delayed start of a task

Postby Matthias Herrmann » Thu Jan 23, 2003 11:11 am

Andrew,
I have the following problem:
In my application I have 4 tasks, one for a waterpump, one for a heater, one for the serial communication and one for a level detector ( PTC sensor ).
The first three tasks can start immediatly after salov comes up. The last one, for the level detector, has to wait 30 seconds before the task can start after the system comes up.
Salvo runs on a PIC 16F628 with 4 Mhz. Any ideas how I can solve this problem??

Regards
Matthias

Matthias Herrmann
 
Posts: 2
Joined: Fri Sep 14, 2001 11:00 pm
Location: Dillenburg, Hessen, Germany

Re: Delayed start of a task

Postby aek » Thu Jan 23, 2003 12:35 pm

Hi Matthias.

Well, the simplest way (assuming that you just want the task to be delayed, and there's no problem with it being created at startup) is to do something like this:

code:
void TaskLevelDetector ( void )
{
OS_Delay(30_SECONDS, label);

while ( 1 ) {
/* body of task */
}
}


i.e. the point is that you can do context switches in the "preamble" of a task -- they don't have to be in the infinite loop. In fact, no matter how you write a task, you can put context switches anywhere inside it.

If you have a problem with the 30s delay (inadequate bits of delays), see our App Note AN-7.

Also note that you can do something quite different -- instead of blindly waiting 30s, you can detect whatever condition you're looking for that says "now is the time to run the level detector," and then either create TaskLevelDetector() on-the-fly or have it waiting for an event to be signaled before it "starts running in its infinite loop."

Similarly, if your problem is that you can't even create the task for 30s (I can't imagine why, but anyway, I'll address it), then you could actually setup an ISR-based delay and after 30s times out, call OSCreateTask() from an ISR(). Diese Methode ist aber furchtbar haesslich, und Ich hoffe, dass es nicht dazu kommt.

Let me know which method ends up working for you.

Regards,

------------------

[This message has been edited by aek (edited January 23, 2003).]

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Delayed start of a task

Postby Matthias Herrmann » Fri Jan 24, 2003 11:03 am

Hi Andrew,
thanks for your answer. Well, I will use the "blind long delay" because of the different conditions of my sensor.
I detect the current which flows through the PTC; low current means that the surface temperature Sensor is on high level and
ready to detect liquid.
A high current indicates two different states:
a: Sensor heats up
b: Sensor detects liquid
But if the Sensor is coverd with liquid from the beginning then I will have
a typical deadlock if I look only at the current.

Ich hoffe Du konntest meine technische Erklaerung zu dem Problem verstehen.

Regards

Matthias

Matthias Herrmann
 
Posts: 2
Joined: Fri Sep 14, 2001 11:00 pm
Location: Dillenburg, Hessen, Germany

Re: Delayed start of a task

Postby aek » Mon Jan 27, 2003 8:20 am

quote:
Ich hoffe Du konntest meine technische Erklaerung zu dem Problem verstehen.
Probemlos.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron