正交编码器
控制连接到 Arduino® 硬件的正交编码器
正交编码器是增量编码器,可用于测量旋转轴的速度和方向。它们将轴的角度旋转转换为数字脉冲,告诉您轴的移动方向。通过测量脉冲之间的时间差,您可以得出速度。您可以在双向位置感测和长度测量应用中使用正交编码器。您可以解码正交信号,将其用作系统的传感输入,以确定旋转设备的速度、加速度和位置。三种解码类型 - X1、X2 和 X4 - 在每个旋转周期分别提供 1、2 或 4 个脉冲。仅支持 X4 解码,因为它提供最高的准确性和角度分辨率。
在使用正交编码器函数之前,请使用 arduino
创建一个 Arduino 对象。有关详细信息,请参阅 Connect to Arduino Hardware。
函数
rotaryEncoder | Connection to quadrature encoder on Arduino or ESP32 hardware |
resetCount | Set count value to zero or user-specified value |
readCount | Read current count value from encoder with X4 decoding |
readSpeed | Read current rotational speed |
主题
- Control Rotary Encoder Knob
This example shows how to use the MATLAB® Support Package for Arduino® Hardware to control a 12-step rotary encoder with a built-in push button.
- Steer Two-Wheel Robot
This example shows how to use the MATLAB® Support Package for Arduino® Hardware to steer a two-wheel Arduino-based robot with closed-loop control.