which MCU to use?

Hi

I built a line follower robot using Arduino Duemilanove.However the bot was slow to respond to turns at high speed and usually missed the line. its taking reading from 8 sensors and calculating the error via PID eqn.The current speed of the bot is arnd 1m/sec.It seems arduino cant handle such hefty calculations.

So i was thinking if i use Arduino mega (ATmega1280) or Sanguino powered (atmega644P) will there be a difference.

No difference WRT speed.

You should improve your algorithm.
Generally moving from float to long will give a good speed-up
Some algorithms can also be rewritten when you have more space: Table loook-up, loop unrolling,....

The bot goes 1 meter/second. That sounds pretty quick. Is that right?

Dont use floats, use ints or longs, use some sort of scaled maths, dont use delays, use direct port manipulation, no delays what so ever, show us your code so we can help you.

1m/sec sounds pretty fast to me...

But I agree that 1) the cpu speed of the arduino ought not be the limiting factor. and 2) none of the other arduino variants is going to be any faster.

1m/sec is the speed over normal track.If the track is bit curvy then it skips the lines and overshoots.Have tried to optimise the code but still it doesnt work.Seems arduino is not fast enough the process the code.

Fast line followers generally use arm mcu's.However i have no idea about them.

If the track is bit curvy then it skips the lines and overshoots

Are you sure that it's lack of controller responsiveness that is the problem? Your system will have latency in many places: the sensors, the Arduino, the motor controllers, and the physical platform itself. Even if the first three items respond in effectively 0 time, would the physical platform be capable of responding fast enough to stay on the line? If your line is (say) 1cm wide, and it suddenly bends 45 degrees, your bot only has to travel 1.4cm forwards before it has passed totally over the line and is unable to recover. At 1m/s, that's a mere 14 milliseconds of physical movement.

If your physical platform can't react in time it doesn't matter how fast the controller is.

Jon
Practical Arduino: www.practicalarduino.com

It is difficult to tell whether your code is operating "as fast as possible for the arduino" without actually seeing the code :slight_smile:

In general:

  1. Never use delay() or delayMicroseconds()
  2. Try to use integer math instead of floating point.
  3. Try to use shorter integers (bytes instead of ints, bytes or ints instead of longs)
  4. certain function calls will take longer than you might think. The most obvious example is Serial.print(), which at 9600bps will take about 1ms for each character printed. Another is analogRead(), which is synchronous and will start and A-D conversion and wait for the result rather (say) continually scanning and instantly returning the most recently read value.