CRINSA-team2025 V1
Documentation du Club Robot INSA Rennes 2025
Chargement...
Recherche...
Aucune correspondance
BrushlessMotor.h
1#ifndef __BRUSHLESSMOTOR_H__
2#define __BRUSHLESSMOTOR_H__
3
4#include <Arduino.h>
5#include <Servo.h>
6
7#include "PeriodicProcess.h"
8
9
10#define MIN_PULSEWIDTH 1000 // the shortest pulse sent to a ESC
11#define MAX_PULSEWIDTH 2000 // the longest pulse sent to a ESC
12#define MIN_VELOCITY 0
13#define MAX_VELOCITY 100
14
15class BrushlessMotor: public PeriodicProcess {
16
17public:
18 BrushlessMotor(): m_enabled(false), m_velocity(0), processingStartup(false){
19 setTimestep(5);
20 }
21
22 void attach(int PIN);
23 void detach();
24
25 void enableStartup();
26 void disableStartup();
27 void updateStartup();
28 void enableMotor();
29 void disableMotor();
30 int setVelocity(int velocity);
31 int setPulsewidth(int pulsewidth);
32 void forcePulsewidth(int pulsewidth);
33 void update();
34 void startupProcess();
35
36 float getVelocity() const {return map(m_velocity,0,180,0,100);}
37 bool isEnabled() const {return m_enabled;}
38
39 int readMicroseconds();
40
41private:
42 Servo m_esc;
43 bool m_enabled ;
44 int m_velocity; // in %
45 bool processingStartup;
46
47
48protected:
49 virtual void process(float timestep);
50};
51
52#endif // __BRUSHLESSMOTOR_H__
virtual void process(float timestep)
Méthode à implémenter obligatoirement pour hériter de PeriodicProcess.
Definition BrushlessMotor.cpp:78
Classe à implémenter pour gérer les appels dans la loop.
Definition PeriodicProcess.h:16
void setTimestep(float timestep)
Sélectionne une nouvelle valeur pour timestep.
Definition PeriodicProcess.h:39