Exerci
XJME1010 Coursework – MCU Systems
Lab #1.1: Circuit Training
Global Health Drone: Autopilot Controller
INTRODUCTION
Global Health Drone is designed to travel across large landscapes in remote and
resource-limited parts of the world – areas where traditional healthcare systems
struggle to provide assistance, particularly during emergencies.
The drone’s job is to search across large landscapes, locating potentially injured
person(s) via camera systems and then use a thermal imaging system to scan and
provide vital medical feedback to medics who can assess and come to help...
So your task is to program a balance control system for the drone which holds it in a stable position while the system performs a thermal scan....
You
• Lab Notes • Practice
Simulation
• Testbed for code
• Unlimited attempts
ReLOAD
•Real Hardware •50 Attempts!
Please read this coursework guide carefully for full instructions, including your objectives, technical background and a mark scheme. Over and Out.
XJME1010: Computing For Engineers
Revision 03 – 12.09.2023
AIM AND OBJECTIVES
The aim is to develop a balance control system which moves your drone to a stable horizontal position and holds it there for 5 seconds while it performs a thermal scan...
APPROACH
Drones are expensive... so you will need to develop your code carefully in two stages using:
-
A drone simulation (in WokWi): develop your code until it is functional and error free ...
-
The ReLOAD drone model: now test your code on a real system and tune the controller
IMPORTANT: You are limited to 50 test runs on the ReLOAD system!
(This represents industry practice – testing on hardware is costly ... only attempted when you have a system you are confident will work effectively!
OBJECTIVES
-
Produce a Flow Chart of your program from the Specification (see Page 4)
-
Write an Arduino drone controller program (based on your Flow Chart) which:
a. Initialises your system hardware
b. Implements a closed-loop controller to reach and maintain a horizontal position-
Your controller should run at 25Hz
-
As a minimum you should implement a Proportional controller
c. Lights LEDs to indicate (System start, Reached Target Angle (Scanning Start), Scanning complete d. Sends flight telemetry data via Serial – see Page 4 for the detail
e. Use good programming practice to produce a well-structured and understandable program
f. Use functions to implement-
Sensor measurement
-
The controller
-
Other functions of your choice...
-
-
Collect and submit evidence from ReLOAD of your system in action (see Deliverables, Page 6)
-
Your flow-chart (1 side of A4)
-
Your program
-
ReLOAD outputs (.CSV and Video file)
-
XJME1010: Computing For Engineers P2
SYSTEM DESCRIPTION
You will develop your controller using the model drone system shown in Figure 1.
The drone is represented by a beam, pivoting at the middle, with a motor-driven propeller at each
end. The beam is free to rotate about the pivot, simulating the drone moving in the air. Your Arduino
controller is connected to:
-
1) A potentiometer which can be used to measure the angle of the drone (relative to ground).
-
2) Two H-Bridge motor controllers, each linked to a high-power DC motor and power supply
Figure 1. Configuration of the model helicopter system
HARDWARE
The hardware in the drone model is described here. You will need to use this to configure your Arduino system correctly, and to calibrate your sensor measurement.
Item Information
Motor
NOTE:
You will control these motors using code provided in the
template (See WOKWI Simulator Section) like this:
alalogWrite(127);
Motor Controller
• D12 - Direction
• D3 - PWM (work duty)
• D9 - Brake
Potentiometer
For calibration, we took the following measurements: 329 -40
40
The potentiometer output voltage will change linearly as a function of the angle shown in Figure 1.
The output Vpot can be measured using Arduino Pin A0
Vpot Angle |
|
536 |
0 |
701
Output LEDS
Use these LEDs to signify the status of the control system.
Start-up LED (Green) = Pin 11 Scanning LED (Yellow) = Pin 10 Scan End LED (Red) = Pin 9
Table 1: Equipment specification for the model helicopter
XJME1010: Computing For Engineers P3
SPECIFICATION
Your balance controller should be written to go through the following process – please read this carefully!
You will need to convert this into a Flow Chart as part of your submission
The process is defined by a series of numbered stages. Each stage requires you to perform some tasks which are detailed.
-
As your control program starts it must initialise the system. Setup your Serial communication so you can send messages. Configure your hardware connections to the sensor and motors. Initialise the motors by sending a 0 (zero) signal to the motor.
-
Show that your balance controller (the programme you write) has started by lighting the Start-up LED for 1 second
-
Your controller should now start. It should run continuously at 25Hz.
-
The controller first reads the angle sensor to determine the current angular position of the drone
-
Now your controller should calculate a motor control signal
-
Convert the motor control signal into control signals for the motor
-
Send telemetry information using Serial communications
-
Check if you moved within 5 degrees of the target angle (e.g. horizontal)
-
Yes? Start your `Scan Timer` and Light the Scanning LED
-
Once Scanning has started – it must continue regardless of the drone angle
-
-
Continue the controller until your Scan Timer reaches 5 seconds
-
-
Shutdown: Light the Shutdown LED for 1 second and turn-off the motors
AUTO-PILOT BLACKBOX DATAFILE
As your program runs it should generate a BlackBox datafile - formatted in the same way as the example below but with your own data.
This must be submitted as part of your coursework to demonstrate that your program runs and how well it performs! (Note the ... just indicates lots more data!)
0.System Started
1.System Initiated
2.Controller Starting
Time,Angle,Error,Control Signal,Motor
0.00,0.3,0.15,45,55
0.02,0.29,0.14,41,65
.....
8.00,0.151,0.01,10,70
4. Shutdown
UNITS: Please ensure you report your data in the following format
Time
Current Angle
Error
Control Signal
Motor
Example data that should be printed to Serial as your program runs.
Note: the numeric values are only examples – yours should use the actual values you record!
seconds
degrees
degrees
n/a
0-100 percentage activation
2 decimal places
2 decimal places
2 decimal places
XJME1010: Computing For Engineers P4
THE CLOSED LOOP CONTROLLER
CONTROLLER TYPE
Your program should implement a closed-loop controller.
The basic version you should attempt is a Proportional Controller – see lecture notes/slides
For additional marks you can implement a more advanced PID controller – see links below This must be made clear in your code comments!
SIMULATION
Please find the simulation and template code at this address:
https://wokwi.com/projects/375829279695206401
Item Purpose |
|
Orange LED |
Motor |
Green LED
Red LED
Template Code
Startup LED Shutdown LED Your starting point!
Yellow LED |
Scanning LED |
Potentiometer |
Angle Sensor |
REFERENCE: PID CONTROLLERS
https://scholarscompass.vcu.edu/cgi/viewcontent.cgi?article=5737&context=etd https://www.omega.co.uk/prodinfo/pid-controllers.html
COMPLETING THE COURSEWORK
HOW IS IT ASSESSED?
The coursework is worth 50% of the overall XJME1010 module mark.
It is designed to be completed individually, without any collaboration with other students.
Expertise: The programming and skills required to complete this coursework relate directly to the learning objectives of this part of the module. They have been covered in the lecture and lab activities – please refer back to these for examples.
Deadline: Please see the deadline on Minerva
Deliverables: You must submit the following items through Minerva – correctly named –to receive a mark
• Each file named in this format: o A Flowchart PDF
o Arduino File:
o ReLOAD CSV Data
o ReLOAD Video
username_XJME1010_.XYZ
username_XJME1010.pdf
username_XJME1010.ino
Original name
Original name
(Use the provided PPTX template!!)
e.g. men18xyz_XJME1010.ino)
e.g. Experiment_1614027456688_data.csv
e.g. RELOA_15_Mar_2021_14_49_5722.mp4
XJME1010: Computing For Engineers
P5
CHECK: The ReLOAD Data files are unique to your username and will be checked against the ReLOAD
Server
Please do not alter data-files or your submission will be investigated for plagiarism!
MARK ALLOCATION
The table below details how marks will be assigned for your project work. These are linked to the learning objectives that this coursework has been designed to assess. These are based on the material you have covered in the lectures, labs and self-study exercises, look back at your notes for examples and reminders!
2. Angle measurement 10
4. Main auto-pilot program 25 a. Features (15) b. Logic and Process (10)
6. Good programming practice 15
PLAGIARISM
Your code will be checked for plagiarism and malpractice – compared to other student’s work.
PLEASE TAKE NOTE – COMPLETE THE COURSEWORK INDIVIDUALLY. DO NOT SHARE CODE OR DISCUSS YOUR SOLUTION!
Objective Mark % |
|
1. Flow chart |
15 |
3. Controller implementation |
15 |
5. Formatted telemetry data |
10 |
7. Performance of the controller |
10 |
XJME1010: Computing For Engineers P6
APPENDIX: DEVELOPING FLOWCHARTS TO SOLVE ENGINEERING PROBLEMS
FLOWCHARTS OVERVIEW
A flowchart is a graphical way to present a process or program. It describes the process from start to finish,
including the key steps that need to be undertaken and any decision making and/or logic. Flowcharts are made up of a number of
different shapes that represent specific actions; arrows between the shapes represent the flow of control through the process rather
than the flow of data.
Start / Finish
Input / Output Data
Decision
Connections
Start Tutorial
Do students look bored or informed?
Yes End Tutorial
No
Talk + wave hands about
Action
Creating a flowchart is a good starting point when designing any kind of program or process as it can help define the architecture of your code and pin-point issues early on in the design.
FLOW CHART – MP3 SONG SHUFFLE EXAMPLE
An example flowchart for a simple song shuffle program is shown in Figure 1. Go through it with just a few songs to see how it would
function. Now consider:
• Will this program do a suitable job of shuffling
the songs?
• How could it be altered to better fulfil the user’s
requirements?
(you’ll do this example in Matlab, Semester 2 of XJME1010).
DESIGNING A FLOW-CHART
When producing a flowchart follow these guidelines:
-
keep it easily readable
-
keep it concise (1 side A4)
-
describe the key steps in the process
-
keep it general (e.g. avoid mentioning code / functions specific to
Matlab/LabVIEW)
Developing flow charts is an important skill. It allows you to breakdown, and documents, how to solve a large complex problem by performing a series of logical, small steps. You (should!) use this approach throughout your degree. Both LabVIEW and MATLAB coursework assignments in XJME1010 will require the submission of a flowchart.
Start program
Read in song list (file)
Count number of songs as variable ‘n;
Generate a random number, ‘x’ between 1 and n
Pick and store song number ‘x’
No
Have we ‘n’ songs in list?
Yes
Output new song list (file/screen)
XJME1010: Computing For Engineers P7
Version
Changes
Revision 01 – 27.03.2023
Revision 03 - 05.04.2023 Revioins 04 – 12.09.2023
First release – basic information
Updated controller min and max limits (P3 Table 1.)
Updated for new equipment with one motor and counter balance weitht
Revision 02 – 01.04.2023 Pin connections for left and right motors (P3) Angle calibration information (P3)
Controller speed reduced to 25Hz (P4) Template code and Simulation updated
XJME1010: Computing For Engineers
P8
CHANGELOG