Motors control

The Adafruit Motor shield V2 have the TB6612 MOSFET drivers with 1.2A per channel current capability (can draw up to 3A peak for approx 20ms at a time). It also has much lower voltage drops across the motor so you get more torque out of your batteries, and there are built-in flyback diodes as well.

The shield is a stackable board that can sit on top of the Arduino. Instead of using a latch and the Arduino's PWM pins, the board have a fully-dedicated PWM driver chip onboard. This chip handles all the motor and speed controls over I2C.

The two motor can be controlled from ROS 2 via the JETTY transport layer on top of the serial link. The Arduino receives the control command/frame from ROS 2 which consists of two integers corresponding to the speeds of the left and right motor. Negative/positive value means the motor going backward/forward.

These values will then be translated to direction and PWM speed signals which will be written to the Adafruit Motor Shield V2 via the I2C interface. On Jarvis, the two motors are attached to the M2 and M3 inputs of the Motor shield. Example motor control via the Adafruit Motor Shield V2 library :

// include the lib
#include <Adafruit_MotorShield.h>

// create a motor object
Adafruit_DCMotor *M2 = AFMS.getMotor(2);
M2->setSpeed(speed); // 0 - 255
M2->run(FORWARD); // or BACKWARD


The comment editor supports Markdown syntax. Your email is necessary to notify you of further updates on the discussion. It will be hidden from the public.
Powered by antd server, (c) 2019 - 2024 Dany LE