most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown
Dependencies: mbed MODSERIAL FATFileSystem
LinearActuator/LinearActuator.hpp
- Committer:
- mkelly10
- Date:
- 2017-10-20
- Revision:
- 9:d5fcdcb3c89d
- Child:
- 10:085ab7328054
File content as of revision 9:d5fcdcb3c89d:
#ifndef BCE_HPP #define BCE_HPP #include "mbed.h" #include "PololuHbridge.hpp" #include "controller.hpp" #include "ltc1298.hpp" #include "PosVelFilter.hpp" //Dependencies //This Class requires adc readings to sense the position of the piston //This is a resource that ends up being shared among other classes in the vehicle //for this reason it makes sense for it to be its own entity that is started in //the main line code class LinearActuator { public: //BuoyancyEngine(PololuHBridge motor, SpiADC adc, PosVelFilter filter, PositionController pid); LinearActuator(float interval, PinName pwm, PinName dir, PinName reset, PinName limit, int adc_ch); // functions for setting up void init(); void update(); void start(); void stop(); void pause(); void unpause(); void refreshPVState(); // setting and getting variables void setPosition_mm(float dist); float getPosition_mm(); float getPosition_counts(); float getVelocity_mms(); void setControllerP(float P); float getControllerP(); void setControllerI(float I); float getControllerI(); void setControllerD(float D); float getControllerD(); void setZeroCounts(int zero); int getZeroCounts(); void setTravelLimit(float limit); float getTravelLimit(); void setPotSlope(float slope); float getPotSlope(); void homePiston(); void setFilterFrequency(float frequency); float getOutput(); bool getSwitch(); void setDeadband(float deadband); bool toggleDeadband(bool toggle); protected: PololuHBridge _motor; PosVelFilter _filter; PIDController _pid; //Timer _time; Ticker _pulse; InterruptIn _limitSwitch; void _switchPressed(); void _switchReleased(); void _calculateSensorSlope(); bool _init; bool _paused; bool _limit; int _adc_channel; float _filterFrequency; float _dt; float _SetPoint_mm; float _position; float _position_mm; float _velocity; float _velocity_mms; float _Pgain; float _Igain; float _Dgain; float _deadband; int _zeroCounts; //gets assigned by homing function. can also be stored in config float _extendLimit; //config variable, limits the extension of the piston, this is same as datum for normal operation, float _pos_vel_wn; //config variable, natural frequecny of the position velocity filter float _slope; int dist_to_counts(float dist); float counts_to_dist(int count); float counts_to_velocity(int count); }; #endif