I have some questions for the software gurus.
What is the best way to do all of the following tasks:
- count encoders without missing a step
- PID controll
- calculate acceleration and deceleration for smooth movement
- calculate position based on encoders count (distance travelled)
- read distance sensors
- calculate position based on distance measurements (triangulation)
- update map
- process image data to find the target
- calculate the destination target
- monitor battery level
- other decision tasks
1. The easier way to do it will be using a multitasking language.
2. Another approach would be to use several microcontrollers and divide the tasks.
3. The usual approach, that uses only one MCU, and uses a complicated timed scheme to do these tasks, perhaps using interrups.
I have worked with NQC to program the Lego RCX brick. Easy to work with, able to set up 10 parallel tasks, start and stop any task at any moment, 32 global variables, some (don't remember the number) local variables... But I didn't find anything similar for PIC or AVR. There is RTOS but it seems too complicated.
I have read a few tutorials on using interrupts, but all at a verry simple level, like say for encoders. Ok, using that, I can make a motor controller module. But how is it possible to do all in one MCU and keep track of each task so that they will not slow down the others, to keep the timing good? I am willing to divide the total processing speed of say 16MHz to the say 8 tasks. That will be 2MHz for each task. How can I calculate all the timings to run in each task in it's own 2MHz slice?
Can someone point me to some documentation and samples on how to do something like this? Or to write some sample code I can further develop to my needs? I just don't know enough programming to do it on my own...
Thanks in advance.