This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5529 usb开发板 ADC

uint8_t Wheel_getPosition(void)
{
    uint8_t position = 0;
    Wheel_getValue();
    //determine which position the wheel is in
    if (positionData > 0x0806)
        position = 7 - (positionData - 0x0806) / 260;  //scale the data for 8 different positions
    else
        position = positionData / 260;
    return position;
}
下面这句不懂:
    if (positionData > 0x0806)
        position = 7 - (positionData - 0x0806) / 260;  //scale the data for 8 different positions
为什吗是0X0806
  • 我明白了,这个是经验值,为了齿轮电位器能更接近翻两页,如果是0X7FF,可能误差大了点,不知是不是正确

  • 这段程序是用来判断滚轮位置的。

    那个滚轮是一个可调电位器。positionData是一个电压的采样值。

    0x0806的选取可能考虑了很多方面,比如容易处理数据、最小电阻等情况,你也可以试着换成其他值的。