使用廉价器件的测电机转速电路
基于微处理器电路提供LCD显示和模拟电机转速输出。
本设计方案使用微处理器、16×2的LCD和旋转编码器,测量和显示电机转速(图1)。使用与电机轴相连的递增编码器测量电机的转轴速度,编码器提供积分脉冲,其频率与转轴速度成比例。1024脉冲旋转编码器为Hengstler 公司的RS-32-0/1024ER.11KB。可以通过计算一段tP时间内,编码器轴的转数nV,计算电机转动速度ωR。通过计算固定tP时间内,编码器产生的脉冲数nP,计算nV:对编码器有nV=nP/1024。转速为
在此,δ=60/(tP×1024) rpm表示所测转速的分辨力。本应用为获得1rpm的分辨力,使用60/1024=58.59ms作为时间基准确定周期。在本设计方案中,廉价微处理器IC1为Microchip公司的PIC16F873完成这些操作。微处理器也驱动IC2的LCD,在每分钟旋转中显示转动速度。
参考文献1中类似方式的电路,将编码器的积分脉冲用于IC1的RB0/INT输入,在脉冲上升沿产生高优先级中断。这些中断允许通过递增计数器计算nP,计数器达到固定时间tP后进行初始化。并且,
微处理器内部的8位定时器(定时器0)记录tP,对14.3 MHz的时钟频率fCLK,定时器每286?s产生一个tM(定时器中断):tM=4×28/fCLK/4=286 ?s。这个公式意味着固定时基tP需要205个定时器中断(tP/tM)。当计数器达到这个次数,根据公式计数nP确定转速。最后,这个值在LCD屏上显示。
此外,如果控制系统必须测量转速,数模转换是必需的。可以将微处理器的PWM(脉宽调制)输出用于R2组成的低通滤波器,不增加昂贵的DAC也完成这个转换。PWM信号的频率为20kHz,低通滤波器的截止频率为160Hz,大大低于PWM频率。本设计中,PWM信号的最大占空周期与1500rpm转速相应。
可以下载IC1程序的源代码,用Microchip的MPLab软件编译。可以根据使用的编码器和公式所需分辨力,改变软件中常量。
英文原文:
Circuit for measuring motor speed uses low-cost components
A microcontroller-based circuit provides both an LCD readout and an analog motor-speed output.
R García-Gil, J Castelló, and JM Espí, Escola Tècnica Superior d’Enginyeria, University of Valencia, Spain; Edited by Charles H Small and Fran Granville -- EDN, 11/8/2007
This Design Idea uses a microcontroller, a 16×2-key LCD, and a rotary encoder to measure and visualize the speed of a motor (Figure 1). You measure the rotor speed of the motor using an incremental encoder coupled to the motor shaft, which provides quadrature pulses with a frequency proportional to the rotor speed. The 1024-pulse rotary encoder is the RS-32-0/1024ER.11KB from Hengstler. You can calculate the rotational speed of the motor, ωR, by counting the number of revolutions that the encoder axis, nV, makes during a certain time period, tP. You calculate nV by counting the number of pulses, nP, that the encoder generates during this fixed period, tP: nV="nP/1024" for this encoder. And the rotational speed is