-
Notifications
You must be signed in to change notification settings - Fork 2
/
DRV8323H.h
61 lines (55 loc) · 1.12 KB
/
DRV8323H.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
DRV8323H BLDC Driver for Arduino ESP32
Date: September 2019
Author: Israel Cayetano
*/
#ifndef _DRV8323H_h
#define _DRV8323H_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#include <PWM_ESP32.h>
#define PWM_6 0
#define PWM_3 1
#define PWM_1 2
#define FORWARD 0
#define REVERSE 1
#define A 0
#define B 1
#define C 2
#define BC 1
#define AC 2
#define AB 3
#define CB 4
#define CA 5
#define BA 6
class BLDC
{
public:
BLDC(uint8_t inh_pins[3], uint8_t inl_pins[3], uint8_t sensor_pins[3]);
~BLDC();
PWM pwmA;
PWM pwmB;
PWM pwmC;
void begin(uint8_t channels[3], double frequency);
void doSequence(bool sensor_a, bool sensor_b, bool sensor_c, bool direction, float duty_cycle);
void setCoast();
void setBrake();
void setHigh(uint8_t coil, float duty_cycle);
void setLow(uint8_t coil);
void setFloat(uint8_t coil);
void readSensors();
bool sens_a;
bool sens_b;
bool sens_c;
protected:
void align();
uint8_t getStep(bool sensor_a, bool sensor_b, bool sensor_c, bool direction);
uint8_t _inh_pins[3];
uint8_t _inl_pins[3];
uint8_t _sensor_pins[3];
uint8_t _step;
};
#endif