DC Motor Connections, Control and Programming.

DC Motor
Contents List
  1. Introduction
  2. What Is a DC Motor?
  3. How a DC Motor Works?
  4. Types of DC Motors
  5. Essential Motor Specifications
  6. DC Motor Connections and Wiring
  7. Choosing a Motor Driver
  8. Controlling DC Motor Speed with PWM
  9. Controlling Motor Direction with an H-Bridge
  10. Programming a DC Motor with Arduino
  11. Controlling Speed with a Potentiometer
  12. Connecting and Controlling Two DC Motors
  13. Common Applications and Hobby Projects
  14. Troubleshooting and Safety Tips
  15. Frequently Asked Questions
  16. Conclusion

Time reading 20min.

1. Introduction

A DC Motor (Direct Current motor) converts electrical energy into rotational mechanical motion. It is widely used in robotics, small vehicles, fans, pumps, conveyors, and many electronics projects because it is relatively simple to operate and easy to integrate into embedded systems.

However, connecting a DC motor to a microcontroller is not as simple as connecting an LED. Motors can draw much more current than a microcontroller pin can safely provide, especially when starting or when the shaft is blocked. A suitable motor driver and an appropriately rated power supply are therefore essential for reliable operation.

In this guide, you will learn how to identify a DC motor’s important specifications, wire it correctly, select a suitable driver, control its speed and direction, and write Arduino code to operate it. You will also learn how to troubleshoot common problems and apply these techniques to practical hobby projects.

2. What Is a DC Motor?

A DC Motor is an electrical machine that uses direct current to produce rotational motion. In a common brushed DC motor, electrical current flows through windings in the rotor, creating a magnetic field that interacts with the motor’s permanent magnets or field windings. This interaction produces torque, which rotates the shaft.

Main parts of a typical brushed DC motor:

  • Stator: The stationary part that produces a magnetic field.
  • Rotor or armature: The rotating part containing the windings.
  • Commutator: A segmented electrical contact that changes the current direction in the rotor windings.
  • Brushes: Conduct current to the rotating commutator.
  • Shaft: Transfers the motor’s rotational movement to a load.
  • Bearings: Support the shaft and allow it to rotate smoothly.

A basic two-wire brushed DC motor is easy to control: applying a suitable DC voltage makes it rotate, reversing the polarity reverses its direction, and changing the effective voltage can change its speed.

A motor’s behavior depends on its design and mechanical load. Applying a higher voltage than the rated value can cause excessive speed, current, and heat, so always follow the motor’s datasheet.

3. How a DC Motor Works?

A brushed DC motor operates through the interaction between electric current and magnetic fields. When current passes through the rotor windings, a force acts on the conductors and produces torque.

As the rotor turns, the commutator and brushes switch the current through the windings to maintain rotation in the same general direction.

Three electrical and mechanical relationships are particularly useful when designing a motor-control system.

Voltage and Speed

For a given motor, increasing the applied voltage generally increases its speed under similar load conditions. However, speed does not depend on voltage alone. Load, friction, winding resistance, motor temperature, and the driver’s voltage drop also affect the result.

Current and Torque

Motor torque is approximately proportional to armature current over the motor’s normal operating range. A heavier load usually requires more torque, which generally means more current.

When the motor is first switched on, its back electromotive force (back EMF) is initially very low. The starting current can therefore be much higher than the normal running current.

If the shaft is blocked, the motor may draw its stall current, which can damage an undersized driver, wiring, or power supply.

Back EMF

When the motor rotates, it generates a voltage that opposes the applied voltage. This is called back EMF.

As speed increases, back EMF usually increases, reducing the current needed to sustain rotation under a given load. When the motor slows down under a heavier load, back EMF falls and current generally rises.

This explains why a motor may draw a large current during startup or when heavily loaded.

4. Types of DC Motors

Different motor types require different control methods. Before selecting a driver or writing code, identify which type you are using.

Brushed DC Motor

A brushed DC motor is a common choice for beginner electronics and robotics projects. It usually has two power wires and can be controlled with a transistor or MOSFET for one-direction operation, or an H-bridge for reversing direction.

Typical uses include small fans, toy vehicles, simple robotic mechanisms, and hobby gearmotors.

Geared DC Motor

A geared DC motor combines a motor with a gearbox. The gearbox reduces output speed and increases available output torque compared with the motor shaft alone, although some power is lost through the gears.

Geared motors are useful for robot wheels, small mobile platforms, and mechanisms that need more torque at lower speeds.

Brushless DC Motor (BLDC)

A brushless DC motor uses electronic commutation instead of mechanical brushes and a commutator. It normally requires a dedicated BLDC controller or electronic speed controller (ESC).

A typical two-wire brushed-motor circuit cannot directly control a BLDC motor. Hobby drone motors, for example, commonly use three motor phase wires connected to an ESC.

Coreless DC Motor

A coreless motor uses a rotor winding without a conventional iron core. Some designs offer low rotor inertia and fast response, making them useful for small precision mechanisms. Their voltage, current, and mechanical limits still need to be checked before use.

5. Essential Motor Specifications

Before wiring a motor, check its datasheet or reliable product documentation. The following specifications help determine the correct power supply, driver, and control method.

Specification Meaning Why it matters
Rated voltage Recommended operating voltage Helps select a suitable motor supply
No-load speed Speed with little or no mechanical load Gives a reference for expected speed
No-load current Current while rotating without significant load Useful for estimating light-load consumption
Rated current Current under a specified operating condition Helps estimate normal power requirements
Stall current Current when the shaft is stopped at the specified voltage Critical when sizing the driver and supply
Rated torque Torque the motor is designed to deliver under stated conditions Helps determine whether it can move the load
Gear ratio Ratio between motor and gearbox output speed Affects output speed and torque
Operating temperature Permitted thermal operating conditions Helps prevent overheating

Important: Do not assume that a driver rated for the motor’s normal running current can also handle its stall current. Compare the driver’s continuous and peak current limits, voltage limits, and thermal requirements against the motor’s actual specifications.

Also distinguish between the motor’s rated current and its stall current. They describe different operating conditions and are not interchangeable.

6. DC Motor Connections and Wiring

The correct wiring depends on whether you need only on/off control, speed control, or speed and direction control.

Basic Two-Wire Motor Connection

A brushed DC motor usually has two terminals. Connecting a suitable DC supply across these terminals makes the motor rotate. Reversing the polarity reverses its direction.

For example, a motor rated for 6 V should normally be operated from a suitable supply near its specified operating voltage, subject to its datasheet and the requirements of the application.

This simple connection is useful for understanding motor operation, but it does not provide electronic speed control or safe microcontroller interfacing by itself.

Why You Should Not Connect a Motor Directly to an Arduino Pin?

Arduino GPIO pins are intended to provide control signals, not to supply the current required by most motors. A motor can draw excessive current, generate electrical disturbances, and produce voltage spikes that can damage the microcontroller.

Use an appropriate driver between the Arduino and the motor. The driver switches the motor’s current while the Arduino provides low-power logic signals.

Wiring a Motor Driver to Arduino

For a typical single brushed DC motor using an H-bridge module, the connections are generally as follows. Always confirm the terminal labels and logic requirements in the documentation for your particular module.

Connection Connect to
Motor output A One motor wire
Motor output B The other motor wire
Motor power input External supply suitable for the motor and driver
Driver logic supply The required logic voltage, if separate
Driver ground Power supply negative and Arduino GND
Direction inputs Arduino digital output pins
PWM or enable input A compatible Arduino PWM pin, if supported
Standby or enable control The required active state for the module

Use a common ground between the Arduino and the driver when the interface requires it. Without a shared reference, the driver may not reliably interpret the Arduino’s logic signals.

Do not assume that every module uses the same power arrangement. Some boards have separate logic and motor supplies; others include regulators or jumpers that change how the power terminals work.

Choosing a Power Supply

The supply must provide a voltage suitable for the motor and enough current for its startup and load conditions.

It must also be compatible with the driver’s voltage and current limits.

For example, a small motor rated at 6 V should not automatically be powered from a 12 V source just because the driver accepts 12 V.

The motor itself must remain within its permitted operating conditions.

Avoid relying on the Arduino’s onboard regulator or USB connection to power a motor unless the entire setup has been explicitly designed and verified for that load.

7. Choosing a Motor Driver

A motor driver is the power interface between the controller and the motor.

It allows a low-power signal from an Arduino or another microcontroller to control the higher current required by the motor.

Transistor or MOSFET Driver

For simple on/off or speed control in one direction, a suitable transistor or logic-level MOSFET can switch the motor current. The circuit must include appropriate inductive-load protection, such as a correctly rated flyback diode for a simple low-side switching circuit.

This arrangement is useful when you do not need to reverse the motor electrically.

H-Bridge Driver

An H-bridge allows current to flow through the motor in either direction. It is commonly used when an application needs forward and reverse rotation, such as a robot car.

The driver may also support PWM speed control. Some modules provide additional features such as current sensing, current limiting, thermal shutdown, or undervoltage protection.

Common Driver Modules
Driver or module Typical use Important consideration
L298N module Beginner projects and small robot motors Its bipolar output stage can produce significant voltage loss and heat
TB6612FNG module Small brushed DC motors and compact robots Check the board’s continuous and peak current limits and thermal conditions
DRV8833 module Small low-voltage motor applications Verify the specific chip and breakout-board ratings
MOSFET switching circuit One-direction motor control Requires suitable gate drive and inductive-load protection

These are examples, not interchangeable parts. Board layouts, cooling, protection circuitry, and manufacturer ratings can differ. Before choosing a driver, compare the motor’s rated voltage, stall current, expected duty cycle, and the driver’s continuous current, peak current, voltage range, and thermal limits. Toshiba’s motor-driver documentation is a useful manufacturer-level reference for this selection process.

8. Controlling DC Motor Speed with PWM

Pulse-width modulation (PWM) is a common method for controlling the effective power delivered to a DC motor. Rather than generating a continuously adjustable voltage, the controller rapidly switches the driver on and off.

The percentage of each PWM cycle spent in the active state is called the duty cycle.

For example:

  • 0% duty cycle: The PWM signal is continuously inactive.
  • 25% duty cycle: The signal is active for approximately one-quarter of each cycle.
  • 50% duty cycle: The signal is active for approximately half of each cycle.
  • 100% duty cycle: The signal is continuously active.

Increasing the duty cycle generally increases motor speed under similar conditions. However, duty cycle is not a direct measurement of RPM: the actual speed also depends on load, supply voltage, motor characteristics, and driver losses.

PWM with Arduino

On many classic Arduino boards, analogWrite() produces PWM on supported pins. For an 8-bit PWM interface, values typically range from 0 to 255:

analogWrite() value Approximate duty cycle
0 0%
64 25%
128 50%
192 75%
255 100%

PWM capabilities and resolution vary by board. Check the official documentation and pinout for your specific Arduino model before selecting a pin.

PWM Frequency and Motor Behavior

PWM frequency affects switching losses, audible noise, current ripple, and driver performance. A frequency that works well for one driver may not be ideal for another.

For beginner projects, use the motor driver’s recommended PWM range and the microcontroller’s supported settings. Avoid changing timer or PWM frequency settings without checking whether they interfere with other functions or libraries.

9. Controlling Motor Direction with an H-Bridge

To reverse a brushed DC motor electronically, the driver must reverse the polarity applied across the motor terminals. An H-bridge performs this function using switching transistors.

How the Direction Inputs Work?

A typical H-bridge has two direction inputs, often labeled IN1 and IN2. For a common control arrangement, the input combinations may work as follows:

IN1 IN2 behavior
LOW LOW Coast or stop, depending on the driver
HIGH LOW Rotate in one direction
LOW HIGH Rotate in the opposite direction
HIGH HIGH Brake or another defined state, depending on the driver

These states are common examples, not a universal rule. Some drivers use different input logic, and some provide separate PWM, enable, or standby pins. Always check the specific driver’s truth table.

Coast vs. Brake

These two stopping behaviors are different:

  • Coast: The driver stops actively powering the motor, allowing it to slow down naturally.

  • Brake: The driver electrically brakes the motor, causing it to slow down more quickly.

The actual behavior depends on the driver’s design and input state. If the motor drives a heavy or fast-moving mechanism, consider how quickly it needs to stop and whether the driver can safely handle the resulting current and energy.

Reversing Direction Safely

Avoid switching directly from full-speed forward to full-speed reverse without considering motor speed and current. The abrupt change can cause high current, mechanical shock, or driver stress.

For a practical control system, reduce the PWM duty cycle, allow the motor to slow down, and then change the direction inputs. For demanding applications, use current monitoring, acceleration limits, or feedback control.

10. Programming a DC Motor with Arduino

This example uses an Arduino Uno and an L298N motor-driver module to control one brushed DC motor. The motor is powered by a suitable external supply, while the Arduino provides direction and PWM signals.

Required Components
  • Arduino Uno or a compatible board
  • One brushed DC motor
  • L298N motor-driver module
  • External power supply compatible with the motor and driver
  • Jumper wires
  • USB cable for programming
  • Optional multimeter for checking power and ground connections

Before powering the circuit, verify that the motor’s stall current is within the driver’s capabilities and that the motor supply voltage is suitable for both the motor and the driver.

Wiring Connections

This example assumes a common L298N module with an ENA enable input and IN1/IN2 direction inputs.

Arduino or supply L298N connection
Arduino pin 5 (PWM) ENA
Arduino pin 7 IN1
Arduino pin 8 IN2
Motor wire 1 OUT1
Motor wire 2 OUT2
External supply positive Motor supply terminal, according to the module’s labeling
External supply negative Driver GND
Arduino GND Driver GND

If the module has an ENA jumper, remove it when you need to control speed using Arduino PWM on ENA. Follow the board documentation for the correct logic and motor-supply connections. Do not connect an external voltage to an Arduino GPIO pin.

Important: The L298N has a relatively large voltage drop compared with many modern MOSFET-based motor drivers. The motor may therefore receive less voltage than the supply voltage, and the driver can become hot. For small, low-voltage motors, a more efficient driver may be a better choice.

Example Arduino Code

The following sketch runs the motor forward, gradually increases its speed, slows it down, then repeats the process in reverse.


const int ENA = 5;  // PWM speed control
const int IN1 = 7;  // Direction input 1
const int IN2 = 8;  // Direction input 2

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);

  stopMotor();
}

void setMotor(int speedValue, bool forward) {
  speedValue = constrain(speedValue, 0, 255);

  if (forward) {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
  } else {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
  }

  analogWrite(ENA, speedValue);
}

void stopMotor() {
  analogWrite(ENA, 0);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
}

void loop() {
  // Accelerate in the forward direction
  for (int speedValue = 0; speedValue <= 200; speedValue += 5) {
    setMotor(speedValue, true);
    delay(50);
  }

  delay(1000);

  // Gradually slow down
  for (int speedValue = 200; speedValue >= 0; speedValue -= 5) {
    setMotor(speedValue, true);
    delay(50);
  }

  stopMotor();
  delay(1000);

  // Accelerate in reverse
  for (int speedValue = 0; speedValue <= 200; speedValue += 5) {
    setMotor(speedValue, false);
    delay(50);
  }

  delay(1000);

  // Gradually slow down
  for (int speedValue = 200; speedValue >= 0; speedValue -= 5) {
    setMotor(speedValue, false);
    delay(50);
  }

  stopMotor();
  delay(2000);
}
Understanding the Code
  • pinMode() configures the motor-control pins as outputs.
  • digitalWrite() sets the direction inputs HIGH or LOW.
  • analogWrite() produces PWM on a supported pin to control the driver’s enable input.
  • constrain() keeps the requested PWM value between 0 and 255.
  • The for loops gradually increase and decrease the PWM value to create a simple speed ramp.
  • stopMotor() sets the PWM output to zero and places the direction inputs LOW.

The example uses a maximum PWM value of 200 rather than 255 to limit the commanded duty cycle. This does not guarantee a particular speed or current limit. If the motor is overloaded or its stall current exceeds the driver’s rating, the circuit can still be damaged.

The example also does not measure actual RPM. It provides open-loop control: the Arduino commands a PWM duty cycle, but it does not verify the motor’s real speed.

11. Controlling Speed with a Potentiometer

A potentiometer can provide a simple manual speed command. The Arduino reads the potentiometer’s analog voltage and converts it into a PWM value for the motor driver.

Potentiometer Connections

For a typical 10 kΩ potentiometer:

  • Connect one outer terminal to Arduino 5 V.
  • Connect the other outer terminal to GND.
  • Connect the center terminal, called the wiper, to analog input A0.

This arrangement assumes a board whose analog input accepts the selected voltage range.

For 3.3 V microcontrollers, use the appropriate supply and input-voltage limits.

Arduino Code

This example controls speed in one direction using the same L298N wiring as the previous section. It assumes that the ENA pin is connected to Arduino pin 5 and that IN1 and IN2 are connected to pins 7 and 8.


const int ENA = 5;
const int IN1 = 7;
const int IN2 = 8;
const int POT = A0;

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);

  // Select one direction
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
}

void loop() {
  int potValue = analogRead(POT);

  // Classic Arduino Uno: map 10-bit ADC to 8-bit PWM
  int motorSpeed = map(potValue, 0, 1023, 0, 255);

  analogWrite(ENA, motorSpeed);

  delay(10);
}
How It Works?

On a classic Arduino Uno, analogRead() typically returns values from 0 to 1023. The map() function converts this range to 0–255, which is suitable for the board’s usual 8-bit analogWrite() interface.

Turning the potentiometer changes the requested PWM duty cycle. At very low duty cycles, the motor may not start because it needs enough torque to overcome friction and the connected load. This is normal for many small motors.

If the motor behaves erratically near the minimum setting, you can add a minimum starting duty cycle or implement a brief startup boost. Such adjustments should be tested carefully because they can increase current and do not replace proper current protection.

12. Connecting and Controlling Two DC Motors

Two brushed DC motors are common in robot cars and small mobile robots. Each motor should have a driver channel capable of handling its own voltage and current requirements.

Dual-Motor Driver

A dual H-bridge module can control two motors independently. One channel drives the left motor, while the other drives the right motor. Each channel may have separate direction inputs and a PWM input or enable signal.

Before connecting both motors, check the driver’s total current limits as well as the limits of each channel. Two motors starting at the same time can place a substantial load on the supply.

Basic Robot Movement

A two-wheel differential-drive robot changes direction by varying the direction and speed of its left and right motors.

  • Forward: Both motors drive the robot forward.
  • Reverse: Both motors drive the robot backward.
  • Turn left: The right motor moves faster than the left, or the left motor reverses while the right motor moves forward.
  • Turn right: The left motor moves faster than the right, or the right motor reverses while the left motor moves forward.
  • Pivot turn: The motors rotate in opposite directions, causing the robot to turn around a point between its wheels.

The exact logic levels depend on the physical motor wiring and the driver’s input arrangement. If one motor is mounted in the opposite orientation, its electrical direction may need to be reversed in software or by swapping its two motor leads.

Why Two Motors May Not Run at the Same Speed?

Even when two motors receive the same PWM duty cycle, their speeds may differ because of manufacturing tolerances, mechanical friction, wheel diameter, battery voltage, and load distribution.

For more accurate straight-line movement, use encoders or other speed sensors and implement feedback control.

PWM alone sets the drive command; it does not guarantee a specific RPM.

13. Common Applications and Hobby Projects

DC motors are useful in many practical electronics projects because they provide a straightforward way to convert electrical control into physical movement.

Robot Car

Use two geared DC motors with a dual H-bridge driver. An Arduino can control forward and reverse movement, speed, and turning. Add distance sensors or line sensors to make the robot respond to its environment.

Mini Conveyor Belt

A geared DC motor can drive a small conveyor. PWM provides basic speed adjustment, while a sensor can detect objects passing along the belt.

For applications that need consistent speed under changing loads, add a speed sensor and feedback control.

Fan Speed Controller

A brushed DC fan can often be controlled with a suitable transistor or motor driver. Select the control method according to the fan’s rated voltage, current, and internal electronics. Some fans require a dedicated control input rather than PWM applied to their supply.

Automatic Mechanism

A DC motor can drive a small gate, sliding platform, or other mechanism. For a safer design, add limit switches, mechanical stops, current monitoring, and a way to stop the motor if movement is obstructed.

A standard DC motor does not inherently know its shaft position. If accurate position control is required, use encoders, limit switches, or another suitable feedback method.

14. Troubleshooting and Safety Tips

Motor-control problems often come from power-supply limitations, wiring errors, driver selection, or incorrect assumptions about PWM and motor speed.

Problem Possible cause Recommended check
Motor does not rotate Incorrect wiring, no motor supply, or disabled driver Check supply voltage, ground, enable, and direction inputs
Arduino resets when the motor starts Supply voltage dips or electrical noise Use a suitable motor supply, improve wiring, and separate noisy power paths where appropriate
Motor only runs at full speed PWM is connected incorrectly or the selected pin does not support PWM Check the board pinout, enable jumper, and driver documentation
Motor rotates in the wrong direction Motor leads or direction logic are reversed Swap the motor leads or reverse the direction commands
Motor or driver becomes too hot Excessive current, mechanical overload, or driver voltage loss Check stall current, load, cooling, and driver ratings
Motor starts inconsistently at low PWM Duty cycle is too low to overcome friction or load Test a suitable minimum starting duty cycle
Two-wheel robot veers to one side Motors, wheels, or loads are not matched Check mechanical alignment and use encoder feedback if needed
Electrical Safety
  • Disconnect power before changing motor wiring.
  • Confirm the motor’s rated voltage and the driver’s permitted voltage range.
  • Size the driver and power supply for realistic startup and stall-current conditions.
  • Use suitable inductive-load protection and follow the driver’s application circuit.
  • Keep exposed conductors from shorting against one another.
  • Check driver temperature and provide cooling if required.
  • Do not allow a motor to remain stalled unless the motor, driver, and power system are designed to tolerate that condition.

For higher-power motors, add appropriate fusing, wiring sized for the expected current, and emergency-stop provisions where needed. Mechanical hazards also matter: rotating shafts, gears, wheels, and belts can pinch fingers or catch loose clothing.

15. Frequently Asked Questions

Can I Connect a DC Motor Directly to an Arduino?

No, not for a typical DC motor. Arduino GPIO pins are designed for low-current logic signals. Use a suitable transistor or motor-driver module and an appropriate motor power supply.

How Can I Control a DC Motor’s Speed?

A common method is PWM. The microcontroller changes the duty cycle of the signal sent to a motor driver, which changes the effective power delivered to the motor. The actual speed depends on the motor, supply voltage, driver losses, and mechanical load.

How Can I Reverse a DC Motor’s Direction?

For a brushed DC motor, reverse the polarity across its terminals. An H-bridge motor driver allows the controller to do this electronically without manually swapping wires.

What Is the Difference Between PWM and Analog Voltage Control?

PWM rapidly switches a signal between its active and inactive states. The duty cycle controls the proportion of time the signal is active. True analog voltage control instead supplies a continuously adjustable voltage. A PWM signal is not automatically a true analog output, even though it can control a motor’s effective power.

Can I Use a 12 V Power Supply with a 6 V DC Motor?

Not directly unless the motor-control system limits the voltage and power delivered to the motor to appropriate levels. A 12 V supply may overdrive a 6 V motor, causing excessive speed, current, and heat. Select a supply and driver arrangement that respects the motor’s specifications.

Why Does My DC Motor Draw a High Current at Startup?

At startup, the motor is not yet rotating, so its back EMF is low. The current is therefore initially limited mainly by winding resistance and the rest of the circuit. As the motor speeds up, back EMF increases and the current typically falls.

Does a Higher PWM Value Always Mean a Higher Motor Speed?

Generally, increasing the duty cycle increases speed under similar operating conditions. However, PWM duty cycle is not a direct speed measurement. Load changes, supply voltage, friction, and motor characteristics all affect actual RPM.

Can I Control Two DC Motors with One Arduino?

Yes. You can control two motors using a dual-channel motor driver, provided the driver and power supply can handle both motors. Independent speed and direction control requires enough control signals or a suitable driver interface.

Do I Need an Encoder to Control Motor Speed?

An encoder is not necessary for basic open-loop speed adjustment using PWM. However, if you need to maintain a target speed as the load changes, an encoder or another suitable speed sensor can provide feedback for closed-loop control.

Which Motor Driver Is Best for Beginners?

There is no single best driver for every motor. Choose one based on motor voltage, stall current, required direction and speed control, thermal limits, and available protection features. Popular modules such as the L298N, TB6612FNG, and DRV8833 have different characteristics, so verify the exact module’s documentation before use.

16. Conclusion

DC motors are fundamental components in robotics, automation, and hobby electronics. Understanding their electrical and mechanical behavior makes it easier to select the right motor, design a reliable connection, and develop effective control software.

The most important principles are to use a suitable motor driver instead of powering a motor directly from a microcontroller pin, select a power supply that meets the motor’s requirements, and use PWM for basic speed control and an H-bridge when electronic direction reversal is needed.

With Arduino, these techniques provide a practical starting point for robot cars, fans, conveyors, and other motion-control projects. As your projects become more demanding, you can build on these fundamentals by adding encoders, feedback control, current sensing, and more advanced motor drivers.

 

قائمة المحتويات

  1. المقدمة
  2. ما هو محرك التيار المستمر؟
  3. كيف يعمل محرك التيار المستمر؟
  4. أنواع محركات التيار المستمر
  5. المواصفات الأساسية للمحرك
  6. توصيلات محرك التيار المستمر وأسلاك التوصيل
  7. اختيار مشغل المحرك
  8. التحكم في سرعة محرك التيار المستمر باستخدام PWM
  9. التحكم في اتجاه المحرك باستخدام جسر H
  10. برمجة محرك التيار المستمر باستخدام Arduino
  11. التحكم في السرعة باستخدام مقاومة متغيرة
  12. توصيل محركي تيار مستمر والتحكم فيهما
  13. تطبيقات شائعة ومشروعات للهواة
  14. استكشاف الأخطاء وإصلاحها ونصائح السلامة
  15. الأسئلة الشائعة
  16. الخاتمة

وقت القراءة: 20 دقيقة.

1. المقدمة

يحوّل محرك التيار المستمر (DC Motor) الطاقة الكهربائية إلى حركة ميكانيكية دورانية. ويُستخدم على نطاق واسع في الروبوتات والمركبات الصغيرة والمراوح والمضخات والسيور الناقلة والعديد من المشروعات الإلكترونية، لأنه سهل التشغيل نسبيًا ويمكن دمجه بسهولة في الأنظمة المدمجة.

محرك تيار مستمر

ومع ذلك، فإن توصيل محرك تيار مستمر بمتحكم دقيق ليس بالبساطة نفسها التي يتطلبها توصيل مصباح LED. فقد يسحب المحرك تيارًا أكبر بكثير مما يستطيع أحد أطراف المتحكم الدقيق توفيره بأمان، خاصة عند بدء التشغيل أو عند توقف عمود المحرك بسبب عائق. لذلك، يُعد استخدام مشغل محرك مناسب ومصدر طاقة بجهد وتيار ملائمين أمرًا ضروريًا لضمان التشغيل الموثوق.

في هذا الدليل، ستتعرف على كيفية تحديد المواصفات المهمة لمحرك التيار المستمر، وتوصيله بصورة صحيحة، واختيار مشغل مناسب له، والتحكم في سرعته واتجاه دورانه، وكتابة كود Arduino لتشغيله. كما ستتعلم كيفية معالجة المشكلات الشائعة وتطبيق هذه المبادئ في مشروعات عملية للهواة.

2. ما هو محرك التيار المستمر؟

محرك التيار المستمر هو آلة كهربائية تستخدم التيار المستمر لإنتاج حركة دورانية. في المحرك التقليدي المزود بفرش، يمر التيار الكهربائي عبر ملفات العضو الدوار، فينشأ مجال مغناطيسي يتفاعل مع المغناطيسات الدائمة أو ملفات المجال داخل المحرك. وينتج عن هذا التفاعل عزم دوران يؤدي إلى دوران العمود.

الأجزاء الداخلية لمحرك التيار المستمر

فيما يلي أهم أجزاء محرك التيار المستمر التقليدي المزود بفرش:

  • الجزء الثابت (Stator): الجزء الذي لا يدور، ويعمل على إنشاء المجال المغناطيسي.
  • الجزء الدوار أو عضو الإنتاج (Rotor / Armature): الجزء الذي يدور ويحتوي على الملفات الكهربائية.
  • المبدّل (Commutator): مجموعة من نقاط التلامس الكهربائية المقسمة إلى أجزاء، تعمل على تغيير اتجاه التيار في ملفات الجزء الدوار.
  • الفُرش (Brushes): تنقل التيار الكهربائي إلى المبدّل الدوار.
  • العمود (Shaft): ينقل الحركة الدورانية من المحرك إلى الحمل المتصل به.
  • المحامل (Bearings): تدعم العمود وتساعده على الدوران بسلاسة.

يسهل التحكم في محرك التيار المستمر التقليدي ذي السلكين. فعند تطبيق جهد مستمر مناسب عليه يبدأ بالدوران، ويؤدي عكس القطبية إلى عكس اتجاه دورانه، بينما يمكن تغيير سرعته بتعديل الجهد الفعّال المطبق عليه.

يعتمد سلوك المحرك على تصميمه والحمل الميكانيكي المتصل به. وقد يؤدي تطبيق جهد أعلى من الجهد المقنن إلى زيادة السرعة والتيار ودرجة الحرارة بصورة مفرطة؛ لذلك، احرص دائمًا على الالتزام بالمواصفات الواردة في ورقة بيانات المحرك.

3. كيف يعمل محرك التيار المستمر؟

يعمل محرك التيار المستمر المزود بفرش نتيجة التفاعل بين التيار الكهربائي والمجالات المغناطيسية. فعندما يمر التيار عبر ملفات الجزء الدوار، تؤثر قوة في الموصلات وينشأ عزم دوران.

وأثناء دوران الجزء الدوار، تعمل الفرش والمبدّل على تغيير مسار التيار داخل الملفات للمحافظة على استمرار الدوران في الاتجاه نفسه بوجه عام.

هناك ثلاث علاقات كهربائية وميكانيكية مهمة تساعد على فهم طريقة تصميم نظام للتحكم في المحرك.

مبدأ عمل محرك التيار المستمر

الجهد والسرعة

بالنسبة إلى المحرك نفسه، تؤدي زيادة الجهد المطبق عليه عادةً إلى زيادة سرعته عند ثبات ظروف الحمل تقريبًا. لكن السرعة لا تعتمد على الجهد وحده؛ إذ تؤثر فيها أيضًا قيمة الحمل والاحتكاك ومقاومة الملفات ودرجة حرارة المحرك وهبوط الجهد عبر مشغل المحرك.

التيار وعزم الدوران

يتناسب عزم دوران المحرك تقريبًا مع تيار عضو الإنتاج ضمن نطاق التشغيل الطبيعي. وعادةً ما يتطلب الحمل الأكبر عزمًا أعلى، وهو ما يعني في الغالب سحب تيار أكبر.

عند تشغيل المحرك للمرة الأولى، تكون القوة الدافعة الكهربائية العكسية (Back EMF) منخفضة جدًا في البداية؛ لذلك، قد يكون تيار بدء التشغيل أعلى بكثير من تيار التشغيل العادي.

وإذا مُنع العمود من الدوران، فقد يسحب المحرك تيار التوقف (Stall Current)، وهو تيار يمكن أن يتسبب في تلف مشغل غير مناسب أو أسلاك غير ملائمة أو مصدر طاقة لا يتحمل الحمل.

القوة الدافعة الكهربائية العكسية (Back EMF)

عندما يدور المحرك، فإنه يولّد جهدًا يعاكس الجهد المطبق عليه، ويُسمى هذا الجهد القوة الدافعة الكهربائية العكسية.

ومع زيادة السرعة، ترتفع هذه القوة عادةً، فينخفض التيار اللازم لاستمرار الدوران عند حمل معين. أما عندما تتراجع سرعة المحرك بسبب زيادة الحمل، فتنخفض القوة الدافعة الكهربائية العكسية ويرتفع التيار عادةً.

وهذا يفسر سبب إمكانية سحب المحرك تيارًا كبيرًا عند بدء التشغيل أو عند تعرضه لحمل ثقيل.

4. أنواع محركات التيار المستمر

تختلف أنواع المحركات في طريقة عملها ومتطلبات التحكم بها. لذلك، من المهم تحديد نوع المحرك الذي تستخدمه قبل اختيار مشغل المحرك أو كتابة الكود اللازم لتشغيله.

أنواع مختلفة من محركات التيار المستمر

محرك التيار المستمر المزود بفرش (Brushed DC Motor)

يُعد هذا النوع من أكثر الخيارات شيوعًا في المشروعات الإلكترونية ومشروعات الروبوتات للمبتدئين. ويحتوي عادةً على سلكين لتغذيته بالطاقة، ويمكن التحكم فيه باستخدام ترانزستور أو ترانزستور MOSFET لتشغيله في اتجاه واحد، أو باستخدام دائرة جسر H لعكس اتجاه الدوران.

تشمل تطبيقاته الشائعة المراوح الصغيرة والمركبات اللعبة والآليات الروبوتية البسيطة ومحركات التيار المستمر المزودة بعلبة تروس والمستخدمة في المشروعات العملية.

محرك التيار المستمر المزود بعلبة تروس (Geared DC Motor)

يجمع هذا المحرك بين المحرك الكهربائي وعلبة تروس. وتعمل علبة التروس على تقليل سرعة الخرج وزيادة عزم الدوران المتاح مقارنةً بعمود المحرك وحده، مع احتمال فقدان جزء من القدرة بسبب الاحتكاك داخل التروس.

تُستخدم هذه المحركات في عجلات الروبوتات والمنصات المتحركة الصغيرة والآليات التي تحتاج إلى عزم أكبر عند سرعات منخفضة.

محرك التيار المستمر دون فرش (BLDC)

يستخدم محرك التيار المستمر دون فرش التبديل الإلكتروني للتيار بدلًا من الفرش والمبدّل الميكانيكيين. وعادةً ما يحتاج إلى وحدة تحكم مخصصة لمحركات BLDC أو وحدة تحكم إلكترونية في السرعة (ESC).

لا يمكن التحكم في هذا النوع مباشرةً باستخدام دائرة تقليدية مخصصة لمحرك تيار مستمر مزود بفرش ذي سلكين. فعلى سبيل المثال، تحتوي محركات الطائرات المسيّرة الشائعة على ثلاثة أسلاك لأطوار المحرك، وتتصل بوحدة ESC مناسبة.

محرك التيار المستمر عديم القلب الحديدي (Coreless DC Motor)

يتميز هذا النوع بتصميم للجزء الدوار لا يعتمد على القلب الحديدي التقليدي. وتوفر بعض تصميماته قصورًا ذاتيًا دورانيًا منخفضًا واستجابة سريعة، ما يجعلها مناسبة للآليات الدقيقة والصغيرة.

ومع ذلك، يجب التحقق من حدود الجهد والتيار والقيود الميكانيكية لهذا المحرك قبل استخدامه في أي تطبيق.

5. المواصفات الأساسية لمحرك التيار المستمر

قبل توصيل المحرك، راجع ورقة البيانات الخاصة به أو وثائق المنتج الموثوقة. تساعدك المواصفات التالية على تحديد مصدر الطاقة المناسب، واختيار مشغل المحرك، وتحديد طريقة التحكم الملائمة.

المواصفات الأساسية لمحرك التيار المستمر

المواصفة المعنى أهميتها
الجهد المقنن جهد التشغيل الموصى به للمحرك. يساعد على اختيار مصدر طاقة مناسب للمحرك.
سرعة الدوران دون حمل سرعة المحرك عند وجود حمل ميكانيكي ضئيل أو عدم وجود حمل. توفر قيمة مرجعية لتقدير السرعة المتوقعة.
التيار دون حمل التيار الذي يسحبه المحرك أثناء الدوران دون حمل ملحوظ. يساعد على تقدير استهلاك التيار في ظروف الحمل الخفيف.
التيار المقنن التيار الذي يسحبه المحرك في ظروف التشغيل المحددة من الشركة المصنعة. يساعد على تقدير متطلبات القدرة أثناء التشغيل العادي.
تيار التوقف (Stall Current) التيار الذي يسحبه المحرك عندما يكون عموده متوقفًا عند الجهد المحدد. عامل أساسي عند تحديد قدرة مشغل المحرك ومصدر الطاقة.
عزم الدوران المقنن عزم الدوران الذي صُمم المحرك لتوفيره في ظروف التشغيل المحددة. يساعد على تحديد قدرة المحرك على تحريك الحمل المطلوب.
نسبة التروس النسبة بين سرعة المحرك وسرعة الخرج من علبة التروس. تؤثر في سرعة الخرج وعزم الدوران المتاح.
درجة حرارة التشغيل الظروف الحرارية التي يُسمح للمحرك بالعمل ضمنها. تساعد على تجنب ارتفاع درجة الحرارة بصورة مفرطة.

مهم: لا تفترض أن مشغل المحرك المصمم لتحمل تيار التشغيل العادي يستطيع أيضًا تحمل تيار التوقف. قارن حدود التيار المستمر والذروة للمشغل، وحدود الجهد، ومتطلبات التبريد، بالمواصفات الفعلية للمحرك.

كذلك، يجب التمييز بين التيار المقنن للمحرك وتيار التوقف؛ فكل منهما يصف حالة تشغيل مختلفة، ولا يمكن استخدام أحدهما بدلًا من الآخر.

6. توصيلات محرك التيار المستمر وأسلاك التوصيل

تعتمد طريقة التوصيل الصحيحة على الوظيفة المطلوبة: هل تحتاج إلى تشغيل المحرك وإيقافه فقط، أم التحكم في سرعته، أم التحكم في السرعة والاتجاه معًا؟

توصيلات محرك التيار المستمر وطرق التحكم فيه

التوصيل الأساسي لمحرك ذي سلكين

يحتوي محرك التيار المستمر المزود بفرش عادةً على طرفين كهربائيين. وعند توصيل مصدر تيار مستمر مناسب بهذين الطرفين، يبدأ المحرك بالدوران. أما عكس قطبية التوصيل فيؤدي إلى عكس اتجاه الدوران.

على سبيل المثال، إذا كان الجهد المقنن للمحرك 6 فولت، فينبغي عادةً تشغيله من مصدر جهد قريب من هذه القيمة، مع مراعاة ورقة البيانات ومتطلبات التطبيق.

يفيد هذا التوصيل البسيط في فهم طريقة عمل المحرك، لكنه لا يوفر تحكمًا إلكترونيًا في السرعة ولا يتيح توصيل المحرك بأمان بالمتحكم الدقيق بمفرده.

لماذا لا ينبغي توصيل المحرك مباشرةً بطرف في Arduino؟

صُممت أطراف الإدخال والإخراج العامة (GPIO) في Arduino لإرسال إشارات التحكم، وليس لتوفير التيار الذي تحتاج إليه معظم المحركات. فقد يسحب المحرك تيارًا مفرطًا، ويولّد اضطرابات كهربائية ونبضات جهد قد تؤدي إلى تلف المتحكم الدقيق.

لذلك، استخدم مشغل محرك مناسبًا بين Arduino والمحرك. يتولى المشغل تمرير تيار المحرك والتحكم فيه، بينما يرسل Arduino إشارات تحكم منخفضة القدرة.

توصيل مشغل المحرك بـ Arduino

في حالة استخدام وحدة جسر H تقليدية للتحكم في محرك تيار مستمر واحد مزود بفرش، تكون التوصيلات العامة كما يلي. احرص دائمًا على مراجعة أسماء الأطراف ومتطلبات الإشارات في وثائق الوحدة التي تستخدمها.

التوصيل يُوصل إلى
خرج المحرك A أحد سلكَي المحرك.
خرج المحرك B سلك المحرك الآخر.
مدخل طاقة المحرك مصدر طاقة خارجي مناسب لجهد المحرك ومتطلبات المشغل.
تغذية دائرة التحكم في المشغل جهد المنطق المطلوب، إذا كان منفصلًا عن تغذية المحرك.
أرضي المشغل (GND) القطب السالب لمصدر الطاقة وطرف GND في Arduino.
مداخل الاتجاه أطراف الإخراج الرقمية في Arduino.
مدخل PWM أو التمكين طرف PWM متوافق في Arduino، إذا كانت الوحدة تدعم ذلك.
الاستعداد أو التمكين الحالة المنطقية المطلوبة لتفعيل الوحدة، وفقًا لوثائقها.

استخدم أرضيًا مشتركًا بين Arduino ومشغل المحرك عندما يتطلب تصميم الواجهة ذلك. فمن دون مرجع كهربائي مشترك، قد لا يتمكن المشغل من تفسير إشارات التحكم الصادرة من Arduino بصورة موثوقة.

لا تفترض أن جميع وحدات تشغيل المحركات تستخدم طريقة التغذية نفسها. فبعض اللوحات تحتوي على مداخل منفصلة لتغذية المنطق والمحرك، بينما تتضمن لوحات أخرى منظمات جهد أو جسور توصيل (Jumpers) تؤثر في طريقة عمل أطراف الطاقة.

اختيار مصدر الطاقة

يجب أن يوفر مصدر الطاقة جهدًا مناسبًا للمحرك وتيارًا كافيًا لظروف بدء التشغيل والحمل الفعلي.

كما يجب أن يتوافق مصدر الطاقة مع حدود الجهد والتيار المسموح بها لمشغل المحرك.

على سبيل المثال، لا ينبغي تشغيل محرك مصمم لجهد 6 فولت تلقائيًا باستخدام مصدر 12 فولت لمجرد أن مشغل المحرك يستطيع تحمل هذا الجهد.

يجب أن يظل المحرك نفسه ضمن ظروف التشغيل المسموح بها وفقًا لمواصفاته.

تجنب الاعتماد على منظم الجهد الموجود على لوحة Arduino أو منفذ USB لتغذية المحرك، ما لم يكن النظام بأكمله مصممًا لهذا الحمل وتم التحقق من قدرته على تحمله.

7. اختيار مشغل المحرك

مشغل المحرك هو واجهة القدرة التي تربط وحدة التحكم بالمحرك.

ويسمح هذا المشغل لإشارة تحكم منخفضة القدرة من Arduino أو أي متحكم دقيق آخر بالتحكم في التيار الأعلى الذي يحتاج إليه المحرك.

أنواع مشغلات محركات التيار المستمر

مشغل باستخدام ترانزستور أو MOSFET

للتحكم في تشغيل المحرك وإيقافه أو تعديل سرعته في اتجاه واحد، يمكن استخدام ترانزستور مناسب أو ترانزستور MOSFET من النوع الذي يتوافق مع مستوى جهد الإشارة. ويجب أن تتضمن الدائرة وسيلة مناسبة للحماية من الجهد الناتج عن الحمل الحثي، مثل دايود الحماية من الجهد العكسي (Flyback Diode) ذي المواصفات الصحيحة، عند استخدام دائرة تبديل بسيطة على الجانب المنخفض.

يُعد هذا الحل مناسبًا عندما لا تحتاج إلى عكس اتجاه دوران المحرك كهربائيًا.

مشغل جسر H (H-Bridge)

يسمح جسر H بمرور التيار عبر المحرك في أي من الاتجاهين، ولذلك يُستخدم على نطاق واسع في التطبيقات التي تتطلب الدوران للأمام والخلف، مثل السيارات الروبوتية.

وقد يدعم المشغل أيضًا التحكم في السرعة باستخدام PWM. كما تتضمن بعض الوحدات ميزات إضافية، مثل قياس التيار، وتحديد التيار، والإيقاف الحراري عند ارتفاع درجة الحرارة، والحماية من انخفاض جهد التغذية.

وحدات مشغلات المحركات الشائعة
المشغل أو الوحدة الاستخدام المعتاد اعتبارات مهمة
L298N مشروعات المبتدئين ومحركات الروبوتات الصغيرة. قد يتسبب تركيب الخرج ثنائي القطبية في هبوط ملحوظ في الجهد وارتفاع درجة الحرارة.
TB6612FNG محركات التيار المستمر الصغيرة المزودة بفرش والروبوتات المدمجة. تحقق من حدود التيار المستمر والذروة للوحة، ومن ظروف التشغيل الحراري.
DRV8833 تطبيقات المحركات الصغيرة ذات جهد التشغيل المنخفض. تحقق من مواصفات الشريحة نفسها ولوحة التوصيل المستخدمة معها.
دائرة تبديل باستخدام MOSFET التحكم في المحرك باتجاه واحد. تتطلب قيادة مناسبة للبوابة وحماية من الجهد الناتج عن الحمل الحثي.

هذه أمثلة على مشغلات مختلفة، وليست بدائل متطابقة يمكن استبدال أحدها بالآخر مباشرةً. فقد تختلف اللوحات في تصميمها ووسائل التبريد ودارات الحماية والحدود التي تحددها الشركات المصنعة.

قبل اختيار المشغل، قارن الجهد المقنن للمحرك وتيار التوقف ودورة التشغيل المتوقعة، بحدود التيار المستمر والتيار الأقصى ونطاق الجهد والقيود الحرارية لمشغل المحرك. كما تُعد وثائق الشركات المصنعة، مثل وثائق Toshiba الخاصة بمشغلات المحركات، مرجعًا فنيًا مفيدًا عند الاختيار.

8. التحكم في سرعة محرك التيار المستمر باستخدام PWM

يُعد تعديل عرض النبضة (PWM) من الطرق الشائعة للتحكم في القدرة الفعّالة التي تصل إلى محرك التيار المستمر. فبدلًا من توليد جهد قابل للتعديل بصورة مستمرة، تقوم وحدة التحكم بتشغيل المشغل وإيقافه بسرعة كبيرة.

تُسمى النسبة المئوية من كل دورة PWM التي تظل فيها الإشارة في الحالة الفعّالة دورة التشغيل (Duty Cycle).

التحكم في سرعة محرك التيار المستمر باستخدام PWM

على سبيل المثال:

  • دورة تشغيل 0%: تظل إشارة PWM غير فعّالة طوال الوقت.
  • دورة تشغيل 25%: تكون الإشارة فعّالة خلال ربع زمن الدورة تقريبًا.
  • دورة تشغيل 50%: تكون الإشارة فعّالة خلال نصف زمن الدورة تقريبًا.
  • دورة تشغيل 100%: تظل الإشارة فعّالة طوال الوقت.

تؤدي زيادة دورة التشغيل عمومًا إلى زيادة سرعة المحرك عند تشابه ظروف التشغيل. لكن دورة التشغيل ليست قياسًا مباشرًا لسرعة الدوران بوحدة RPM؛ فالسرعة الفعلية تتأثر أيضًا بالحمل وجهد التغذية وخصائص المحرك وفقد الجهد داخل مشغل المحرك.

استخدام PWM مع Arduino

في العديد من لوحات Arduino التقليدية، تنتج الدالة analogWrite() إشارة PWM على الأطراف التي تدعم هذه الوظيفة. وعند استخدام واجهة PWM بدقة 8 بت، تتراوح القيم المعتادة بين 0 و255.

قيمة analogWrite() دورة التشغيل التقريبية
0 0%
64 25%
128 50%
192 75%
255 100%

تختلف إمكانات PWM ودقة الإشارة من لوحة إلى أخرى. لذلك، راجع الوثائق الرسمية ومخطط أطراف التوصيل الخاصين بطراز Arduino الذي تستخدمه قبل اختيار الطرف المناسب.

تردد PWM وتأثيره في أداء المحرك

يؤثر تردد PWM في خسائر التبديل والضوضاء المسموعة وتموج التيار وأداء مشغل المحرك. وقد لا يكون التردد الملائم لمشغل معين مناسبًا لمشغل آخر.

في المشروعات المخصصة للمبتدئين، استخدم نطاق تردد PWM الذي توصي به الشركة المصنعة لمشغل المحرك، مع الالتزام بإعدادات المتحكم الدقيق المدعومة. وتجنب تغيير إعدادات المؤقتات أو تردد PWM قبل التأكد من أن ذلك لن يؤثر في وظائف أخرى أو في المكتبات البرمجية المستخدمة.

9. التحكم في اتجاه المحرك باستخدام جسر H

لعكس اتجاه دوران محرك التيار المستمر المزود بفرش إلكترونيًا، يجب أن يتمكن المشغل من عكس القطبية المطبقة على طرفَي المحرك. وتؤدي دائرة جسر H هذه الوظيفة باستخدام ترانزستورات التبديل.

التحكم في اتجاه محرك التيار المستمر باستخدام جسر H

كيف تعمل مداخل التحكم في الاتجاه؟

يحتوي جسر H التقليدي على مدخلين للتحكم في الاتجاه، يُشار إليهما غالبًا بالرمزين IN1 وIN2. وفي أحد أنماط التحكم الشائعة، يمكن أن تعمل مجموعات الحالات المنطقية كما يلي:

حالة IN1 حالة IN2 السلوك
LOW LOW التوقف الحر أو التوقف، حسب تصميم المشغل.
HIGH LOW الدوران في أحد الاتجاهين.
LOW HIGH الدوران في الاتجاه المعاكس.
HIGH HIGH الكبح أو حالة أخرى يحددها المشغل.

هذه الحالات أمثلة شائعة وليست قاعدة تنطبق على جميع المشغلات. فقد تستخدم بعض الوحدات منطقًا مختلفًا للمداخل، أو توفر أطرافًا منفصلة لإشارة PWM أو التمكين أو الاستعداد. لذلك، راجع دائمًا جدول الحالات المنطقية (Truth Table) الخاص بمشغل المحرك الذي تستخدمه.

التوقف الحر (Coast) مقابل الكبح (Brake)

يختلف التوقف الحر عن الكبح الكهربائي في طريقة إيقاف المحرك:

  • التوقف الحر (Coast): يتوقف المشغل عن تغذية المحرك بالطاقة بصورة فعّالة، فيتباطأ المحرك تدريجيًا حتى يتوقف بفعل الاحتكاك والحمل.
  • الكبح (Brake): يستخدم المشغل حالة كهربائية تؤدي إلى كبح المحرك، ما يساعد على تقليل سرعته والتوقف بصورة أسرع.

يعتمد السلوك الفعلي على تصميم المشغل والحالة المنطقية المطبقة على مداخله. وإذا كان المحرك يحرك آلية ثقيلة أو سريعة الحركة، فضع في الحسبان سرعة التوقف المطلوبة وقدرة المشغل على تحمل التيار والطاقة الناتجين أثناء الكبح.

عكس اتجاه الدوران بأمان

تجنب الانتقال مباشرةً من الدوران بأقصى سرعة إلى الدوران بأقصى سرعة في الاتجاه المعاكس دون مراعاة سرعة المحرك والتيار. فقد يؤدي هذا التغيير المفاجئ إلى تيار مرتفع أو صدمة ميكانيكية أو إجهاد مشغل المحرك.

في نظام تحكم عملي، خفّض قيمة دورة تشغيل PWM تدريجيًا، واترك المحرك يبطئ قبل تغيير مداخل الاتجاه. وفي التطبيقات التي تتطلب أداءً أكثر دقة، يمكنك إضافة مراقبة التيار أو تحديد معدلات التسارع والتباطؤ أو استخدام نظام تحكم بالتغذية الراجعة.

10. برمجة محرك التيار المستمر باستخدام Arduino

يوضح هذا المثال كيفية استخدام لوحة Arduino Uno مع وحدة تشغيل المحركات L298N للتحكم في محرك تيار مستمر واحد مزود بفرش. يتغذى المحرك من مصدر طاقة خارجي مناسب، بينما ترسل لوحة Arduino إشارات التحكم في الاتجاه والسرعة باستخدام تعديل عرض النبضة (PWM).

توصيل وبرمجة محرك تيار مستمر باستخدام Arduino Uno ووحدة L298N

المكونات المطلوبة
  • لوحة Arduino Uno أو لوحة متوافقة معها.
  • محرك تيار مستمر واحد مزود بفرش.
  • وحدة تشغيل المحركات L298N.
  • مصدر طاقة خارجي متوافق مع المحرك ومشغل المحرك.
  • أسلاك توصيل.
  • كابل USB لبرمجة لوحة Arduino.
  • جهاز قياس متعدد (Multimeter)، اختياري، لفحص توصيلات الطاقة والأرضي.

قبل تشغيل الدائرة، تحقق من أن تيار التوقف للمحرك يقع ضمن حدود قدرة مشغل المحرك، وأن جهد مصدر الطاقة مناسب لكل من المحرك والمشغل.

توصيلات الأسلاك

يفترض هذا المثال استخدام وحدة L298N شائعة تحتوي على مدخل تمكين ENA ومدخلي اتجاه IN1 وIN2.

طرف Arduino أو مصدر الطاقة طرف وحدة L298N
الطرف 5 في Arduino، ويدعم PWM ENA
الطرف 7 في Arduino IN1
الطرف 8 في Arduino IN2
سلك المحرك الأول OUT1
سلك المحرك الثاني OUT2
الطرف الموجب لمصدر الطاقة الخارجي مدخل تغذية المحرك، وفقًا للتسميات الموجودة على الوحدة.
الطرف السالب لمصدر الطاقة الخارجي GND في المشغل.
الأرضي في Arduino GND في المشغل.

إذا كانت وحدة L298N تحتوي على جسر توصيل (Jumper) خاص بالطرف ENA، فأزله عند الحاجة إلى التحكم في السرعة باستخدام إشارة PWM من Arduino. واتبع وثائق اللوحة للتأكد من توصيل تغذية المنطق وتغذية المحرك بالطريقة الصحيحة. لا توصل أي جهد خارجي مباشرةً بأطراف GPIO في Arduino.

مهم: يتميز مشغل L298N بهبوط جهد أكبر نسبيًا مقارنةً بالعديد من مشغلات المحركات الحديثة التي تعتمد على ترانزستورات MOSFET. ولذلك، قد يصل إلى المحرك جهد أقل من جهد مصدر الطاقة، كما قد ترتفع حرارة المشغل أثناء التشغيل. بالنسبة إلى المحركات الصغيرة ذات جهد التشغيل المنخفض، قد يكون استخدام مشغل أكثر كفاءة خيارًا أفضل.

مثال على كود Arduino

يشغّل البرنامج التالي المحرك في الاتجاه الأمامي، ثم يزيد سرعته تدريجيًا ويخفضها بعد ذلك، قبل تكرار العملية في الاتجاه العكسي.

const int ENA = 5;  // PWM speed control
const int IN1 = 7;  // Direction input 1
const int IN2 = 8;  // Direction input 2

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);

  stopMotor();
}

void setMotor(int speedValue, bool forward) {
  speedValue = constrain(speedValue, 0, 255);

  if (forward) {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
  } else {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
  }

  analogWrite(ENA, speedValue);
}

void stopMotor() {
  analogWrite(ENA, 0);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
}

void loop() {
  // Accelerate in the forward direction
  for (int speedValue = 0; speedValue <= 200; speedValue += 5) {
    setMotor(speedValue, true);
    delay(50);
  }

  delay(1000);

  // Gradually slow down
  for (int speedValue = 200; speedValue >= 0; speedValue -= 5) {
    setMotor(speedValue, true);
    delay(50);
  }

  stopMotor();
  delay(1000);

  // Accelerate in reverse
  for (int speedValue = 0; speedValue <= 200; speedValue += 5) {
    setMotor(speedValue, false);
    delay(50);
  }

  delay(1000);

  // Gradually slow down
  for (int speedValue = 200; speedValue >= 0; speedValue -= 5) {
    setMotor(speedValue, false);
    delay(50);
  }

  stopMotor();
  delay(2000);
}
شرح الكود
  • تضبط الدالة pinMode() أطراف التحكم في المحرك لتعمل كمخارج.
  • تستخدم الدالة digitalWrite() لتعيين مداخل الاتجاه إلى الحالة المنطقية HIGH أو LOW.
  • تنتج الدالة analogWrite() إشارة PWM على طرف مدعوم للتحكم في مدخل تمكين المشغل.
  • تحافظ الدالة constrain() على قيمة السرعة المطلوبة ضمن النطاق من 0 إلى 255.
  • تزيد حلقات for قيمة PWM تدريجيًا ثم تخفضها، لتوفير تسارع وتباطؤ تدريجيين.
  • تضبط الدالة stopMotor() خرج PWM على الصفر وتجعل مداخل الاتجاه في الحالة LOW.

يستخدم المثال قيمة PWM قصوى تبلغ 200 بدلًا من 255 لتقليل دورة التشغيل المطلوبة. لكن هذا لا يضمن سرعة معينة أو يحدد التيار الفعلي للمحرك. فإذا تعرض المحرك لحمل زائد أو تجاوز تيار التوقف قدرات المشغل، فقد تتلف الدائرة رغم ذلك.

كذلك، لا يقيس هذا البرنامج سرعة الدوران الفعلية بوحدة RPM. فهو يعتمد على التحكم المفتوح الحلقة (Open-Loop Control)، حيث يحدد Arduino قيمة PWM المطلوبة دون التحقق من السرعة الحقيقية للمحرك.

11. التحكم في السرعة باستخدام مقاومة متغيرة

يمكن استخدام المقاومة المتغيرة (Potentiometer) لتحديد سرعة المحرك يدويًا بطريقة بسيطة. يقرأ Arduino الجهد التناظري الصادر منها، ثم يحوّل القراءة إلى قيمة PWM يرسلها إلى مشغل المحرك.

التحكم في سرعة محرك التيار المستمر باستخدام مقاومة متغيرة وArduino

توصيلات المقاومة المتغيرة

عند استخدام مقاومة متغيرة بقيمة نموذجية تبلغ 10 كيلو أوم، تكون التوصيلات كما يلي:

  • وصّل أحد الطرفين الخارجيين للمقاومة المتغيرة بجهد 5 فولت في Arduino.
  • وصّل الطرف الخارجي الآخر بالأرضي (GND).
  • وصّل الطرف الأوسط، المعروف باسم المنزلق (Wiper)، بالمدخل التناظري A0.

تفترض هذه الطريقة أن لوحة المتحكم تقبل نطاق الجهد المستخدم على المدخل التناظري.

أما عند استخدام متحكم يعمل بجهد 3.3 فولت، فيجب اختيار جهد التغذية المناسب والالتزام بحدود الجهد المسموح بها لمداخل اللوحة.

كود Arduino

يتحكم هذا المثال في سرعة المحرك في اتجاه واحد، باستخدام توصيلات L298N نفسها الموضحة في القسم السابق. ويفترض أن الطرف ENA متصل بالطرف 5 في Arduino، وأن IN1 وIN2 متصلان بالطرفين 7 و8 على الترتيب.

const int ENA = 5;
const int IN1 = 7;
const int IN2 = 8;
const int POT = A0;

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);

  // Select one direction
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
}

void loop() {
  int potValue = analogRead(POT);

  // Classic Arduino Uno: map 10-bit ADC to 8-bit PWM
  int motorSpeed = map(potValue, 0, 1023, 0, 255);

  analogWrite(ENA, motorSpeed);

  delay(10);
}
كيف يعمل البرنامج؟

في لوحة Arduino Uno التقليدية، تعيد الدالة analogRead() عادةً قيمة تتراوح بين 0 و1023. وتحوّل الدالة map() هذا النطاق إلى قيم من 0 إلى 255، بما يتناسب مع واجهة PWM المعتادة ذات الدقة 8 بت في هذه اللوحة.

عند تدوير المقاومة المتغيرة، تتغير قيمة دورة تشغيل PWM المطلوبة، وبالتالي يتغير متوسط القدرة التي تصل إلى المحرك. ومع ذلك، قد لا يبدأ المحرك عند القيم المنخفضة جدًا، لأنه يحتاج إلى عزم كافٍ للتغلب على الاحتكاك والحمل المتصل به. وهذا سلوك طبيعي في كثير من المحركات الصغيرة.

إذا كان المحرك يعمل بصورة غير مستقرة عند أقل إعداد للسرعة، فيمكن تجربة حد أدنى مناسب لدورة التشغيل أو إضافة دفعة قصيرة عند بدء التشغيل (Startup Boost). ويجب اختبار هذه التعديلات بعناية، لأنها قد تزيد التيار المسحوب، كما أنها لا تغني عن توفير حماية مناسبة للتيار.

12. توصيل محركي تيار مستمر والتحكم فيهما

يُستخدم محركان من نوع التيار المستمر المزود بفرش كثيرًا في السيارات الروبوتية والروبوتات المتحركة الصغيرة. ويجب أن تكون كل قناة من قنوات مشغل المحرك قادرة على تحمل متطلبات الجهد والتيار الخاصة بالمحرك المتصل بها.

توصيل محركين للتحكم في حركة سيارة روبوتية باستخدام Arduino ومشغل مزدوج

مشغل لمحركين

تستطيع وحدة تشغيل مزدوجة من نوع جسر H التحكم في محركين بصورة مستقلة. تتحكم القناة الأولى في المحرك الأيسر، بينما تتحكم القناة الثانية في المحرك الأيمن. وقد تحتوي كل قناة على مداخل منفصلة لتحديد الاتجاه، بالإضافة إلى مدخل PWM أو مدخل تمكين للتحكم في السرعة.

قبل توصيل المحركين، تحقق من حدود التيار الإجمالية للمشغل، وكذلك الحدود الخاصة بكل قناة. فقد يؤدي بدء تشغيل المحركين في الوقت نفسه إلى تحميل مصدر الطاقة بتيار كبير.

الحركات الأساسية للروبوت

يغير الروبوت ذو العجلتين، الذي يعتمد على نظام الدفع التفاضلي، اتجاه حركته عن طريق تغيير اتجاه وسرعة المحرك الأيسر مقارنةً بالمحرك الأيمن.

  • الحركة إلى الأمام: يدفع المحركان الروبوت إلى الأمام.
  • الحركة إلى الخلف: يدفع المحركان الروبوت إلى الخلف.
  • الانعطاف إلى اليسار: يتحرك المحرك الأيمن بسرعة أعلى من الأيسر، أو ينعكس اتجاه المحرك الأيسر بينما يستمر الأيمن في دفع الروبوت إلى الأمام.
  • الانعطاف إلى اليمين: يتحرك المحرك الأيسر بسرعة أعلى من الأيمن، أو ينعكس اتجاه المحرك الأيمن بينما يستمر الأيسر في دفع الروبوت إلى الأمام.
  • الدوران حول المحور (Pivot Turn): يدور المحركان في اتجاهين متعاكسين، فيدور الروبوت حول نقطة تقع بين عجلتيه.

تعتمد مستويات الإشارات المنطقية المطلوبة على طريقة توصيل المحركات فعليًا وعلى ترتيب مداخل المشغل. وإذا كان أحد المحركين مثبتًا في اتجاه معاكس للآخر، فقد تحتاج إلى عكس اتجاهه كهربائيًا في البرنامج أو بتبديل سلكيه.

لماذا قد تختلف سرعة المحركين؟

حتى عند تشغيل المحركين بقيمة دورة تشغيل PWM نفسها، قد تختلف سرعتهما بسبب تفاوتات التصنيع، والاحتكاك الميكانيكي، واختلاف أقطار العجلات، وجهد البطارية، وتوزيع الحمل على الروبوت.

لتحسين دقة الحركة في خط مستقيم، يمكن استخدام مشفرات الدوران (Encoders) أو مستشعرات أخرى لقياس السرعة، ثم تطبيق نظام تحكم بالتغذية الراجعة لتصحيح الاختلاف بين المحركين.

تحدد إشارة PWM أمر التشغيل المطلوب، لكنها لا تضمن وصول المحرك إلى سرعة دوران محددة بوحدة RPM.

13. التطبيقات الشائعة ومشروعات الإلكترونيات للهواة

تُستخدم محركات التيار المستمر في العديد من المشروعات الإلكترونية العملية، لأنها توفر طريقة مباشرة لتحويل إشارات التحكم الكهربائية إلى حركة فعلية.

تطبيقات محركات التيار المستمر في المشروعات الإلكترونية والروبوتات

السيارة الروبوتية

يمكن استخدام محركين من نوع التيار المستمر المزودين بعلبة تروس، مع وحدة تشغيل مزدوجة من نوع جسر H. وتتيح لوحة Arduino التحكم في الحركة إلى الأمام والخلف، وضبط السرعة، وتغيير اتجاه السيارة. كما يمكن إضافة مستشعرات المسافة أو مستشعرات تتبع الخط لجعل الروبوت قادرًا على الاستجابة لما يحيط به.

سير ناقل صغير

يمكن استخدام محرك تيار مستمر مزود بعلبة تروس لتشغيل سير ناقل صغير. ويوفر تعديل عرض النبضة (PWM) إمكانية ضبط السرعة الأساسية، بينما يمكن استخدام مستشعر لاكتشاف الأجسام التي تمر على السير.

إذا كان التطبيق يتطلب الحفاظ على سرعة ثابتة رغم تغير الحمل، فيمكن إضافة مستشعر لقياس السرعة واستخدام نظام تحكم بالتغذية الراجعة لتصحيح الاختلافات.

وحدة التحكم في سرعة المروحة

يمكن في كثير من الحالات التحكم في سرعة مروحة تعمل بمحرك تيار مستمر مزود بفرش باستخدام ترانزستور مناسب أو مشغل محرك. ويجب اختيار طريقة التحكم وفقًا للجهد والتيار المقننين للمروحة ولطبيعة دائرتها الإلكترونية الداخلية.

تحتاج بعض المراوح إلى مدخل تحكم مخصص، بدلًا من تطبيق إشارة PWM على مصدر تغذيتها مباشرةً. لذلك، راجع مواصفات المروحة قبل تحديد طريقة التحكم المناسبة.

الآليات الأوتوماتيكية

يمكن استخدام محرك تيار مستمر لتحريك بوابة صغيرة أو منصة منزلقة أو آلية ميكانيكية أخرى. ولتصميم أكثر أمانًا، أضف مفاتيح تحديد نهاية المشوار (Limit Switches) ومحددات ميكانيكية، ووسيلة لمراقبة التيار، وآلية لإيقاف المحرك إذا تعذر استمرار الحركة بسبب وجود عائق.

لا يستطيع محرك التيار المستمر التقليدي معرفة موضع عموده تلقائيًا. لذلك، إذا كان التطبيق يتطلب تحكمًا دقيقًا في الموضع، فاستخدم مشفرات الدوران (Encoders) أو مفاتيح تحديد نهاية المشوار أو وسيلة مناسبة أخرى للتغذية الراجعة.

14. استكشاف الأخطاء وإصلاحها ونصائح السلامة

غالبًا ما تنتج مشكلات التحكم في المحركات عن محدودية مصدر الطاقة، أو أخطاء التوصيل، أو اختيار مشغل غير مناسب، أو افتراضات غير صحيحة بشأن PWM وعلاقة إشارة التحكم بسرعة المحرك.

استكشاف أعطال محركات التيار المستمر وفحص التوصيلات وإجراءات السلامة

المشكلة السبب المحتمل ما الذي ينبغي فحصه؟
المحرك لا يدور. توصيلات غير صحيحة، أو غياب تغذية المحرك، أو عدم تفعيل المشغل. افحص جهد مصدر الطاقة والأرضي وإشارة التمكين ومداخل الاتجاه.
إعادة تشغيل Arduino عند بدء حركة المحرك. انخفاض جهد التغذية أو حدوث تشويش كهربائي. استخدم مصدر طاقة مناسبًا للمحرك، وحسّن التوصيلات، وافصل مسارات الطاقة المسببة للتشويش عن المسارات الحساسة عند الحاجة.
المحرك يعمل بأقصى سرعة فقط. توصيل PWM بصورة غير صحيحة أو استخدام طرف لا يدعم PWM. راجع مخطط أطراف اللوحة، وجسر التمكين، ووثائق مشغل المحرك.
المحرك يدور في الاتجاه الخاطئ. عكس توصيلات المحرك أو منطق التحكم في الاتجاه. بدّل سلكَي المحرك أو اعكس أوامر الاتجاه في البرنامج.
ارتفاع حرارة المحرك أو مشغل المحرك بصورة مفرطة. تيار زائد، أو حمل ميكانيكي أكبر من اللازم، أو هبوط جهد في المشغل. افحص تيار التوقف والحمل والتبريد والحدود المسموح بها للمشغل.
بدء المحرك بصورة غير مستقرة عند قيم PWM المنخفضة. دورة التشغيل غير كافية للتغلب على الاحتكاك أو الحمل. اختبر حدًا أدنى مناسبًا لدورة التشغيل عند بدء المحرك.
انحراف الروبوت ذي العجلتين إلى أحد الجانبين. عدم تطابق المحركين أو العجلتين أو الأحمال الميكانيكية. تحقق من المحاذاة الميكانيكية، واستخدم التغذية الراجعة من مشفرات الدوران عند الحاجة.
السلامة الكهربائية
  • افصل مصدر الطاقة قبل تغيير توصيلات المحرك.
  • تحقق من الجهد المقنن للمحرك ومن نطاق الجهد المسموح به لمشغل المحرك.
  • اختر مشغل المحرك ومصدر الطاقة بحيث يتحملان ظروف بدء التشغيل وتيار التوقف الفعلي المتوقع.
  • استخدم وسائل مناسبة للحماية من الجهد الناتج عن الأحمال الحثية، واتبع دائرة التطبيق الموصى بها من الشركة المصنعة للمشغل.
  • امنع ملامسة الموصلات المكشوفة بعضها ببعض لتجنب حدوث قصر كهربائي.
  • راقب درجة حرارة مشغل المحرك، ووفر التبريد المناسب إذا لزم الأمر.
  • لا تسمح ببقاء المحرك في حالة توقف مع استمرار تغذيته بالتيار، إلا إذا كان المحرك والمشغل ومصدر الطاقة مصممين لتحمل هذه الحالة.

عند التعامل مع المحركات ذات القدرة الأعلى، أضف مصهرات كهربائية مناسبة، واستخدم أسلاكًا ذات مقطع يتحمل التيار المتوقع، ووفر وسيلة لإيقاف الطوارئ عند الحاجة.

ولا تقتصر السلامة على الجوانب الكهربائية؛ فالأعمدة الدوارة والتروس والعجلات والسيور قد تسبب انحشار الأصابع أو تعلق الملابس الفضفاضة. لذلك، احرص على إبعاد اليدين والملابس عن الأجزاء المتحركة أثناء التشغيل.

15. الأسئلة الشائعة

هل يمكن توصيل محرك تيار مستمر مباشرةً بلوحة Arduino؟

لا، ليس بالنسبة إلى معظم محركات التيار المستمر. فقد صُممت أطراف GPIO في Arduino لإرسال إشارات منطقية ذات تيار منخفض، وليست لتغذية المحركات مباشرةً. استخدم ترانزستورًا مناسبًا أو وحدة تشغيل للمحرك، مع مصدر طاقة يتوافق مع متطلبات المحرك.

كيف يمكن التحكم في سرعة محرك التيار المستمر؟

إحدى الطرق الشائعة هي استخدام تعديل عرض النبضة (PWM). إذ يغيّر المتحكم الدقيق دورة تشغيل الإشارة المرسلة إلى مشغل المحرك، مما يغيّر القدرة الفعّالة التي تصل إليه. وتعتمد السرعة الفعلية أيضًا على خصائص المحرك وجهد التغذية وفقد الجهد في المشغل والحمل الميكانيكي.

كيف يمكن عكس اتجاه دوران محرك التيار المستمر؟

بالنسبة إلى محرك التيار المستمر المزود بفرش، يمكن عكس اتجاه الدوران عن طريق عكس القطبية المطبقة على طرفَي المحرك. وتتيح وحدة تشغيل من نوع جسر H تنفيذ ذلك إلكترونيًا دون الحاجة إلى تبديل الأسلاك يدويًا في كل مرة.

ما الفرق بين PWM والتحكم باستخدام جهد تناظري؟

تعتمد PWM على التبديل السريع للإشارة بين حالتين: الفعّالة وغير الفعّالة، وتحدد دورة التشغيل النسبة الزمنية التي تظل فيها الإشارة فعّالة.

أما التحكم التناظري الحقيقي فيعتمد على توفير جهد قابل للتعديل بصورة مستمرة. لذلك، فإن إشارة PWM ليست خرجًا تناظريًا حقيقيًا تلقائيًا، حتى لو استُخدمت للتحكم في القدرة الفعّالة التي تصل إلى المحرك.

هل يمكن استخدام مصدر طاقة 12 فولت مع محرك تيار مستمر مصمم لجهد 6 فولت؟

لا ينبغي فعل ذلك مباشرةً، إلا إذا كان نظام التحكم في المحرك يحد الجهد والقدرة اللذين يصلان إليه ضمن مستويات مناسبة. فقد يؤدي استخدام مصدر 12 فولت مع محرك مصمم لجهد 6 فولت إلى سرعة مفرطة وتيار مرتفع وارتفاع كبير في درجة الحرارة. اختر مصدر الطاقة وترتيب المشغل بما يتوافق مع مواصفات المحرك.

لماذا يسحب محرك التيار المستمر تيارًا مرتفعًا عند بدء التشغيل؟

عند بدء التشغيل، لا يكون المحرك قد بدأ بالدوران بعد، ولذلك تكون القوة الدافعة الكهربائية العكسية منخفضة. ويُحدَّد التيار في هذه اللحظة أساسًا بمقاومة ملفات المحرك وبقية عناصر الدائرة. ومع ازدياد سرعة المحرك، ترتفع القوة الدافعة الكهربائية العكسية، وينخفض التيار عادةً.

هل تؤدي زيادة قيمة PWM دائمًا إلى زيادة سرعة المحرك؟

بوجه عام، تؤدي زيادة دورة التشغيل إلى زيادة السرعة عند تشابه ظروف التشغيل. ومع ذلك، فإن دورة تشغيل PWM ليست قياسًا مباشرًا للسرعة؛ إذ تؤثر تغيرات الحمل وجهد التغذية والاحتكاك وخصائص المحرك في سرعة الدوران الفعلية.

هل يمكن التحكم في محركين باستخدام لوحة Arduino واحدة؟

نعم، يمكن التحكم في محركين باستخدام مشغل ذي قناتين، بشرط أن يتحمل المشغل ومصدر الطاقة متطلبات المحركين معًا. ويتطلب التحكم المستقل في سرعة كل محرك واتجاهه عددًا كافيًا من إشارات التحكم أو استخدام واجهة مناسبة توفر هذه الوظائف.

هل أحتاج إلى مشفر دوران (Encoder) للتحكم في سرعة المحرك؟

لا تحتاج إلى مشفر دوران عند استخدام PWM لضبط السرعة بصورة أساسية بنظام التحكم المفتوح الحلقة. لكن إذا كنت تريد المحافظة على سرعة مستهدفة رغم تغير الحمل، فيمكن استخدام مشفر دوران أو مستشعر سرعة مناسب لتوفير التغذية الراجعة وتطبيق تحكم مغلق الحلقة.

ما أفضل مشغل محرك للمبتدئين؟

لا يوجد مشغل واحد يناسب جميع المحركات. يعتمد الاختيار على جهد المحرك وتيار التوقف ومتطلبات التحكم في الاتجاه والسرعة والقيود الحرارية وميزات الحماية المتوفرة.

تُعد وحدات مثل L298N وTB6612FNG وDRV8833 خيارات شائعة، لكنها تختلف في خصائصها وحدود تشغيلها. لذلك، تحقّق من وثائق الوحدة المحددة قبل استخدامها.

16. الخاتمة

تُعد محركات التيار المستمر من المكونات الأساسية في الروبوتات وأنظمة الأتمتة ومشروعات الإلكترونيات للهواة. ويساعد فهم خصائصها الكهربائية والميكانيكية على اختيار المحرك المناسب، وتصميم توصيلات موثوقة، وتطوير برامج فعّالة للتحكم في الحركة.

ومن أهم المبادئ التي ينبغي مراعاتها استخدام مشغل مناسب للمحرك بدلًا من تغذيته مباشرةً من أحد أطراف المتحكم الدقيق، واختيار مصدر طاقة يلبي متطلبات المحرك، واستخدام PWM للتحكم الأساسي في السرعة، والاستعانة بدائرة جسر H عندما تحتاج إلى عكس اتجاه الدوران إلكترونيًا.

توفر هذه التقنيات مع Arduino نقطة انطلاق عملية لتطوير السيارات الروبوتية والمراوح والسيور الناقلة وغيرها من مشروعات التحكم في الحركة. ومع زيادة متطلبات مشروعاتك، يمكنك تطوير هذه الأساسيات بإضافة مشفرات الدوران، وأنظمة التحكم بالتغذية الراجعة، ودوائر قياس التيار، ومشغلات محركات أكثر تقدمًا.

Leave a comment