better-tool-library icon indicating copy to clipboard operation
better-tool-library copied to clipboard

Enhancement Idea: Plot the Machine's power curve

Open jbaehr opened this issue 1 year ago • 1 comments

When defining a machine, one can enter the rpm range and the max torque (at a given rpm; one only of the values is required; the other follows with P=2πM) With these values it should be possible to plot the spindle's theoretical power curve. This would give a nice addition to the current dialog.

Example for a small 250W BLDC spindle with 85% efficiency... image ... generated from this python code

import matplotlib.pyplot as plt
import numpy as np

n_min=10000
n_nom = 15000
n_max = 30000

P = 250 * 0.85
M = P / (2*np.pi * n_nom/60)

n_low = np.arange(n_min, n_nom, 100)
n_high = np.arange(n_nom, n_max, 100)
n = np.concatenate([n_low, n_high])
p = np.concatenate([
    2*np.pi * M * n_low/60,
    P + 0*n_high])
m = np.concatenate([
    M + 0*n_low,
    P / (2*np.pi * n_high/60)])

fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.set_xlabel('Spindle Speed / rpm')

ax2.plot(n, p, 'b-')
ax2.set_ylabel('Power Output / W', color='b')
ax2.set_ylim(top=230)
#ax2.grid(True)

ax1.plot(n, m, 'r-')
ax1.set_ylabel('Torque / Nm', color='r')
ax1.grid(True)

plt.show()

jbaehr avatar Jan 05 '25 23:01 jbaehr

I actually worked on that before and even finished a widget for it:

https://github.com/knipknap/better-tool-library/blob/main/btl/ui/curve.py

But the widget is not yet used by BTL, so the code is dormant. The goal was not just to display the torque curve, but also to enable more advanced curves as well, so the widget allows for editing the curve directly.

However, I never finished it, honestly mostly because I lost interest; my machine just doesn't need it for decent results and I never use that dialog after the initial one time setup. But I think it is an important feature for many spindles to enable better HSM support.

knipknap avatar Jan 06 '25 08:01 knipknap