Go Down

Topic: arduino due vs arduino uno (Read 7808 times) previous topic - next topic

ignacio_matador

hi,

I developed a code which is running at 50Hz into arduino uno. It is basically arithmetic operations (+, -, x, /, sq(), sqrt). My requisitions are at least 500Hz, but  if it ran at 1khz, it will be great.

I am looking for other alternative, and i wonder if i could get it with an arduino due, launchpad tiva-c, or I need looking for other hardware with better specifications.

I guess a lot of you have reviewed the difference between both hardwares. Could you give me any recommendation or suggestion?

Thank you so much and sorry the inconveniences

regards

AdderD

#1
Aug 12, 2013, 03:10 pm Last Edit: Aug 12, 2013, 11:17 pm by Collin80 Reason: 1
It is tough to say for sure. But, here is what I can tell you:

1. I'm pretty sure the processor in the Uno will do 1 instruction per clock (for most instructions).
2. It runs at 16MHz.
3. It is 8 bit

This means that the Uno can execute 16 million 8 bit instructions per second.

The Due:
1. It is pipelined and somewhat superscalar
2. It runs at 84Mhz
3. It is 32 bit.

All of this adds up to it being able to execute around 104 million 32 bit instructions per second.

Now, neither of them have floating point support. If you are actually using sqrt then slap yourself across the face as hard as you can. Done? Now do it again. For the love of God, use a look up table. If you use a Due you'll have plenty of space to store the table. Never, ever, ever, ever use floating point on a processor that doesn't have an FPU. There is almost always a better way to do it (like, say, in fixed point integer math). The due will help here as well because it natively crunches 32 bits per operation and so will deal much more quickly with large numbers. This is on top of how much faster it already is (104MIPS as opposed to 16 MIPS).

What exactly are you trying to do? Maybe I could suggest something.

EDIT: I was trying to be a bit humorous in my reply but it probably does sound rude... Don't take it personally.

tbit

Wow I found that response kinda rude but kinda funny at the same time  ]:D :smiley-mr-green: ...but good advice.
Dan - www.togglebit.net - Arduino DUE proto shields - Arduino DUE CAN shields

ignacio_matador

Hi,

Don't worry for the answer, i found it funny. All my variables are double, and i would no like to lose precision. I found some alternatives using assembly, but i don't know how to combine assembly and c under arduino.

It seem that sqrt, division, sq and pow make slow my code. I have a couple of hundred of each. What it is your recomendation then?

I am developing some models :-D

Thank u so much for your coments


AdderD

Unfortunately the use of double precision floating point variables on a Uno will really slow things down. To make matters worse, division and square roots are long operations in floating point. It sounds like you need precision and that's a problem. If you could deal with loss of precision then switching to 64 bit long integers (using them as fixed point numbers) and using look up tables for the hard functions like sqrt would make things a lot faster. The Due can crunch 32 bit numbers in a single cycle and I believe even has op codes for operations that yield 64 bit numbers. But, it has no floating point support at all.

So, I guess my suggestion is this:

1. If precision is important to you then find a processor that does have an FPU. Some ARM Cortex chips do have FPU. You could probably use a BeagleBone Black or Raspberry Pi.

2. If you can lose some precision then use 64 bit integers. A 64 bit signed integer has a range of about +/- 9,223,372,036,854,775,808. Let's say you know that none of your numbers is ever more than +/- 8000. Then you could easily support 15 digits of precision to the right of the decimal point. That's pretty precise. Just for reference, 32 bit integers are +/- 2,147,483,648 which means if you knew you were going to stay within +/- 2000 you could have 6 digits of decimal precision. That's probably not enough though, is it? If it is then you're in luck because the Due will be really screaming fast.

If you go with #2 then precalculate a look up table of around 1024 or 2048 sqrt values. You won't have to precalculate divisions because they'll be hardware accelerated and you can probably get away with doing powers in a tricky way too. If you only need integer powers then that's pretty easy.

ignacio_matador

really thank you so much for your replies.

I am thinking about migrating to beaglebone black as u said. I would like to programing in C, i guess this is not a problem, and i need 4 AO, so i am planning to use pwm and a dac (any recommendation about any dac circuit?). Could you give your feedback about that? do you think it will be a good solution?

thank you so much

Go Up