Alex Pirciu
/
BFMC
a
Diff: include/Drivers/vnh.hpp
- Revision:
- 1:ceee5a608e7c
diff -r c3e774091195 -r ceee5a608e7c include/Drivers/vnh.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/Drivers/vnh.hpp Thu Mar 28 07:44:42 2019 +0000 @@ -0,0 +1,82 @@ +/** + ****************************************************************************** + * @file VNH.hpp + * @author RBRO/PJ-IU + * @version V1.0.0 + * @date day-month-2017 + * @brief This file contains the class declaration for the VNH Bridge Driver + * functionality. + ****************************************************************************** + */ + +/* Inclusion guard */ +#ifndef VNH_HPP +#define VNH_HPP + +/* The mbed library */ +#include <mbed.h> +/* Functions to compute common mathematical operations and transformations */ +#include <cmath> + +namespace drivers{ + // ! Current getter interface + class ICurrentGetter{ + public: + virtual float GetCurrent(void)=0; + }; + + /** + * @brief Command setter interface. + * + */ + class ICommandSetter{ + public: + virtual void Run(float pwm); + }; + + //! VNH class. + /*! + * It is used for implementing motor bridge control. + * */ + class VNH:public ICurrentGetter, public ICommandSetter + { + public: + /* Constructor */ + VNH(PinName, PinName, PinName, PinName); + /* Destructor */ + ~VNH(); + /* Start */ + void Start(void); + /* Stop */ + void Stop(void); + /* Run */ + void Run(float speed); + /* Brake */ + void Brake(); + /* Inverse */ + void Inverse(float f_speed); + /* Get current */ + float GetCurrent(void); + + private: + /* Go current */ + void Go(float speed); + /* increment member */ + float increment; + /* current speed member */ + float current_speed; + /* PWM */ + PwmOut pwm; + /* pin A */ + DigitalOut ina; + /* pin B */ + DigitalOut inb; + /* current value */ + AnalogIn current; + }; + + +}; // namespace drivers + + +#endif