Hi
I am implementing a controller but I want to compare it with some other by their calculation load.
what are the methods to do ti?
I am using matlab for design and simulation of the controller
You should get a programmer to do this, as this typically requires sufficient pseudo-code hand assemble and count instruction cycles. An experience programmer can probably look at the code and make an educated guess.
TTFN
I can do absolutely anything. I'm an expert!
faq731-376 forum1529
I put the code I want to time in a loop and read a hard ware counter before and after the loop to find the time in micro or nano seconds. Then I divide by the number of times the code was execute.
Warning. If there is a cache this method will not work if the code in question will be flush out each iteration.
Counting clock cycles may work with a DSP but modern micro controllers have long pre-fetch queues and the timing of instructions may be altered by the execution of previous instructions.
For an accurate count, for sure, but that assumes that you already have functional code, or that you are comparing two different functional codes. That might not be an option.
TTFN
I can do absolutely anything. I'm an expert!
faq731-376 forum1529