JMotor
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
JMotorDriverEsp32PWMDir Class Reference

for motor controllers with one direction input and one speed input pin More...

#include <JMotorDriverEsp32PWMDir.h>

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

Public Member Functions

 JMotorDriverEsp32PWMDir (byte _ch, byte _enablePin, byte _dirPin, bool _rev=false)
 constructor, sets pins, default PWM
 
 JMotorDriverEsp32PWMDir (byte _ch, byte _enPin, byte _dirPin, int freq, int resolution, bool _rev=false)
 constructor, sets pins, custom PWM settings
 
bool set (float val)
 set motor power
 
bool setEnable (bool _enable)
 use to enable or disable a motor, and sets up pin states
 
bool getEnable ()
 get the enable state of the driver
 
float getMaxRange ()
 high end of the range
 
float getMinRange ()
 low end of the range
 
- Public Member Functions inherited from JMotorDriver
bool enable ()
 enable motor
 
bool disable ()
 disable motor
 

Public Attributes

JMotorDriverEsp32PWM pwmDriver
 
bool reverse = false
 

Detailed Description

for motor controllers with one direction input and one speed input pin

Note
platform: ESP32

Constructor & Destructor Documentation

◆ JMotorDriverEsp32PWMDir() [1/2]

JMotorDriverEsp32PWMDir::JMotorDriverEsp32PWMDir ( byte  _ch,
byte  _enablePin,
byte  _dirPin,
bool  _rev = false 
)
inline

constructor, sets pins, default PWM

Parameters
_chledc channel (must be unique for each driver)
_enablePinpin to output speed signal on
_dirPinpin to output direction signal on
_rev= false: if false(default), direction pin set HIGH for positive speed, LOW for negative speed

◆ JMotorDriverEsp32PWMDir() [2/2]

JMotorDriverEsp32PWMDir::JMotorDriverEsp32PWMDir ( byte  _ch,
byte  _enPin,
byte  _dirPin,
int  freq,
int  resolution,
bool  _rev = false 
)
inline

constructor, sets pins, custom PWM settings

Parameters
_chledc channel (must be unique for each driver)
_enPinpin to output speed signal on
_dirPinpin to output direction signal on
freq<= int(80E6 / 2^resolution), 2kHz default and recommended for motor PWM
resolutionbits of resolution, tradeoff with frequency, default 12
_rev= false: if false(default), direction pin set HIGH for positive speed, LOW for negative speed

Member Function Documentation

◆ getEnable()

bool JMotorDriverEsp32PWMDir::getEnable ( )
inlinevirtual

get the enable state of the driver

Return values
(bool)true if enabled, false if disabled

Reimplemented from JMotorDriver.

◆ getMaxRange()

float JMotorDriverEsp32PWMDir::getMaxRange ( )
inlinevirtual

high end of the range

Note
usually 1.0
Return values
(float)maxRange

Reimplemented from JMotorDriver.

◆ getMinRange()

float JMotorDriverEsp32PWMDir::getMinRange ( )
inlinevirtual

low end of the range

Note
usually -1.0, if 0, that indicates a motor controller with no reverse function
Return values
(float)minRange

Reimplemented from JMotorDriver.

◆ set()

bool JMotorDriverEsp32PWMDir::set ( float  val)
inlinevirtual

set motor power

Note
val should be between getMinRange and getMaxRange, but constrained internally
Parameters
val(float) val
Return values
(bool)false if at end of power range, true otherwise

Reimplemented from JMotorDriver.

◆ setEnable()

bool JMotorDriverEsp32PWMDir::setEnable ( bool  _enable)
inlinevirtual

use to enable or disable a motor, and sets up pin states

Note
setEnable(true) must be called before a motor driver will activate
Parameters
_enable(bool) true=enable, false=disable
Return values
(bool)true if state changed, false if state already set

Reimplemented from JMotorDriver.

Member Data Documentation

◆ pwmDriver

JMotorDriverEsp32PWM JMotorDriverEsp32PWMDir::pwmDriver

◆ reverse

bool JMotorDriverEsp32PWMDir::reverse = false

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