This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:practical:hardware:sut:esp32:emb10_1 [2024/02/28 22:12] – pczekalski | en:iot-open:practical:hardware:sut:esp32:emb10_1 [2024/04/09 12:58] (current) – [Result validation] pczekalski | ||
|---|---|---|---|
| Line 31: | Line 31: | ||
| <note warning> | <note warning> | ||
| === Step 1 === | === Step 1 === | ||
| - | Include servo control library, specific for ESP32 and declare GPIO: | + | Include servo control library, specific for ESP32 and declare GPIO, minimum and maximum duty cycle values: |
| <code c> | <code c> | ||
| #include < | #include < | ||
| #define SRV_PIN 37 | #define SRV_PIN 37 | ||
| </ | </ | ||
| - | ==== Step 2 ==== | + | MG 90 servos that we use in our lab are specific. As mentioned above, to achieve a full 180-degree rotation range, their minimum and maximum duty cycle timings go far beyond standards. Here, we declare minimum and maximum values for the duty cycle (in microseconds) and a PWM control channel (2): |
| + | <code c> | ||
| + | #define PWMSRV_Ch | ||
| + | #define srv_min_us | ||
| + | #define srv_max_us 2400 | ||
| + | </ | ||
| + | === Step 2 === | ||
| + | Define a servo controller object: | ||
| + | <code c> | ||
| + | static Servo srv; | ||
| + | </ | ||
| - | ==== Step 3 ==== | + | === Step 3 === |
| + | Initialise parameters (duty cycle, channel, GPIO): | ||
| + | <code c> | ||
| + | srv.attach(SRV_PIN, | ||
| + | </ | ||
| + | 50Hz frequency is standard, so we do not need to configure it. | ||
| + | === Step 4 === | ||
| + | Rotating a servo is as easy as writing the desired angle to the controller class, e.g.: | ||
| + | <code c> | ||
| + | srv.write(SRV_PIN, | ||
| + | delay(2000); | ||
| + | </ | ||
| - | ... | + | ===== FAQ ===== |
| - | === Step n === | + | **How do I know minimum and maximum values for the timings for servo operation? |
| - | //Describe activities done in Step n.// | + | |
| ==== Result validation ==== | ==== Result validation ==== | ||
| - | //Provide some result validation methods for self-assessment.// | + | Observe the red arrow to rotate accordingly. Remember |
| - | + | ||
| - | ===== 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 | + | |
| - | //Provide some FAQs in the following form:\\ | + | |
| - | **Question? | + | |
| - | // | + | |
| + | <WRAP noprint> | ||
| ===== Project information ===== | ===== Project information ===== | ||
| {{: | {{: | ||
| Line 74: | Line 88: | ||
| {{: | {{: | ||
| </ | </ | ||
| - | + | </ | |
| - | + | ||