Development of cargo monitoring system for a rapid response team (disaster aid) Overview of concepts demonstrated during Labs 3 and 4.

Slides:



Advertisements
Similar presentations
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
Advertisements

Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Lab 3 Details. Lab 3 Develop a bio-feedback system based on a PWM (pulse width modulated) thermal sensor Use temperature setting to control the delays.
Peripherals and their Control An overview of industrially available “peripheral devices” Some ideas for Laboratories and Quiz / Exam questions.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
COMP3221: Microprocessors and Embedded Systems Final Exam Lecturer: Hui Wu Session 1, 2005.
6/2/2015 Concept of Test Driven Development applied to Embedded Systems M. Smith University of Calgary, Canada 1 Automated Testing Environment Concepts.
Thermal arm-wrestling Design of a video game using two programmable flags (PF) interrupts Tutorial on handling 2 Hardware interrupts from an external device.
Lab. 2 – More details – Tasks 4 to 6 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have.
Calculating acceleration using ADXL213 – dual axis accelerometer.
Display Interrupt Service Routine for cargo monitoring system Overview of concepts demonstrated during Labs 3 and 4.
Lab. 2 Overview 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have that knowledge?
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
Development of cargo monitoring system for a rapid response team (disaster aid) Overview of concepts that you will demonstrate during Labs 3 and 4.
1 More on Arrays Passing arrays to or from methods Arrays of objects Command line arguments Variable length parameter lists Two dimensional arrays Reading.
1 CS 201 Passing Function as Parameter & Array Debzani Deb.
Getting the O in I/O to work on a typical microcontroller Activating a FLASH memory “output line” Part 1 Main part of Laboratory 1 Also needed for “voice.
Chapter 1 Program Design
Blackfin BF533 EZ-KIT Control The O in I/O
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Peripherals and their Control An overview of industrially available “peripheral devices” that use “pulse-width modulation” for information passing. Review.
Outlines Chapter 3 –Chapter 3 – Loops & Revision –Loops while do … while – revision 1.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Unit 5 Lecture 2 Error Control Error Detection & Error Correction.
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system Manual control of RC car.
Making Decisions (True or False) Relational Operators >greater than =greater than or equal to
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
1 Chapter 4: Basic Control Flow ► Chapter Goals  To be able to implement decisions using if statements  To understand statement blocks  To learn how.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
Chapter 11 Hash Tables © John Urrutia 2014, All Rights Reserved1.
Logic Analyzer ECE-4220 Real-Time Embedded Systems Final Project Dallas Fletchall.
Verification & Validation. Batch processing In a batch processing system, documents such as sales orders are collected into batches of typically 50 documents.
Mistakes, Errors and Defects. 12/7/2015Mistakes, Errors, Defects, Copyright M. Smith, ECE, University of Calgary, Canada 2 Basic Concepts  You are building.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Multi-threaded projects Services and Drivers Alternate ways of doing Labs 1, 2, 3 and 4.
12/14/2015 Concept of Test Driven Development applied to Embedded Systems M. Smith University of Calgary, Canada 1 Automated Testing Environment Concepts.
Calculating acceleration using ADXL213 – dual axis accelerometer Use equivalent idea in Lab. 3 with thermal sensor.
LAB I1 Class Y Laboratory Measurements I1 Book(s) must be collected at VIA Lib Wednesday the between 4 and 6 pm..
Accelerated Motion Chapter 3. Accelerated Motion Develop descriptions of accelerated motions. Use graphs and equations to solve problems involving moving.
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Arrays.
CSCI 156: Lab 11 Paging. Our Simple Architecture Logical memory space for a process consists of 16 pages of 4k bytes each. Your program thinks it has.
Arrays Chapter 6. Objectives learn about arrays and how to use them in Java programs learn how to use array parameters and how to define methods that.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
Data Structures Arrays and Lists Part 2 More List Operations.
“Lab. 5” – Updating Lab. 3 to use DMA Test we understand DMA by using some simple memory to memory DMA Make life more interesting, since hardware is involved,
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Developing Tasks to use with a co-operative scheduler Ideas for Assignment 2 Lab. 2, 3 and 4 Review for Midterm on Lab. 2 Ideas of defects, errors and.
Resource Review Excel formula basics Demonstrate how to enter manual formulas Examine some of the available functions and their usage Discuss the.
You will be able to calculate Instantaneous speed Average speed Of falling or rising objects.
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
Chapter 2 Motion in One Dimension. Kinematics Describes motion while ignoring the external agents that might have caused or modified the motion (Dynamics.
Stack Data Structure, Reverse Polish Notation, Homework 7
Fall 2017 CISC124 9/21/2018 CISC124 First onQ quiz this week – write in lab. More details in last Wednesday’s lecture. Repeated: The quiz availability.
Using variables, for..loop and functions to help organize your code
Automated Testing Environment
Thermal arm-wrestling
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Lab. 2 – More details – Later tasks
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Thermal arm-wrestling
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
General purpose timers
Getting serious about “going fast” on the TigerSHARC
Explaining issues with DCremoval( )
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Thermal arm-wrestling
Working with the Compute Block
Display Interrupt Service Routine for cargo monitoring system
Presentation transcript:

Development of cargo monitoring system for a rapid response team (disaster aid) Overview of concepts demonstrated during Labs 3 and 4

2 / 28 Disaster Relief Issues Disaster likely to be in remote areas  Roads are blocked, bridges destroyed – transportation very difficult Cargo to be delivered by skid-air drop  Basically, fly very low over the area, throw out a small parachute, cargo-skid is pulled out of the aircraft and falls to ground – not parachuted down Mixed cargo  Perishable goods (food)  Delicate communication equipment (electronics) Need to know if cargo has been abused during transportation or delivery

3 / 28 Cargo Monitoring System During transport  Quick indication of health of product NOW  Acceleration in range – accuracy of +- 1/16 G  Temperature steady – accuracy of +- 1 / 32 C On delivery  Display of ranges that cargo has experienced  Range of temperatures and accelerations  Other cargo information

4 / 28 Overall design Initialize stuff (C++) Calculate Temperature Store temperature, calculate averages and ranges Calculate Acceleration Store acceleration, calculate averages and ranges General Purpose Timer controlling Display as ISR Temperature / Acceleration graphic (non-text) display Changes, actual temperatures Core temperature ISR clock used for Temperature / Acceleration determination Communications with LCD MOSI / MISO format -- ISR Temperature / Acceleration information Text format main( )

5 / 28 How is the project being split up? Devices use pulse-width modulation  Acceleration – Handle through examples in the lectures  Temperature – You are handling this in Lab. 3 LCD display – SPI interface  Acceleration – Handle through examples in the lectures  Temperature – You are handling this in Lab. 4

6 / 28 Warning I plan to do these lectures to document the delivery of a design using a test driven development approach I don’t know where the final project (code etc) will end up at this moment.  Design decisions may change as I go along.  If design decisions change, then I will have to change some of my tests and code. HOWEVER, I HAVE NO INTENTION OF GOING TO BACK AND MODIFYING THE EARLIER LECTURE NOTES. SO KEEP THAT IN MIND IF YOU DON’T ATTEND ALL THE CLASSES

7 / 28 Overall design Initialize stuff (C++) Calculate Temperature Store temperature, calculate averages and ranges Calculate Acceleration Store acceleration, calculate averages and ranges General Purpose Timer controlling Display as ISR Temperature / Acceleration graphic (non-text) display Changes, actual temperatures Core temperature ISR clock used for Temperature / Acceleration determination Communications with LCD MOSI / MISO format -- ISR Temperature / Acceleration information Text format main( )

8 / 28 Do the easy part first To calculate range  maxAcc, minAcc, nowAcc need to be determined? How to calculate acceleration average?  Store nowAcc in an array, update the array with new values, discard old values? Quick indicators needed  Acceleration stable, increasing, decreasing Calculate Acceleration Store acceleration, calculate averages and ranges

9 / 28 First problems – interpreting requirements Quick indicators  Acceleration stable, increasing, decreasing What do these requirements mean? Most of the time the cargo will be experienced 1G acceleration downwards due to gravity Acceleration can occur in 3 dimensions

10 / 28 First problems – interpreting requirements Quick indicators  Acceleration stable, increasing, decreasing What do these requirements mean? If we plan to use ADXL213 Dual axis accelerometers, then we need 2 ADXL213 Dual axis accelerometers  One doing x and y  One doing x and z  Could plan to use the two x-acceleration values as cross checks on each other to make sure that equipment is working How does the accelerometer behave if cargo experiences acceleration outside of design limits of accelerometer?  Saturation – if bigger than biggest allowed is measured, then returns biggest allowed  Aliasing – wrap-around -- if bigger than biggest allowed in measured, then looks like smallest allowed or perhaps even big in the wrong direction – like a car odometer (distance) that goes to and then Need to find out -- Do some experiments? Manual has the information?

11 / 28 Design details added Initialize stuff (C++) Calculate Temperature Store temperature, calculate averages and ranges Calculate Acceleration Store acceleration, calculate averages and ranges General Purpose Timer controlling Display as ISR Temperature / Acceleration graphic (non-text) display Changes, actual temperatures #define ACCELERATION_STEADY 1 #define ACCELERATION_DECREASING 2 #define ACCELERATION_INCREASING 3 variable acceleration_changing Communication between main( ) and ISR main( )

12 / 28 Develop first test -- Requirements variable acceleration_changing is modified in main( ) depending on whether current acceleration is greater than, equal to, or less than the average acceleration Display ISR uses this information to modify how the LED flash (flicker up, flicker down, steady) Set_Acceleration_Mode( current_Acc, average_ACC)

13 / 28 First Test concept TEST START acceleration_now == average_acceleration Set_Acceleration_Mode(acceleration_now, average_acceleration) CHECK(acceleration_changing shown as steady) acceleration_now < average_acceleration Set_Acceleration_Mode(acceleration_now, average_acceleration) CHECK(acceleration_changing shown as decreasing) acceleration_now > average_acceleration Set_Acceleration_Mode(acceleration_now, average_acceleration) CHECK(acceleration_changing shown as increasing) TEST END

14 / 28 Three files are going to be needed Lab3 directory – where product will end up being built lab3prototypes.h #define ACCELERATION_STEADY 1 #define ACCELERATION_DECREASING 2 #define ACCELERATION_INCREASING 3 void Set_Acceleration_Mode(long int current_Acc, long int average_ACC); CodeAcceleration.cpp Set_Acceleration_Mode( current_Acc, average_ACC) { All necessary code to make function work } Lab3 tests directory – where all tests will be built TestsAcceleration.cpp TEST(Set_Acceleration_Mode, DEVELOPER_TEST) { All necessary code to test that function works }

15 / 28 Write the test code using E-TDD syntax #include “../Lab3/lab3prototypes.h” TEST(Set_Acceleration_Mode, DEVELOPER_TEST) // acceleration_now == average_acceleration Set_Acceleration_Mode(6, 6); CHECK(acceleration_changing == ACCELERATION_STEADY); // acceleration_now < average_acceleration Set_Acceleration_Mode(0, 6); CHECK(acceleration_changing == ACCELERATION_DECREASING); // acceleration_now > average_acceleration Set_Acceleration_Mode(acceleration_now, average_acceleration) CHECK(acceleration_changing == ACCELERATION_INCREASING); } Now write the code that satisfies the test

16 / 28 Design details added Calculate Acceleration Store acceleration, calculate averages and ranges General Purpose Timer controlling Display as ISR Temperature / Acceleration graphic (non-text) display Changes, actual temperatures #define ACCELERATION_STEADY 1 #define ACCELERATION_DECREASING 2 #define ACCELERATION_INCREASING 3 variable acceleration_changing Communication between main( ) and ISR Where is best to place this variable 1.On the stack? 2.As an extern? 3.In.section dataA?

17 / 28 Where to place variable acceleration_changing? CHOICE 1 – on the stack inside the test method TEST(Set_Acceleration_Mode, DEVELOPER_TEST) int acceleration_changing = 0; Set_Acceleration_Mode(6, 6); CHECK(acceleration_changing == ACCELERATION_STEADY); CHOICE 2 – as an external global variable, with the variable declared in another file extern int acceleration_changing; TEST(Set_Acceleration_Mode, DEVELOPER_TEST) Set_Acceleration_Mode(6, 6); CHECK(acceleration_changing == ACCELERATION_STEADY); CHOICE 3 – as a global variable, declared in this file but used by functions in other files int acceleration_changing = 0; TEST(Set_Acceleration_Mode, DEVELOPER_TEST) Set_Acceleration_Mode(6, 6); CHECK(acceleration_changing == ACCELERATION_STEADY);

18 / 28 What is the correct design decision? Why is that the correct decision? Decision Now write the code that satisfies the test

19 / 28 Next test – Ability to calculate Average Ability to calculate an average acceleration based on an array of previous acceleration values bool CalculateAverage(int *previous, int num, int *average_value) previous is the array of previous values num is the number of elements in the array average_value is the average acceleration calculated Returns true if the average value can be calculated

20 / 28 Design details added Calculate Acceleration Store acceleration, calculate averages and ranges General Purpose Timer controlling Display as ISR Temperature / Acceleration graphic (non-text) display Changes, actual temperatures Array information is not needed in any global sense THEREFORE PLACE THE ARRAY ON THE STACK (local variable) Where is best to place the arrays used in averaging previous acceleration measurements? 1.On the stack? 2.As an extern? 3.In.section dataA?

21 / 28 Write the test code using E-TDD syntax #include “../Lab3/lab3prototypes.h” TEST(AverageCalculation, DEVELOPER_TEST) int previous_values[10] = {0, 0, 2, 2, 1, 1, 10, 10, 10, 10}; int average_value = 0; bool result = true; // Empty array -- invalid number of points as array length result = CalculateAverage(previous_values, 0, &average_value); CHECK(result == false); // Average first two values average_value = 6; result = CalculateAverage(previous_values, 2, &average_value); CHECK(result == true); CHECK(average_value == 0); // Average first four values result = CalculateAverage(previous_values, 4, &average_value); CHECK(result == true); CHECK(average_value == 1); etc. Now write the code that satisfies the test

22 / 28 Next test – Ability to store previous acceleration values in a defined array Need to store values into an array Problem – suppose array is of size 10 – how do you store the 11 th array entry?  Answer – use circular buffers  GUI note: Don’t use % function (modulus) as this involves a division – very slow on this processor. bool AddToArray(int *previous, int num, int new_acceleration_value) Returns true if the AddToArray( ) operation can be performed

23 / 28 Write the test code using E-TDD syntax (1) #include “../Lab3/lab3prototypes.h” TEST(AddToArray, DEVELOPER_TEST) { #define MAX_ARRAY_SIZE 8 // WOULD THIS BE BETTER DEFINED INSIDE../Lab3/lab3prototypes.h? int previous_values[MAX_ARRAY_SIZE] = {0, 0, 0, 0, 0, 0, 0, 0}; bool result; // Have a new acceleration value of 1 – add to the array int expected [MAX_ARRAY_SIZE] = {1, 0, 0, 0, 0, 0, 0, 0}; result = AddToArray(previous_values, MAX_ARRAY_SIZE, 1); CHECK(result == true); ARRAYS_EQUAL(expected1, previous_values, MAX_ARRAY_SIZE); // Have new acceleration values of 2 and then 3 – add those to the array int expected2[MAX_ARRAY_SIZE] = {1, 2, 3, 0, 0, 0, 0, 0}; result = AddToArray(previous_values, MAX_ARRAY_SIZE, 2); CHECK(result == true); result = AddToArray(previous_values, MAX_ARRAY_SIZE, 3); CHECK(result == true); ARRAYS_EQUAL(expected2, previous_values, MAX_ARRAY_SIZE); …………………………MORE TEST CODE TO COME …………………………….

24 / 28 Write the test code using E-TDD syntax (2) TEST(AddToArray, DEVELOPER_TEST) { ……… TEST CODE CONTINUED ……… // Have new acceleration values of 2 and then 3 – add those to the array int expected2[MAX_ARRAY_SIZE] = {1, 2, 3, 0, 0, 0, 0, 0}; result = AddToArray(previous_values, MAX_ARRAY_SIZE, 2); result = AddToArray(previous_values, MAX_ARRAY_SIZE, 3); ARRAYS_EQUAL(expected2, previous_values, MAX_ARRAY_SIZE); // Now add eight new values to the array – that will force a wrap-around of the array value // Now the three oldest values have been overwritten // int expected2[MAX_ARRAY_SIZE] = {1, 2, 3, 0, 0, 0, 0, 0}; int expected3[MAX_ARRAY_SIZE] = {9, 10, 11, 4, 5, 6, 7, 8}; for (int count = 4; count < 4 + MAX_ARRAY_SIZE; count++) { result = AddToArray(previous_values, MAX_ARRAY_SIZE, count); CHECK(result == true); } ARRAYS_EQUAL(expected3, previous_values, MAX_ARRAY_SIZE); } NOW WRITE THE CODE THAT SATISFIES THE TEST

25 / 28 ADXL213 Dual Axis Accelerometer PF9 PF8

26 / 28 Calculation the acceleration using information from the hardware Let us assume that we have the time (in clock pulses) for T1 (T1_high) and T2 (T2_period) Need to develop the tests to check that correctly calculate the acceleration when the acceleration is in the range +1.7G to -1.7G bool CalculateAcceleration(int T1_high, int T2_period, int *new_acceleration_value)

27 / 28 Before tomorrow’s class Write the tests needed to show that bool CalculateAcceleration(int, int, int *) correctly calculates the acceleration when the acceleration is in the range +1.7G to -1.7G Through this test design – identify the “design defect” in the current project design concept for the transportation monitoring device

28 / 28 Disaster Relief Issues Disaster likely to be in remote areas  Roads are blocked, bridges destroyed – transportation very difficult Cargo to be delivered by skid-air drop  Basically, fly very low over the area, throw out a small parachute, cargo-skid is pulled out and falls to ground – not parachuted down Mixed cargo  Perishable goods (food), delicate communication equipment (electronics) Need to know if cargo has been abused during transportation or delivery!!!!!!