简体   繁体   English

如何增加 HID 轴的范围? (几度后方向盘达到极限)

[英]How could I increase the range of an HID axis? (steering wheel hits limit after a few degrees)

I have an encoder that gives 4300 increments per rev.我有一个编码器,每转可提供 4300 个增量。 And I need at least 3 turns in either direction.我需要在任一方向上至少转 3 圈。 (for a steering wheel) However, when I turn it just a bit, it already hits the extremums. (对于方向盘)但是,当我稍微转动它时,它已经达到了极值。 This is after a few degrees clockwise:这是顺时针几度后:

在此处输入图像描述

This is my descripor:这是我的描述:

在此处输入图像描述

My code:我的代码:

  while (1)
  {
      steer.direction = position - position_p;
      position_p = position;

      USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, &steer, sizeof(steer));
      HAL_Delay(5);
  }

I have tried using an absolute value.我尝试过使用绝对值。 With 8 bits it just overflows after a few degrees and comes back to the opposite extremum.对于 8 位,它只是在几度后溢出并返回到相反的极值。 Maybe 16 bits could solve that but I can't get it to work that way.也许 16 位可以解决这个问题,但我无法让它以这种方式工作。

I managed to use a 16 bit absolute position.我设法使用了 16 位绝对 position。 I think it didn't work because the "send" function only took 8-bit values.我认为它不起作用,因为“发送” function 仅采用 8 位值。 So I've split the 16 bit variable into a 2x8-bit array.因此,我将 16 位变量拆分为 2x8 位数组。 (im using cubeIDE) (我使用立方体IDE)

  steer.direction[0] = position & 0x00FF;
  steer.direction[1] = position >> 8;

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Teensy Arduino作为Android HID设备,经过几次输入后停顿 - Teensy Arduino as Android HID Device, stalls after a few inputs 如何在 HID 移动到 Windows 上的不同端口后识别它 - How to identify a HID after it's moved to a different port on Windows 如何在 USB HID 报告中发送重音字符和 unicode - How can I send accented characters and unicode in a USB HID report 如何使用libusb-1.0接收HID报告? - How do I receive HID reports using libusb-1.0? 如何调试未附带驱动程序的USB HID设备? - How can I debug a USB HID device that does not come with a driver? 如何从USB HID设备读取输入? - How do I read input from a USB HID device? 我有2个相同的HID USB设备,每个设备都有其自己的控制程序,每个程序如何知道那里有哪个HID设备? - I have 2 identical HID USB devices, each one has it's own control program, how can each program know which HID device is theres? 如何检查我的条形码扫描仪是否符合USB HID POS扫描仪规范? - How do I check if my barcode scanner adheres to the USB HID POS Scanner specification? 如何从ASP.NET应用程序中连接到服务器端USB(HID)设备? - How can I connect to a Server Side USB (HID) Device from within an ASP.NET Application? 如何在 GadgetFS 中指定 HID 报告 - How to specify the HID Report in GadgetFS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM