rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes
DualHBridgeStepper Class Referencefinal

#include <stepper.h>

Inheritance diagram for DualHBridgeStepper:
Inheritance graph
[legend]
Collaboration diagram for DualHBridgeStepper:
Collaboration graph
[legend]

Public Member Functions

void initialize (DcMotor *motorPhaseA, DcMotor *motorPhaseB, float reactionTime)
 
bool step (bool positive) override
 
void sleep () override
 
- Public Member Functions inherited from StepperHw
void pause (int divisor=1) const
 

Protected Member Functions

bool update (float dutyMult)
 
- Protected Member Functions inherited from StepperHw
void setReactionTime (float ms)
 

Private Attributes

DcMotorm_motorPhaseA = nullptr
 
DcMotorm_motorPhaseB = nullptr
 
uint8_t m_phase = 0
 

Detailed Description

Definition at line 48 of file stepper.h.

Member Function Documentation

◆ initialize()

void DualHBridgeStepper::initialize ( DcMotor motorPhaseA,
DcMotor motorPhaseB,
float  reactionTime 
)

Definition at line 37 of file stepper_dual_hbridge.cpp.

38{
39 setReactionTime(reactionTime);
40
41 m_motorPhaseA = motorPhaseA;
42 m_motorPhaseB = motorPhaseB;
43
44 efiAssertVoid(ObdCode::CUSTOM_ERR_ASSERT, engineConfiguration->stepperNumMicroSteps <= maxNumSteps, "stepperNumMicroSteps");
45}
DcMotor * m_motorPhaseA
Definition stepper.h:60
DcMotor * m_motorPhaseB
Definition stepper.h:61
void setReactionTime(float ms)
Definition stepper.cpp:202
static constexpr engine_configuration_s * engineConfiguration
@ CUSTOM_ERR_ASSERT
static const int maxNumSteps

Referenced by applyIACposition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sleep()

void DualHBridgeStepper::sleep ( )
overridevirtual

Reimplemented from StepperHw.

Definition at line 104 of file stepper_dual_hbridge.cpp.

Here is the call graph for this function:

◆ step()

bool DualHBridgeStepper::step ( bool  positive)
overridevirtual

Implements StepperHw.

Definition at line 47 of file stepper_dual_hbridge.cpp.

47 {
48 // Check that we've been initialized
50 return false;
51 }
52
56 if (!positive)
57 numStepIncr = -numStepIncr;
58 for (int i = engineConfiguration->stepperNumMicroSteps; i > 0; i--) {
59 m_phase = (m_phase + numStepIncr) & tableSizeMask;
60 update(dutyMult);
61 // sleep 1/Nth of the pause time
63 }
64 return true;
65 }
66
67 // For the full-stepping mode, we use a traditional "two phase on" drive model
68 // because "wave drive" (one phase on) method has less torque.
69 // For explanation, pls see: https://github.com/rusefi/rusefi/pull/3213#discussion_r700746453
70
71 // step phase, wrapping
72 if (positive) {
73 m_phase = (m_phase + 1) & 0x03;
74 } else {
75 m_phase = (m_phase - 1) & 0x03;
76 }
77
78 update(1.0f);
79 pause();
80
81 return true;
82}
uint8_t m_phase
Definition stepper.h:63
static constexpr int tableSizeMask
Here is the call graph for this function:

◆ update()

bool DualHBridgeStepper::update ( float  dutyMult)
protected

Definition at line 84 of file stepper_dual_hbridge.cpp.

84 {
86 return false;
87 }
88
90 // phase B is 90 degrees shifted
92
93 // Set phases according to the table
95 m_motorPhaseB->set(dutyMult * microPhases[m_phaseB]);
96 return true;
97 }
98 // Set phases according to the table
101 return true;
102}
virtual bool set(float duty)=0
Sets the motor duty cycle.
static const int8_t microPhases[]
static const int8_t phaseA[]
static const int8_t phaseB[]

Referenced by sleep(), and step().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ m_motorPhaseA

DcMotor* DualHBridgeStepper::m_motorPhaseA = nullptr
private

Definition at line 60 of file stepper.h.

Referenced by initialize(), step(), and update().

◆ m_motorPhaseB

DcMotor* DualHBridgeStepper::m_motorPhaseB = nullptr
private

Definition at line 61 of file stepper.h.

Referenced by initialize(), step(), and update().

◆ m_phase

uint8_t DualHBridgeStepper::m_phase = 0
private

Definition at line 63 of file stepper.h.

Referenced by step(), and update().


The documentation for this class was generated from the following files: