08-14-2012 10:58 AM
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
08-14-2012 06:49 PM
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:
08-15-2012 09:05 AM
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.
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
08-15-2012 06:15 PM
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.
08-16-2012 08:17 PM
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.
08-16-2012 08:33 PM
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.
08-19-2012 11:04 AM
08-21-2012 03:53 AM
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