test

Dependencies:   ADS1015 MPU6050 MPU6050 PixelArray mbed

Files at this revision

API Documentation at this revision

Comitter:
Ishy
Date:
Thu Nov 30 09:02:00 2017 +0000
Commit message:
TestCode;

Changed in this revision

ADS1015.lib Show annotated file Show diff for this revision Revisions of this file
MPU6050.lib Show annotated file Show diff for this revision Revisions of this file
MPU6050_belt.lib Show annotated file Show diff for this revision Revisions of this file
PixelArray.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r ad6765bb587f ADS1015.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADS1015.lib	Thu Nov 30 09:02:00 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Momo/code/ADS1015/#7227a2b2a048
diff -r 000000000000 -r ad6765bb587f MPU6050.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPU6050.lib	Thu Nov 30 09:02:00 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Momo-Medical/code/MPU6050/#dc92d3573d50
diff -r 000000000000 -r ad6765bb587f MPU6050_belt.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPU6050_belt.lib	Thu Nov 30 09:02:00 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Momo/code/MPU6050/#ebe4230c882d
diff -r 000000000000 -r ad6765bb587f PixelArray.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PixelArray.lib	Thu Nov 30 09:02:00 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Momo-Medical/code/PixelArray/#9494ded1e0c9
diff -r 000000000000 -r ad6765bb587f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 30 09:02:00 2017 +0000
@@ -0,0 +1,384 @@
+#include "mbed.h"                                                                   // Include files and define parameters.
+#include "Adafruit_ADS1015.h"
+#include "MPU6050.h"
+#include "MPU6050_belt.h"
+#include "neopixel.h"
+
+#define NUMBER_LED_FRONT (3)  // declaren waarvoor dient                                                     
+#define ONE_COLOR
+
+//------------------------------------
+// Hyperterminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
+
+//Serial pc(SERIAL_TX, SERIAL_RX, 115200);
+//Serial pi(PC_10, PC_11, 115200);
+//I2C i2c_sensorplate_adc(PB_9, PB_8);  
+//MPU6050 angle_device_sensorplate(PB_9, PB_8);  
+//DigitalOut myled(LED1);
+//DigitalIn button_lock(PC_1);                                                       // Input on intterupt base decleration. 
+//DigitalIn button_reposition(PC_2);
+//DigitalIn button_mute(PC_0);
+//DigitalIn button_new_patient(PC_3);
+//
+//MPU6050_belt angle_device_reference_belt(PB_9, PB_8);                                  // i2c pins // i2c address hardcoded 0x69.
+//Adafruit_ADS1115 piezo_resistive_adc1(&i2c_sensorplate_adc, 0x48);                  // i2c pins, i2c address.
+//Adafruit_ADS1115 piezo_resistive_adc2(&i2c_sensorplate_adc, 0x49);                  // i2c pins, i2c address.
+//Adafruit_ADS1115 piezo_electric_adc(&i2c_sensorplate_adc, 0x4B);                    // i2c pins, i2c address.
+//
+//short piezo_resistive_array[8] = {0,0,0,0,0,0,0,0};                                 // 8 PR sensors 1 time per cycle.
+//short piezo_electric_array[5] = {0,0,0,0,0};                                        // 1 PE sensor 5 times per cycle.
+//int angle = 0;                                                                      // Accelerometer Z-axis.
+//float accelerometer_sensorplate[3] = {0.0, 0.0, 0.0};                               // Raw accelerometer data.
+//float gyroscope_sensorplate[3];                                                     // Raw gyroscope data.
+//float accelerometer_reference_belt[3];                                              // Raw accelerometer data from belt.
+//float gyroscope_reference_belt[3];   
+//
+//int connection_test_sensorplate; 
+
+InterruptIn button_lock(PC_0);                                                       // Input on intterupt base decleration. 
+InterruptIn button_reposition(PC_1);
+InterruptIn button_mute(PC_2);
+InterruptIn button_new_patient(PC_3);
+
+DigitalOut  LED_on_dev_board1(LED1);                                                // Decleration of digital outputs.                                          
+DigitalOut  LED_on_dev_board2(LED2);
+DigitalOut  LED_on_dev_board3(LED3);
+DigitalOut  LED_on_dev_board4(LED4);
+DigitalOut speaker1(PC_8);               // relatie aangeven!
+DigitalOut speaker2(PC_6);
+//neopixel::PixelArray indicator_LEDs(PA_7);                                           
+
+PwmOut lock_feedback_LED(PB_13);                                                      // Declaration of pulse with modulation outputs.                                
+PwmOut mute_feedback_LED(PB_1);
+PwmOut new_patient_feedback_LED(PB_14);
+PwmOut reposition_feedback_LED(PB_15);
+
+//Timer button_lock_hold_timer;                                                       // Timer for time lock button should be pressed.
+//Timer button_calibration_hold_timer;                                                // Timer for calibration function (new patient holding 5 seconds).
+//Timer delay_between_button_pressed;                                                 // Timer for time between two buttons (to prevent pressing buttons simultaneously). 
+//Timer speaker_timer;                                                                // Timer for speaker activation.
+Timer piezo_electric_sample_timer;                                                  // Timer for equally time-spaced samples.
+
+/* 
+The code underneath this commentbox has some fixed parameters for serial/ADC reading:
+-> The address for the angle_device_reference_belt is set to 0x68 in the file MPU6050_belt (rule number: 19);
+-> The adress for the angle_device_sensorplate is set to 0x69 in the file MPU6050.h (rule number: 19);
+-> This is because of using the same I2C line;
+-> For detailed information/questions about this item, please read the technical manual or contact: Ricardo Molenaar | ricardo.molenaar@gmail.com
+*/
+I2C i2c_sensorplate_adc(PB_9, PB_8);                                                  // I2C for sensorplate.
+//I2C i2c_power_adc(PB_11, PB_10);                                                         // I2C for accupack. 
+MPU6050 angle_device_sensorplate(PB_9, PB_8);                                          // i2c pins // i2c address hardcoded 0x68.
+//MPU6050_belt angle_device_reference_belt(PB_9, PB_8);                                  // i2c pins // i2c address hardcoded 0x69.
+Adafruit_ADS1115 piezo_resistive_adc1(&i2c_sensorplate_adc, 0x48);                  // i2c pins, i2c address.
+Adafruit_ADS1115 piezo_resistive_adc2(&i2c_sensorplate_adc, 0x49);                  // i2c pins, i2c address.
+Adafruit_ADS1115 piezo_electric_adc(&i2c_sensorplate_adc, 0x4B);                    // i2c pins, i2c address.
+//Adafruit_ADS1115 adsAccu(&i2c_power_adc, 0x48);                                     // i2c pins, i2c address.
+Serial usb_serial(SERIAL_TX, SERIAL_RX);                                            // tx, rx  
+Serial pi_serial(PC_10, PC_11);                                                     // tx, rx  
+Ticker total_readout_cycle;                                                         // Polling cycle.
+// End of commentbox related to the serial configuration/ADC reading components. 
+
+int boot_delay_ms = 500;
+int total_readout_cycle_time_us = 100000;                                           // Cycle time in us.
+int i2c__frequency = 400000;                                                              // I2C Frequency.
+int baud_rate = 115200;                                                             // Baud rate.
+short piezo_resistive_array[8] = {0,0,0,0,0,0,0,0};                                 // 8 PR sensors 1 time per cycle.
+short piezo_electric_array[5] = {0,0,0,0,0};                                        // 1 PE sensor 5 times per cycle.
+int angle = 0;                                                                      // Accelerometer Z-axis.
+float accelerometer_sensorplate[3] = {0.0, 0.0, 0.0};                               // Raw accelerometer data.
+float gyroscope_sensorplate[3];                                                     // Raw gyroscope data.
+float accelerometer_reference_belt[3];                                              // Raw accelerometer data from belt.
+float gyroscope_reference_belt[3];                                                  // Raw gyroscope data from belt.
+char LED_colour = 'g';                                                              // Variable to set LED colour (standard set to green, untill PI sends other character). Other possible colours: red ('r') & yellow ('y').
+bool lock_state = false, lock_flag = 0, mute_state = 0, alarm = 0, calibration_flag = 0, intensity_select = 1;            // Boolean variables for logging states.
+bool mute_flag = 0, new_patient_flag = 0, reposition_flag = 0;                      // Flag variables.
+bool speaker_state = 0, LED_red_state = 0, LED_yellow_state = 0, LED_green_state = 0, power_plug_state = 0;
+bool speaker_logged = 0, LED_red_logged = 0, LED_yellow_logged = 0, LED_green_logged = 0, power_plug_logged = 0; // is toevoegen
+int locktime_ms = 2000;                                                             // Waittime for lock user interface in ms.
+int calibrationtime_ms = 5000;                                                      // Time to press new_patient button for calibration system.
+int calibration_flash = 0;                                                          // Variable for flash LED's to indicate calibration.
+int buttondelay_ms = 750;                                                           // Button delay in ms.
+int delay_lock_interface = 3000*60;                                                 // Delay for non using interface locktime.
+int speaker_active_ms = 750;                                                        // Time to iterate speaker on and off when alarm occurs.
+int alarm_voltage = 2400;                                                           // Needed voltage for alarm expressed as a digital 15 bit value (= 20% of max battery voltage).
+int LED_red_intensity = 0, LED_blue_intensity = 0, LED_green_intensity = 0;         // Variables to set LED intensity.
+short batteryvoltage_current = 0, batteryvoltage_last = 0, powervoltage_current, powervoltage_last;                  // Variables to manage batteryvoltage. Maybe change current to other?
+const int digital_value_ADC_powervoltage_unplugged = 15000;                         // Digital value to set the indicating LEDs to wall blue (should be set off later). const in hoofdletters
+int intensity_day = 40, intensity_night = 10;                                       // Intensity settings for LED's to wall.
+double intensity = 0.0, control_LED_intensity = 0.0;                                // Variable between 0 and 1 to set the intensity of the LED's above the buttons. Intensity change to smart name!
+
+/*************************** TEST ********************************/
+// Verify algoritm function: for belt activation, set test_belt 1 (connect pin p20 to 3.3V).
+Timer test_timer;                                                           
+DigitalIn test_pin(PA_11, PullDown);
+
+// Variable to set if belt is used to test algorithm: 
+bool test_belt = 0; 
+
+// Set test mode on (log functions to pc serial: interrupts, LED intensity and serial messages): 
+bool test_mode = 1;
+
+// Variable for connection test (should be changed):
+int connection_test_sensorplate; 
+
+
+void read_adc() {
+    piezo_electric_sample_timer.reset();                                            // Clock gebruiken o.i.d.?
+    piezo_electric_sample_timer.start();
+//    connection_test_sensorplate = angle_device_sensorplate.testConnection();
+    
+    if (test_mode == 1) {
+        usb_serial.printf("Connection test sensorplate = %d\n", connection_test_sensorplate);
+    }
+    
+    if (connection_test_sensorplate == 1) {
+        piezo_electric_array[0] = piezo_electric_adc.readADC_SingleEnded(0);            // First PE readout.
+
+        for (uint8_t k = 0; k < 4; ++k) {
+            piezo_resistive_array[k] =    piezo_resistive_adc1.readADC_SingleEnded(k);  // First 4 PR readout.
+        }
+      
+//        while(piezo_electric_sample_timer.read_us()<(1*(total_readout_cycle_time_us/5))) {} // Wait untill 20% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+
+        piezo_electric_array[1] = piezo_electric_adc.readADC_SingleEnded(0);            // Second PE readout.
+
+        for (uint8_t k = 0; k < 4; ++k) {
+            piezo_resistive_array[k+4] =  piezo_resistive_adc2.readADC_SingleEnded(k);  // Last 4 PR readout.
+        }
+
+//        while(piezo_electric_sample_timer.read_us()<(2*(total_readout_cycle_time_us/5))) {} // Wait untill 40% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+
+        piezo_electric_array[2] = piezo_electric_adc.readADC_SingleEnded(0);            // Third PE readout.
+
+//        angle_device_sensorplate.getAccelero(accelerometer_sensorplate);                // Get accelerometer data.
+//        angle = accelerometer_sensorplate[2]*100;
+//        if(angle == 0) {
+//            MPU6050 angle_device_sensorplate(PB_9, PB_8);
+//            angle_device_sensorplate.getAccelero(accelerometer_sensorplate);
+//            angle = accelerometer_sensorplate[2]*100;
+//        }
+//        angle_device_sensorplate.getGyro(gyroscope_sensorplate);                        // Get gyroscope data.
+//
+////        if (test_belt == 1) {
+////            angle_device_reference_belt.getGyro(gyroscope_reference_belt);              // Get gyroscope data from Belt.
+////            angle_device_reference_belt.getAccelero(accelerometer_reference_belt);      // Get accelerometer data from belt.
+////        }
+//        
+//        if (connection_test_sensorplate == 1) {                                                     // If statement for sending serial information sensorplate data when connection test is active. 
+//            // Receiving order sensor information: 3 accelero sensors & 3 gyroscope sensors from sensorplate; 3 accelero sensors & 3 gyroscope sensors from belt. Is splitted in two parts - part 2/2. 
+//            pi_serial.printf("?,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n", accelerometer_sensorplate[0], accelerometer_sensorplate[1], accelerometer_sensorplate[2], gyroscope_sensorplate[0], gyroscope_sensorplate[1], gyroscope_sensorplate[2], accelerometer_reference_belt[0], accelerometer_reference_belt[1], accelerometer_reference_belt[2], gyroscope_reference_belt[0], gyroscope_reference_belt[1], gyroscope_reference_belt[2]);
+//        } // binair print and convert in pi
+
+//        while(piezo_electric_sample_timer.read_us()<(3*(total_readout_cycle_time_us/5))) {}  // Wait untill 60% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+
+        piezo_electric_array[3] = piezo_electric_adc.readADC_SingleEnded(0);        // Fourth PE readout.
+    }
+
+//    timer_functions();
+
+    batteryvoltage_current = batteryvoltage_last;
+    powervoltage_current = powervoltage_last;
+//    read_voltage();                                                                 // Read_voltage function to control alarm.
+    
+    if (test_mode == 1) {
+        usb_serial.printf("Voltage = %d   ,   %d\n", batteryvoltage_current, powervoltage_current);
+    }
+    
+//    uint32_t val = 0;
+//    colour_select_indicating_LED_wall(LED_colour);                                  // Function to select colour.     
+//    indicator_LEDs.update(generate, NUMBER_LED_FRONT, val);                         // Function to set the LED's which shines to the wall (indicating change patient position).
+//    set_userinterface_LED();                                                        // Set LED's of user interface (LED's above buttons).
+
+//    while(piezo_electric_sample_timer.read_us()<(4*(total_readout_cycle_time_us/5))) {}  // Wait untill 80% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+
+//    if (test_mode == 1){                                                            // If statement for test purposal. 
+//        usb_serial.printf("Angle device sensorplate = %d\n",angle_device_sensorplate.testConnection());
+//    }
+    
+    if (connection_test_sensorplate == 1) {
+        piezo_electric_array[4] = piezo_electric_adc.readADC_SingleEnded(0);         // Fifth PE readout.
+    }
+
+//    while(piezo_electric_sample_timer.read_us()<(4.25*(total_readout_cycle_time_us/5))) {}  // Wait untill 85% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+
+    if (test_mode == 1) {
+        usb_serial.printf("!,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n", piezo_resistive_array[0], piezo_resistive_array[1], piezo_resistive_array[2], piezo_resistive_array[3], piezo_resistive_array[4], piezo_resistive_array[5], piezo_resistive_array[6], piezo_resistive_array[7], piezo_electric_array[0], piezo_electric_array[1], piezo_electric_array[2], piezo_electric_array[3], piezo_electric_array[4]); // print all to serial port
+    }
+    
+    if (test_mode == 1) {                                                            // If statements for test purposal (untill * mark).
+        usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
+    }
+//    if (test_pin == 1) {
+//        test_mode = 1;
+//        usb_serial.printf("%d\n",test_mode);
+//    }
+//    if (test_pin == 0) {
+//        test_mode = 0;
+//        usb_serial.printf("%d\n",test_mode);
+//    }
+
+    if (test_mode == 1) {
+        usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
+    }                                                                                
+                                                                                    // * End of if statements for test purposal. 
+}
+
+
+int main() {
+    //i2c_sensorplate_adc.frequency(400000);
+//    connection_test_sensorplate = angle_device_sensorplate.testConnection();
+//    pc.printf("Connection test sensorplate = %d\n", connection_test_sensorplate);
+//    while(1) {
+//        
+//        piezo_electric_array[0] = piezo_electric_adc.readADC_SingleEnded(0);            // First PE readout.
+//
+//        for (uint8_t k = 0; k < 4; ++k) {
+//            piezo_resistive_array[k] = piezo_resistive_adc1.readADC_SingleEnded(k);  // First 4 PR readout.
+//        }
+//
+//        angle_device_sensorplate.getAccelero(accelerometer_sensorplate);                // Get accelerometer data.
+//        angle = accelerometer_sensorplate[2]*100;
+//        if(angle == 0) {
+//            MPU6050 angle_device_sensorplate(PB_9, PB_8);
+//            angle_device_sensorplate.getAccelero(accelerometer_sensorplate);
+//            angle = accelerometer_sensorplate[2]*100;
+//        }
+//        angle_device_sensorplate.getGyro(gyroscope_sensorplate);                        // Get gyroscope data.
+//        
+//        pc.printf("?,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n", accelerometer_sensorplate[0], accelerometer_sensorplate[1], accelerometer_sensorplate[2], gyroscope_sensorplate[0], gyroscope_sensorplate[1], gyroscope_sensorplate[2], accelerometer_reference_belt[0], accelerometer_reference_belt[1], accelerometer_reference_belt[2], gyroscope_reference_belt[0], gyroscope_reference_belt[1], gyroscope_reference_belt[2]);
+//        pc.printf("!,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n", piezo_resistive_array[0], piezo_resistive_array[1], piezo_resistive_array[2], piezo_resistive_array[3], piezo_resistive_array[4], piezo_resistive_array[5], piezo_resistive_array[6], piezo_resistive_array[7], piezo_electric_array[0], piezo_electric_array[1], piezo_electric_array[2], piezo_electric_array[3], piezo_electric_array[4]); // print all to serial port
+//        wait(1);
+//    }
+    
+    wait_ms(boot_delay_ms);                                                         // Wait to boot sensorplate first.
+    i2c_sensorplate_adc.frequency(i2c__frequency);                                        // Set frequency for i2c connection to sensorplate (variable is declared in config part).
+//    i2c_power_adc.frequency(i2c__frequency);                                              // Same as line 695, but now for ADC to read battery- en powervoltage. 
+    usb_serial.baud(baud_rate);                                                     // Set serial USB connection baud rate (variable is declared in config part).
+    pi_serial.baud(baud_rate);                                                      // Same as line 697, but now for serial PI connection.
+    piezo_resistive_adc1.setGain(GAIN_TWOTHIRDS);                                   // Set ranges of ADC to +/-6.144V (end is marked with #):
+    piezo_resistive_adc2.setGain(GAIN_TWOTHIRDS);                                   
+    piezo_electric_adc.setGain(GAIN_TWOTHIRDS);                                     
+//    adsAccu.setGain(GAIN_TWOTHIRDS);                                                // #) End of configuration ADC ranges.
+    pi_serial.format(8, SerialBase::None, 1);                                       // Set serial communication line with PI. 
+
+    //button_lock.fall(&trigger_lock);                                                // Interrupt for rising edge lock button.
+//    button_lock.rise(&end_timer_lock_button);
+//    button_reposition.fall(&reposition_button_triggered);
+//    button_reposition.rise(&rise_reposition);
+//    button_mute.fall(&mute_button_triggered);
+//    button_new_patient.fall(&trigger_new_patient);                                  // New patient/calibration button rising event.
+//    button_new_patient.rise(&activate_new_patient_function);                                    // Falling edge for calibration algorithm option.
+//    delay_between_button_pressed.reset();                                           // Delaytimer reset en start.
+//    delay_between_button_pressed.start();
+
+//    set_intensity_LEDs();                                                                // Initialize intensity for user interface LED's and LED's shines to wall.  
+//    lock_feedback_LED = control_LED_intensity;                                      // Lock LED initialization.
+
+//    connection_test_sensorplate = angle_device_sensorplate.testConnection();
+//    total_readout_cycle.attach_us(&read_adc, total_readout_cycle_time_us);          // Call function to start reading sensorplate and other functionalities.
+
+    while (1) {
+//        wait_us(total_readout_cycle_time_us+1);                                     // Wait indefinitely.
+//        usb_serial.printf("%d\n", connection_test_sensorplate);
+        piezo_electric_sample_timer.reset();                                            // Clock gebruiken o.i.d.?
+        piezo_electric_sample_timer.start();
+        connection_test_sensorplate = angle_device_sensorplate.testConnection();
+        
+        if (test_mode == 1) {
+            usb_serial.printf("Connection test sensorplate = %d\n", connection_test_sensorplate);
+        }
+        
+        if (connection_test_sensorplate == 1) {
+            piezo_electric_array[0] = piezo_electric_adc.readADC_SingleEnded(0);            // First PE readout.
+    
+            for (uint8_t k = 0; k < 4; ++k) {
+                piezo_resistive_array[k] =    piezo_resistive_adc1.readADC_SingleEnded(k);  // First 4 PR readout.
+            }
+          
+    //        while(piezo_electric_sample_timer.read_us()<(1*(total_readout_cycle_time_us/5))) {} // Wait untill 20% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+    
+            piezo_electric_array[1] = piezo_electric_adc.readADC_SingleEnded(0);            // Second PE readout.
+    
+            for (uint8_t k = 0; k < 4; ++k) {
+                piezo_resistive_array[k+4] =  piezo_resistive_adc2.readADC_SingleEnded(k);  // Last 4 PR readout.
+            }
+    
+    //        while(piezo_electric_sample_timer.read_us()<(2*(total_readout_cycle_time_us/5))) {} // Wait untill 40% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+    
+            piezo_electric_array[2] = piezo_electric_adc.readADC_SingleEnded(0);            // Third PE readout.
+    
+    //        angle_device_sensorplate.getAccelero(accelerometer_sensorplate);                // Get accelerometer data.
+    //        angle = accelerometer_sensorplate[2]*100;
+    //        if(angle == 0) {
+    //            MPU6050 angle_device_sensorplate(PB_9, PB_8);
+    //            angle_device_sensorplate.getAccelero(accelerometer_sensorplate);
+    //            angle = accelerometer_sensorplate[2]*100;
+    //        }
+    //        angle_device_sensorplate.getGyro(gyroscope_sensorplate);                        // Get gyroscope data.
+    //
+    ////        if (test_belt == 1) {
+    ////            angle_device_reference_belt.getGyro(gyroscope_reference_belt);              // Get gyroscope data from Belt.
+    ////            angle_device_reference_belt.getAccelero(accelerometer_reference_belt);      // Get accelerometer data from belt.
+    ////        }
+    //        
+    //        if (connection_test_sensorplate == 1) {                                                     // If statement for sending serial information sensorplate data when connection test is active. 
+    //            // Receiving order sensor information: 3 accelero sensors & 3 gyroscope sensors from sensorplate; 3 accelero sensors & 3 gyroscope sensors from belt. Is splitted in two parts - part 2/2. 
+    //            pi_serial.printf("?,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n", accelerometer_sensorplate[0], accelerometer_sensorplate[1], accelerometer_sensorplate[2], gyroscope_sensorplate[0], gyroscope_sensorplate[1], gyroscope_sensorplate[2], accelerometer_reference_belt[0], accelerometer_reference_belt[1], accelerometer_reference_belt[2], gyroscope_reference_belt[0], gyroscope_reference_belt[1], gyroscope_reference_belt[2]);
+    //        } // binair print and convert in pi
+    
+    //        while(piezo_electric_sample_timer.read_us()<(3*(total_readout_cycle_time_us/5))) {}  // Wait untill 60% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+    
+            piezo_electric_array[3] = piezo_electric_adc.readADC_SingleEnded(0);        // Fourth PE readout.
+        }
+    
+    //    timer_functions();
+    
+        batteryvoltage_current = batteryvoltage_last;
+        powervoltage_current = powervoltage_last;
+    //    read_voltage();                                                                 // Read_voltage function to control alarm.
+        
+        if (test_mode == 1) {
+            usb_serial.printf("Voltage = %d   ,   %d\n", batteryvoltage_current, powervoltage_current);
+        }
+        
+    //    uint32_t val = 0;
+    //    colour_select_indicating_LED_wall(LED_colour);                                  // Function to select colour.     
+    //    indicator_LEDs.update(generate, NUMBER_LED_FRONT, val);                         // Function to set the LED's which shines to the wall (indicating change patient position).
+    //    set_userinterface_LED();                                                        // Set LED's of user interface (LED's above buttons).
+    
+    //    while(piezo_electric_sample_timer.read_us()<(4*(total_readout_cycle_time_us/5))) {}  // Wait untill 80% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+    
+    //    if (test_mode == 1){                                                            // If statement for test purposal. 
+    //        usb_serial.printf("Angle device sensorplate = %d\n",angle_device_sensorplate.testConnection());
+    //    }
+        
+        if (connection_test_sensorplate == 1) {
+            piezo_electric_array[4] = piezo_electric_adc.readADC_SingleEnded(0);         // Fifth PE readout.
+        }
+    
+    //    while(piezo_electric_sample_timer.read_us()<(4.25*(total_readout_cycle_time_us/5))) {}  // Wait untill 85% of cycle. Energy efficiency is not fine in this situation, correct if low energy is needed.
+    
+        if (test_mode == 1) {
+            usb_serial.printf("!,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n", piezo_resistive_array[0], piezo_resistive_array[1], piezo_resistive_array[2], piezo_resistive_array[3], piezo_resistive_array[4], piezo_resistive_array[5], piezo_resistive_array[6], piezo_resistive_array[7], piezo_electric_array[0], piezo_electric_array[1], piezo_electric_array[2], piezo_electric_array[3], piezo_electric_array[4]); // print all to serial port
+        }
+        
+        if (test_mode == 1) {                                                            // If statements for test purposal (untill * mark).
+            usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
+        }
+    //    if (test_pin == 1) {
+    //        test_mode = 1;
+    //        usb_serial.printf("%d\n",test_mode);
+    //    }
+    //    if (test_pin == 0) {
+    //        test_mode = 0;
+    //        usb_serial.printf("%d\n",test_mode);
+    //    }
+    
+        if (test_mode == 1) {
+            usb_serial.printf("Loop time: %d ms\n",piezo_electric_sample_timer.read_ms());
+        }     
+    }
+}
diff -r 000000000000 -r ad6765bb587f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 30 09:02:00 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e7ca05fa8600
\ No newline at end of file