# Look up table or function

Hello!

In the nearby future, I will test a DC motor and plot his current to torque ratio. Which depends on the PWM frequency due to the inductance of the motor.

For my project(inverted pendulum) I will calculate the force/torque needed for control, therefore, my idea was to use a Look Up Table and some interpolation to get the correct PWM frequency. Im thinking in an array of 100 values.

Second idea in mind is plotting the torque graph and use a fitting tool to subtract the function and use this for calculating the PWM frequency. My guess is that this will be a 4th order spline

The question is:
Which would be faster? A lut or the mathematical calculation?

Edit: More background info
The pendulum is on a linear rail and moved with a timing belt and a reduction to the DC motor.

I want to measure the torque because I've noticed that when I run at high PWM frequency 10kHz+ the ON time is to short to produce a linear torque because of the motors time constant. A very low PWM frequency gives adds a lot of resistance in the coil and therefore dissipates a lot of energy and also horrible sounds. So my plan was to play with different PWM frequency's and get a full understanding of what happens.

The lut or function will be used when a low force is needed so that the corresponding PWM frequency can be determined.

Koenzo:
Hello!

In the nearby future I will test a DC motor and plot his voltage to torque ratio. Which depends on the pwm frequency due the inductance of the motor.

For my project(inverted pendulum) I will calculate the force/torque needed for control therefore my idea was to use a lut and some interpolation to get the correct pwm signal. Im thinking in an array of 100 values.

Second idea in mind is plotting the torque graph and use a fitting tool to subtract the function and use this for calculating the pwm signal. My guess is that this will be a 4th order spline

The question is:

Which would be faster? A lut or the mathematical calculation?

First get your project properly defined. Motor torque is dependent on current, not voltage. Unless you have an extremely weak power source, the voltage should remain fairly constant.

If you are using PWM to power the motor, then you must measure the current when the voltage is high, and not continuously.

Paul

Paul_KD7HB:
First get your project properly defined. Motor torque is dependent on current, not voltage. Unless you have an extremely weak power source, the voltage should remain fairly constant.

If you are using PWM to power the motor, then you must measure the current when the voltage is high, and not continuously.

Paul

That's my bad, true that current is proportional to the torque. I'm gonna change it so that other readers won't get confused.
Secondly I will measure the output force with a strain gauge since the exact motor parameters are not known.

I don't understand how you want to apply the strain gauge and wires to a turning motor. A stalled motor has characteristics very different from a running motor.

Also consider your input (feedback) from the pendulum and its dynamic behaviour. It won't help much to interpolate values from a static table, instead you'll need a (PID...) regulator for stabilizing the pendulum.

A DC motor is an inductance, i.e. it tries to keep its current constant. That's why a high PWM frequency may not have the desired effect, because during gaps the current continues flowing through the clamping diodes of the driver board.

Also the dependency between duty cycle and torque is not fixed, it also depends on the motor rpm and load. I bet that you'll notice that yourself, when you continue with the construction and use of your table.

Thanks for you're response, it is a learning curve for sure!

But on-topic what would be better/faster? I have read some posts about sin(x) functions :

He states that the price you pay is accuracy, but there rises the question of what accuracy the sin(x) function gives/ how discrete is this?

in short, is a function like y(x) = ax^4 + bx^3 + cx^2 + dx better or worse than a LUT where x is predefined.

If the table is small enough to fit into memory, and the steps are fine enough, then a table lookup is much faster than an expression evaluation. Often a combined table and interpolation function, like used for sin(x), will match both space and accuracy requirements.