• AVR Freaks

Hot!Does Mathematical Calculations need Analysis

Author
microLearner
Junior Member
  • Total Posts : 104
  • Reward points : 0
  • Joined: 2017/02/27 20:26:37
  • Location: 0
  • Status: offline
2019/06/22 10:35:13 (permalink)
0

Does Mathematical Calculations need Analysis

This is the motor critical application. Generally my tendency if i see any mathematical calculation example to do RPM calculation is declare variables in terms float and simply multiply, divide etc. Is it a bad tendency? Should i always plan how to do these calculations using either fixed point etc or take help of existing libraries or write myself some assembly level instructions etc. Please advise.
#1

2 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 2888
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: online
    Re: Does Mathematical Calculations need Analysis 2019/06/22 10:55:12 (permalink)
    5 (3)
    It's not the best idea to use float math on microcontrollers without an FPU: float math consumes way more computing power than integer/fixed point math.
    Assembly programming is usually not necessary - the C compiler is quite efficient.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    Aussie Susan
    Super Member
    • Total Posts : 3608
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Does Mathematical Calculations need Analysis 2019/06/23 19:32:44 (permalink)
    5 (2)
    As du00..1 says, you need to understand your problem and then determine the domain/range of the various values. Once you know that, you can typically perform the calculations using fixed-point integer maths.
    As you mention this in the dsPICxxx forum, if you really need fast maths then use the DSP core - there are built-in functions that help with the assembler side of that. If you use Q1.15 format (or some other Q format variant of your choosing) then there are functions that help you there as well.
    Susan
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5