forked from nullsub/laser_grbl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.h
161 lines (127 loc) · 5.89 KB
/
config.h
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
config.h - compile time configuration
Part of LasaurGrbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2011 Sungeun K. Jeon
Copyright (c) 2011 Stefan Hechenberger
LasaurGrbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LasaurGrbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef config_h
#define config_h
#include <inttypes.h>
#include <stdbool.h>
#define LASAURGRBL_VERSION "v12.02h"
#define BAUD_RATE 115200
#define CONFIG_X_STEPS_PER_MM (4.58) //microsteps/mm
#define CONFIG_Y_STEPS_PER_MM (7.8) //microsteps/mm
#define CONFIG_Z_STEPS_PER_MM (5.611) //microsteps/mm
#define CONFIG_PULSE_MICROSECONDS (30)
#define CONFIG_FEEDRATE (1500.0) // in millimeters per minute
#define CONFIG_SEEKRATE (1500.0)
#define CONFIG_ACCELERATION 1000000.0 // mm/min^2, typically 1000000-8000000, divide by (60*60) to get mm/sec^2
#define CONFIG_JUNCTION_DEVIATION 0.05 // mm
#define CONFIG_X_ORIGIN_OFFSET 0 // mm, x-offset of table origin from physical home
#define CONFIG_Y_ORIGIN_OFFSET 0 // mm, y-offset of table origin from physical home
#define CONFIG_Z_ORIGIN_OFFSET 0.0 // mm, z-offset of table origin from physical home
#define CONFIG_INVERT_X_AXIS 0 // 0 is regular, 1 inverts the x direction
#define CONFIG_INVERT_Y_AXIS 0 // 0 is regular, 1 inverts the y direction
#define LIMITS_OVERWRITE_DDR DDRD
#define LIMITS_OVERWRITE_PORT PORTD
#define LIMITS_OVERWRITE_BIT 7
#define SENSE_DDR DDRD
#define SENSE_PORT PORTD
#define SENSE_PIN PIND
#define POWER_BIT 2
#define CHILLER_BIT 3
#define DOOR_BIT 5
#define LIMIT_DDR DDRC
#define LIMIT_PORT PORTC
#define LIMIT_PIN PINC
#define X1_LIMIT_BIT 0
#define X2_LIMIT_BIT 1
#define Y1_LIMIT_BIT 2
#define Y2_LIMIT_BIT 3
#define AIRGAS_DDR DDRC
#define AIRGAS_PORT PORTC
#define AIR_BIT 4
#define GAS_BIT 5
#define STEPPING_DDR DDRB
#define STEPPING_PORT PORTB
#define X_STEP_BIT 0
#define Y_STEP_BIT 1
#define Z_STEP_BIT 2
#define X_DIRECTION_BIT 3
#define Y_DIRECTION_BIT 4
#define Z_DIRECTION_BIT 5
#define SENSE_MASK ((1<<POWER_BIT)|(1<<CHILLER_BIT)|(1<<DOOR_BIT))
#define LIMIT_MASK ((1<<X1_LIMIT_BIT)|(1<<X2_LIMIT_BIT)|(1<<Y1_LIMIT_BIT)|(1<<Y2_LIMIT_BIT))
#define STEPPING_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT))
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT))
// figure out INVERT_MASK
// careful! direction pins hardcoded here
// (1<<X_DIRECTION_BIT) | (1<<Y_DIRECTION_BIT)
#if CONFIG_INVERT_X_AXIS && CONFIG_INVERT_Y_AXIS
#define INVERT_MASK 24U
#elif CONFIG_INVERT_X_AXIS
#define INVERT_MASK 8U
#elif CONFIG_INVERT_Y_AXIS
#define INVERT_MASK 16U
#else
#define INVERT_MASK 0U
#endif
// The temporal resolution of the acceleration management subsystem. Higher number give smoother
// acceleration but may impact performance.
// NOTE: Increasing this parameter will help any resolution related issues, especially with machines
// requiring very high accelerations and/or very fast feedrates. In general, this will reduce the
// error between how the planner plans the motions and how the stepper program actually performs them.
// However, at some point, the resolution can be high enough, where the errors related to numerical
// round-off can be great enough to cause problems and/or it's too fast for the Arduino. The correct
// value for this parameter is machine dependent, so it's advised to set this only as high as needed.
// Approximate successful values can range from 30L to 100L or more.
#define ACCELERATION_TICKS_PER_SECOND 100L //---> 80
// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
// of the buffer and all stops. This should not be much greater than zero and should only be changed
// if unwanted behavior is observed on a user's machine when running at very slow speeds.
#define ZERO_SPEED 0.0 // (mm/min)
// Minimum stepper rate. Sets the absolute minimum stepper rate in the stepper program and never runs
// slower than this value, except when sleeping. This parameter overrides the minimum planner speed.
// This is primarily used to guarantee that the end of a movement is always reached and not stop to
// never reach its target. This parameter should always be greater than zero.
#define MINIMUM_STEPS_PER_MINUTE 800U // (steps/min) - Integer value only
// 1600 @ 32step_per_mm = 50mm/min
#define CHAR_XOFF '\x13'
#define CHAR_XON '\x11'
// #define CHAR_STOP '\x03'
// #define CHAR_RESUME '\x02'
#define CHAR_STOP '!'
#define CHAR_RESUME '~'
#define X_AXIS 0
#define Y_AXIS 1
#define Z_AXIS 2
#define clear_vector(a) memset(a, 0, sizeof(a))
#define clear_vector_double(a) memset(a, 0.0, sizeof(a))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
// bit math
// see: http://www.arduino.cc/playground/Code/BitMath
// see: http://graphics.stanford.edu/~seander/bithacks.html
//
// y = (x >> n) & 1; // n=0..15. stores nth bit of x in y. y becomes 0 or 1.
//
// x &= ~(1 << n); // forces nth bit of x to be 0. all other bits left alone.
//
// x &= (1<<(n+1))-1; // leaves alone the lowest n bits of x; all higher bits set to 0.
//
// x |= (1 << n); // forces nth bit of x to be 1. all other bits left alone.
//
// x ^= (1 << n); // toggles nth bit of x. all other bits left alone.
//
// x = ~x; // toggles ALL the bits in x.