Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Development of cargo monitoring system for a rapid response team (disaster aid) Overview of concepts demonstrated during Labs 3 and 4."— Presentation transcript:

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

2 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 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 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 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 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 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 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 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 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 999999 and then 000000 Need to find out -- Do some experiments? Manual has the information?

11 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 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 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 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 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 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 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 18 / 28 What is the correct design decision? Why is that the correct decision? Decision Now write the code that satisfies the test

19 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 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 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 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 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 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 25 / 28 ADXL213 Dual Axis Accelerometer PF9 PF8

26 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 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 / 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!!!!!!


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

Similar presentations


Ads by Google