![]() ![]() Some PWM signals with different duty cycles are shown in Figure 2.3. The duty cycle is defined as the fraction of time the signal is high: duty cycle = HIGH / (HIGH + LOW). The system is designed in such a way that (HIGH+LOW) is constant, which means the frequency is fixed. What is PWM? The basic idea of PWM is to create a digital output wave of fixed frequency, but allow the microcontroller to vary its duty cycle. Normally this can be achieved through PWM (Pulse Width Modulation). Until now I have not explained how to control speed of DC motor. Void MotorAB_Direction2(int milliseconds) Void MotorAB_Direction1(int milliseconds) Serial.println("Motor A & B: Direction 2") Serial.println("Motor A & B: Direction 1") Enable Motor A, Motor B: Constant Speed ![]() The following table describes how I bind Arduino with L298N. Do some experiments, which bring you some exciting experience. It is better to get your own hands dirty. Direction 1 can be forward or backward, it depend on how you connect to your motor. In my previous tutorial we already learned how to make the Bluetooth communication between the Arduino Board and the Smartphone using the HC-05 Bluetooth module and explained the Arduino code needed for the first example. Note: you may wondering what is Direction 1 and Direction 2. The first example is controlling a simple LED and the second one is controlling a Stepper Motor using smartphone. The following table summarizes how to operate this shield: Enable Motor 5V (Input): power for this driver boardįigure 2.2 – L298N Dual H-bridge DC Motor Driver Shield.ENB (Input): 5V enable Motor B, 0V disable Motor B.ENA (Input): 5V enable Motor A, 0V disable Motor A Connect the Bluetooth module and the servo motor: In this example we use Hardware Serial, because The Software Serial library is conflicting with Servo library.5V pin can provide 5V voltage output, which can be used to power some other sensors, e.g. Vms and GND are used to connect external power source, which can be in the range from 6V to 35V. In the middle of this board’s right side, there are three pins: Vms, GND, and 5V. ![]() In this picture, red is the positive end and black is the GND end for the motors. On this board it did not tell me which one is the positive or GND terminal, so I just hook it up the same way for both. On the hardware there are two motor connectors, which are labeled Motor A and Motor B. As the Figure 2.2 displays, this motor driver can let us drive two independent DC motors, controlling the speed and the direction of each one. If the H-bridge is put in the braking state, all residual motion caused by momentum is ceased, and the motor stops.įor this robot car I use a Dual H-bridge motor diver shield, which is based on H-bridge driver chip L298N. On the contrary, in the backward state this voltage is reversed, which leads to reverse operation of the motor. In the forward state, two diagonally opposing switches are closed, causing a positive voltage through the motor. In the open state, all the switches are open and the motor won’t spin. Figure 2.1 – H-bridge operation (Source: Exploring Arduino)Īs you can see, the H-bridge has four states: open, forward, backward and breaking. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |