将 i2c smartdrive 传感器与 Pio Cli 命令一起用于 运行 电机
Using the i2c smartdrive sensor with a Pio Cli commands to run motors
这是我的 i2c 传感器:http://www.mindsensors.com/rpi/76-smartdrive-high-current-motor-controller请在文档会话中查看 pdf
基于此 google 指南 https://developer.android.com/things/sdk/pio/pio-cli.html 我需要将 XX ZZ YY UU 放入 运行 确定速度、方向、持续时间等的电机...
例如:pio i2c I2C1 0x1B 写入寄存器缓冲区 0xXX 0xYY 0xUU 0xZZ
因为(在这种情况下)我将在我的 android things 应用程序上使用 writeRegBuffer() 来 运行 一个、两个或两个电机确定速度、方向、持续时间等?
例如:我(通过 jcenter)在 intel edison/android things DP2 中使用了这个驱动程序,但现在我想创建一个 AT 驱动程序以在 nx pico 和 rpi 3 中使用 smartdrive,因为不会再有mraa:
https://github.com/androidthings/contrib-drivers/issues/70
我的问题是:如果你看到这里:https://github.com/intel-iot-devkit/upm/blob/master/src/smartdrive/smartdrive.hpp
尤其是在这方面:https://github.com/intel-iot-devkit/upm/blob/master/src/smartdrive/smartdrive.cxx
在函数中
SmartDrive::Run_Seconds(int motor_id, int direction, uint8_t speed, uint8_t duration, bool wait_for_completion, int next_action )
你会看到writeArray(array, sizeof(array));
好的。我需要帮助才能在使用 writeRegBuffer(int reg, byte[] buffer, int length)
和 write(byte[] buffer, int length)
的 android 中使用它
根据您链接的 PIO CLI tool 文档,i2c
命令的格式为:
$ pio i2c <bus_name> <slave_address> <command> <reg> <val>
您的电机控制器的默认从地址为 0x36 并使用寄存器。例如,您可以像这样使用此工具写入 "Motor 1 Speed" 寄存器(地址 0x46):
$ pio i2c I2C1 0x36 write-reg-byte 0x46 <speed_value>
代码中的相同操作如下所示:
PeripheralManagerService manager = new PeripheralManagerService();
I2cDevice device = manager.openI2cDevice("I2C1", 0x36);
device.writeRegByte(0x46, speed);
运行电机1在A方向
pio i2c I2C1 0x1B 写原始 0x46 128 0x05 0x00 0xD1
运行电机1在B方向
pio i2c I2C1 0x1B 写原始 0x46 127 0x05 0x00 0xD1
运行电机2在A方向
pio i2c I2C1 0x1B 写原始 0x4E 128 0x05 0x00 0xD1
运行电机2在B方向
pio i2c I2C1 0x1B 写原始 0x4E 127 0x05 0x00 0xD1
这是我的 i2c 传感器:http://www.mindsensors.com/rpi/76-smartdrive-high-current-motor-controller请在文档会话中查看 pdf
基于此 google 指南 https://developer.android.com/things/sdk/pio/pio-cli.html 我需要将 XX ZZ YY UU 放入 运行 确定速度、方向、持续时间等的电机...
例如:pio i2c I2C1 0x1B 写入寄存器缓冲区 0xXX 0xYY 0xUU 0xZZ
因为(在这种情况下)我将在我的 android things 应用程序上使用 writeRegBuffer() 来 运行 一个、两个或两个电机确定速度、方向、持续时间等?
例如:我(通过 jcenter)在 intel edison/android things DP2 中使用了这个驱动程序,但现在我想创建一个 AT 驱动程序以在 nx pico 和 rpi 3 中使用 smartdrive,因为不会再有mraa:
https://github.com/androidthings/contrib-drivers/issues/70
我的问题是:如果你看到这里:https://github.com/intel-iot-devkit/upm/blob/master/src/smartdrive/smartdrive.hpp 尤其是在这方面:https://github.com/intel-iot-devkit/upm/blob/master/src/smartdrive/smartdrive.cxx 在函数中
SmartDrive::Run_Seconds(int motor_id, int direction, uint8_t speed, uint8_t duration, bool wait_for_completion, int next_action )
你会看到writeArray(array, sizeof(array));
好的。我需要帮助才能在使用 writeRegBuffer(int reg, byte[] buffer, int length)
和 write(byte[] buffer, int length)
根据您链接的 PIO CLI tool 文档,i2c
命令的格式为:
$ pio i2c <bus_name> <slave_address> <command> <reg> <val>
您的电机控制器的默认从地址为 0x36 并使用寄存器。例如,您可以像这样使用此工具写入 "Motor 1 Speed" 寄存器(地址 0x46):
$ pio i2c I2C1 0x36 write-reg-byte 0x46 <speed_value>
代码中的相同操作如下所示:
PeripheralManagerService manager = new PeripheralManagerService();
I2cDevice device = manager.openI2cDevice("I2C1", 0x36);
device.writeRegByte(0x46, speed);
运行电机1在A方向 pio i2c I2C1 0x1B 写原始 0x46 128 0x05 0x00 0xD1
运行电机1在B方向 pio i2c I2C1 0x1B 写原始 0x46 127 0x05 0x00 0xD1
运行电机2在A方向 pio i2c I2C1 0x1B 写原始 0x4E 128 0x05 0x00 0xD1
运行电机2在B方向 pio i2c I2C1 0x1B 写原始 0x4E 127 0x05 0x00 0xD1