A library to control a linear actuator box

Committer:
crussell21
Date:
Mon Feb 24 08:34:01 2020 +0000
Revision:
1:cf533adb862c
Parent:
0:1a5f4c492b1a
inverted conditional so switch up and down are flipped to a more logical interpretation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
crussell21 0:1a5f4c492b1a 1 #ifndef LINEAR_ACTUATOR_CONTROL_H
crussell21 0:1a5f4c492b1a 2 #define LINEAR_ACTUATOR_CONTROL_H
crussell21 0:1a5f4c492b1a 3
crussell21 0:1a5f4c492b1a 4 #include "mbed.h"
crussell21 0:1a5f4c492b1a 5
crussell21 0:1a5f4c492b1a 6 class LinearActuatorControl {
crussell21 0:1a5f4c492b1a 7 private:
crussell21 0:1a5f4c492b1a 8 DigitalIn _controlMode;
crussell21 0:1a5f4c492b1a 9 DigitalIn _runMode;
crussell21 0:1a5f4c492b1a 10
crussell21 0:1a5f4c492b1a 11 PwmOut _linAct1;
crussell21 0:1a5f4c492b1a 12 PwmOut _linAct2;
crussell21 0:1a5f4c492b1a 13 PwmOut _linAct3;
crussell21 0:1a5f4c492b1a 14 PwmOut _linAct4;
crussell21 0:1a5f4c492b1a 15
crussell21 0:1a5f4c492b1a 16 DigitalIn _actBtn1;
crussell21 0:1a5f4c492b1a 17 DigitalIn _actBtn2;
crussell21 0:1a5f4c492b1a 18 DigitalIn _actBtn3;
crussell21 0:1a5f4c492b1a 19 DigitalIn _actBtn4;
crussell21 0:1a5f4c492b1a 20
crussell21 0:1a5f4c492b1a 21 float _idlePositions[4]; //stores values of idle positions, deafult all 0, user defined with setIdlePositions
crussell21 0:1a5f4c492b1a 22 float _actPositions[4]; //stores current positions of the actuators, updated by move()
crussell21 0:1a5f4c492b1a 23 float _manualPositionsDown[4]; //positions of actuators when switch is down
crussell21 0:1a5f4c492b1a 24 float _manualPositionsUp[4]; //positions of actuators when switch is up
crussell21 0:1a5f4c492b1a 25
crussell21 0:1a5f4c492b1a 26 float _convertToPulseWidth_us(float); //takes in value from 0 to 1 for actuator extention percentage, and converts this to the appropriate pulse width in us
crussell21 0:1a5f4c492b1a 27 public:
crussell21 0:1a5f4c492b1a 28 LinearActuatorControl();
crussell21 0:1a5f4c492b1a 29
crussell21 0:1a5f4c492b1a 30 //user function to command actuators to move, takes any float value from 0 to 1 for the percent extension of the actuator (0.45 = 45% extended)
crussell21 0:1a5f4c492b1a 31 //changes _actPositions array
crussell21 0:1a5f4c492b1a 32 void move(float pos1, float pos2, float pos3, float pos4);
crussell21 0:1a5f4c492b1a 33
crussell21 0:1a5f4c492b1a 34 //similar to move, but sets the idle positions for the actuators
crussell21 0:1a5f4c492b1a 35 void setIdlePositions(float pos1, float pos2, float pos3, float pos4);
crussell21 0:1a5f4c492b1a 36 void setManualPositionsDown(float pos1, float pos2, float pos3, float pos4);
crussell21 0:1a5f4c492b1a 37 void setManualPositionsUp(float pos1, float pos2, float pos3, float pos4);
crussell21 0:1a5f4c492b1a 38
crussell21 0:1a5f4c492b1a 39 //used to check the state of the machine, will return true if in auto+run mode
crussell21 0:1a5f4c492b1a 40 bool inUserSequence();
crussell21 0:1a5f4c492b1a 41
crussell21 0:1a5f4c492b1a 42 void refresh(); //should be called refresh or update?
crussell21 0:1a5f4c492b1a 43 };
crussell21 0:1a5f4c492b1a 44
crussell21 0:1a5f4c492b1a 45 #endif