Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:practical:hardware:sut:esp32:emb10_1 [2024/02/28 22:09] – [Start] pczekalskien:iot-open:practical:hardware:sut:esp32:emb10_1 [2024/04/09 12:58] (current) – [Result validation] pczekalski
Line 22: Line 22:
 ==== Task to be implemented ==== ==== Task to be implemented ====
 Rotate the servo to the following angles: 0, 90, 180, 135, 45 and back to 0 degrees. Rotate the servo to the following angles: 0, 90, 180, 135, 45 and back to 0 degrees.
 +<note warning>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!</note>
  
 ==== Start ==== ==== Start ====
-Check if the servo is in the camera view. Servo is controlled with GPIO 37.+Check if the servo is in the camera view. The servo is controlled with GPIO 37.
  
 ==== Steps ==== ==== Steps ====
-// Write some extra information ifi.e. some steps are optional; otherwise, cancel this paragraph (but do not remove the header).//+**Write your application all in the ''setup()'' functionleaving ''loop()'' empty.** 
 +<note warning>Do not keep the servo rotating when leaving the labImplement your code as non-repeating. A servo that remains rotating for a long time may easily wear out its gears, overheat and even burn!</note>
 === Step 1 === === Step 1 ===
-//Describe activities done in Step 1.//+Include servo control library, specific for ESP32 and declare GPIO, minimum and maximum duty cycle values: 
 +<code c> 
 +#include <Servo.h> 
 +#define SRV_PIN 37 
 +</code> 
 +MG 90 servos that we use in our lab are specificAs 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     2 
 +#define srv_min_us  550 
 +#define srv_max_us 2400 
 +</code>
  
-...+=== Step 2 === 
 +Define a servo controller object: 
 +<code c> 
 +static Servo srv; 
 +</code>
  
-=== Step === +=== Step === 
-//Describe activities done in Step n.//+Initialise parameters (duty cycle, channel, GPIO): 
 +<code c> 
 +srv.attach(SRV_PIN, PWMSRV_Ch,srv_min_us, srv_max_us); 
 +</code> 
 +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,180); 
 +delay(2000); 
 +</code>
  
-==== Result validation ==== 
-//Provide some result validation methods for self-assessment.// 
  
 ===== FAQ ===== ===== 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. 
-// 
  
 +**How do I know minimum and maximum values for the timings for servo operation?**: Those parameters are provided along with servo technical documentation, so you should refer to them. Our configuration reflects the servos we use (MG90/SG90), and as you can see, it goes far beyond the standard servo rotation control that is a minimum of 1000us and a maximum of 2000us. Using standard configuration, your servo won't rotate at full 180 degrees but at a shorter rotation range.
 +
 +==== Result validation ====
 +Observe the red arrow to rotate accordingly. Remember to give the servo some time to operate.
 +
 +<WRAP noprint>
 ===== Project information ===== ===== Project information =====
 {{:en:iot-open:logo_iot_200_px.png?200|}}\\ {{:en:iot-open:logo_iot_200_px.png?200|}}\\
Line 62: Line 88:
 {{:en:iot-open:ccbync.png?100|}} {{:en:iot-open:ccbync.png?100|}}
 </figure> </figure>
- +</WRAP>
- +
en/iot-open/practical/hardware/sut/esp32/emb10_1.1709158158.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