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
Diff: bench.h
- Revision:
- 11:fc82dd22a527
- Parent:
- 10:77fcbad99a31
- Child:
- 15:a84d54e25775
--- a/bench.h Mon Feb 17 15:15:24 2020 +0000 +++ b/bench.h Wed Aug 12 12:05:58 2020 +0000 @@ -12,8 +12,7 @@ #include "lcm101.h" #include "SPTEPressureSensor.h" #include "Valve.h" - -#include "PinDetect.h" +#include "LinearActuator.h" /** * Class to read out sensory information from the second test bench: @@ -43,9 +42,9 @@ // 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 p_spte0 = SPTE_0, PinName p_spte1 = SPTE_1,PinName p_valve = VALVE_PIN,PinName p_laDir = LINACT_DIR_PIN, PinName p_laPwm = LINACT_PWM_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); + PinName tx = USBTX, PinName rx = USBRX); //setup @@ -58,6 +57,10 @@ bool isLogging();//indicates if we are now datalogging void stopLogging();//halts the data logging if we are now datalogging + void StopLogging(); //halts the data logging if we are now datalogging + void StartLogging(const char * fname_append = "data"); //starts datalogging + void RestartLogging(const char * fname_append = "data");//restart datalogging + void LogData(); //reading angle sensors As5048* get_as5048(); @@ -88,6 +91,11 @@ bool getValve(); void setValve(bool pressurise); + // controlling linear actuator + void setDir(bool dir); + bool getDir(); + void setPWM(int pwm); + /** Object for printing/receiving data to the PC the test rig is connected * to. Note that it uses the MODSERIAL.h class. */ @@ -103,17 +111,16 @@ Ticker tick_update, tick_serial, tick_logging; //for the updating of sensor values, printing of serial data and logging of data Timer timer; + Timer keyIntT;//timer to debounce keypresses + int keyIntOffset;//for setting initial value of keyIntT 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; - + char k; //value from keyboard + //joint angle As5048 as5048_; @@ -129,6 +136,9 @@ //valve ValveDigital valveFesto; + //linear actuator + LinearActuator LinAct; + //SD card SDFileSystem sd; FILE * fp_data; @@ -141,9 +151,10 @@ 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(); + + //for toggling logging or printing + void ToggleState(MODSERIAL_IRQ_INFO *q); + void ToggleLogging(); // serial printing