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
33class HomingAxis : public Plugin {
34 public:
35 HomingAxis();
36 HomingAxis(
37 uint8_t limit_switch_port,
38 DecimalPosition value_at_limit,
39 int direction,
40 DecimalPosition velocity
41 );
42
43 void begin();
44
45 uint8_t read_state();
46
47 void start_homing_routine();
48 void wait_for_homing();
49
50 void set_axis_value();
51
52
53 BlockPort output;
54
55 protected:
56 void run();
57
58 private:
59 uint8_t limit_switch_port_number;
60 Button limit_switch_button;
61 DecimalPosition value_at_limit;
62 int homing_direction;
63 DecimalPosition homing_velocity;
64
65 uint8_t current_homing_state;
66
67 DecimalPosition current_position = 0;
68
69 void move_forward();
70 void move_backward();
71
72};
73
80class Homing : public Plugin{
81
82 public:
83 Homing();
84
85 void begin();
86
87 void add_axis(
88 uint8_t limit_switch_port,
89 DecimalPosition value_at_limit,
90 int direction,
91 DecimalPosition velocity,
92 BlockPort *target);
93
94 void start_homing_routine();
95
96 private:
97 HomingAxis axes[MAX_NUM_AXES];
98 int nb_axes = 0;
99 int axis_currently_homing = -1;
100 DecimalPosition speed;
101
102 protected:
103 void loop();
104};
105
106
107#endif
BlockPorts provide a unified interface for mapping inputs and outputs of different StepDance componen...
Definition core.hpp:148
Button class for handling digital input buttons.
Definition digital_in.hpp:52
Definition homing.hpp:33