Stepdance Software Library
Loading...
Searching...
No Matches
homing.hpp
1#include <stdint.h>
2#include <sys/types.h>
3/*
4Filters Module of the StepDance Control System
5
6This module contains an assortment of motion filters
7
8[More Details to be Added]
9
10A part of the Mixing Metaphors Project
11(c) 2025 Ilan Moyer, Jennifer Jacobs, Devon Frost
12
13*/
14#include "core.hpp"
15#include "digital_in.hpp"
16
17#ifndef homing_h //prevent importing twice
18#define homing_h
19
20#define MAX_NUM_AXES 5
21
22#define HOMING_DIR_FWD 1.0
23#define HOMING_DIR_BWD -1.0
24
25// --- HOMING STATE ---
26#define HOMING_AXIS_STATE_BEGIN 0 // beginning homing on the axis
27#define HOMING_AXIS_STATE_BACKING_OFF 1 // homing switch was active at start of axis homing.
28#define HOMING_AXIS_STATE_SEEKING 2 // traveling in the direction of the homing switch.
29#define HOMING_AXIS_STATE_CENTERING 3 // traveling towards the home position.
30#define HOMING_STATE_FINISHED 4 // this gets set when all axes are homed.
31#define HOMING_STATE_WAITING 5 // this gets set when homing routine is called for all axes.
32
33
38class HomingAxis : public Plugin {
39 public:
40 HomingAxis();
41 HomingAxis(
42 uint8_t limit_switch_port,
43 DecimalPosition value_at_limit,
44 int direction,
45 DecimalPosition velocity
46 );
47
48 void begin();
49
50 uint8_t read_state();
51
52 void start_homing_routine();
53 void wait_for_homing();
54
55 void set_axis_value();
56
57
58 BlockPort output;
59
60 protected:
61 void run();
62
63 private:
64 uint8_t limit_switch_port_number;
65 Button limit_switch_button;
66 DecimalPosition value_at_limit;
67 int homing_direction;
68 DecimalPosition homing_velocity;
69
70 uint8_t current_homing_state;
71
72 DecimalPosition current_position = 0;
73
74 void move_forward();
75 void move_backward();
76
77};
79
86class Homing : public Plugin{
87
88 public:
89 Homing();
90
94 void begin();
95
106 uint8_t limit_switch_port,
107 DecimalPosition value_at_limit,
108 int direction,
109 DecimalPosition velocity,
110 BlockPort *target);
111
116
117 private:
118 HomingAxis axes[MAX_NUM_AXES];
119 int nb_axes = 0;
120 int axis_currently_homing = -1;
121 DecimalPosition speed;
122
123 protected:
124 void loop();
125};
126
127
128#endif
BlockPorts provide a unified interface for mapping inputs and outputs of different StepDance componen...
Definition core.hpp:152
void start_homing_routine()
Launch the homing routine (machine will move until it hits the limit switch for each registered axis)...
void begin()
Initialize the Homing plugin. Must be called during setup().
void add_axis(uint8_t limit_switch_port, DecimalPosition value_at_limit, int direction, DecimalPosition velocity, BlockPort *target)
Register an axis to home. The homing routine will go through the regisered axes and home each one in ...