8#define eprintf(_STR, ...) fprintf(ERRSTREAM, _STR, __VA_ARGS__)
10#define DIGITAL_HIGH_VOLTS 5.0
11#define DIGITAL_LOW_VOLTS 0.0
12#define WIND_UP_VOLTS 0.8
13#define WIND_DOWN_VOLTS 0.0
14#define DEFAULT_MUSCLE_TONE 1.0
15#define MAX_MUSCLE_TENSION 30.0
16#define MOTOR_SHAFT_DIAMTR 6
17#define LOADCELL_TARE_NSAMP 100
134 unsigned maxChannels_mtr, maxChannels_enc;
136 unsigned (*motor_enable_config)[2];
137 unsigned (*motor_value_config)[2];
138 unsigned (*encoder_config)[2];
139 unsigned (*encoder_opt_config)[2];
140 unsigned (*loadcell_config)[2];
143 double muscleToneTension;
144 double maxMuscleTension;
147 double loadcell_offset, loadcell_gain;
148 double encoder_offset_angle;
149 double encoder_angle_to_excursion_ratio;
151 double mtrTension_offset, mtrTension_gain;
154 double refMuscleTension;
155 double myMuscleTension;
174 myosyn(
unsigned muscleChannel);
341 void (*
controlRoutine)(
unsigned numOutputs,
double* outputs,
unsigned numInputs,
double* inputs);
This is the class object for each muscle channel.
void windUp()
Function starts/energizes the motor of the muscle channel to wind up the tendons to prevent slack.
void stopMuscleControl()
Stops the force controller and update the status of the muscle channel. This function only needs to b...
double getMaxMuscleTension()
Returns the upper limit of possible muscle tensions by the motor of the muscle channel.
double getMuscleToneTension()
Returns the current muscle tone of the muscle channel.
void setReferenceTension(double myTension)
The current reference/target muscle tension which the internal closed-loop controller will attempt to...
double loadcellV2F(double LCvoltage)
Returns the force on the loadcell when supplied with the voltage based on the gain and bias set by ca...
myosyn()
Default constructor of the myosyn class. Auto-selects muscle channel when setting up a muscle channel...
void readMuscleTension()
Uses the DAQ subsystem to read the muscle tension detected by the loadcell and puts it in the interna...
void calibrateTension(double loadCellGain=NAN)
Sets the gain to calibrate the transformation of the loadcell voltage to force in newtons....
void setMuscleToneTension(double myMuscleTone_value)
Sets the minimum tension held by the motor of a muscle channel. Corresponds to muscle tone and is the...
void startMuscleControl()
Starts the force controller and update the status of the muscle channel. This function only needs to ...
double encoderAngle2Excursion(double encoderAngle)
Returns the tendon excursion given an encoder angle.
void setMuscleStatus(muscleStatus newStatus)
Function sets the status of the muscle channel object.
void executeControl()
Executes the control law set by the controlRoutine function pointer.
muscleStatus getMuscleStatus()
Returns the status of the muscle channel. The possible statuses are listed in the enum muscleStatus.
double getReferenceTension()
Returns the current reference/target muscle tension that the motor controller is trying to achieve/ma...
void(* stopDAQ)()
Function pointer to the global myosynStop function to stop data acquisition. Only need to call this f...
double getTendonExcursion()
Returns the current tendon excursion value (in mm) in the internal memory.
double getMuscleTension()
Returns the current muscle tension value (in newtons) in the internal memory.
void(* startDAQ)()
Function pointer to the global myosynStart function to start data acquisition. Only need to call this...
void windDown()
Function stops/deenergizes the motor of the muscle channel to wind down the tendons before system shu...
void readTendonExcursion()
Uses the DAQ subsystem to read the tendon excursion detected by the shaft encoder and puts it in the ...
void setMaxMuscleTension(double max_tension)
Sets the upper limit to possible muscle tension of the motor of the muscle channel as a protection.
unsigned getChannelID()
Returns the channel ID number of the muscle channel.
void setMotorCommand(double newCommand)
Sets the current motor command to be sent to the DC motor.
void calibrateExcursion(double spoolDiameter=NAN)
Calibrates the rotary incremental shaft encoder to zero degrees and set the conversion from angle to ...
void(* controlRoutine)(unsigned numOutputs, double *outputs, unsigned numInputs, double *inputs)
[FOR FUTURE USE ONLY] Function pointer to any control law you might want the muscle channel to use.
double getMotorCommand()
Returns the current motor command that is being commanded to the motor.
unsigned myosynNumMuscles()
Returns the number of muscles configured by the library.
unsigned muscle_ld_cell[8][2]
_DAQarrangement
Enumerates the different types of configurations supported by myosyn.
unsigned muscle_mtr_en[16][2]
double mtr_trque_calib[16][2]
double myosynSamplingRate(double newSamplingRate=myosyn_samplingRate_global)
Sets the sampling rate of the data acquisition and controller of all the muscle channels....
unsigned muscle_enc_kleo[8][2]
enum _muscleStatus muscleStatus
This ENUM lists the possible statuses of each muscle channel.
DAQarrangement myosynGetConfiguration()
_muscleStatus
This ENUM lists the possible statuses of each muscle channel.
int myosynGetLeaderChannel()
Returns the leader muscle channel which governs/triggers data acquisition on all other muscles.
void myosynStart()
This routine starts the data acquisition on all muscle channels that haven't already been started so ...
double loadcell_calib[8][2]
unsigned muscle_enc_ring[8][2]
void myosynWriteOutputs()
Global function to write all DAQ outputs in a synchronized manner. The results are put into the class...
void myosynWaitForClock()
This blocking function waits for the clock period to finish between two function calls....
unsigned numConfiguredMuscles
void myosynReadInputs()
Global function to read all DAQ inputs in a synchronized manner. The results are put into the class o...
void myosynStop()
This function sops the data acquisition of all muscle channels that were started (ie....
double myosyn_samplingRate_global
enum _DAQarrangement DAQarrangement
Enumerates the different types of configurations supported by myosyn.
unsigned muscle_enc_spl[12][2]
DAQarrangement myosynConfiguration
void myosynSetConfiguration(DAQarrangement DAQconfiguration)
Set the muscle configuration/arrangement type of the library. List of possibilities in the DAQarrange...
unsigned muscle_mtr_val[16][2]
unsigned muscle_enc_mtr[12][2]
void myosynSetLeaderChannel(int newLeader)
Sets the leader/master muscle channel which governs/triggers data acquisition on all other muscles.