Tutorial 8 Demo Assignment
Tutorial 8 Demo Assignment
Reading: You should now have completed all the required reading for this module. Use this week to catch up on any
reading you need to do.
1. Introduction
Next week you will be given the module assignment, this is worth 60% of the module mark. This will be a take away
exam but under exam conditions so you will not be able to ask for help in completing it. For this tutorial, we will
practise doing a demonstration assignment (this will be a lot simpler than the actual assignment) but it will help you
understand how to tackle your actual module assignment. Use this week to ask for help in understanding any parts
of the Arduino or Labview aspects you’ve have difficulty with during this course as you will be getting examined on
this knowledge next week.
This demo assignment is split up into two parts, development of an Arduino system using Tinkercad and
development of a Labview interface. You will have two tutorials to complete the work.
2. Problem definition
• Design a car that you can drive forward in a straight line (you will only need 1 dc motor to accomplish this) but it
will automatically stop if an obstacle is detected.
• If it gets too dark, the car should automatically switch on its headlights.
• Use a Labview interface to control the car and display any sensor readings.
• Add any modifications that you think improve the performance of this car beyond what is required (i.e.
demonstrate what else you have learnt during this module that is relevant to the problem).
Note: Adding more of the same sensors is not demonstrating any additional knowledge.
It is best to think about what we need to complete this task. Figure 1 shows a simple schematic of what would be a
solution, this was quickly drawn in Powerpoint (we will reuse this image in our final presentation).
We will aim to communicate messages between the Arduino and Labview with a text string. We will develop each
part separately (Arduino part given in section 3, Labview part given in section 4) which can be done in either order
and then bring both parts together for the final demonstration.
3. Arduino development
We do not need to write our code from scratch, we have lots of example programs from previous tutorials that we
can use as a starting point. We will need to somehow merge these various programs to complete our solution. Below
is a list of useful tutorial programs:
It is best to start with one of these programs as a starting point, for example the motor driver, and then added the
relevant parts of the code from the other programs. Be sure to not just directly copy things across but be sure you
know what you are doing, for example the motor driver uses pin 11 on the Arduino however the illuminate LED on
the ultrasonic program also uses pin 11 so you will need to change one of these connections and alter the program
code accordingly.
Have a go at merging these tutorials to see if you can get your solution working.
3.2. Solution
One possible solution is shown in figure 2 with program code given in figure 3. A few points to note:
The power supplied has been replaced with batteries, you would not be able to drive a car that is continuous
plugged in hence we should use batteries instead.
We will be streaming information to Labview so have produced a 3 character string on the serial for this
(ultrasonic reading, light level reading, status of LEDs – on or off). However we have left in other Serial.print
information for diagnostics, this is acceptable for the assignment as it allows us to demonstrate that the program
is working.
We are mapping the input speed for the motor in the range 0 (stop) to 255 (full forward) and therefore we can
remove the reversing (i.e. -reqSpeed) part of the code.
Be sure to include plenty of comments and keep program code structured and circuit diagrams tidy as you will
need to demonstrate this in the presentation (section 5).
We have solved the problem although there are a multitude of improvements we could make to make this solution
better. A few suggestions below:
We could add hysteresis and a delay to the light switching to take account of switching problems around the 100
cut-off value, you could demonstrate this by showing when the LEDs switch on and off for various scenarios.
The ultrasonic will not work at close range, so it is probably worth putting in another sensor for this scenario, for
example a microswitch to act as a bumper – the car should immediately stop if this is activated (and therefore
should ideally be on an interrupt).
We could add PID for more accurate motor control and demonstrate its implementation by changing the battery
voltage.
etc ...
4. Labview development
It will be easiest to use one of our tutorial examples as a starting point to this problem. Starting with
Tutorial_7_Arduino_Labview_Comms figure 9, alter the Labview program to display the relevant sensor information
(which is transmitted over the serial comms or in our case typed as an input string) and set an appropriate motor
speed.
Adjust the Front Panel display so it makes the program easy to use with all relevant information clearly visible and
easy to comprehend (for example a meter may be easier to read than a value printed onto the screen).
Give this a go before moving onto one possible solution given in section 3.2.
3.2. Solution
A basic solution to the problem is shown in figure 4. Input values are scaled accordingly so that our character input
string now displays data as physically relevant values. The motor speed is set as a percentage of maximum speed
with the output string (to be sent to the Arduino) calculated and displayed.
The program in figure 4 is functional but very basic and only gives the minimum requirements needed to complete
the problem. We could adjust the program slightly to make it a more intelligent controller. In figure 5 we have taken
the ultrasonic measurement and used it to switch on a warning light if the distance falls below 1m (note this does
not stop the car but just informs the user of the proximity warning). This value is then taken and used to limit the
maximum speed of the car to 50% (by using the Max & Min icon) if an object is close by (which is probably a good
idea). The Front Panel is suitably arranged to clearly display all information as shown in figure 6, note that all the
meters have their ranges set appropriately to show the full range of measurements possible.
Run the program and enter character string ZAB which is a long ultrasonic measurement, low light level and
headlights switched on. Note that you will need to type ZAB and then click on the tick icon to enter the characters, if
you press return this is just another character as far as Labview is concerned (and you will get 4 characters being
entered). You should be able to change the speed from 0% to 100%. Now try AAB, the proximity light should
illuminate and you cannot set a speed of more than 50%. This is a small change in the program but does add more
useful functionality to it.
Note: The speed value indicator in the Block Diagram has changed from orange to blue. This is because I changed the
indicator to display int rather than double – in this case it is much clearer to the user to see an integer value rather
than a value with lots of decimal places (subtle point but makes the interface much more presentable). If you did
decide to display decimal places, how many would be appropriate?
Figure 5: A slightly more intelligent interface for our car compared to figure 4.
We have solved the problem although there are a multitude of improvements we could do to make this solution
better. A few suggestions below:
Add a communications error warning light into your display (you should also include a similar check in your
Arduino program for messages going in the other direction).
We have used scaling factors to convert our sensor readings to physical values. It would be better to load in
calibration data (from a file), fit this and then use the fitting coefficients to scale our values (this then potentially
lets us recalibrate the system at any time).
Incorporate a fuzzy controller into your design so for example you may wish to control the speed as a function of
object distance and light level.
You could add a neural network into your solution. Although you cannot incorporate this into Labview or
Tinkercad, you could show the principle by demonstrating it on Matlab. For example program the neural network
to recognise a speed limit sign (read 2 numbers) and then send this value (simply defined in Tinkercad as #define
SPEEDLIMIT 65) over the serial comms to Labview to use in its speed control algorithm.
etc …
5. Presentation
You will need to be able to record your work for the assignment submission. It is important to use the opportunity to
showcase what you achieved towards meeting the project specifications. Have a go at making a short presentation
(even if it is just component parts) of this demo assignment to get feedback during the tutorial session.
Note that we are not marking video quality (so there is no chance of winning as Oscar for your video) however the
content is important and the video quality should make it easy to see detail and clearly hear any descriptions given.
You can record your presentation in one go or do several shorter recordings and edit these (cut, paste sections
together). You will need to make sure you adhere to the time limit as the marker will stop viewing the video at the
defined time limit and so you will not get any credit for material presented after that time. You should try to keep
video recordings to less than 100 MB if possible.
The software you use will depend on which computer you are using to record your presentation. If you are using
your own computer then you can use any software, if you are using a University cluster PC then you will need to use
the software available on that.
Panopto (this is the University recommended software, can do video editing also).
Microsoft STREAM.
5.1.2. Other free software (will need to be on your own personal PC).
OBS Studio is my personal favourite for screen capture. Remember you can use OBS on your PC whilst using AVD
to run software on a University PC.
Shotcut – video editing software, easy to use. My personal favourite for video editing, very intuitive, easy to cut,
paste and add captions, output is compressed (even if you do not make any changes to the video) so file sizes are
relatively small. I used this for the tutorial videos on Canvas.
Openshot – video editing software, easy to use.
Davinci Resolve – full professional editing software (used by movie studios in Hollywood), steep learning curve to
learn all the features.
Handbrake – video compression software, useful to compress your video file size down as Canvas upload is
limited for students to 100 MB. Check the quality after compression.
… probably lots more options if you do a Google search
John Hedley, School of Engineering, 2022. Page 7
MEC3027/8058 Instrumentation and Drives
Create a ZOOM or TEAMS meeting with just yourself and record the meeting.
You need to be clear but succinct about presenting your work, keep your presentation to specific details and
demonstrate all the work you have accomplished. It is important to know what you have tried to do, how you have
done it and a demonstration that it is working. Below is a list of what you should include:
Start with a schematic of your solution to the problem, for example you would show figure 1 of this tutorial, and
show a bullet list on what you will be demonstrating. You do not need to spend time going through the list
(remember we can pause the video) but give a brief verbal description of what you are showing.
Then give a view of the overall Tinkercad circuit, then the Labview program and finally the Labview interface.
Again this can be brief to give the viewer a quick view of your overall solution and what to expect in the rest of
the demonstration.
The next part is the most important, you need to show each part of what you have achieved, i.e. demonstrate
each point of your initial bullet list. You will need to show the code, the circuit and a demonstration of it working,
for example:
a. For the automatic headlights, show the piece of code that records the light reading and automatically switches
on the LED, then show the Tinkercad connections (ZOOM in on this part of the circuit) and then run the
simulation to show that the headlights do come on when the light levels are low.
b. Show that the speed is limited to 50% by showing the Labview code for this part and then run the Front Panel
and demonstrate the speed is limited if the proximity light is on.
c. If you have done a Fuzzy Controller, you can show the input membership functions, output membership
functions, the mapping, the code used on Labview and then demonstrate it working on Labview (easiest way
to do this is to have numeric indicators on the Front Panel to show input and output values for the Fuzzy
Controller).
d. …etc… for each bullet point provided at the start of your presentation.
Each of these steps should take around 30s or less to show otherwise you are spending too long describing it.
Finish your presentation by showing all your Arduino code (you will need to start at the top of the program and
slowly scroll down the code or alternatively present the code as shown in these tutorials). We do not want an
explanation (your verbal description at this point can be quickly recapping what you have achieved) but this way,
we can pause the video if we need to check any of your coding.
It is important to use your presentation time allowance to efficiently demonstrate all the goals you have achieved for
this project. We will stop watching after the allocated time so be sure to keep within time. Remember that each
examiner will be marking around 20 hours of presentation video so it is important that you present clear
explanations on what you are demonstrating.
This is also relevant for life after university, whether it is a company meeting or trying to secure funds from investors
for your own business – you will have a limited amount of time to get your point across so make sure when you
present, it is clear, concise and to the point.
0 – 40: Little evidence of work done, basic requirements of functional Arduino and Labview not met.
40 – 50: Car and Labview functions but to a very basic level with no intelligent control (for example only
conditional statements are used to make decisions: if --- then ---, etc).
50 – 60: Good effort, you have demonstrated you have understood the material to a reasonable level and your
car and Labview are well designed with a range of functionality beyond the basic requirements.
60 – 70: Excellent effort, similar to the 50-60 range of marks but done to a very high standard and you have
achieved all the learning outcomes required from the module.
70 – 100: Exceptional work, you have progressed beyond the module notes and have demonstrated you have
made the extra effort to learn and implement relevant knowledge in excess of the syllabus requirements. You
have leadership attributes.
Note: Quick Google search shows the ‘5 Essential Leadership Skills and Practices are: 1) self-development, 2) team
development, 3) strategic thinking and acting, 4) ethical practice and civic-mindedness, 5) innovation’. For marks over
70, I will be expecting you to achieve 1,3 and 5 of this list.
From the marking criteria, content deserves a mark of around 50% however effort has been put into making the
code and interface presentable and easy to read so this would give it a mark of around 55%. There has been plenty
of suggestions given in sections 2.3 and 3.3 that would significantly increase the mark.
IMPORTANT NOTE: The actual assignment will have more specifications to meet and therefore if you submit the
programs given in this tutorial for your actual module assignment, it will fail to meet a lot of the requirements
asked for. So using this solution for your actual assignment would probably get you a mark of around 20%.
7. Summary
This completes the tutorials for MEC3027/8058. The demo assignment has shown you how to bring together simpler
programs from the tutorials to make a more complete system. Care must be taken when integrating these programs
together but with careful preparation and a little planning, you can build up quite complex systems from these initial
basic programs.