servo

Description

This sample demonstrates the functionality of the MG996R servo motor. This is done by endlessly varying the current angle from 0 degress (leftmost position) to 180 degrees (rightmost position) using a step size of 10 degress. As per the MG996R datasheet, the period of the PWM signal is set to 20ms.

Purpose

Use this sample to check if you’ve successfully managed to hook up the MG996R servo motor to your development board.

Hardware

This sample requires the MG996R servo motor be connected to the development board. Information on how to set up the servo motor can be found here: The MG996R servo motor.

Where to find?

This sample is located under: samples/servo.

API reference

You can find the API documentation here.

Configurations

This sample has no configurable feats.

How to build

To build this sample, run:

west build -p -b frdm_imx93//a55 samples/servo -D DTC_OVERLAY_FILE=frdm_imx93.overlay

The resulting binary may be found under: build/zephyr/zephyr.bin.

How to run

To run the sample, follow the steps detailed in Booting the board.

Expected behavior

If everything went well, your serial console (ttyACM1/COM4) should continuously display messages similar to the ones shown below:

../_images/servo_sample_output.png

Furthermore, the motor’s rotation angle should change by 10 degrees every second as shown below [1], [2]:

../_images/servo_video.gif