Motor - PWM Motor

.

Plugin details

Type: Motor

Name: PWM Motor

Status: COLLECTION A COLLECTION D

GitHub: _P098_PWM_motor.ino

Maintainer: TD-er

Used libraries: .

Supported hardware

.

Configuration

../_images/P098_DeviceConfiguration.png
  • Name: Required by ESPEasy, must be unique among the list of available devices/tasks.

  • Enabled: The device can be disabled or enabled. When not enabled the device should not use any resources.

Motor Control

  • GPIO -> Motor Fwd: Select the GPIO that is connected to the Motor Forward connection.

  • Motor Fwd Inverted: Some motors need the signal to be inverted. This checkbox provides that option.

  • GPIO -> Motor Rev: Select the GPIO that is connected to the Motor Reverse connection.

  • Motor Fwd Inverted: Some motors need the signal to be inverted. This checkbox provides that option.

  • Motor Control: Select the type of motor control:

Available options:

../_images/P098_MotorControlOptions.png
  • No PWM: The motor is controlled by applying a High level (or Low when the matching Inverted option is checked) to the Forward or Reverse GPIO pin.

  • PWM: The motor is controlled by applying a PWM signal with the set frequency and duty-cycle (next options). Attention Check the documentation if the motor can be controlled via PWM, as in some cases this can cause damage to the motor or electronics involved!

  • PWM Frequency: The frequency of the PWM signal. Some motors run best at a specific frequency, usually noted in their documentation.

  • PWM Duty Cycle: The duty cycle of the PWM signal. Usually also specified in the motor documentation.

  • PWM Soft Start/Stop: This option will use a speed-fade-in at the start of moving, and fade-out near the end of moving. This makes the movement smoother.

Feedback

  • GPIO <- Encoder(optional): If the motor is equiped with a rotary encoder, the encoder signal can be connected to this GPIO pin. This is optional.

  • Encoder Pull-Up: When checked will activate the internal pull-up resistor for the Encoder GPIO. Depending on the encoder electronics a stronger (lower value like 4k7 or 10k) pull-up may be required, that should then be installed separately. This option can then be unchecked.

  • Encoder Timeout: The maximum time that is allowed for the encoder to start providing pulses after the motor movement is started.

  • Virtual speed: The number of steps/ms that the motor will move.

  • Position 0 Supplement: The number of steps that compensates for the overshoot or undershoot when moving to the Home position.

  • GPIO <- Analog Feedback(optional): Not implemented yet. Only available on ESP32.

Limit Switches

  • GPIO <- Limit A(optional): Select the GPIO that is connected to the Home-detection switch. This is optional.

  • Limit A Pull-Up: Enables the internal pull-up for the GPIO. When using longer wiring, a stronger (lower value like 4k7 or 10k) pull-up resistor may be required for a stable signal.

  • Limit A Inverted: Will invert the state of the limit switch.

  • Limit A Debounce: The limit-switch debounce time, range 0 to 1000 msec.

  • GPIO <- Limit B(optional): Select the GPIO that is connected to the End-detection switch. This is optional.

  • Limit B Pull-Up: Enables the internal pull-up for the GPIO. When using longer wiring, a stronger (lower value like 4k7 or 10k) pull-up resistor may be required for a stable signal.

  • Limit B Inverted: Will invert the state of the limit switch.

  • Limit B Debounce: The limit-switch debounce time, range 0 to 1000 msec.

Data Acquisition

This group of settings, Single event with all values and Send to Controller settings are standard available configuration items. Send to Controller is only visible when one or more Controllers are configured.

  • Interval: Interval is optional, and will be set to 0 sec. The data will be collected and optionally sent to any configured controllers using this interval.

Values

The plugin provides the Position, LimitA, LimitB and LimitApos values. LimitA or LimitB will be set to 1 when the motor is at that position, and the matching settings are configured, above.

Commands available

Command

Extra information

pwmmotorhome

Move the motor to the Home position.

Revert the motor until the limit switch A, aka Home, position is reached.

This will cause the limitA event to be generated.

pwmmotorend

Move the motor to the End position.

Move the motor forward until the limit switch B, aka End, position is reached.

This will cause the limitB event to be generated.

pwmmotorforward[,<steps>]

Move the motor forward.

steps: Number of steps to move. If steps <= 0 it will move forward until limit switch B (End) is reached.

Move the motor a number of steps, or until the limit switch B, aka End, position is reached. If steps <= 0 then it will move forward until the End position is reached.

This will cause the positionReached event to be generated, and also the limitB event if End is reached.

pwmmotorreverse[,<steps>]

Move the motor backward (reverse).

steps: Number of steps to move. If steps <= 0 it will move backward until limit switch A (Home) is reached.

Move the motor a number of steps, or until the limit switch A, aka Home, position is reached. If steps <= 0 then it will move backward until the Home position is reached.

This will cause the positionReached event to be generated, and also the limitA event if Home is reached.

pwmmotorstop

Stop the motor.

Stop the motor moving (if, of course, it is moving).

pwmmotormovetopos,<absolute_position>

absolute_position: The absolute position, relative to the Home position.

Move the motor to an absolute position.

Move the motor to an absolute position. Expects to have the Home position defined, by moving to the Home position at least once.

This will cause the positionReached event to be generated, and also the limitA or limitB event if that is reached.

Events

Event

Example

<taskname>#limitA

Limit switch A is reached

If limit switch A is configured, then this event will be generated once the switch is reached.

<taskname>#limitB

Limit switch B is reached

If limit switch B is configured, then this event will be generated once the switch is reached.

<taskname>#positionReached

Requested position is reached

After a command pwmmotor<command>[,<argument>] is completed, this event will be generated.

<taskname>#encoderTimeout

A time-out has occurred.

The command took longer then the configured time-out duration, causing this event to be generated.

Change log

Added in version 2.0:

added Initial release version.