pwm_cycle_time: New module for output pins with dynamic cycle times

Remove support for changing the cycle time of pwm pins from the
output_pin module.  Use a new pwm_cycle_time module that supports
setting dynamic cycle times.  This simplifies the output_pin code and
low-level pin update code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2023-01-13 11:20:19 -05:00
parent 1baa45913f
commit fd2feff67d
9 changed files with 204 additions and 38 deletions

View File

@@ -8,6 +8,11 @@ All dates in this document are approximate.
## Changes
20240123: The output_pin SET_PIN CYCLE_TIME parameter has been
removed. Use the new
[pwm_cycle_time](Config_Reference.md#pwm_cycle_time) module if it is
necessary to dynamically change a pwm pin's cycle time.
20240123: The output_pin `maximum_mcu_duration` parameter is
deprecated. Use a [pwm_tool config section](Config_Reference.md#pwm_tool)
instead. The option will be removed in the near future.

View File

@@ -3153,6 +3153,24 @@ pin:
# See the "output_pin" section for the definition of these parameters.
```
### [pwm_cycle_time]
Run-time configurable output pins with dynamic pwm cycle timing (one
may define any number of sections with an "pwm_cycle_time" prefix).
Pins configured here will be setup as output pins and one may modify
them at run-time using "SET_PIN PIN=my_pin VALUE=.1 CYCLE_TIME=0.100"
type extended [g-code commands](G-Codes.md#pwm_cycle_time).
```
[pwm_cycle_time my_pin]
pin:
#value:
#shutdown_value:
#cycle_time: 0.100
#scale:
# See the "output_pin" section for information on these parameters.
```
### [static_digital_output]
Statically configured digital output pins (one may define any number

View File

@@ -839,17 +839,10 @@ The following command is available when an
enabled.
#### SET_PIN
`SET_PIN PIN=config_name VALUE=<value> [CYCLE_TIME=<cycle_time>]`: Set
the pin to the given output `VALUE`. VALUE should be 0 or 1 for
"digital" output pins. For PWM pins, set to a value between 0.0 and
1.0, or between 0.0 and `scale` if a scale is configured in the
output_pin config section.
Some pins (currently only "soft PWM" pins) support setting an explicit
cycle time using the CYCLE_TIME parameter (specified in seconds). Note
that the CYCLE_TIME parameter is not stored between SET_PIN commands
(any SET_PIN command without an explicit CYCLE_TIME parameter will use
the `cycle_time` specified in the output_pin config section).
`SET_PIN PIN=config_name VALUE=<value>`: Set the pin to the given
output `VALUE`. VALUE should be 0 or 1 for "digital" output pins. For
PWM pins, set to a value between 0.0 and 1.0, or between 0.0 and
`scale` if a scale is configured in the output_pin config section.
### [palette2]
@@ -978,6 +971,21 @@ babystepping), and subtract if from the probe's z_offset. This acts
to take a frequently used babystepping value, and "make it permanent".
Requires a `SAVE_CONFIG` to take effect.
### [pwm_cycle_time]
The following command is available when a
[pwm_cycle_time config section](Config_Reference.md#pwm_cycle_time)
is enabled.
#### SET_PIN
`SET_PIN PIN=config_name VALUE=<value> [CYCLE_TIME=<cycle_time>]`:
This command works similarly to [output_pin](#output_pin) SET_PIN
commands. The command here supports setting an explicit cycle time
using the CYCLE_TIME parameter (specified in seconds). Note that the
CYCLE_TIME parameter is not stored between SET_PIN commands (any
SET_PIN command without an explicit CYCLE_TIME parameter will use the
`cycle_time` specified in the pwm_cycle_time config section).
### [query_adc]
The query_adc module is automatically loaded.

View File

@@ -374,6 +374,13 @@ is defined):
template expansion, the PROBE (or similar) command must be run prior
to the macro containing this reference.
## pwm_cycle_time
The following information is available in
[pwm_cycle_time some_name](Config_Reference.md#pwm_cycle_time)
objects:
- `value`: The "value" of the pin, as set by a `SET_PIN` command.
## quad_gantry_level
The following information is available in the `quad_gantry_level` object