Version 3 is with update to the test rig with a linear actuator

Dependencies:   SPTE_10Bar_5V mbed AS5048 SDFileSystem MODSERIAL PinDetect LCM101 LinearActuator

Committer:
cnckiwi31
Date:
Mon Dec 09 11:15:47 2019 +0000
Revision:
6:02507d7a6f51
Parent:
5:63063a9fa51c
Child:
8:bc467f5fe7c3
Added documentation to the Bench class most relevant for controlling test rig

Who changed what in which revision?

UserRevisionLine numberNew contents of line
megrootens 0:3855d4588f76 1 #ifndef _BENCH02_H_
megrootens 0:3855d4588f76 2 #define _BENCH02_H_
cnckiwi31 5:63063a9fa51c 3 #include "MODSERIAL.h"
megrootens 0:3855d4588f76 4
megrootens 0:3855d4588f76 5 #include "mbed.h"
cnckiwi31 5:63063a9fa51c 6 #include <string>
cnckiwi31 5:63063a9fa51c 7
cnckiwi31 5:63063a9fa51c 8 #include "SDFileSystem.h"
cnckiwi31 5:63063a9fa51c 9 #include "constants.h"
cnckiwi31 5:63063a9fa51c 10
megrootens 0:3855d4588f76 11 #include "as5048.h"
megrootens 0:3855d4588f76 12 #include "lcm101.h"
cnckiwi31 4:1cdce6c6c94e 13 #include "SPTEPressureSensor.h"
cnckiwi31 5:63063a9fa51c 14 #include "Valve.h"
cnckiwi31 5:63063a9fa51c 15
cnckiwi31 5:63063a9fa51c 16 #include "PinDetect.h"
megrootens 0:3855d4588f76 17
megrootens 0:3855d4588f76 18 /**
cnckiwi31 6:02507d7a6f51 19 * Class to read out sensory information from the second test bench:
cnckiwi31 6:02507d7a6f51 20 * the knee joint angle as measured by an AMS AS5048 absolute rotary sensor
cnckiwi31 6:02507d7a6f51 21 * the vertical force applied externally at the hip joint
cnckiwi31 6:02507d7a6f51 22 * the pressure (for example of an actuator used in the device under test).
cnckiwi31 6:02507d7a6f51 23 * Additionally, an on /off valve can pressurise the actuator on the leg
megrootens 0:3855d4588f76 24 */
megrootens 0:3855d4588f76 25 class Bench {
megrootens 0:3855d4588f76 26 public:
megrootens 0:3855d4588f76 27
megrootens 0:3855d4588f76 28 static const float kCutOffDegrees = 180.0f;
megrootens 0:3855d4588f76 29 static const float kCutOffRadians = 3.14159265359f;
megrootens 0:3855d4588f76 30
megrootens 0:3855d4588f76 31 enum Joint {
megrootens 0:3855d4588f76 32 TOES,
megrootens 0:3855d4588f76 33 ANKLE,
megrootens 0:3855d4588f76 34 KNEE,
megrootens 0:3855d4588f76 35 HIP
megrootens 0:3855d4588f76 36 };
cnckiwi31 5:63063a9fa51c 37
cnckiwi31 5:63063a9fa51c 38 // constructor
cnckiwi31 5:63063a9fa51c 39 Bench(PinName mosi = AS5048_MOSI, PinName miso = AS5048_MISO, PinName sck = AS5048_SCLK, PinName cs = AS5048_CS,
cnckiwi31 5:63063a9fa51c 40 bool use5kN = sensors::use5kN,PinName p_lcm101 = LCM101,
cnckiwi31 5:63063a9fa51c 41 PinName p_spte0 = SPTE_0, PinName p_spte1 = SPTE_1,PinName p_valve = VALVE_PIN,
cnckiwi31 5:63063a9fa51c 42 PinName sd_mosi = SD_MOSI, PinName sd_miso = SD_MISO, PinName sd_sck = SD_SCK, PinName sd_cs = SD_CS,
cnckiwi31 5:63063a9fa51c 43 PinName tx = USBTX, PinName rx = USBRX, PinName but0 = SW2, PinName but1 = SW3);
megrootens 0:3855d4588f76 44
cnckiwi31 5:63063a9fa51c 45
cnckiwi31 5:63063a9fa51c 46 //setup
cnckiwi31 5:63063a9fa51c 47 void initialise();
megrootens 0:3855d4588f76 48
cnckiwi31 5:63063a9fa51c 49 void setLoggingFrequency(float logHertz);
cnckiwi31 5:63063a9fa51c 50 void setExtraColumns(string extraColumnNames[], int numCols);
cnckiwi31 5:63063a9fa51c 51 void setExtraData(float data[]);
cnckiwi31 5:63063a9fa51c 52 void update();
megrootens 0:3855d4588f76 53
cnckiwi31 5:63063a9fa51c 54 bool isLogging();//indicates if we are now datalogging
cnckiwi31 5:63063a9fa51c 55 void stopLogging();//halts the data logging if we are now datalogging
cnckiwi31 5:63063a9fa51c 56
cnckiwi31 5:63063a9fa51c 57 //reading angle sensors
cnckiwi31 5:63063a9fa51c 58 As5048* get_as5048();
cnckiwi31 5:63063a9fa51c 59
megrootens 0:3855d4588f76 60 float getDegrees(int i_joint);
megrootens 0:3855d4588f76 61 float getDegrees(Joint joint);
megrootens 0:3855d4588f76 62
megrootens 0:3855d4588f76 63 float getRadians(int i_joint);
megrootens 0:3855d4588f76 64 float getRadians(Joint joint);
megrootens 0:3855d4588f76 65
megrootens 0:3855d4588f76 66 const char* getJointName(int i_joint);
megrootens 0:3855d4588f76 67 const char* getJointName(Joint joint);
megrootens 0:3855d4588f76 68
cnckiwi31 5:63063a9fa51c 69 //reading and calibrating force and pressure sensors
megrootens 0:3855d4588f76 70 float getForce();
cnckiwi31 4:1cdce6c6c94e 71 void nullForce();
cnckiwi31 4:1cdce6c6c94e 72
cnckiwi31 4:1cdce6c6c94e 73 float getPressure0();
cnckiwi31 4:1cdce6c6c94e 74 void nullPressure0();
cnckiwi31 4:1cdce6c6c94e 75 float getPressure1();
cnckiwi31 4:1cdce6c6c94e 76 void nullPressure1();
megrootens 0:3855d4588f76 77
cnckiwi31 5:63063a9fa51c 78 //controlling valve
cnckiwi31 5:63063a9fa51c 79 bool getValve();
cnckiwi31 5:63063a9fa51c 80 void setValve(bool pressurise);
cnckiwi31 5:63063a9fa51c 81
cnckiwi31 5:63063a9fa51c 82 //printing data
cnckiwi31 5:63063a9fa51c 83 MODSERIAL pc;
cnckiwi31 5:63063a9fa51c 84
cnckiwi31 5:63063a9fa51c 85 void pausePrint();
cnckiwi31 5:63063a9fa51c 86 void resumePrint();
cnckiwi31 5:63063a9fa51c 87
cnckiwi31 5:63063a9fa51c 88 private:
cnckiwi31 5:63063a9fa51c 89 //timing
cnckiwi31 5:63063a9fa51c 90 int loggingUS; //microseconds between recording data logging
cnckiwi31 5:63063a9fa51c 91 float loggingHz;// Hz of data logging
cnckiwi31 5:63063a9fa51c 92
cnckiwi31 5:63063a9fa51c 93 Ticker tick_update, tick_serial, tick_logging; //for the updating of sensor values, printing of serial data and logging of data
cnckiwi31 5:63063a9fa51c 94 Timer timer;
cnckiwi31 5:63063a9fa51c 95 int firstReadMS; //first timer value read
cnckiwi31 5:63063a9fa51c 96 bool startedLogging; //in the middle of a logging cycle
cnckiwi31 5:63063a9fa51c 97
cnckiwi31 5:63063a9fa51c 98 bool is_logging;
cnckiwi31 5:63063a9fa51c 99 bool is_printing;
cnckiwi31 5:63063a9fa51c 100 bool was_printing; //if printing is paused true if is_printing was true
cnckiwi31 5:63063a9fa51c 101
cnckiwi31 5:63063a9fa51c 102 //buttons
cnckiwi31 5:63063a9fa51c 103 PinDetect lowerBut;
cnckiwi31 5:63063a9fa51c 104 PinDetect upperBut;
cnckiwi31 5:63063a9fa51c 105
cnckiwi31 5:63063a9fa51c 106 //joint angle
cnckiwi31 5:63063a9fa51c 107 As5048 as5048_;
cnckiwi31 5:63063a9fa51c 108
cnckiwi31 5:63063a9fa51c 109 //load cells
cnckiwi31 5:63063a9fa51c 110 Lcm101 loadCell5kN;
cnckiwi31 5:63063a9fa51c 111 Lcm101 loadCell1kN;
cnckiwi31 5:63063a9fa51c 112 bool use5kN;//determine which load cell is used
cnckiwi31 5:63063a9fa51c 113
cnckiwi31 5:63063a9fa51c 114 //pressure sensors
cnckiwi31 5:63063a9fa51c 115 SPTEPressureSensor spte0;
cnckiwi31 5:63063a9fa51c 116 SPTEPressureSensor spte1;
cnckiwi31 5:63063a9fa51c 117
cnckiwi31 5:63063a9fa51c 118 //valve
cnckiwi31 5:63063a9fa51c 119 ValveDigital valveFesto;
cnckiwi31 5:63063a9fa51c 120
cnckiwi31 5:63063a9fa51c 121 //SD card
cnckiwi31 5:63063a9fa51c 122 SDFileSystem sd;
cnckiwi31 5:63063a9fa51c 123 FILE * fp_data;
cnckiwi31 5:63063a9fa51c 124 int fname_prepend;//file number
cnckiwi31 5:63063a9fa51c 125 bool sd_card_present;//card detected
cnckiwi31 5:63063a9fa51c 126
cnckiwi31 5:63063a9fa51c 127 static const int maxCols = 5;
cnckiwi31 5:63063a9fa51c 128 int usedExtraCols; //number of extra columns useds
cnckiwi31 5:63063a9fa51c 129 string extraColNames[maxCols];//names of extra columns (up to maxCols allowed with 15 characters)
cnckiwi31 5:63063a9fa51c 130 float extraColValues[maxCols];//value held in extra columns for current time step
cnckiwi31 5:63063a9fa51c 131
cnckiwi31 5:63063a9fa51c 132 void InitSdCard();
cnckiwi31 5:63063a9fa51c 133 void StartLogging(const char * fname_append = "data");
cnckiwi31 5:63063a9fa51c 134 void StopLogging();
cnckiwi31 5:63063a9fa51c 135 void LogData();
cnckiwi31 5:63063a9fa51c 136 void ToggleLogging();
cnckiwi31 5:63063a9fa51c 137
cnckiwi31 5:63063a9fa51c 138 // serial printing
cnckiwi31 5:63063a9fa51c 139 void TogglePrinting();
cnckiwi31 5:63063a9fa51c 140 void PrintStatus();
cnckiwi31 5:63063a9fa51c 141 void PrintMenu();
cnckiwi31 5:63063a9fa51c 142 };
megrootens 0:3855d4588f76 143
megrootens 0:3855d4588f76 144
megrootens 0:3855d4588f76 145
megrootens 0:3855d4588f76 146 #endif