-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgantry.hpp
75 lines (69 loc) · 2.28 KB
/
gantry.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <Arduino.h>
#define SCREW_LEAD_X 2
#define SCREW_LEAD_Y 8
#define SCREW_LEAD_Z 8
#define STEPS_PER_REVOLUTION 200
#define MM_TO_Y_HOME 0 //was 151
#define NEEDLE_Z_PROJ 10
#define Z_REALIGN 13
#define NEEDLE_Y_PROJ 13
#define NEEDLE_X_PROJ 21.75
#define SERVO_BEGIN 0
#define SERVO_INJECT_DIST 100
#define X_AXIS 0
#define Y_AXIS 1
#define Z_AXIS 2
#define FORWARD 0
#define BACKWARD 1
#define STEP_PIN_X 49
#define STEP_PIN_Y 53
#define STEP_PIN_Z 46
#define DIR_PIN_X 48
#define DIR_PIN_Y 51
#define DIR_PIN_Z 47
#define CAP_SENSE_PIN 30
#define SERVO_PIN A0
#define LIMIT_Y_HOME_PIN 2
#define LIMIT_X_HOME_PIN 21
#define LIMIT_Z_HOME_PIN 22
#define potpin A2 // analog pin used to connect the potentiometer
#define ASCII_TO_INT 48 //subtract 48 from an ascii value to make it a decimal value (e.g. 56 -> 8)
#define HEADLESS 0 // where we just go through a basic series of operations with no cmds expected from pi
// Requests from Pi
#define REQ_ECHO_MSG (int) '0'
#define REQ_POSITION_UPDATE (int) '1'
#define REQ_MOVE_Y_HOME (int) '2'
#define REQ_MOVE_STEPPER (int) '3'
#define REQ_GO_TO_WORK (int) '4' // after pi gives coordinate pi tells to go ahead...
#define REQ_WAIT_COORDINATE '5'
#define REQ_RESET (int) '9'
// Commands to Pi
#define CMD_STATUS_MSG (int) '0'
#define CMD_GANTRY_INITIALIZED (int) '1'
#define CMD_POSITION_UPDATE (int) '2'
#define CMD_COORDINATE_RECEIVED (int) '7'
#define CMD_WAIT_COORDINATE (int) '8'
#define CMD_FINISH (int) '9'
int mm_to_steps(int axis, double distance);
void select_direction_pin(int dir);
int select_step_pin(int axis);
void gantry_init();
int move_stepper(int axis, int nSteps, int dir);
void move_y_home();
int wait_for_coordinate();
int move_cap_to_IL();
void wait_for_error_check();
int depth_finder();
void position_needle();
void inject_needle();
void go_home();
void move_y_back();
void move_back_from_IL(int z_depth);
void pull_needle();
void decode_coordinate(const char* msg);
void decode_req_move_stepper(const char* msg);
void send_cmd(int cmd);
void status_msg(const char* msg);
int process_req(const char* in_cmd);
void wait_for_begin_cmd();
void send_position_update(int axis, int dir);