QuadroCopter  0.1.4
motors.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2017 Michael Brookes
3 
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef BEAGLEBONE_MOTOR_MOTORS_H
19 #define BEAGLEBONE_MOTOR_MOTORS_H
20 
21 #include "../pwmDevice.h"
22 #include <string>
23 
24 namespace quadro {
25 
26  namespace pwm {
27 
31  class motors : public pwmDevice {
32 
33  public:
37  motors() { };
38 
45  motors( pinBlocks _block, PWMPins _pin );
46 
52  void setTargetSpeed( long _targetSpeed );
53 
57  void reversePolarity();
58 
65  void start();
66 
71  void stop();
72 
73  long currentDuty;
75  int currentRun;
77 
78  protected:
79 
86  long getMaxSpeed();
87 
94  long getMinSpeed();
95 
102  int getSpeedStep();
103 
109  void setMaxSpeed( long _maxSpeed );
110 
116  void setMinSpeed( long _minSpeed );
117 
124  void setSpeedStep( int _speedStep );
125 
126  private:
127 
131  enum status {
132  On = 1,
133  Off = 0,
134  Error = 3
135  };
136 
140  enum polarity {
141  Negative = 0,
142  Positive = 1
143  };
144 
150  void setStatus( status _status );
151 
157  void increaseSpeed( unsigned short _SpeedMod = 250 );
158 
164  void decreaseSpeed( unsigned short _SpeedMod = 250 );
165 
171  static void* maintainTargetSpeed( void* );
172 
173  pthread_t threadHandle;
174  int threadRet;
175  int speedStep;
176 
177  long targetSpeed;
178  long maxSpeed;
179  long minSpeed;
180 
181  status Status;
182  };
183 
184  }
185 
186 }
187 
188 #endif //BEAGLEBONE_MOTOR_MOTORS_H
void setMinSpeed(long _minSpeed)
Definition: motors.cpp:121
void reversePolarity()
Definition: motors.cpp:56
void setSpeedStep(int _speedStep)
Definition: motors.cpp:131
Definition: motors.h:31
pinBlocks
Definition: overlayBase.h:43
long getMinSpeed()
Definition: motors.cpp:111
long getMaxSpeed()
Definition: motors.cpp:106
int currentRun
Storage for the current Run value.
Definition: motors.h:75
void setTargetSpeed(long _targetSpeed)
Definition: motors.cpp:31
motors()
Definition: motors.h:37
long currentDuty
Storage for the current Duty value.
Definition: motors.h:73
int getSpeedStep()
Definition: motors.cpp:116
Definition: pwmDevice.h:38
Definition: aeronautics.h:23
void start()
Definition: motors.cpp:81
long currentPeriod
Storage for the current Period value.
Definition: motors.h:74
void setMaxSpeed(long _maxSpeed)
Definition: motors.cpp:126
PWMPins
PinNum refers to a exposed PWM Pin on your BBB, this enum can be expanded to include more if required...
Definition: overlayBase.h:51
int currentPolarity
Storage for the current Polarity value.
Definition: motors.h:76
void stop()
Definition: motors.cpp:98