Code for the COVR project DROPSAW project test rig (previously used for the Heros testing).
Dependencies: SPTE_10Bar_5V mbed AS5048 SDFileSystem MODSERIAL LCM101_DROPSAW LinearActuator
bench.h
- Committer:
- cnckiwi31
- Date:
- 2020-02-17
- Revision:
- 10:77fcbad99a31
- Parent:
- 8:bc467f5fe7c3
- Child:
- 11:fc82dd22a527
- Child:
- 12:b0a6faaa5e9f
File content as of revision 10:77fcbad99a31:
#ifndef _BENCH02_H_ #define _BENCH02_H_ #include "MODSERIAL.h" #include "mbed.h" #include <string> #include "SDFileSystem.h" #include "constants.h" #include "as5048.h" #include "lcm101.h" #include "SPTEPressureSensor.h" #include "Valve.h" #include "PinDetect.h" /** * Class to read out sensory information from the second test bench: * the knee joint angle as measured by an AMS AS5048 absolute rotary sensor * the vertical force applied externally at the hip joint * the pressure (for example of an actuator used in the device under test). * Additionally, an on /off valve can pressurise the actuator on the leg */ class Bench { public: static const float kCutOffDegrees = 180.0f; static const float kCutOffRadians = 3.14159265359f; enum Joint { TOES, ANKLE, KNEE, HIP }; enum DACChannel { A, B }; // constructor Bench(PinName mosi = AS5048_MOSI, PinName miso = AS5048_MISO, PinName sck = AS5048_SCLK, PinName cs = AS5048_CS, bool use5kN = sensors::use5kN,PinName p_lcm101 = LCM101, PinName p_spte0 = SPTE_0, PinName p_spte1 = SPTE_1,PinName p_valve = VALVE_PIN, PinName sd_mosi = SD_MOSI, PinName sd_miso = SD_MISO, PinName sd_sck = SD_SCK, PinName sd_cs = SD_CS, PinName tx = USBTX, PinName rx = USBRX, PinName but0 = SW2, PinName but1 = SW3); //setup void initialise(); void setLoggingFrequency(float logHertz); void setExtraColumns(string extraColumnNames[], int numCols); void setExtraData(float data[]); void update(); bool isLogging();//indicates if we are now datalogging void stopLogging();//halts the data logging if we are now datalogging //reading angle sensors As5048* get_as5048(); float getDegrees(int i_joint); float getDegrees(Joint joint); float getRadians(int i_joint); float getRadians(Joint joint); const char* getJointName(int i_joint); const char* getJointName(Joint joint); //reading and calibrating force and pressure sensors float getForce(); void nullForce(); float getPressure0(); void nullPressure0(); float getPressure1(); void nullPressure1(); //MAX5322 DACs (two channels per DAC) void setDACA(DACChannel ch, unsigned int bitValue); void setDACB(DACChannel ch, unsigned int bitValue); //controlling valve bool getValve(); void setValve(bool pressurise); /** Object for printing/receiving data to the PC the test rig is connected * to. Note that it uses the MODSERIAL.h class. */ MODSERIAL pc; void pausePrint(); void resumePrint(); private: //timing int loggingUS; //microseconds between recording data logging float loggingHz;// Hz of data logging Ticker tick_update, tick_serial, tick_logging; //for the updating of sensor values, printing of serial data and logging of data Timer timer; int firstReadMS; //first timer value read bool startedLogging; //in the middle of a logging cycle bool is_logging; bool is_printing; bool was_printing; //if printing is paused true if is_printing was true //buttons PinDetect lowerBut; PinDetect upperBut; //joint angle As5048 as5048_; //load cells Lcm101 loadCell5kN; Lcm101 loadCell1kN; bool use5kN;//determine which load cell is used //pressure sensors SPTEPressureSensor spte0; SPTEPressureSensor spte1; //valve ValveDigital valveFesto; //SD card SDFileSystem sd; FILE * fp_data; int fname_prepend;//file number bool sd_card_present;//card detected static const int maxCols = 5; int usedExtraCols; //number of extra columns useds string extraColNames[maxCols];//names of extra columns (up to maxCols allowed with 15 characters) float extraColValues[maxCols];//value held in extra columns for current time step void InitSdCard(); void StartLogging(const char * fname_append = "data"); void StopLogging(); void LogData(); void ToggleLogging(); // serial printing void TogglePrinting(); void PrintStatus(); void PrintMenu(); }; #endif