Go Down

Topic: Arduino Capabilities - Lengthy equations? (Read 1 time) previous topic - next topic

NH

I wondering if the Arduino platform is capable of what I need, I think it is, but I want to check.

I need to take 3 inputs from sensors, put them through a rather long equation, then multiply by time, and arrive at a final value.  Is the Arduino capable of processing a long equation, over and over again, to display a value?  

When I say "long equation", I mean something like this (or longer):
((((X/Y+Z)^2)/((M+N/P)^3))^(1/2)+((5-G/H)/(B*H))^2)/(1-(X+Y)/Z)+(1425+R/M*C*A)^2/(((B*C*100/D)*2)^(1/2)))*T

Thanks (I'm still new to this, so please excuse my ignorance)

cubemike99

#1
Jan 04, 2011, 12:37 am Last Edit: Jan 04, 2011, 12:38 am by cubemike99 Reason: 1
Hey there. As far as I know, it should be fine. What you will have to make sure of though, is to use the right data type. For example, an unsigned int takes relatively little memory to store, but it also only has a range of 0 to about 32000. A float, on the other hand is between 3.4028235E+38 and -3.4028235E+38 and has 6-7 digits of resolution, including decimals but uses significantly more room.

What you also might encounter is a pause or slowdown in your code due to the intensive math you have to do. So if you are sampling data only, say, once every 30 min, you should be fine.

In conclusion, a dog can dig, but a backhoe is much faster. The Arduino will do it, but thats not to say it wont break a sweat.


retrolefty

#2
Jan 04, 2011, 12:45 am Last Edit: Jan 04, 2011, 12:47 am by retrolefty Reason: 1
You also have to try and avoid mixing of data types in the formula. I see lots of constant numbers being used and I believe these will default to 16 bit integer types. Also things like ^(1/2) will not give the results you would expect unless first changed to floats ^(1.0/2.0)

Anyway I'm sure it can be accomplished but lots of bear traps both large and small lie ahead for you I think.  ;)

Lefty

NH

Cool, thats good news.

Now, how fast do you think it could process this equation?  You mentioned once every 30 min is reasonable, but I'm looking for much faster.  Is once a second reasonable?  

retrolefty

#4
Jan 04, 2011, 12:48 am Last Edit: Jan 04, 2011, 12:49 am by retrolefty Reason: 1
Quote
Is once a second reasonable?


I would guess yes, a 8 bit processor running at 16mhz is not fast by todays standards, but it's not a mechanical adding machine.  ;)

Go Up