Multitasking

Hello, I want to work on a new project but I am having some issues with how I should go about doing it. What I have are 4 actuators which use variable resistors for positioning, flashing run LED (health), serial port command line, and an Ethernet port. I need to move all 4 actuators together with PWM by varying the duty cycle to represent a trapezoidal acc/decel while reading the sensors for positioning (and calculate the decel time). The serial port can be used if I plug my laptop into it locally or if I use my laptop from across the room the Ethernet port (telnet or something).

Could someone point me in the correct direction on how I can make multiple things work at the same time?

Thank you,

Blink Without Delay example.

http://www.gammon.com.au/blink

Thank you both. I will look into these more.
Question, why would you do it this way and not with an RTOS?

Wouldn’t and RTOS allow for more flexibility when your adding new features to the code?
Also what happens when you are trying to take care of the serial/Ethernet ports.

Thanks,

rdevries:
Thank you both. I will look into these more.
Question, why would you do it this way and not with an RTOS?

Wouldn’t and RTOS allow for more flexibility when your adding new features to the code?
Also what happens when you are trying to take care of the serial/Ethernet ports.

Thanks,

An RTOS would take up some chip resources and cost a little time that could otherwise be used by the application directly. There are some who have developed small lean RTOSs to run on the 8 bit AVR chips but I think only a minority of users utilize a RTOS. I think as the ARM based boards get cheaper and cheaper their much more capacity and power would lend better to using a RTOS, but for simple 8 bit AVRs I think it’s a rare application the benefits from using a RTOS.

Just kick the RTOS training wheels off and write your application as a single program. :wink:

Lefty

It's a little hard to explain, although this question comes up from time to time.

Also what happens when you are trying to take care of the serial/Ethernet ports.

Could you explain your question a bit more? What is "take care of"?

You have 3 timers on the chip which can potentially do 6 lots of PWM, so you are probably better off understanding how the timers work than worrying about a RTOS.