Their price is similar 25 euros for Arduino Uno (from farnell) and 29 Euros for ChipKit Uno32.
However the hardware specs are much better for ChipKit (32 bit controller compared to only 16 bit for arduino. Also ChipKit has a higher frequency - 80 MHz compared to only 16 MHz).
I have run a simple program which counts the number of prime numbers smaller than a limit.
You may find the test program at the end of this post. The same program was run on both platforms.
Results are as follows:
------------------------------prime numbers smaller than 10000
Arduino Uno:
- Duration: 2375 miliseconds
- Count primes: 1229
- Duration: 98 miliseconds.
- Count primes: 1229
prime numbers smaller than 20000
Arduino Uno:
- Duration: 5757 miliseconds.
- Count primes: 2262
- Duration: 204 miliseconds.
- Count primes: 2262
prime numbers smaller than 30000
Arduino Uno:
- Duration: 9737 miliseconds.
- Count primes: 3245
- Duration: 323 miliseconds.
- Count primes: 3245
As you can see on the largest test, ChipKit is 30x faster than Arduino.
I could not test on significantly larger numbers because Arduino is only 16bits microcontroller (the largest number that can fit is 2^16).
The program is:
------------------------------bool isPrime(int p){
if ( p == 2 ) return true;
if ( p > 2 ){
int m = sqrt(p);
for(int i = 2; i <= m; ++i){
if (p%i==0) return false;
}
return true;
}
}
unsigned long time_start, time_stop, runtime;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
int run_once = 0;
void loop(){
if (!run_once){
time_start = millis();
int count_primes = 0;
for(int i = 2; i <= 30000; ++i){
if (isPrime(i))
count_primes++;
}
time_stop = millis();
runtime = time_stop - time_start;
Serial.print("Duration: ");
Serial.println(runtime);
Serial.print("Count primes: ");
Serial.println(count_primes );
run_once = 1;
}
}
No comments:
Post a Comment