This is an old revision of the document!


EMB10: Controlling standard servo

You will learn how to control a standard miniature servo in this scenario. Standard miniature, so-called “analogue” servo is controlled with a PWM signal of 50Hz with a duty cycle between 1 ms (rotate to 0) and 2 ms (rotate to 180 degrees), where 1.5 ms corresponds to 90 degrees.

Do not keep the servo rotating when leaving the lab. Implement your code as non-repeating. A servo that remains rotating for a long time may easily wear out its gears, overheat and even burn!

A servo has a red arrow presenting the gauge's current position.

Note that servos tend to have relatively high implementation inaccuracy. Moreover, as the arrow is not in the centre of view of the camera but instead to the corner, the reading may be subject to error because of the parallaxes and lens distortion.

The servo is an actuator. It requires a time to operate. So, you should give it time to operate between consecutive changes of the control PWM signal (requests to change its position). Moreover, because of the observation via camera, too quick rotation may not be observable at all depending on the video stream fps. A gap of 2s between consecutive rotations is usually a reasonable choice.

Prerequisites

To ease servo control, instead of use of ledc we will use a dedicated library:

ib_deps = dlloydev/ESP32 ESP32S2 AnalogWrite@^5.0.2

This library requires minimum setup but, on the other hand, supports, i.e. fine-tuning of the minimum and maximum duty cycle as some servos tend to go beyond 1ms and above 2ms to achieve a full 180-degree rotation range. It is usually provided in the technical documentation accompanying the servo.

Suggested Readings and Knowledge Resources

Hands-on Lab Scenario

Task to be implemented

Rotate the servo to the following angles: 0, 90, 180, 135, 45 and back to 0 degrees.

Start

Check if the servo is in the camera view. The servo is controlled with GPIO 37.

Steps

Write some extra information if, i.e. some steps are optional; otherwise, cancel this paragraph (but do not remove the header).

Step 1

Describe activities done in Step 1.

Step n

Describe activities done in Step n.

Result validation

Provide some result validation methods for self-assessment.

FAQ

This section is to be extended as new questions appear.
When using the printed version of this manual, please refer to the latest online version of this document to obtain the valid and up-to-date list of the FAQ. Provide some FAQs in the following form:
Question?: Answer.

Project information


This Intellectual Output was implemented under the Erasmus+ KA2.
Project IOT-OPEN.EU Reloaded – Education-based strengthening of the European universities, companies and labour force in the global IoT market.
Project number: 2022-1-PL01-KA220-HED-000085090.

Erasmus+ Disclaimer
This project has been funded with support from the European Commission.
This publication reflects the views of only the author, and the Commission cannot be held responsible for any use that may be made of the information contained therein.

Copyright Notice
This content was created by the IOT-OPEN.EU Reloaded consortium, 2022,2024.
The content is Copyrighted and distributed under CC BY-NC Creative Commons Licence, free for Non-Commercial use.

en/iot-open/practical/hardware/sut/esp32/emb10_1.1709158165.txt.gz · Last modified: 2024/02/28 22:09 by pczekalski
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0