Go Down

Topic: Will two Arduinos work better for the multi-tesks project (Read 384 times) previous topic - next topic

maxiexc

Hello everyone

My friends and I are currently working one a Tricoptor project. And our original goal is to have an 100Hz update rate( Which we find impossible on AVR later). While tuning PID, we found that our system only maintain an update rate about 30Hz, Which is a little bit not   enough.

I'm wondering that, beside using Arduino DUE to gain faster update rate. Will using two Arduino like MEGA+NANO be an option? If so, how should I divide my code to get better performance. Our project currently have five part: receiving control signal( by Serial through wireless ), getting MPU 6050's signal( by I2C), PID calculating and ESC& servo signal output.

Although I think divide the whole process into two Arduino is a workable plan, but I have no clue on which part should I divide, It will be great idea if anyone can give me an suggestion.   

AWOL

Quote
If so, how should I divide my code to get better performance.

Put lines 100 to 237 on processor 1, and all the rest on processor 2.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

bigred1212

If you make it 100 to 238, then you can take advantage of the Parson's coefficient.  Might help with speed.

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

maxiexc


Put lines 100 to 237 on processor 1, and all the rest on processor 2.

Is this even possible? All I know is I can put different calculation to different processor. Can I ignore the structure and divide it by lines?

PeterH

There is an Ardu-IMU project which gives you a self-contained solution to manage the IMU and take care of all the complex number crunching required to deal with that. That would give you a known efficient working solution for the most complex part of your project, leaving your main Arduino and whatever sketch you're running on it to just deal with the closed loop control algorithm. You'll need to read up on the Ardu-IMU and see what sort of update frequency it can achieve - your 100 Hz target seems pretty hard to me, but perhaps it's possible; if not, re-check the analysis that told you 100Hz was necessary, because you may have set the requirements harder than they need to be.
I only provide help via the forum - please do not contact me for private consultancy.

Grumpy_Mike



Put lines 100 to 237 on processor 1, and all the rest on processor 2.

Is this even possible? All I know is I can put different calculation to different processor. Can I ignore the structure and divide it by lines?

They are taking the piss because of your piss poor question. No detailes no sensible answer.

Quote
getting MPU 6050's signal( by I2C),

That is your bottle neck use the I2C master libary, this allows you to up the speed of the bus to 400KHz and beyond if your device can take it. You have got pull up resistors on the bus lines haven't you?
Forget two processors.

joe mcd

Quote
While tuning PID, we found that our system only maintain an update rate about 30Hz, Which is a little bit not   enough.


The first rule of performance tuning: find out where the time is spent.  Actually this rule  is also rules 2,3,4,5,6,7,8,9, etc.
Do not guess!  Human intuition on computer performance is very unreliable.  Measure, measure, measure!

For the Arduino simply have a few long variables, e.g.  loopStart, loopMid, LoopWhatever, .,,.
Assign loopStart = micros();  and so forth.  At the end of the loop print the values (not in the loop!).
By this method you will find the actual bottleneck - not somebody's guess.

I did performance tuning for a living, I ALWAYS start with rule #1.

Joe





Grumpy_Mike

Quote
I did performance tuning for a living, I ALWAYS start with rule #1.

I would rather start with rule #4.  ;)

Go Up