1 / 29

Development of cargo monitoring system for a rapid response team (disaster aid)

Development of cargo monitoring system for a rapid response team (disaster aid). Overview of concepts for a “real” embedded system. Disaster Relief Issues. Disaster likely to be in remote areas Roads are blocked, bridges destroyed – transportation very difficult

anne-cash
Télécharger la présentation

Development of cargo monitoring system for a rapid response team (disaster aid)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Development of cargo monitoring system for arapid response team (disaster aid) Overview of concepts for a “real” embedded system

  2. 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. 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. Overall design General Purpose Timercontrolling Display asISR Temperature / Accelerationgraphic (non-text) displayChanges, actual temperatures main( ) Play music and monitor light levels might be nice too Initialize stuff (C++) Calculate Temperature Core timerISR clockused forTemperature / Accelerationdetermination Store temperature, calculate averages and ranges Communications with LCDMOSI / MISO format -- ISR Temperature / AccelerationinformationText format Calculate Acceleration Store acceleration, calculate averages and ranges

  5. 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.This means that all the tests and functions developed in the lectures for handling acceleration using a pulse-width modulated device will need to be modified by you for handling temperature • LCD display – SPI interface • Acceleration – Handle through examples in the lectures • Temperature – You are handling this in Lab. 4 • This means that all the tests and functions developed in the lectures for displaying acceleration using am SPI display device will need to be modified by you for handling temperature

  6. 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. Overall design General Purpose Timercontrolling Display asISR Temperature / Accelerationgraphic (non-text) displayChanges, actual temperatures main( ) Initialize stuff (C++) Calculate Temperature Core timerISR clockused forTemperature / Accelerationdetermination Store temperature, calculate averages and ranges Communications with LCDMOSI / MISO format -- ISR Temperature / AccelerationinformationText format Calculate Acceleration Store acceleration, calculate averages and ranges

  8. 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. 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. 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 measuring equipment is working • How does the accelerometer behave if cargo experiences acceleration outside of design limits of accelerometer? • Saturation – if bigger acceleration is experienced than biggest than can be measured, then returns biggest acceleration allowed • Aliasing – wrap-around -- if bigger than biggest that can be 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. Design details added main( ) #define ACCELERATION_STEADY 1#define ACCELERATION_DECREASING 2#define ACCELERATION_INCREASING 3 volatile variable acceleration_changing Initialize stuff (C++) Calculate Temperature Communicationbetweenmain( )and ISRmeans use volatile variables Store temperature, calculate averages and ranges General Purpose Timercontrolling Display asISR Temperature / Accelerationgraphic (non-text) displayChanges, actual temperatures Calculate Acceleration Store acceleration, calculate averages and ranges

  12. 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 the lights up (acceleration increasing), flicker the lights down (acceleration decreasing)), steady lights (acceleration reasonably stable – within some limits), ) Set_Acceleration_Mode( current_Acc, average_ACC)

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

  14. Lab3 directory – where product will end up being built lab3prototypes.h #define ACCELERATION_STEADY 1 Lab. 3 TEMPERATURE_STEADY#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 } Three files are going to be needed

  15. 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. Design details added #define ACCELERATION_STEADY 1#define ACCELERATION_DECREASING 2#define ACCELERATION_INCREASING 3 variable acceleration_changing • Where is best to place thisvariable • On the stack? • As an extern? • In .section L1_data? Communicationbetweenmain( )and ISR General Purpose Timercontrolling Display asISR Temperature / Accelerationgraphic (non-text) displayChanges, actual temperatures Calculate Acceleration Store acceleration, calculate averages and ranges

  17. 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. What is the correct design decision?Why is that the correct decision? • Decision • Now write the code that satisfies the test

  19. 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. Design details added Array information is not needed in any global sense THEREFORE PLACE THE ARRAYON THE STACK (local variable) • Where is best to place thearrays used in averagingprevious accelerationmeasurements? • On the stack? • As an extern? • In .section L1_data? General Purpose Timercontrolling Display asISR Temperature / Accelerationgraphic (non-text) displayChanges, actual temperatures Calculate Acceleration Store acceleration, calculate averages and ranges

  21. Write the test code using E-TDD syntax #include “../Lab3/lab3prototypes.h” TEST(AverageCalculation, DEVELOPER_TEST) LAB3 – Equivalent with Temperature 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 lengthresult =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. 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 11th 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. ReminderHow 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.This means that all the tests and functions developed in the lectures for handling acceleration using a pulse-width modulated device will need to be modified by you for handling temperature • LCD display – SPI interface • Acceleration – Handle through examples in the lectures • Temperature – You are handling this in Lab. 4 • This means that all the tests and functions developed in the lectures for displaying acceleration using am SPI display device will need to be modified by you for handling temperature

  24. Write the test code using E-TDD syntax (1) #include “../Lab3/lab3prototypes.h” TEST(AddToArray, DEVELOPER_TEST) { LAB3 – Equivalent with Temperature #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 …………………………….

  25. Write the test code using E-TDD syntax (2) TEST(AddToArray, DEVELOPER_TEST) { LAB3 – Equivalent with Temperature Array ……… 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

  26. ADXL213 Dual Axis Accelerometer PF9 PF8

  27. Calculation the acceleration using information from the hardware • LAB3 – Equivalent with Temperature Sensor • Let us assume that we have measured 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)

  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

  29. 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!!!!!!

More Related