代做MEC 5882/6882 – Instrumentation, Sensing and Monitoring Lab 3 – Micro Servo Lab代写留学生数据结构程序

2025-05-07 代做MEC 5882/6882 – Instrumentation, Sensing and Monitoring Lab 3 – Micro Servo Lab代写留学生数据结构程序

MEC 5882/6882 - Instrumentation, Sensing and Monitoring

Lab 3 - Micro Servo Lab

Laboratory Handout

Lab 3 - Micro Servo Lab constitutes 8% of your unit mark in total. To complete this lab, you are required to complete all the six (6) tasks instructed in this lab handout over two laboratory sessions in Week 7 (Part A of the handout) and Week 8 (Part B of the handout).

Introduction - What is SONAR?

SONAR or Sound Navigation and Ranging was initially used to locate objects underwater. SONAR is also being routinely used in-air for robot navigation and large-scale high-resolution seafloor mapping.

SONAR systems are often categorised into two types: active and passive. Passive systems use an array of hydrophones (a microphone designed to be used underwater) to passively “listen” to the noise emitted from objects. Active systems on the other hand actively send out acoustic pulses and wait for the echoes reflected from the objects.

The purpose of this laboratory experiment is to implement an actuating mechanism in combination with the ultrasonic distance measuring module you developed in the previous lab to measure angular displacement. In this lab, you are required to develop an in-air SONAR system which has the capability of measuring distances to multiple objects over 180° span and map the measurements with respect to angle.

Learning Outcomes

By the end of this laboratory experiment, you will have the knowledge and tools:

1.  To understand the basic Arduino Digital I/O functions.

2.  To control a micro-servo using Arduino.

Development Kit

You will be provided with the following equipment for the duration of the lab:

•    1 × Arduino Uno with USB cable,

•    1 × breadboard,

•    1 × ultrasonic module (HC-SR04),

•    1 × ultrasonic sensor mounting bracket,

•    1 × computer with Arduino IDE,

•   Additional electronic wiring as required,

•    1 × micro-servo.

IMPORTANT - Before you begin:

•    It is crucial to connect the ultrasonic sensor to the ground (GND) terminal before connecting the circuit to the power source to avoid damaging the hardware.

•   The testing area should not be less than 0.5 m2  and the surface of the object should be as smooth as possible to increase the accuracy of the results.

•   The digital pins 0 (RX) and 1(TX) are used for serial communication. Please do not use these pins for any other communication.

General Hints

•    Draw a schematic of the system and your concept before starting. This will help to ensure that you can efficiently complete the tasks.

•    Many Arduino example sketches are available; use them to build up your system. Consider what your task is at a basic level and find similar projects/tasks.

•    Make sure you select the correct board type of Arduino in the IDE.

Required Tasks

Please complete the following task in order, and make sure to save your work as it will be reused in future sessions.

Part A - Week 7

Task 1 – Servo Control

In this task, you are required to complete the connections between the micro-servo and Arduino and develop a program for the Arduino to control the servo.

Connect the ultrasonic module to the correct pins of Arduino:

• PWM pin (orange) of the micro-servo should be connected to digital I/O pins of Arduino.

• Connect VCC (red) from micro-servo to 5V on Arduino

• GND (brown) of micro-servo to GND pin on Arduino.

• Define the pins in your program according to your connections

Implement your own Arduino program (Visit Arduino Website for reference):

• Define your servo object and attach the servo using servo attach() function in the setup code.

• Define initial angle of the servo, servoPosition = 0.

• For every time step dt, increase servoPosition and update it to your servo using servo write() function.

• When the servo completes a half circle (i.e. 180°), reset its position and repeat the process.

• Print the servo position through the serial port at every time step.

By completing this task, your program must be able to rotate the servo over 180° span repeatedly.

Task 2 – Ultrasonic Module Integration

Connect the ultrasonic module to the Arduino. Integrate the distance measurement code you completed in Lab 1 – Microcontroller Programming to your servo control loop.

Print the measured distance together with the servo position through the serial monitor at every time step.

Hint: the time step dt is directly related to the pulse repetition frequency in Lab 1. Remember to set this value accordingly in order to get the correct measurements.

By completing this task, your program must be able to return the measured distance and the servo position, while the servo motor is sweeping over 180° repeatedly. Record this data in the table provided on page 6.

Time Step                            Measured distance (cm)                            Servo position (Degrees)

1                                                                                                                        0

2                                                                                                                       10

3                                                                                                                       20

.                                                                                                                         .

.                                                                                                                         .

N                                                                                                                      180

Task 3 – Data Page

After completing Task 1 to 2, please call the lab supervisor to check your setup and demonstrate the recorded data.