Change references to BLDCDriver to FOCDriver in current sense base class

change setPwm function in FOCDriver to accept 3 args, with a default value for the 3rd

Change stepper driver classes to use 3 arg setPwm, ignoring 3rd arg.

created InlineCurrentSenseSync class in lib/currentsense.

fixed timer bug in calibrate encoder, in main

defined a label for serialusb, to make it easier to swap out.
This commit is contained in:
copper280z
2023-11-10 21:49:39 -05:00
parent deea94b076
commit 5125602875
11 changed files with 390 additions and 38 deletions

View File

@@ -110,12 +110,12 @@ DQCurrent_s CurrentSense::getFOCCurrents(float angle_el)
/**
Driver linking to the current sense
*/
void CurrentSense::linkDriver(BLDCDriver *_driver)
void CurrentSense::linkDriver(FOCDriver *_driver)
{
driver = _driver;
}
void CurrentSense::linkDriver(StepperDriver *_driver)
{
driver = _driver;
}
// void CurrentSense::linkDriver(StepperDriver *_driver)
// {
// driver = _driver;
// }

View File

@@ -24,8 +24,8 @@ class CurrentSense{
* Linking the current sense with the motor driver
* Only necessary if synchronisation in between the two is required
*/
void linkDriver(BLDCDriver *driver);
void linkDriver(StepperDriver *driver);
void linkDriver(FOCDriver *driver);
// void linkDriver(StepperDriver *driver);
// variables
bool skip_align = false; //!< variable signaling that the phase current direction should be verified during initFOC()
@@ -72,4 +72,4 @@ class CurrentSense{
DQCurrent_s getFOCCurrents(float angle_el);
};
#endif
#endif

View File

@@ -1,7 +1,8 @@
#ifndef FOCMOTOR_H
#define FOTMOTOR_H
#ifndef FOCDRIVER_H
#define FOCDRIVER_H
#include "Arduino.h"
#include "../foc_utils.h"
class FOCDriver{
public:
@@ -11,6 +12,9 @@ class FOCDriver{
virtual void disable() = 0;
virtual void setPwm(float a, float b, float c);
// virtual void setPwm(uint8_t a, uint8_t b);
long pwm_frequency;
float voltage_power_supply;
float voltage_limit;
@@ -18,4 +22,4 @@ class FOCDriver{
void* params = 0;
};
#endif
#endif

View File

@@ -12,7 +12,7 @@ class StepperDriver: public FOCDriver{
* @param Ua phase A voltage
* @param Ub phase B voltage
*/
virtual void setPwm(float Ua, float Ub) = 0;
virtual void setPwm(float Ua, float Ub, float Uc=NOT_SET) = 0;
};
#endif
#endif