LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I do cooperative task scheduling for Arduino

Hello dude,

      I'm sorry for confusing about my question. My question is, "Is there any timer interrupt function for LabVIEW?" The following is an example of timer interrupt of Arduino.

In Arduino, it has timer interrupt, like millis() function http://arduino.cc/en/Tutorial/BlinkWithoutDelay. In this example, there are two tasks; blinking LED() and millis() tasks. Actually, millis() task is timer interrupt that triggers blinking LED() task every 1 second (as example).

Regards,

pak

0 Kudos
Message 11 of 18
(1,275 Views)

paksoft wrote:


In Arduino, it has timer interrupt, like millis() function http://arduino.cc/en/Tutorial/BlinkWithoutDelay. In this example, there are two tasks; blinking LED() and millis() tasks. Actually, millis() task is timer interrupt that triggers blinking LED() task every 1 second (as example).

No offense but none of that is true.  There is no such thing as a "timer interrupt" in Arduino.  The only "interrupt" on an Arduino is an interrupt pin.  This pin is used to interrupt normal execution of code and is not used in that example nor is it possible to be utilized via LIFA, unfortunately.

Here is the equivalent of that Arduino example in LabVIEW:

ExecAfterTimeElasped.png

0 Kudos
Message 12 of 18
(1,275 Views)

Hi dude,

       May be you are talking about hardware (external) interrupt. Please check here. http://arduino.cc/playground/Code/Interrupts But I'm talking about these interrupts (software interrupt, ref: wiki) as show in figure bellow: I'm sorry for misunderstanding and confusing, it's my bad.

8-15-2012 9-41-28 PM.jpg

There are a lot of information of these interrupts.

http://www.engblaze.com/microcontroller-tutorial-avr-and-arduino-timer-interrupts/

http://www.uchobby.com/index.php/2007/11/24/arduino-interrupts/

http://en.wikipedia.org/wiki/Interrupts

Thank for your example. I've got some idea.

Regards,

pak

0 Kudos
Message 13 of 18
(1,275 Views)

I apologize.  I've never heard of "timer interrupts" before and from what I've read in your links, BlinkWithoutDelay example is not technically a "timer interrupt" but attempts to mimic one.  That is why I was confused.

0 Kudos
Message 14 of 18
(1,275 Views)

Ok, I'll try this way. I do cooperative RTOS at Arduino side, but I learn that Arduino is busy with communication. And I do not want to put my customer code under "checkForCommand();" please refer the following way as well.

void loop()

{  

  // Check for commands from LabVIEW and process them.

  checkForCommand();

 

  // Place your custom loop code here (this may slow down communication with LabVIEW)

}

Therefore, I need to pause the communication line with Arduino and LabVIEW in order to get some time for cooperative RTOS. So how should I do pause/start the communication? For example, communication will pause if I sent 'H' and resume if I sent 'R' from Arduino side.

0 Kudos
Message 15 of 18
(1,275 Views)

If you stop communication then you can never tell it to start again.  Also, it does not halt execution.  If it receives a command, it processes it and then executes the "custom loop code" when it has finished with the command.

0 Kudos
Message 16 of 18
(1,275 Views)

Hi Nathan

I only meant that the first wait multiple ms waits un undefined time, mostly shorter than the requested time.

greetings from the Netherlands
0 Kudos
Message 17 of 18
(1,275 Views)

Hi dude,

    I have a solution to my question as follow:

void loop()

{  

  Cooperative Task Scheduler function();  //this scheduler calls Task0, Task1 and Task2 in every 333 ms interval

}

// Check for commands from LabVIEW and process them.

void Task0()

{

  checkForCommand();

}

void Task1()

{

}

void Task2()

{

}

Thank for your reply and example.

Best regards,

pak

0 Kudos
Message 18 of 18
(1,275 Views)