Channels are modules that store the machine's positional state.
More...
#include <channels.hpp>
|
|
void | begin () |
| | Initialize the Channel with no output port. Not for normal use.
|
| void | begin (OutputPort *target_output_port, uint8_t output_signal) |
| | Initialize the Channel with a target OutputPort and output signal.
|
| void | set_max_pulse_rate (float max_pulses_per_sec) |
| | Sets the maxium allowable pulse rate for the channel.
|
| void | set_ratio (float input_units, float channel_units=1.0) |
| | Sets the transmission ratio for all target transmissions.
|
| void | set_upper_limit (DecimalPosition upper_limit_input_units) |
| | Sets the upper position limit for the channel. Useful if you want the channel to stop transmitting motion streams at a certain upper threshold.
|
| void | set_lower_limit (DecimalPosition lower_limit_input_units) |
| | Sets the lower position limit for the channel. Useful if you want the channel to stop transmitting motion streams at a certain lower threshold.
|
|
void | disable_upper_limit () |
| | Disables the upper position limit.
|
|
void | disable_lower_limit () |
| | Disables the lower position limit.
|
| void | disable_limits () |
| | Disables the channel.
|
|
void | disable () |
| | Disables the channel.
|
|
void | enable () |
| | Enables the channel.
|
| void | enable_filtering (uint16_t num_samples=20) |
| | Enables a moving average filter with a specified sample window. The bigger the window, the smoother the output but the less responsive the motion.
|
|
void | disable_filtering () |
| | Disables the moving average filter.
|
| int8_t | is_outside_limits () |
| | Checks if the current channel position is outside the set limits.
|
| void | invert_output () |
| | Inverts the channel output direction.
|
| void | invert_output (bool invert) |
| | Inverts the channel output direction. Useful for reversing motor direction without changing wiring.
|
|
|
DecimalPosition | target_position |
| | Target position of the channel in pulses. Target positon is what the channel is driving toward.
|
|
DecimalPosition | current_position |
| | Current position of the channel in pulses. Current position is where the channel is currently at.
|
|
DecimalPosition | filtered_target_position |
| | Filtered target position of the channel in pulses. This is used when the enableFiltering() method is used to smooth out motion.
|
|
bool | filtering_on = false |
| | Flag indicating whether filtering is enabled for the channel.
|
Channels are modules that store the machine's positional state.
A Channel directly interfaces with an OutputPort by mapping to a particular signal flag (e.g. "X").Channels contain a target position variable that can be modified by upstream components such as motion generators. They also contain a variable representing their current position. Each interrupt frame, the channel increments or decrements the current position when needed to drive |target-current| < 0.5, and correspondingly sets step and direction flags on its mapped OutputPort. Any number of channels can be instantiated, often corresponding to axes of the machine machine. Basic Modules may contain multiple channels that map to distinct flags on the same OutputPort. Driver Modules typically have multiple channels that each map to a unique OutputPort, that then generate step/direction signals for a motor drive module. Here's an example of how to instantiate and configure a Channel and map it to an OutputPort:
#define module_driver
#include "stepdance.hpp"
void setup() {
output_x.
begin(OUTPUT_A);
channel_x.
begin(&output_x, SIGNAL_X);
}
void loop(){
dance_loop();
}
◆ begin()
| void Channel::begin |
( |
OutputPort * | target_output_port, |
|
|
uint8_t | output_signal ) |
Initialize the Channel with a target OutputPort and output signal.
- Parameters
-
| target_output_port | Pointer to the target OutputPort. |
| output_signal | Index of the output signal (SIGNAL_X, SIGNAL_Y, etc.). |
◆ disable_limits()
| void Channel::disable_limits |
( |
| ) |
|
|
inline |
Disables the channel.
Disables all position limits.
◆ enable_filtering()
| void Channel::enable_filtering |
( |
uint16_t | num_samples = 20 | ) |
|
Enables a moving average filter with a specified sample window. The bigger the window, the smoother the output but the less responsive the motion.
- Parameters
-
| num_samples | Number of samples for filtering. Default is 20. |
◆ invert_output() [1/2]
| void Channel::invert_output |
( |
| ) |
|
Inverts the channel output direction.
Inverts the channel output direction. Useful for reversing motor direction without changing wiring.
◆ invert_output() [2/2]
| void Channel::invert_output |
( |
bool | invert | ) |
|
Inverts the channel output direction. Useful for reversing motor direction without changing wiring.
- Parameters
-
| invert | If true, inverts the output direction; if false, restores the normal direction. |
◆ is_outside_limits()
| int8_t Channel::is_outside_limits |
( |
| ) |
|
Checks if the current channel position is outside the set limits.
- Returns
- int8_t Returns 0 if inside limits, 1 if outside upper limit, or -1 if outside lower limit.
◆ set_lower_limit()
| void Channel::set_lower_limit |
( |
DecimalPosition | lower_limit_input_units | ) |
|
Sets the lower position limit for the channel. Useful if you want the channel to stop transmitting motion streams at a certain lower threshold.
- Parameters
-
| lower_limit_input_units | Lower limit in input (world) units. |
◆ set_max_pulse_rate()
| void Channel::set_max_pulse_rate |
( |
float | max_pulses_per_sec | ) |
|
Sets the maxium allowable pulse rate for the channel.
- Parameters
-
| max_pulses_per_sec | Maximum allowable pulse rate in pulses per second. |
◆ set_ratio()
| void Channel::set_ratio |
( |
float | input_units, |
|
|
float | channel_units = 1.0 ) |
Sets the transmission ratio for all target transmissions.
- Parameters
-
| input_units | Number of input units corresponding to channel_units. |
| channel_units | Number of channel units corresponding to input_units. Default is 1.0. |
◆ set_upper_limit()
| void Channel::set_upper_limit |
( |
DecimalPosition | upper_limit_input_units | ) |
|
Sets the upper position limit for the channel. Useful if you want the channel to stop transmitting motion streams at a certain upper threshold.
- Parameters
-
| upper_limit_input_units | Upper limit in input (world) units. |
The documentation for this class was generated from the following file: