定时器用在编码器模式时,使用另一个配置为捕获模式的定时器测量两个编码器事件之间的周期,可获得动态信息(速度、加速度和减速度):
The timer, when configured in Encoder Interface mode provides information on the sensor’s
current position. You can obtain dynamic information (speed, acceleration, deceleration) by
measuring the period between two encoder events using a second timer configured in
capture mode. The output of the encoder which indicates the mechanical zero can be used
for this purpose. Depending on the time between two events, the counter can also be read
at regular times. You can do this by latching the counter value into a third input capture
register if available (then the capture signal must be periodic and can be generated by
another timer). when available, it is also possible to read its value through a DMA request
generated by a real-time clock.
The timer, when configured in Encoder Interface mode provides information on the sensor’s
current position. You can obtain dynamic information (speed, acceleration, deceleration) by
measuring the period between two encoder events using a second timer configured in
capture mode. The output of the encoder which indicates the mechanical zero can be used
for this purpose. Depending on the time between two events, the counter can also be read
at regular times. You can do this by latching the counter value into a third input capture
register if available (then the capture signal must be periodic and can be generated by
another timer). when available, it is also possible to read its value through a DMA request
generated by a real-time clock.
个人是汽车工程专业的,刚刚好接触过一些,不过是高转速的,这里我也说说我的思路。
首先从楼主的想法说起,有什么弊端呢,通过转接的方式楼主只能得出理论转速,而不是实际转速,但是楼主说了是低速电机,那应该问题不大。因为高速时电机输出脉冲和实际转速之间要考虑摩擦,振动,以及高速下发热问题。
还是那句话,低速楼主的方案可行,主要是要解决两个定时器的问题。
这个查阅用户手册,进行配置就好了,两个定时器同时用是没有什么问题的,至于你用寄存器还是库版本就个人爱好了。
定时器计算脉冲,但是它是不会知道脉冲是哪里来的,你配置好了相关功能,他就只会计数。
当定时器配置成编码器接口模式时,提供传感器当前位置的信息。使用第二个配置在捕获模式的定时器,可以测量两个编码器事件的间隔,获得动态的信息(速度,加速度,减速度)。指示机械零点的编码器输出可被用做此目的。根据两个事件间的间隔,可以按照固定的时间读出计数器。如果可能的话,你可以把计数器的值锁存到第三个输入捕获寄存器(捕获信号必须是周期的并且可以由另一个定时器产生);也可以通过一个由实时时钟产生的DMA请求来读取它的值。
当定时器配置成编码器接口模式时,接口提供了传感器当前位置的信息。使能另一个定时器,将编码器的第3个信号(机械零)连接1外部中断,在中断中,读取定时器的技术值,就可以获得动态的速度、加速度、减速度的信息。
这种接法感觉是完全可以的,只要在两个外设中不要有长时间占用的情况就应该不会有问题。
可以接,一个计数,一个测脉宽,如果脉冲幅度较小需要通过脉冲分配器,如果脉冲信号幅度足够大就可以连接
但是软件处理需要做好,不能让两个数据发生冲突