Controlling a servo using RTL8722DM

A simple project on controlling the servo motor with PWM

Public Chat
Similar projects worth following
Pulse-Width Modulation (PWM) can be implemented on the Ameba in several ways. PWM signal is a digital square wave, where the frequency is constant, but that fraction of the time the signal is on (the duty cycle) can be varied between 0 and 1.

Ameba RTL8722DM is a low-power dual-band WLAN and Bluetooth Low Energy SoC by Realtek. The RTL8722DM also include memory for Wi-Fi protocol functions and application making it simple for anyone to develop various kind of IoT applications. At the same time it has a wide range of peripheral interfaces. With all these interfaces, it can connect to most of the electronics components like LEDs, temperature and humidity sensors, and so on.

A typical servo has 3 wires, the red wire is for power, black or brown one should be connected to GND, and the other one is for signal data. We use PWM signal to control the rotation angle of the axis of the servo. The frequency of the signal is 50Hz, that is length 20ms. Each servo defines its pulse bandwidth, which is usually 1ms~2ms.

To control the rotation angle, for example if 1ms-length pulse rotates the axis to degree 0, then 1.5 ms pulse rotates the axis to 90 degrees, and 2 ms pulse rotates the axis to 180 degrees. Furthermore, a servo defines the “dead bandwidth”, which stands for the required minimum difference of the length of two consecutive pulse for the servo to work.

More Resources:

If you need additional technical documents or the source code for this project. Please visit the official websites and join the Facebook group and forum.

Edit details

  • 1 × Ameba RTL8722DM microcontroller
  • 1 × Servo Motor Electronic Components / Misc. Electronic Components
  • 1 × Jumper wire Fiber Optics / Emitters

  • 1

    First, connect the servo motor to Ameba RTL8722DM as shown in the wiring diagram.

  • 2

    The programming of the Ameba RTL8722DM can be done using Arduino IDE which makes it very easy to write code and upload code to the Ameba Board.

    To open the example code in Arduino IDE, Open "File" -> "Examples" -> "AmebaAnalog" -> "ServoSweep".

  • 3
    Final Results!

    Verify and upload the code. Press the reset button on Ameba once the uploading is complete.

    You will see the servo motor rotate from 0 to 180 degree, and after that rotate back to 0 degree.

View all 3 instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates