Pages: [1]   Go Down
Author Topic: which MCU to use?  (Read 941 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
 

Logged

0
Offline Offline
Edison Member
*
Karma: 0
Posts: 1103
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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,....
« Last Edit: September 27, 2010, 07:18:50 am by mpeuser » Logged

NYC
Offline Offline
Full Member
***
Karma: 0
Posts: 129
The singularity is near!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Portugal
Offline Offline
God Member
*****
Karma: 6
Posts: 962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 132
Posts: 6746
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Melbourne, Australia
Offline Offline
Full Member
***
Karma: 1
Posts: 226
Cyborg-in-progress
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 132
Posts: 6746
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.
Logged

Pages: [1]   Go Up
Jump to: