[英]Curve for stepper motor frequency ease-in
I am writing some software to control a five phase stepper motor. 我正在编写一些软件来控制五相步进电机。 The speed of the stepper motor is controlled by the frequency of a pulse I am sending to the motor controller.
步进电机的速度由我发送到电机控制器的脉冲频率控制。 My present challenge is that I want to ease-in and ease-out of movements.
我目前面临的挑战是,我想要放松和放松动作。 I am actually replicating the behaviour of some old software which I do not have the source code for.
我实际上复制了一些我没有源代码的旧软件的行为。 I have an understanding of the logic of the easing, and it behaves as so:
我理解了缓动的逻辑,它的行为如下:
For example… when the sustained speed is 693 Hz, the ease-in is 766 milliseconds long. 例如......当持续速度为693 Hz时,缓入为766毫秒。 I have sampled this ease-in curve using a Saleae logic analyzer.
我使用Saleae逻辑分析仪对这个轻松曲线进行了采样。 Here is the curve:
这是曲线:
The starting frequency is 97.77 Hz. 起始频率为97.77 Hz。 Here is a link to the actual data .
这是实际数据的链接 。 So I am trying to figure out how to implement the proper logic / formula for this in code.
所以我试图找出如何在代码中实现适当的逻辑/公式。 The following bit of code will spit out increments of Hz that are relatively close to the increments I need, but the thing I can't figure out is how to get it to repeat/hold the same
current_freq
for an increasingly long duration of time – which is what essentially creates the curve that you see in the graph. 下面的代码将吐出相对接近我需要的增量的Hz增量,但我无法弄清楚的是如何让它在相当长的时间内重复/保持相同的
current_freq
-这实质上是创建您在图表中看到的曲线。 My multiplier creating the increments is also off, but it is relatively close… 我的乘数创建增量也是关闭的,但它相对接近...
** edit – I think the below in theory works as far as adding a dimension of incrementing time to hold the stepping up current_freq
, but there's something wrong with my implementation... it's just doing each frequency once. **编辑 - 我认为下面的理论工作就是增加一个增加时间的维度来保持升级
current_freq
,但是我的实现有些问题......它只是做了一次每个频率。
current_freq = 97.
end_freq = 1134
t = 4
# number of times to send the current freqency
print current_freq
while current_freq < end_freq:
i = 1
t = t+t * .1673
print i
while i <= t:
print current_freq
i = i+1
break
current_freq = current_freq + current_freq * .1673
Any ideas? 有任何想法吗? Is this a logarithm?
这是对数吗? Sin or cos?
罪还是cos? In case it isn't blatantly obvious I am horrible at math.
如果它没有明显的明显,我在数学上很可怕。
If you are trying to print out the new frequency multiple times, just remove the line with break
. 如果您尝试多次打印新频率,只需删除中
break
。
This code produces the output that follows. 此代码生成后面的输出。
current_freq = 97.
end_freq = 1134
# number of times to send the current freqency
t = 4
while current_freq < end_freq:
i = 1
t = t + t * .1673
print("t=%10f" % (t))
while i <= t:
print("i=", i, end=' ')
print(" freq %.2f" % current_freq)
i = i + 1
#break
current_freq = current_freq + current_freq * .1673
Output (truncated) 输出(截断)
t= 4.669200
i= 1 freq 97.00
i= 2 freq 97.00
i= 3 freq 97.00
i= 4 freq 97.00
t= 5.450357
i= 1 freq 113.23
i= 2 freq 113.23
i= 3 freq 113.23
i= 4 freq 113.23
i= 5 freq 113.23
t= 6.362202
i= 1 freq 132.17
i= 2 freq 132.17
i= 3 freq 132.17
i= 4 freq 132.17
i= 5 freq 132.17
i= 6 freq 132.17
t= 7.426598
i= 1 freq 154.28
i= 2 freq 154.28
i= 3 freq 154.28
i= 4 freq 154.28
i= 5 freq 154.28
i= 6 freq 154.28
i= 7 freq 154.28
t= 8.669068
i= 1 freq 180.10
i= 2 freq 180.10
i= 3 freq 180.10
i= 4 freq 180.10
i= 5 freq 180.10
i= 6 freq 180.10
i= 7 freq 180.10
i= 8 freq 180.10
t= 10.119403
i= 1 freq 210.22
i= 2 freq 210.22
i= 3 freq 210.22
i= 4 freq 210.22
i= 5 freq 210.22
i= 6 freq 210.22
i= 7 freq 210.22
i= 8 freq 210.22
i= 9 freq 210.22
i= 10 freq 210.22
t= 11.812379
i= 1 freq 245.40
i= 2 freq 245.40
i= 3 freq 245.40
i= 4 freq 245.40
i= 5 freq 245.40
i= 6 freq 245.40
i= 7 freq 245.40
i= 8 freq 245.40
i= 9 freq 245.40
i= 10 freq 245.40
i= 11 freq 245.40
.
.
.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.