A library to control a linear actuator box

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers linearActuatorControl.h Source File

linearActuatorControl.h

00001 #ifndef LINEAR_ACTUATOR_CONTROL_H
00002 #define LINEAR_ACTUATOR_CONTROL_H
00003 
00004 #include "mbed.h"
00005 
00006 class LinearActuatorControl {
00007     private:
00008         DigitalIn _controlMode;
00009         DigitalIn _runMode;
00010         
00011         PwmOut _linAct1;
00012         PwmOut _linAct2;
00013         PwmOut _linAct3;
00014         PwmOut _linAct4;
00015 
00016         DigitalIn _actBtn1;
00017         DigitalIn _actBtn2;
00018         DigitalIn _actBtn3;
00019         DigitalIn _actBtn4;
00020 
00021         float _idlePositions[4];        //stores values of idle positions, deafult all 0, user defined with setIdlePositions
00022         float _actPositions[4];         //stores current positions of the actuators, updated by move()
00023         float _manualPositionsDown[4];  //positions of actuators when switch is down
00024         float _manualPositionsUp[4];    //positions of actuators when switch is up
00025         
00026         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
00027     public:
00028         LinearActuatorControl();
00029 
00030         //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)
00031         //changes _actPositions array
00032         void move(float pos1, float pos2, float pos3, float pos4);
00033 
00034         //similar to move, but sets the idle positions for the actuators
00035         void setIdlePositions(float pos1, float pos2, float pos3, float pos4);
00036         void setManualPositionsDown(float pos1, float pos2, float pos3, float pos4);
00037         void setManualPositionsUp(float pos1, float pos2, float pos3, float pos4);
00038 
00039         //used to check the state of the machine, will return true if in auto+run mode
00040         bool inUserSequence();
00041 
00042         void refresh();     //should be called refresh or update?
00043 };
00044 
00045 #endif