---+ Controlling the DC motors The motors cannot be driven by the Arduino PWM outputs directly but they must pass through a motor driver boosting the signal power In our case an [[http://www.st.com/content/ccc/resource/technical/document/datasheet/82/cc/3f/39/0a/29/4d/f0/CD00000240.pdf/files/CD00000240.pdf/jcr:content/translations/en.CD00000240.pdf][ L298N ]]bridge is used, which is well described on [[http://www.instructables.com/id/Arduino-Modules-L298N-Dualhttp://www.instructables.com/id/Arduino-Modules-L298N-Dual-H-Bridge-Motor-Controll/-H-Bridge-Motor-Controll/][this page]]. This table shows how the driver module is connected to the Arduino Uno: <table cellpadding="4" cellspacing="0" style="width: 510px; height: 68px;"><col width="43*"></col> <col width="43*"></col> <col width="43*"></col> <col width="43*"></col> <col width="43*"></col> <col width="43*"></col> <tbody> <tr valign="top"> <td width="17%"> <p align="center">EN A</p> </td> <td width="17%"> <p align="center">IN 1</p> </td> <td width="17%"> <p align="center">IN 2</p> </td> <td width="17%"> <p align="center">IN 3</p> </td> <td width="17%"> <p align="center">IN 4</p> </td> <td width="17%"> <p align="center">EN B</p> </td> </tr> <tr valign="top"> <td height="19" width="17%"> <p align="center">%BLUE%11%ENDCOLOR%</p> </td> <td width="17%"> <p align="center">10</p> </td> <td width="17%"> <p align="center">9</p> </td> <td width="17%"> <p align="center">7</p> </td> <td width="17%"> <p align="center">6</p> </td> <td width="17%"> <p align="center">%BLUE%5%ENDCOLOR%</p> </td> </tr> </tbody> </table> The following pins on the Arduino Uno are PWM pins: 3,5,6,9,11 The IN1-IN4 pins define the direction of the movement and the EN pin, which is a PWM signal, controls the speed. Then controlling the robot through Bluetooth then the PWM pins allow me to have values between 0 and 255. However, the motors need a certain current before they start moving. Since the motor values sent through the protocol are 9 bits (10 bit ADC on the Arduino but forward and backward on a single joystick potentiometer) I shift the forward or backward value by 1 bit and I and it with 0xC0. After that I add the left/right value shifted right by 2 bits which should allow me to increase the speed of one wheel with respect to the other and thus turn left or right. -- %USERSIG{UliRaich - 2017-11-21}% ---++ Comments %COMMENT%
This topic: Embedded_Systems
>
WebHome
>
RobotKit
>
RobotSoftware
>
ControlOfTheDCMotor
Topic revision: r4 - 2017-11-24 - uli
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback