### Starting Planner Operation C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Starts the operation. ```cpp void start(); ``` -------------------------------- ### GyverStepper Initialization Examples (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md Provides various examples for initializing the GyverStepper object, showing different constructors for 2-wire, 4-wire, 4-wire half-step, and virtual drivers, with and without an enable pin. ```C++ // stps - steps for one turn of the shaft (for calculations with degrees) // STEP, DIR, PIN1, PIN2, PIN3, PIN4 - Any GPIO // en - Pin disconnecting the driver, any GPIO Gstepper stepper (Steps, STEP, DIR);// Driver STEP-DIR Gstepper stepper (Steps, STEP, DIR, EN);// Driver STEP-DIR + PIN Enable GSTEPPER STEPPER (STEPS, PIN1, PIN2, PIN3, PIN4);// driver 4 PIN GSTEPPER STEPPER (STEPS, PIN1, PIN2, PIN3, PIN4, EN);// Driver 4 PIN + Enable Gstepper stPper (STEPS, PIN1, PIN2, PIN3, PIN4);// Driver 4 Pin Hole Gstepper stepper (stps, Pin1, PIN2, PIN3, PIN4, EN);// Driver 4 Pin Hole + Enable GSTEPPER STEPPER (2048);// virtual driver, indicate only the number of steps ``` -------------------------------- ### GPlanner API Usage Examples (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md Provides examples of various methods available in the GPlanner class for multi-axis stepper control. Includes functions for adding steppers, setting backlash, enabling/disabling motors, setting speed and acceleration, getting status, pausing/stopping/resuming movement, setting/getting current and target positions, and manual/automatic ticking. ```C++ VOID Addstepper (Uint8_T Axis, STEPPER & STP);// Connect the STEPPER class motor on the axis axis // Note: the type of driver should match the planner and motors VOID Setbacklash (Uint8_t Axis, Uint16_T Steps);// Set the back of the ramp on the axis axis in the number of steps steps VOID Enable ();// Turn on the motors Void Disable ();// Turn off the motors VOID Power (Bool V);// Switch power // SETTINGS VOID setmaxSpeed (Float NV);// Installation of the maximum speed of the planner in the step/s VOID setaccoleration (uint16_t na);// Installation of acceleration of the planner in the step/sec^2 // planner uint32_t getperiod ();// returns time to the ISS until the next call Tick/Tickmanual Bool Ready ();// True - ready to accept the next point of the route VOID PAUSE ();// pause (get to a given point and wait).Ready () will not return True until you are on a pause VOID Stop ();// Stop smoothly (with a given acceleration) VOID Brake ();// sharply stop the motors from any regime VOID Resume ();// Continue after stopping/pauses VOID Reset ();// throw off the counters of all motors in 0 VOID Home ();// Send to 0 for all axes uint8_t getstatus ();// current status: 0 - stand, 1 - go, 2 - we go to the point of the pause, 3 -t - we circle at speed // SPEED VOID SetSpeed (Uint8_t Axis, Float Speed);// Permanent rotation mode for axis axis at the speed of Speed Step/S (MB Neutheity) // Position VOID setcurrent (int16_t cur []);// establish the current position of the engines VOID setcurrent (int32_t cur []);// establish the current position of the engines Int32_T Getcurrent (int Axis);// Get the current position on the axis axis // set the target in steps and start movement.Type - Absolute // Absolute - specific coordinates of the point where to move // Relative - displacement relative to the current motors provisions // will return True if the goal is set.FALSE if the goal coincides with the current Bool settarget (int32_t target []); Bool settarget (int16_t target []); Bool settarget (int32_t target [], type); Bool settarget (int16_t target [], type); Int32_T Gettarget (int Axis);// Get a target in steps on axis axis // ticker // ticker, call as often as possible.Will return True if the motor is spinning // Steps are taken here both for movement by points and for speed rotation Bool Tick (); // Hand ticker for a call in an interruption or somewhere else.20..50 US is performed Bool Tickmanual (); ``` -------------------------------- ### GyverStepper C++ Basic Usage Example Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md This example demonstrates how to initialize and use the GyverStepper library in an Arduino setup. It shows how to configure the stepper motor, set run modes (speed and position), set target values, and continuously update the motor state using the tick() function in the loop. ```C++ #include GSTEPPER STEPPER (2048, 5, 3, 4, 2); VOID setup () { Serial.Begin (115200); // Speed maintenance mode STEPPER.SETRUNMODE (keep_Speed); // you can set the speed STEPPER.SETSPEED (120);// in steps/second STEPPER.SETSPEEDDEG (80);// in degrees/s // Message to the target position STEPPER.SETRUNMODE (follow_pos); // you can establish a position STEPPER.SETTARGET (-2024);// in steps STEPPER.SETTARGETDEG (-360);// In degrees // Installation Max.speeds in degrees/s STEPPER.SetmaxSpeeddeg (400); // Installation Max.Speed in steps/second STEPPER.SetmaxSpeed (400); // Installation of acceleration in degrees/second STEPPER.SETACCELERATIONDEG (300); // Installation of acceleration in steps/sec/s STEPPER.SETACCELERATION (300); // Disconnect the motor when reaching the goal STEPPER.Autopower (True); // Turn on the motor (if the pin is specified) STEPPER.ENABLE (); } VOID loop () { // just twist tudes-fuckers if (! stepper.tick ()) { Static Bool Dir; Dir =! Dir; STEPPER.SETTARGET (DIR? -1024: 1024); } } ``` -------------------------------- ### Example Route Planning with GyverPlanner2 C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md This snippet demonstrates how to set up and use the GyverPlanner2 library to move two stepper motors along a predefined route stored in memory. It shows how to initialize the planner and motors, set acceleration and speed, define the starting point, and continuously add target points from the route array in the main loop while calling the `Tick` function to handle motor movement and buffer management. It also includes code for serial plotting of motor positions. ```C++ // Example with a route recorded in memory // See the schedule, or better start the STEPPERPLOT int path [] [2] = {{ {100, 250}, {160, 30}, {230, 250}, {60, 100}, {270, 100} }; // number of points (let the compiler consider it) // as the weight of the total array / (2+2) byte int nodeamount = sizeof (Path) / 4; #include "gyverplanner2.h" STEPPER STEPPER1 (2, 3); STEPPER STEPPER2 (4, 5); GPlanner2 Planner; VOID setup () { Serial.Begin (115200); // Add steps to the axis Planner.Addstepper (0, STEPPER1);// axis 0 Planner.Addstepper (1, STEPPER2);// axis 1 // set acceleration and speed Planner.Setacceleration (500); Planner.SetmaxSpeed (500); // The starting point of the system should coincide with the first point of the route Planner.Setcurrent (Path [0]); Planner.Start (); } int// Mainplane Mixture meter VOID loop () { // here is the movement of motors, call as often as possible Planner.Tick (); // If there is a place in the planner's buffer if (Planner.available ()) { // Add the point of the route and whether it is a stop point (0 - no) Planner.Addtarget (Path [Count], 0); IF (++ Count >= Sizeof (Path) / 4) Count = 0;// Clothing } // asynchronously I bring graphics to the port Static uint32_t tmr; if (millis () - tmr >= 20) { TMR = Millis (); Serial.print (stPper1.pos); Serial.print (','); Serial.println (stPper2.pos); } } ``` -------------------------------- ### Basic GyverStepper Usage Example (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md An example Arduino sketch demonstrating basic initialization of a GyverStepper object with a 2-wire driver, setting initial direction and position, and manually stepping the motor in the main loop. ```C++ #include STEPPER STEPPER (2, 3); VOID setup () { stepper.dir = 1;// or -1 stepper.pos = 0;// access to position } VOID loop () { // Twist manually STEPPER.STEP ();// make a step Delay (10); } ``` -------------------------------- ### Basic GPlanner Example (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md Demonstrates how to initialize and use the GPlanner library for basic multi-axis stepper motor control. It shows how to create STEPPER objects, add them to the planner, set speed and acceleration, send target positions, and continuously update the planner using the Tick() method. ```C++ // Basic example: how to create and launch a planner // When starting, the motors will be sent to the first position // when reaching - on the second.After that, the movement will stop // Open Plotter and see graphs #incLude "gyverplanner.h" // Create the motors of the STEPPER class indicating the type of driver and pins // Motors should be with the same type of driver // Here they are handsome STEPPER STEPPER1 (2, 3); STEPPER STEPPER2 (4, 5); // Create a planner, indicate in <> the type of driver like motors // and the number of axes equal to the number of engines (any more than 1) GPlanner Planner; VOID setup () { Serial.Begin (115200); // Add steps to the axis Planner.Addstepper (0, STEPPER1);// axis 0 Planner.Addstepper (1, STEPPER2);// axis 1 // set acceleration and speed Planner.Setacceleration (100); Planner.SetmaxSpeed (300); Planner.Reset ();// Reset all positions in 0 (they are already in 0 at launch) // array with target positions of the axes, the size of the array is equal to the number of axes int target [] = {300, 200}; // Send Planner.Settarget (Target); } VOID loop () { // here is the movement of motors, call as often as possible Planner.Tick (); // will return True if all the engines have arrived if (Planner.read ()) { // Download a new point int Newtarget [] = {10, 50}; Planner.Settarget (Newtarget); } // asynchronously I bring graphics to the port Static uint32_t tmr; if (millis () - tmr> = 20) { TMR = Millis (); Serial.print (stPper1.pos); Serial.print (','); Serial.println (stPper2.pos); } } ``` -------------------------------- ### GyverStepper API Usage Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Provides a list of common functions available in the GPlanner class for controlling motors, setting parameters, managing movement, and getting status or position information. ```cpp void addStepper(uint8_t axis, Stepper &stp); // connect a Stepper class motor to axis // note: the driver type must match between the planner and the motors void setBacklash(uint8_t axis, uint16_t steps); // set backlash compensation for axis in steps void enable(); // enable motors void disable(); // disable motors void power(bool v); // toggle power // SETTINGS void setMaxSpeed(float nV); // set maximum planner speed in steps/sec void setAcceleration(uint16_t nA); // set planner acceleration in steps/sec^2 // PLANNER uint32_t getPeriod(); // returns time in microseconds until the next tick/tickManual call bool ready(); // true - ready to accept the next route point void pause(); // pause (reach the target point and wait). ready() will not return true while paused void stop(); // stop smoothly (with specified acceleration) void brake(); // stop motors abruptly from any mode void resume(); // continue after stop/pause void reset(); // reset counters of all motors to 0 void home(); // send to 0 on all axes uint8_t getStatus(); // current status: 0 - stopped, 1 - moving, 2 - moving to pause point, 3 - rotating at speed // SPEED void setSpeed(uint8_t axis, float speed); // continuous rotation mode for axis with speed steps/sec (can be negative) // POSITION void setCurrent(int16_t cur[]); // set current motor position void setCurrent(int32_t cur[]); // set current motor position int32_t getCurrent(int axis); // get current position on axis // set target in steps and start movement. type - ABSOLUTE (default) or RELATIVE // ABSOLUTE - specific coordinates of the point to move to // RELATIVE - offset relative to current motor positions // returns true if target is set. false if target matches current position bool setTarget(int32_t target[]); bool setTarget(int16_t target[]); bool setTarget(int32_t target[], type); bool setTarget(int16_t target[], type); int32_t getTarget(int axis); // get target in steps on axis // TICKER // ticker, call as often as possible. Returns true if motor is rotating // steps are made here for both point-to-point movement and rotation at speed bool tick(); // manual ticker for calling in interrupt or elsewhere. Executes in 20..50 us bool tickManual(); ``` -------------------------------- ### Getting Target Position C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Gets the current target in steps for the specified axis. ```cpp int32_t getTarget(int axis); ``` -------------------------------- ### API Reference for GyverPlanner2 C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md This snippet lists the main functions available in the GyverPlanner2 library for controlling stepper motors. It covers functions for configuration, enabling/disabling motors, setting motion parameters (speed, acceleration, backlash), managing the planner state (start, stop, resume, reset), checking status and buffer availability, setting speed for continuous rotation, and managing target positions (absolute/relative) and current position. ```C++ VOID Addstepper (Uint8_T Axis, STEPPER & STP);// Connect the STEPPER class motor on the axis axis // Note: the type of driver should match the planner and motors VOID Setbacklash (Uint8_t Axis, Uint16_T Steps);// Set the back of the ramp on the axis axis in the number of steps steps VOID Enable ();// Turn on the motors Void Disable ();// Turn off the motors VOID Power (Bool V);// Switch power // SETTINGS VOID setmaxSpeed (Float NV);// Installation of the maximum speed of the planner in the step/s VOID setaccoleration (uint16_t na);// Installation of acceleration of the planner in the step/sec^2 VOID Setdta (Float Newdta);// Install DT shift shifts in a turn, 0.0 .. 1.0.0.3 // planner uint32_t getperiod ();// returns time to the ISS until the next call Tick/Tickmanual VOID Start ();// Start work VOID Stop ();// Stop smoothly (with a given acceleration) VOID Brake ();// sharply stop the motors from any regime VOID Resume ();// Continue after stopping or the final point of the route VOID Reset ();// throw off the counters of all motors in 0 Bool Ready ();// Flag of reaching a stop point.After it you need to call resume Bool Available ();// True - there is a place for a new point in the planner's buffer uint8_t getstatus ();// current status: // 0 Waiting for the command (stopped) // 1 waiting for the buffer // 2 on the way // 3 per pause // 4 on stop // 5 SetSpeed is spinning // SPEED VOID SetSpeed (Uint8_t Axis, Float Speed);// Permanent rotation mode for axis axis at the speed of Speed Step/S (MB Neutheity) // Position // Add a new point of the route.Coordinate array, ending flag and absolute/relative VOID Addtarget (Int32_t Tar [], Uint8_t L, GS_Postype Type = Absolute); VOID Addtarget (int16_t tar [], uint8_t l, gs_postype test = absolute); // Absolute - specific coordinates of the point where to move // Relative - displacement relative to the current motors provisions VOID setcurrent (int16_t cur []);// establish the current position of the engines VOID setcurrent (int32_t cur []);// establish the current position of the engines Int32_T Getcurrent (int Axis);// Get the current position on the axis axis Int32_T Gettarget (int Axis);// Get the current target in steps on the axis axis // ticker // ticker, call as often as possible.Will return True if the motor is spinning // Steps are taken here for movement by points, for rotation in speed, as well as restructuring the buffer Bool Tick (); // Hand ticker for a call in an interruption or somewhere else.20..50 US is performed Bool Tickmanual (); // Buffer handler.It itself is called in Tick.It is necessary to call manually when working with Tickmanual // will return True if the planner sent motors to a new position (at that moment you can run the timer) Void Checkbuffer (); // ======= The defines of settings ========== // announce before connecting the library #define gs_fast_profile size_massive (for example 10) Includes a fast speed planner.Acceleration/braking area is broken for the indicated number of segments (+8 bytes SRAM for the site), onThe cranberries will be the same. This allows you to quickly calculate the speed of the motor and reach 30,000 step/s on the acceleration site (in normal mode, half as much). ``` -------------------------------- ### Getting Planner Status C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Returns the current status: 0 - waiting for command (stopped), 1 - waiting for buffer, 2 - in transit, 3 - paused, 4 - stopping, 5 - rotating with setSpeed. ```cpp uint8_t getStatus(); ``` -------------------------------- ### Getting Current Position C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Gets the current position for the specified axis. ```cpp int32_t getCurrent(int axis); ``` -------------------------------- ### Checking Planner Buffer C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Buffer handler. Called internally by tick(). Must be called manually when working with tickManual(). Returns true if the planner sent motors to a new position (at this moment, a timer can be started). ```cpp void checkBuffer(); ``` -------------------------------- ### Getting Next Tick Period C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Returns the time in microseconds until the next call to tick/tickManual. ```cpp uint32_t getPeriod(); ``` -------------------------------- ### Initializing GPlanner (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md Shows the template-based initialization syntax for the GPlanner class. It requires specifying the driver type and the number of axes as template parameters. This is the first step to using the multi-axis planner. ```C++ GPlanner Planner; ``` -------------------------------- ### GPlanner2 Initialization (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md Provides the syntax for declaring and initializing a GPlanner2 object. It shows how to specify the driver type, the number of axes, and optionally the buffer size during object creation. ```C++ GPlanner2 Planner;// Announcement GPlanner2 Planner;// + buffer size (in silence 32) ``` -------------------------------- ### Initializing GyverStepper Planner Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Initializes the GPlanner object with a specified driver type and the number of axes. The driver type should match the Stepper motor objects used. ```cpp GPlanner<драйвер, количество осей> planner; ``` -------------------------------- ### Configuring Fast Speed Profile Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Defines a preprocessor macro to enable the fast speed planner profile. This profile divides acceleration/deceleration into segments for faster speed calculation, improving performance during acceleration. ```cpp // ======= CONFIGURATION DEFINES ======= // declare before including the library #define GS_FAST_PROFILE размер_массива (например 10) ``` -------------------------------- ### Setting Planner Acceleration C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Sets the acceleration of the planner in steps/sec^2. ```cpp void setAcceleration(uint16_t nA); ``` -------------------------------- ### Initializing GStepper2 Object (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Demonstrates various ways to initialize the GStepper2 object for different stepper motor driver types (2-wire, 4-wire, half-step) and configurations (with/without enable pin, virtual). Requires specifying steps per revolution and pin assignments. ```cpp GStepper2 stepper(шаговНаОборот, step, dir); // драйвер step-dir GStepper2 stepper(шаговНаОборот, step, dir, en); // драйвер step-dir + пин enable GStepper2 stepper(шаговНаОборот, pin1, pin2, pin3, pin4); // драйвер 4 пин GStepper2 stepper(шаговНаОборот, pin1, pin2, pin3, pin4, en); // драйвер 4 пин + enable GStepper2 stepper(шаговНаОборот, pin1, pin2, pin3, pin4); // драйвер 4 пин полушаг GStepper2 stepper(шаговНаОборот, pin1, pin2, pin3, pin4, en); // драйвер 4 пин полушаг + enable GStepper2 stepper; // виртуальный драйвер step-dir GStepper2 stepper; // виртуальный драйвер 4 пин ``` -------------------------------- ### Enabling GPlanner Fast Profile (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md Shows how to use the #define gs_fast_profile preprocessor directive to enable the fast speed profile for the GPlanner. This define should be placed before including the library header. It explains that this mode improves acceleration performance by segmenting the acceleration/braking area, increasing SRAM usage slightly. ```C++ #define gs_fast_profile size_massive (for example 10) ``` -------------------------------- ### Enabling Motors C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Enables the motors. ```cpp void enable(); ``` -------------------------------- ### Checking If Planner Ready C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Flag indicating reaching the stop point. After this, resume() should be called. ```cpp bool ready(); ``` -------------------------------- ### Using GyverStepper2 Functions in C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md This snippet lists the main functions available in the GyverStepper2 library, covering basic step control, direction/enable inversion, power management, position/speed/acceleration control, target setting, and movement control (Tick, Ready, Pause, Resume, Stop, Brake). ```C++ // === Inherited from stepper ===== VOID STEP ();// make a step VOID Inverten (Bool Val);// Invert behavior en pina VOID ReVerse (Bool Val);// Invert the direction of the motor Void Disable ();// Disconnect power and EN VOID Enable ();// Turn on power and en VOID Attachstep (VOID (*handler) (uint8_t));// Connect the step processor VOID Attachpower (VOID (*handler) (bool));// Connect the food handler int32_t pos;// current position in steps int8_t dir;// Direction (1, -1) // ========= gstepper2 ============= // ticker Bool Tick ();// Move ticker, call often.Will return True if the motor moves Bool Tickmanual ();// Hand Ticker for calling in interrupting the timer with the Getperiod () period.Will return True if the motor moves Bool Ready ();// True will return once if the motor has reached the established position and stopped // rotation VOID SetSpeed (Int16_T Speed);// set speed in steps/s and start rotation VOID SetSpeed (Float Speed);// set speed in steps/seconds and start rotation // Movement to the goal VOID settarget (int32_t ntar, gs_postype type = Absolute);// Set the target in steps and optionally Absolute/Relative mode VOID settargetdeg (int32_t ntar, gs_postype type = absolute);// set a target in degrees and optionally Absolute/Relative mode int32_t gettarget ();// Get a target position in steps VOID setaccoleration (uint16_t na);// Installation of acceleration in the step/sec^2 VOID SetmaxSpeed (Intsed);// set the speed of movement when following the settarget () position in steps/s VOID setmaxSpeed (Float Speed);// set the speed of movement when following the settarget () position in steps/sec, float VOID setmaxSpeedDeg (int spEED);// set the speed of movement when following a position in the city/s VOID setmaxSpeeddeg (Float Speed);// Set the speed of movement when following a position in hail/s, float VOID setcurrent (int32_t npos);// set the current position int32_t getcurrent ();// get the current position VOID Reset ();// drop the current position in 0 // Everyone Void Autopower (Bool Mode);// Auto Detachment of the motor when reaching the position - True (by silence. False) uint32_t getperiod ();// get the current period of ticks VOID Brake ();// stop the motor abruptly VOID PAUSE ();// pause - get to a given point and wait (Ready () will not return True until you are on a pause) VOID Resume ();// Continue movement after stopping/pause uint8_t getstatus ();// current status: 0 - stand, 1 - go, 2 - we go to the point of the pause, 3 - we spin at speed, 4 - inhibit ``` -------------------------------- ### Setting Max Planner Speed C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Sets the maximum speed of the planner in steps/sec. ```cpp void setMaxSpeed(float nV); ``` -------------------------------- ### Initializing STEPPERCORE Class - C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md This snippet demonstrates various ways to initialize the `STEPPER` class from the STEPPERCORE library. It shows constructors for 2-wire (STEP/DIR) and 4-wire stepper drivers, including options for an enable pin (`EN`), half-stepping mode (`STEPPER4Wire_HALF`), and virtual driver implementations (`STEPPER_VIRTUAL`). The constructors require specifying the driver type template parameter and providing the necessary pin numbers. ```C++ STEPPER STEPPER (STEP, DIR);// Driver STEP-DIR STEPPER STEPPER (STEP, DIR, EN);// Driver STEP-DIR + PIN Enable STEPPER stpeper (PIN1, PIN2, PIN3, PIN4);// driver 4 PIN STEPPER stPper (PIN1, PIN2, PIN3, PIN4, EN);// Driver 4 PIN + Enable STEPPER STEPPER (PIN1, PIN2, PIN3, PIN4);// Driver 4 Pin Hole STEPPER STEPPER (PIN1, PIN2, PIN3, PIN4, EN);// Driver 4 Pin Hole + Enable STEPPER STEPPER;// STEP-DIR virtual driver STEPPER STEPPER;// virtual driver 4 pin ``` -------------------------------- ### Enabling Fast Speed Profile C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Enables the fast speed planner. The acceleration/deceleration segment is divided into the specified number of sections (+8 bytes SRAM per section), where the speed will be constant. This allows for faster motor speed calculation and achieving 30000 steps/s during acceleration (twice as fast as in normal mode). Declare before including the library. ```cpp #define GS_FAST_PROFILE размер_массива (например 10) ``` -------------------------------- ### Configuring GyverStepper2 with Defines in C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md This snippet shows how to use preprocessor defines to configure the GyverStepper2 library, such as disabling the acceleration module to reduce code size or enabling a fast speed planner profile for higher acceleration speeds. ```C++ #define GS_NO_ACCEL // Disable the movement module with acceleration (reduce code weight) #define gs_fast_profile size_massive (for example 10) Includes a fast speed planner.Acceleration/braking area is broken For the indicated number of segments (+8 bytes of SRAM to the site), the speed will be the same on them. This allows you to quickly calculate the speed of the motor and reach 30,000 step/s on the acceleration site (in normal mode, half as much). ``` -------------------------------- ### Toggling Motor Power C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Toggles motor power. ```cpp void power(bool v); ``` -------------------------------- ### Initializing GyverStepper2 in C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md This snippet shows various ways to initialize the GSTEPPER2 object for different motor driver types (STEP-DIR, 4-wire) and configurations (with/without Enable pin, half-step, virtual drivers). ```C++ GSTEPPER2 STEPPER (WHECHOOL REGULATION, STEP, DIR);// Driver STEP-DIR GSTEPPER2 STEPPER (WHECHOOL REGULATION, STEP, DIR, EN);// Driver STEP-DIR + PIN Enable GSTEPPER2 STEPPER (WHECHOOL, PIN1, PIN2, PIN3, PIN4);// driver 4 PIN GSTEPPER2 STEPPER (WHECHOOL, PIN1, PIN2, PIN3, PIN4, EN);// Driver 4 PIN + Enable Gstepper2 stPper (step -off, PIN1, PIN2, PIN3, PIN4);// Driver 4 Pin Hole GSTEPPER2 STEPPER (Shagyna Two, PIN1, PIN2, PIN3, PIN4, EN);// Driver 4 Pin Hole + Enable GSTEPPER2 STEPPER;// STEP-DIR virtual driver Gstepper2 stPper;// virtual driver 4 pin ``` -------------------------------- ### Executing Manual Planner Tick C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Manual ticker for calling in an interrupt or elsewhere. Executes in 20-50 us. ```cpp bool tickManual(); ``` -------------------------------- ### Controlling GSTEPPER2 with Target and Tick (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md Demonstrates basic usage of GSTEPPER2 for controlling a single stepper motor. It initializes the stepper, sets maximum speed and acceleration, defines a target position, and uses the tick() method in the main loop for asynchronous movement. It also shows how to check if the target is reached (read()) and update the target, and how to asynchronously print the current position. Requires the gyverstepper2.h library. ```C++ // Twist here, tick in look #include "gyverstepper2.h" GSTEPPER2 STEPPER (2048, 2, 3); VOID setup () { Serial.Begin (9600); //stepper.enable (); STEPPER.SetmaxSpeed (100);// speed to the target STEPPER.SETACCELERATION (200);// Acceleration STEPPER.SETTARGET (300);// target } Bool Dir = 1; VOID loop () { STEPPER.Tick ();// Motor asynchronously spins here // if you arrive if (stepper.read ()) { Dir =! Dir;// unfold STEPPER.SETTARGET (DIR * 300);// We go the other way } // asynchronous conclusion to the port Static uint32_t tmr; if (millis () - tmr> = 30) { TMR = Millis (); Serial.println (stpeper.pos); } } ``` -------------------------------- ### Setting Backlash Compensation C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Sets backlash compensation for the specified axis in steps. ```cpp void setBacklash(uint8_t axis, uint16_t steps); ``` -------------------------------- ### Stopping Planner Smoothly C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Stops smoothly (with the set acceleration). ```cpp void stop(); ``` -------------------------------- ### Checking Planner Buffer Availability C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md True if the planner buffer has space for a new point. ```cpp bool available(); ``` -------------------------------- ### GyverStepper C++ API Reference Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md This snippet lists the core functions available in the GyverStepper library, detailing their purpose, parameters, and return values for controlling stepper motor movement, position, speed, and state. ```C++ // Note: Further in the text by default, I mean "even if not to cause a function" // The movement of the motor occurs here, call as often as possible! // has a built -in timer // Returns True if the motor moves to the target or spins along Keep_Speed Bool Tick (); // Returns the same as Tick, i.e.The motor is spinning or not Bool getstate (); // Invert the direction of the motor - True (by default. False) VOID Reverse (Bool Dir); // Invert the behavior en Pina - True (by silence. False) VOID Inverten (Bool Rev); // Installation of the operating mode, mode: // follow_pos - following the position of Settarget (...) // keep_Speed - holding speed of setspeed (...) VOID Setrunmode (GS_RUNMODE MODE); // Installation of the current position of the motor in steps and degrees VOID setcurrent (LONG POS); VOID setcurrentdeg (Float POS); // Reading the current position of the motor in steps and degrees Long getcurrent (); Float getcurrentdeg (); // Installation of the target position in steps and degrees (for the FOLLOW_POS mode) // type - absolute or relative, by default costs absolute VOID settarget (LONG POS); VOID settarget (LONG POS, GS_Postype Type); Void settargetdeg (Float POS); VOID settargetdeg (Float Pos, GS_Postype Type); // Obtaining the target position in steps and degrees Long gettarget (); Float gettargetdeg (); // Installation of maximum speed (according to the module) in steps/second and degrees/second (for Follow_POS mode) // by the silence.300 VOID setmaxSpeed (Float Speed); VOID setmaxSpeeddeg (Float Speed); // Installation of acceleration in steps and degrees per second (for the Follow_POS mode). // at a value of 0 acceleration is turned off and the motor works // according to the profile of constant maximum speed setmaxSpeed (). // by the silence.300 VOID setaccoleration (Intscel); VOID setaccolerationdeg (Float Accel); // Auto Detection EN when reaching the position - True (by the silence. False) Void Autopower (Bool Mode); // smooth stop with a given acceleration VOID Stop (); // Hard stop VOID Brake (); // hard stop + reset of position in 0 (for endings) VOID Reset (); // Installation of targeted speed in steps/second and degrees/second (for Keep_Speed mode) VOID SetSpeed (Float Speed); VOID SetSpeeddeg (Float Speed); // Obtaining targeted speed in steps/second and degrees/second (for Keep_Speed mode) Float GetSpeed (); Float getspeeddeg (); // Turn on the motor (PIN EN) VOID Enable (); // Turn off the motor (PIN EN) Void Disable (); // Returns the minimum period of the tick of the motor in microseconds at the settled setmaxSpeed () speed. // can be used to configure the timer interruptions, in the processor of whichwow will be tick () (see Timerisr example) uint16_t getminperiod (); // The current period "TIKA" for debugging and all of this uint16_t steptime; // connect an external processor for step and switch power Void Attachstep (Handler) Void Attachpower (Handler) ``` -------------------------------- ### Connecting Stepper Motor C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Connects a Stepper class motor to the specified axis. Note: The driver type must match between the planner and the motors. ```cpp void addStepper(uint8_t axis, Stepper &stp); ``` -------------------------------- ### Resuming Planner Operation C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Continues after stopping or reaching the end point of the route. ```cpp void resume(); ``` -------------------------------- ### Setting Current Position (int32) C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Sets the current position of the motors. ```cpp void setCurrent(int32_t cur[]); ``` -------------------------------- ### Executing Planner Tick C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Ticker function, call as often as possible. Returns true if a motor is rotating. This handles steps for point-to-point movement, constant speed rotation, and buffer restructuring. ```cpp bool tick(); ``` -------------------------------- ### Adding Target Point (int32) C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Adds a new route point. Array of coordinates, end flag, and absolute/relative type. ABSOLUTE - specific target coordinates, RELATIVE - offset relative to current motor positions. ```cpp void addTarget(int32_t tar[], uint8_t l, GS_posType type = ABSOLUTE); ``` -------------------------------- ### Setting Current Position (int16) C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Sets the current position of the motors. ```cpp void setCurrent(int16_t cur[]); ``` -------------------------------- ### Adding Target Point (int16) C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Adds a new route point. Array of coordinates, end flag, and absolute/relative type. ABSOLUTE - specific target coordinates, RELATIVE - offset relative to current motor positions. ```cpp void addTarget(int16_t tar[], uint8_t l, GS_posType type = ABSOLUTE); ``` -------------------------------- ### Setting Turn Speed Change Dt C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Sets the dt for speed change during turns, 0.0..1.0, default 0.3. ```cpp void setDtA(float newDta); ``` -------------------------------- ### STEPPERCORE Class Interface (C++) Source: https://github.com/gyverlibs/gyverstepper/blob/main/README_EN.md Defines the public functions and variables available in the STEPPERCORE class/structure, used for controlling stepper motor behavior, power, and tracking position/direction. ```C++ VOID STEP ();// make a step VOID Inverten (Bool Val);// Invert behavior en pina VOID Reverse (Bool Val);// Invert the direction of the motor Void Disable ();// Disconnect power and EN VOID Enable ();// Turn on power and en VOID Power (Bool);// Switch power VOID Attachstep (VOID (*handler) (uint8_t));// Connect the step processor VOID Attachpower (VOID (*handler) (bool));// Connect the food handler int32_t pos;// current position in steps int8_t dir;// Direction (1, -1) ``` -------------------------------- ### Disabling Motors C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Disables the motors. ```cpp void disable(); ``` -------------------------------- ### Braking Motors Abruptly C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Abruptly stops the motors from any mode. ```cpp void brake(); ``` -------------------------------- ### Resetting Motor Counters C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Resets the counters of all motors to 0. ```cpp void reset(); ``` -------------------------------- ### Setting Constant Rotation Speed C++ Source: https://github.com/gyverlibs/gyverstepper/blob/main/README.md Sets constant rotation mode for the specified axis with speed in steps/sec (can be negative). ```cpp void setSpeed(uint8_t axis, float speed); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.