Right so let me get this bit straight, is an RTOS more useful when you need human interaction and need that to be real time to humans or does an RTOS make sense for applications where there is virtually no human interaction but it needs to be rock solid and easy to develop a large system.
An OS lets you (for example) isolate human interaction into a single task hygienically separated from the rest of the system. That task then communicates with other tasks depending on what needs to happen based on human input.
But equally a completely automated solution benefits from an OS because a human is only an input/output "device" same as any nonliving actor. The key is that you identify the activities of the application and the channels of comunication they need agaist each other. In this kind of thinking the point is to largely avoid global variables that only create access conflicts.
As an example my last project (well current) is to control a motor, I have a speed i want it to achieve and maintain with varying loads and i have a tacho output from the motor. So my program structure involves 2 interrupts. I have the chip running on 8MHz and I have one of the counters running at 1MHz and firing an interrupt every 50 counts and counting up a variable up so that I have a "clock" that ticks every 50uS. So every time a tacho signal is received it looks up the current "time" and stores it, so I have 2 variables storing tacho "times" and at each time the tacho interrupt fires I shift the current value into a "last time" variable and store the new value in the current one so that at any time i can with a separate function called from my main program loop do the math to work out the time between pulses and deduce motor speed and decide what to do about it.
OK, just some quick thoughts, your mileage may vary.
1. Get rid of the timer interrupt in this form. Do the counting in a hardware counter and only interupt on overflow. Maintain overflow count in SW but the rest of the count in HW that you read only when you actually need the count.
2. You only need the tacho count when you are going to also do something about it. So in principle you should decide on the speed controller cycle time and get your input in sync with that cycle. Anything faster is busy work that gets you nowhere.
I don't wish to design this thing for you but assuming you have a regular PID type speed controller, then this task is reduced to something like this:
- The RTOS scheduler clock is a natural base for the controller cycle time. At least in FreeRTOS you can hook up a tick procedure to run at every scheduler tick regardless of what task is otherwise selected to run. The tick procedure is a natural place to put your PID controller(s) so they run once every tick without exception. Thus your controller cycle time is the same as your OS tick time.
- set up one HW counter to be your timebase for the speed measurement. That counter can increment _real_fast_ to provide good time resolution (in a recent rev counter project i had the timebase at 50 ns, i.e. counting the 20MHz xtal straight). Use counter overflow interrupts only to update a RAM variable to maintain the high word of the count when tacho speed is slow. The low word count is incremented in HW directly.
- tacho pulses you can either count in SW or HW depending on the max pulse frequency and what HW you have available (some AVRs have HW event pipelines and DMA channels that could dramatically speed up processing by delegating stuff to HW). Also some MCUs such as Atmel XMega have a quadrature encoder input built in. You can decrease the interupt load by reading the counts mainly synced to the scheduler ticks but also by interrupting on a tacho pulse and only then reading the timebase counter. There are various ways to do it and to trade off processor load to accuracy or the other way around.
So you will be using interrupts, OS or no OS, but the usage will perhaps be a bit more coordinated and definitely supported by the OS if you know how to do it "right".
Does an application like this benefit from an OS of any sort or am i already doing the best I can do ?
I hope you got from the above that the way you do it now is far from optimal whether you have an OS or not. Again it is just me but i would definitely consider one of the OSes i have mentioned.
unless i can find an ARM based chip that will run at low and high temperatures (125+C) I'm stuck with something like atmels AVR32 which has only one part that is automotive rated.
Good news is that an official FreeRTOS port exists for AVR32 MCUs, at least UC3A.