Stepdance Software Library
Loading...
Searching...
No Matches
VelocityGenerator Class Reference

Used for generating a position signal that advances at a constant speed. More...

#include <generators.hpp>

Inheritance diagram for VelocityGenerator:

Public Member Functions

void begin ()
 Initialize the VelocityGenerator. Must be called to set up the generator.

Public Attributes

volatile ControlParameter speed_units_per_sec = 0
 ControlParameter specifying the generation speed in units per second. You can set it directly or map an input to it.
BlockPort output
 Output BlockPort for the generated position signal.

Protected Member Functions

void run ()

Detailed Description

Used for generating a position signal that advances at a constant speed.

A VelocityGenerator maintains an internal target position and increments it over time at a specified speed (units per second). This can be used to move a downstream component at a specified rate. Here's an example of how to instantiate and configure a VelocityGenerator:

//will drive a channel at a constant speed. WARNING, if no limits are implemented, the axis will drive until it crashes.
#define module_driver
#include "stepdance.hpp"
Channel channel_x;
OutputPort output_a;
void setup() {
// Initialize OutputPort and enable drivers
output_a.begin(OUTPUT_A);
enable_drivers();
// Map VelocityGenerator output to channel target position
vel_gen.output.map(channel_x.input_target_position);
vel_gen.begin();
vel_gen.speed_units_per_sec = 20.0; // example speed
// Initialize channel on an output signal
channel_x.begin(&output_a , SIGNAL_E);
dance_start();
}
void loop(){
dance_loop();
}

Member Data Documentation

◆ output

BlockPort VelocityGenerator::output

Output BlockPort for the generated position signal.

velocity_gen.output.map(channelX.input_target_position); // Drive a channel at constant speed

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