Skip to main content
Mod Moved Comments To Chat
added 703 characters in body
Source Link
jDAQ
  • 2.6k
  • 1
  • 10
  • 19

What you call "up to speed" is usually called missing deadlines, and for some systems, called hard real-time systems, you have that those deadlines are critical (if you miss them someone might die or the system might be completely broken).

In your case (as I recall) your system was not even able to execute the sequence of instructions

Yi = 0.1441Ui + 0.2281Ui-1 + 0.1441Ui-2 + 0.6777Yi-1 - 0.254Yi-2 

once before getting the new data from the ADC (at the rate of 76 kHz).

First, determine how fast each of your tasks should run, in the case of that filter, does it have to run at 76 kHz? If so, write the best, "smallest in assembly", that does the job, and check which assembly instructions it use.

For each of those instructions \$i\$ you can find the usual time they take to run (the average \$ t_i\$) and the worst case scenario (never more than \$T_i\$ ). If your system is not a critical one, summing the number of each instruction, \$ N_i\$, and the time they take to run you get

$$ t_{total} = \sum_i N_i t_i,$$

$$ T_{total} = \sum_i N_i T_i.$$

Now, if you only had that task running, it would be enough that

$$ \frac{1}{T_{total}} < f_{task},$$

or if your system allows a few missed deadlines

$$ \frac{1}{t_{total}} < f_{task}.$$

But in reality, this approach is simplistic, and for system with many tasks you have to find all the needed time of all the tasks and make sure that they fit in your system, and even so, depending on how they run you might still miss a deadline by a few miliseconds or microseconds.

Rule of thumb

for a small project, calculate an estimate of \$ T_{total} \$ for the fastest (must be executed the most times per second) and more computationally demanding task, probably that filter of yours using float multiplication. Once you have that, find a microcontroller that can execute that task in less than \$\frac{1}{10}\$ of the time in between calls to that demanding task, meaning you will have \$\frac{9}{10}\$ of your time free to run other tasks.

Usually a ballpark of the number of instructions means that you can find which microcontroller will be able to run your system. And in your case, since you use floating-point numbers, having a microcontroller with a FPU.

What you call "up to speed" is usually called missing deadlines, and for some systems, called hard real-time systems, you have that those deadlines are critical (if you miss them someone might die or the system might be completely broken).

In your case (as I recall) your system was not even able to execute the sequence of instructions

Yi = 0.1441Ui + 0.2281Ui-1 + 0.1441Ui-2 + 0.6777Yi-1 - 0.254Yi-2 

once before getting the new data from the ADC (at the rate of 76 kHz).

First, determine how fast each of your tasks should run, in the case of that filter, does it have to run at 76 kHz? If so, write the best, "smallest in assembly", that does the job, and check which assembly instructions it use.

For each of those instructions \$i\$ you can find the usual time they take to run (the average \$ t_i\$) and the worst case scenario (never more than \$T_i\$ ). If your system is not a critical one, summing the number of each instruction, \$ N_i\$, and the time they take to run you get

$$ t_{total} = \sum_i N_i t_i,$$

$$ T_{total} = \sum_i N_i T_i.$$

Now, if you only had that task running, it would be enough that

$$ \frac{1}{T_{total}} < f_{task},$$

or if your system allows a few missed deadlines

$$ \frac{1}{t_{total}} < f_{task}.$$

But in reality, this approach is simplistic, and for system with many tasks you have to find all the needed time of all the tasks and make sure that they fit in your system, and even so, depending on how they run you might still miss a deadline by a few miliseconds or microseconds.

What you call "up to speed" is usually called missing deadlines, and for some systems, called hard real-time systems, you have that those deadlines are critical (if you miss them someone might die or the system might be completely broken).

In your case (as I recall) your system was not even able to execute the sequence of instructions

Yi = 0.1441Ui + 0.2281Ui-1 + 0.1441Ui-2 + 0.6777Yi-1 - 0.254Yi-2 

once before getting the new data from the ADC (at the rate of 76 kHz).

First, determine how fast each of your tasks should run, in the case of that filter, does it have to run at 76 kHz? If so, write the best, "smallest in assembly", that does the job, and check which assembly instructions it use.

For each of those instructions \$i\$ you can find the usual time they take to run (the average \$ t_i\$) and the worst case scenario (never more than \$T_i\$ ). If your system is not a critical one, summing the number of each instruction, \$ N_i\$, and the time they take to run you get

$$ t_{total} = \sum_i N_i t_i,$$

$$ T_{total} = \sum_i N_i T_i.$$

Now, if you only had that task running, it would be enough that

$$ \frac{1}{T_{total}} < f_{task},$$

or if your system allows a few missed deadlines

$$ \frac{1}{t_{total}} < f_{task}.$$

But in reality, this approach is simplistic, and for system with many tasks you have to find all the needed time of all the tasks and make sure that they fit in your system, and even so, depending on how they run you might still miss a deadline by a few miliseconds or microseconds.

Rule of thumb

for a small project, calculate an estimate of \$ T_{total} \$ for the fastest (must be executed the most times per second) and more computationally demanding task, probably that filter of yours using float multiplication. Once you have that, find a microcontroller that can execute that task in less than \$\frac{1}{10}\$ of the time in between calls to that demanding task, meaning you will have \$\frac{9}{10}\$ of your time free to run other tasks.

Usually a ballpark of the number of instructions means that you can find which microcontroller will be able to run your system. And in your case, since you use floating-point numbers, having a microcontroller with a FPU.

Source Link
jDAQ
  • 2.6k
  • 1
  • 10
  • 19

What you call "up to speed" is usually called missing deadlines, and for some systems, called hard real-time systems, you have that those deadlines are critical (if you miss them someone might die or the system might be completely broken).

In your case (as I recall) your system was not even able to execute the sequence of instructions

Yi = 0.1441Ui + 0.2281Ui-1 + 0.1441Ui-2 + 0.6777Yi-1 - 0.254Yi-2 

once before getting the new data from the ADC (at the rate of 76 kHz).

First, determine how fast each of your tasks should run, in the case of that filter, does it have to run at 76 kHz? If so, write the best, "smallest in assembly", that does the job, and check which assembly instructions it use.

For each of those instructions \$i\$ you can find the usual time they take to run (the average \$ t_i\$) and the worst case scenario (never more than \$T_i\$ ). If your system is not a critical one, summing the number of each instruction, \$ N_i\$, and the time they take to run you get

$$ t_{total} = \sum_i N_i t_i,$$

$$ T_{total} = \sum_i N_i T_i.$$

Now, if you only had that task running, it would be enough that

$$ \frac{1}{T_{total}} < f_{task},$$

or if your system allows a few missed deadlines

$$ \frac{1}{t_{total}} < f_{task}.$$

But in reality, this approach is simplistic, and for system with many tasks you have to find all the needed time of all the tasks and make sure that they fit in your system, and even so, depending on how they run you might still miss a deadline by a few miliseconds or microseconds.