MBSD ASSIGNMENT Level indicator
Massimo Violante
Politecnico di Torino Dip. Automatica e Informatica
Goal
n You have to implement a level indicator, which is composed of the following elements
Ultrasonic Ranging Sensor
Echo
Level
Trig
Ranging Estimator
2
The ultrasonic ranging sensor
n The sensor is equivalent to HC-SR04
n It provides 2cm – 400cm non-contact measurement function n Therangingaccuracycanreachto3mm
n See data sheet at the following URL https://www.electroschematics.com/wp-content/uploads/2013/07/HCSR04-datasheet-version-1.pdf
n The behavior of the Sensor is as follows:
n TheRangingEstimatorgeneratesapulseontheTrigsignalwithpulsedurationofatleast10μs
n TheHC-SR04deviceproducesaresponseontheEchosignal.Thepulsedurationisproportionalto the measured distance according to the following formula
𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑐𝑚 = 𝐸𝑐h𝑜 𝑝𝑢𝑙𝑠𝑒 𝑑𝑢𝑟𝑎𝑡𝑖𝑜𝑛 [𝜇𝑠]
58
n Triggeringpulsesshallbedistantatleast60mstopreventechos
3
Ranging estimator
n The ranging estimator measures the distance (by taking 4 consecutive measures and computing the average), and generates an output as follows
n In case the measure is in between 10cm and 100 cm the Level output blinks with frequency 10 Hz and duty cycle from 10% to 100% depending on the measurement (10cm=10%, 100cm=100%)
n In case the measurement is outside below 10cm or higher than 100 cm the Level output blinks with frequency 2 Hz and duty cycle 50%
n In case the sensor is disconnected (no measure is received), the Level output blinks with frequency 1 Hz and duty cycle 50%
4
Work products
n Simulinkprojectcontainingtworeferencedsubsystemsproperlyinterconnected
n Plant: containing a model of the ultrasonic ranging sensor for simulation purposes only. The distance shall be
controllable using a knob to provide al the possible scenarios
n Controller: containing a model of the ranging estimator for code generation purposes
n Ccodeforthecontrollerobtainedthroughcodegeneration(usingcompactfileplacementandreusable function interface)
n GoogleTest-based unit testing for the controller code providing 100% statement and 100% branch coverage
n Source code that integrates the generated code into the Trampoline RTOS
n The ultrasonic sensor shall be simulated in C code, and the Level output can be printed on the console
n Optional:SimulinkmodelthatdeploystherangingestimatortoArduinoUno/Megaashardwareusingthe HC-SR04 as ranging sensor, and the Arduino Uno/Mega LED as Level output
n Reportinpdfformat(max5pagesincludingcoverpage)thatdescribesthedevelopedsolution
5
Evaluation criteria
n The evaluation is based on the following criteria
n Max 15 points: the solution shall provide the requested behavior
n Max 12 points: completeness (all the mandatory parts are provided) n Max 6 points: bonus points for hardware implementation
6
Deliverable
n All the files you intend to deliver shall be contained into a single ZIP file submitted using “portale della didattica/elaborati”
n PAY ATTENTION: only ZIP file would be considered (no ARJ, TAR, GZ, 7Z, …). In case you submit your work in an archive other than ZIP file your assignment will be evaluaed 0 points, and you will have to take the oral exam.
n Deadline 11/06/2021 24:00
7