robot upgrade options

Hi,

I have a larger robot running on a Mega2650 and I am working on upgrading it. I am moving to a Due board to upgrade hardware and I was looking for suggestions for improving the sketch. The current sketch loop frequency is about 10Hz, I was hoping to improve that significantly, and eventually add a SLAM module (separate hardware and software) and keep the Arduino as a central processing unit.

The current sketch is 1100 lines, includes 109 variables, and compiles to 56kB. There are 15 outputs and 12 inputs. My loop consists of 10 functions called sequentially.

I have started looking at freeRTOS but am quite intimidated by it so far, as I am a programmer by hobby not profession (I started with Arduino a few years ago), my main focus is just building an interesting robot.

Would you recommend freeRTOS for this project? Do people use freeRTOS successfully for robot applications? If not what do you recommend?

Would you recommend freeRTOS for this project?

I would not.

If not what do you recommend?

I would recommend that you explain what problem you are trying to solve. 1100 lines is not that much code.

I wrote an app (not for the Arduino, obviously) that was over 500,000 lines. No need to pretend that there was a real time operating system in that code. I doubt yours needs one, either.

The robot sketch is the largest sketch I've made. I was planning on adding additional devices, processing, and functions that will reduce the loop frequency further, so I am concerned that controls will become less responsive. I am looking into what is taking the most resources, do you know a good way to evaluate that? I am just printing the millis between points in the code. I believe that many sensor readings and serial communications are likely contributing a lot.

do you know a good way to evaluate that?

I do that by looking at the code, and understanding what each function does, and knowing approximately how long each function takes. Calling, and printing the value returned by, millis() at suitable points provides a reality check.

I believe that many sensor readings and serial communications are likely contributing a lot.

Do you absolutely need to read every sensor on every pass through loop()? Is the serial data going out or coming in? If it is going out, it is of no benefit to the Arduino, so stop sending it.

And presumably you have used delay() at an absolute minimum- if at all- and used millis()-based timing?

Yes I am using a soft-timers type approach to all timed events. Thanks for your suggestions.