Skip to content

Commit 51cff04

Browse files
committed
Create
1 parent d84e55c commit 51cff04

68 files changed

Lines changed: 11967 additions & 8 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# Swift Pro Firmware V4.1.1 (Base on [Grbl v0.9j](https://github.com/grbl/grbl) )
1+
# Swift Pro Firmware V4.1.0 (Base on [Grbl v0.9j](https://github.com/grbl/grbl) )
22

33
----------
4-
## Update Summary for v4.1.1
5-
* Fix cmd M17 bug
6-
* Add closed-loop stepper control (step losing detection and auto-adjusting)
4+
75
## Update Summary for v4.1.0
86
* Transplant Grbl framework.
97
* Optimize stepper motor performance,improve motor speed,fix motor shake.
@@ -16,9 +14,9 @@
1614
#### Not support app control
1715
#### For uArmStudio control
1816

19-
- input and Grove module in BLOCKLY are not supported.
20-
- Draw/Laser is not supported.
21-
- 3D Printing is not supported.
17+
- BLOCKLY is not support **input** and **Grove** module.
18+
- Draw/Laser is not support.
19+
- 3D Printing is not support.
2220

2321
## Communication protocol
2422
#### For serial terminal control
@@ -50,7 +48,7 @@ not support currently **P2240,P2241**.
5048
* Open XLoader and select your uArm's COM port from the drop down menu on the lower left.
5149
* Select the appropriate device from the dropdown list titled "Device".
5250
* Check that Xloader set the correct baud rate for the device: 115200 for Mega (ATMEGA2560).
53-
* Now use the browse button on the top right of the form to browse to your hex file.
51+
* Now use the browse button on the top right of the form to browse to your grbl hex file.
5452
* Once your hex file is selected, click "Upload"
5553
The upload process generally takes about 10 seconds to finish. Once completed, a message will appear in the bottom left corner of XLoader telling you how many bytes were uploaded. If there was an error, it would show instead of the total bytes uploaded. Steps should be similar and may be done through the command prompt.
5654

Source code/config.h

Lines changed: 414 additions & 0 deletions
Large diffs are not rendered by default.

Source code/coolant_control.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
coolant_control.c - coolant control methods
3+
Part of Grbl
4+
5+
Copyright (c) 2012-2015 Sungeun K. Jeon
6+
7+
Grbl is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
Grbl is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#include "grbl.h"
22+
23+
24+
void coolant_init()
25+
{
26+
COOLANT_FLOOD_DDR |= (1 << COOLANT_FLOOD_BIT);
27+
#ifdef ENABLE_M7
28+
COOLANT_MIST_DDR |= (1 << COOLANT_MIST_BIT);
29+
#endif
30+
coolant_stop();
31+
}
32+
33+
34+
void coolant_stop()
35+
{
36+
COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT);
37+
#ifdef ENABLE_M7
38+
COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT);
39+
#endif
40+
}
41+
42+
43+
void coolant_set_state(uint8_t mode)
44+
{
45+
if (mode == COOLANT_FLOOD_ENABLE) {
46+
COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT);
47+
48+
#ifdef ENABLE_M7
49+
} else if (mode == COOLANT_MIST_ENABLE) {
50+
COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT);
51+
#endif
52+
53+
} else {
54+
coolant_stop();
55+
}
56+
}
57+
58+
59+
void coolant_run(uint8_t mode)
60+
{
61+
if (sys.state == STATE_CHECK_MODE) { return; }
62+
protocol_buffer_synchronize(); // Ensure coolant turns on when specified in program.
63+
coolant_set_state(mode);
64+
}

Source code/coolant_control.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
coolant_control.h - spindle control methods
3+
Part of Grbl
4+
5+
Copyright (c) 2012-2015 Sungeun K. Jeon
6+
7+
Grbl is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
Grbl is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#ifndef coolant_control_h
22+
#define coolant_control_h
23+
24+
25+
void coolant_init();
26+
void coolant_stop();
27+
void coolant_set_state(uint8_t mode);
28+
void coolant_run(uint8_t mode);
29+
30+
#endif

Source code/cpu_map.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
cpu_map.h - CPU and pin mapping configuration file
3+
Part of Grbl
4+
5+
Copyright (c) 2012-2015 Sungeun K. Jeon
6+
7+
Grbl is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
Grbl is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
/* The cpu_map.h files serve as a central pin mapping selection file for different processor
22+
types, i.e. AVR 328p or AVR Mega 2560. Each processor has its own pin mapping file.
23+
(i.e. cpu_map_atmega328p.h) Grbl officially supports the Arduino Uno, but the
24+
other supplied pin mappings are supplied by users, so your results may vary. */
25+
26+
// NOTE: With new processors, only add the define name and filename to use.
27+
28+
#ifndef cpu_map_h
29+
#define cpu_map_h
30+
31+
32+
#ifdef CPU_MAP_ATMEGA328P // (Arduino Uno) Officially supported by Grbl.
33+
#include "cpu_map/cpu_map_atmega328p.h"
34+
#endif
35+
36+
#ifdef CPU_MAP_ATMEGA2560 // (Arduino Mega 2560) Working @EliteEng
37+
#include "cpu_map/cpu_map_atmega2560.h"
38+
#endif
39+
40+
/*
41+
#ifdef CPU_MAP_CUSTOM_PROC
42+
// For a custom pin map or different processor, copy and edit one of the available cpu
43+
// map files and modify it to your needs. Make sure the defined name is also changed in
44+
// the config.h file.
45+
#endif
46+
*/
47+
48+
#endif
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
/*
2+
cpu_map_atmega2560.h - CPU and pin mapping configuration file
3+
Part of Grbl
4+
5+
Copyright (c) 2012-2015 Sungeun K. Jeon
6+
7+
Grbl is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
Grbl is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
/* This cpu_map file serves as a central pin mapping settings file for AVR Mega 2560 */
22+
23+
24+
#ifdef GRBL_PLATFORM
25+
#error "cpu_map already defined: GRBL_PLATFORM=" GRBL_PLATFORM
26+
#endif
27+
28+
29+
#define GRBL_PLATFORM "Atmega2560"
30+
31+
// Serial port pins
32+
#define SERIAL_RX USART0_RX_vect
33+
#define SERIAL_UDRE USART0_UDRE_vect
34+
35+
// Increase Buffers to make use of extra SRAM
36+
//#define RX_BUFFER_SIZE 256
37+
//#define TX_BUFFER_SIZE 128
38+
//#define BLOCK_BUFFER_SIZE 36
39+
//#define LINE_BUFFER_SIZE 100
40+
41+
/*
42+
// Define step pulse output pins. NOTE: All step bit pins must be on the same port.
43+
#define STEP_DDR DDRA
44+
#define STEP_PORT PORTA
45+
#define STEP_PIN PINA
46+
#define X_STEP_BIT 2 // MEGA2560 Digital Pin 24
47+
#define Y_STEP_BIT 3 // MEGA2560 Digital Pin 25
48+
#define Z_STEP_BIT 4 // MEGA2560 Digital Pin 26
49+
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)) // All step bits
50+
51+
// Define step direction output pins. NOTE: All direction pins must be on the same port.
52+
#define DIRECTION_DDR DDRC
53+
#define DIRECTION_PORT PORTC
54+
#define DIRECTION_PIN PINC
55+
#define X_DIRECTION_BIT 7 // MEGA2560 Digital Pin 30
56+
#define Y_DIRECTION_BIT 6 // MEGA2560 Digital Pin 31
57+
#define Z_DIRECTION_BIT 5 // MEGA2560 Digital Pin 32
58+
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) // All direction bits
59+
60+
// Define stepper driver enable/disable output pin.
61+
#define STEPPERS_DISABLE_DDR DDRB
62+
#define STEPPERS_DISABLE_PORT PORTB
63+
#define STEPPERS_DISABLE_BIT 7 // MEGA2560 Digital Pin 13
64+
#define STEPPERS_DISABLE_MASK (1<<STEPPERS_DISABLE_BIT)
65+
*/
66+
67+
// Define homing/hard limit switch input pins and limit interrupt vectors.
68+
// NOTE: All limit bit pins must be on the same port
69+
#define LIMIT_DDR DDRD
70+
#define LIMIT_PORT PORTD
71+
#define LIMIT_PIN PIND
72+
#define X_LIMIT_BIT 4 // MEGA2560 Digital Pin 10
73+
#define Y_LIMIT_BIT 4 // MEGA2560 Digital Pin 11
74+
#define Z_LIMIT_BIT 4 // MEGA2560 Digital Pin 12
75+
#define LIMIT_INT PCIE0 // Pin change interrupt enable pin
76+
#define LIMIT_INT_vect PCINT0_vect
77+
#define LIMIT_PCMSK PCMSK0 // Pin change interrupt register
78+
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)) // All limit bits
79+
80+
// Define spindle enable and spindle direction output pins.
81+
#define SPINDLE_ENABLE_DDR DDRD
82+
#define SPINDLE_ENABLE_PORT PORTD
83+
#define SPINDLE_ENABLE_BIT 4 // MEGA2560 Digital Pin 6
84+
#define SPINDLE_DIRECTION_DDR DDRD
85+
#define SPINDLE_DIRECTION_PORT PORTD
86+
#define SPINDLE_DIRECTION_BIT 4 // MEGA2560 Digital Pin 5
87+
88+
// Define flood and mist coolant enable output pins.
89+
// NOTE: Uno analog pins 4 and 5 are reserved for an i2c interface, and may be installed at
90+
// a later date if flash and memory space allows.
91+
#define COOLANT_FLOOD_DDR DDRD
92+
#define COOLANT_FLOOD_PORT PORTD
93+
#define COOLANT_FLOOD_BIT 4 // MEGA2560 Digital Pin 8
94+
#ifdef ENABLE_M7 // Mist coolant disabled by default. See config.h to enable/disable.
95+
#define COOLANT_MIST_DDR DDRD
96+
#define COOLANT_MIST_PORT PORTD
97+
#define COOLANT_MIST_BIT 4 // MEGA2560 Digital Pin 9
98+
#endif
99+
100+
// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
101+
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
102+
#define CONTROL_DDR DDRD
103+
#define CONTROL_PIN PIND
104+
#define CONTROL_PORT PORTD
105+
#define RESET_BIT 4 // MEGA2560 Analog Pin 8
106+
#define FEED_HOLD_BIT 4 // MEGA2560 Analog Pin 9
107+
#define CYCLE_START_BIT 4 // MEGA2560 Analog Pin 10
108+
#define SAFETY_DOOR_BIT 4 // MEGA2560 Analog Pin 11
109+
#define CONTROL_INT PCIE2 // Pin change interrupt enable pin
110+
#define CONTROL_INT_vect PCINT2_vect
111+
#define CONTROL_PCMSK PCMSK2 // Pin change interrupt register
112+
#define CONTROL_MASK ((1<<RESET_BIT)|(1<<FEED_HOLD_BIT)|(1<<CYCLE_START_BIT)|(1<<SAFETY_DOOR_BIT))
113+
#define CONTROL_INVERT_MASK CONTROL_MASK // May be re-defined to only invert certain control pins.
114+
115+
// Define probe switch input pin.
116+
#define PROBE_DDR DDRD
117+
#define PROBE_PIN PIND
118+
#define PROBE_PORT PORTD
119+
#define PROBE_BIT 4 // MEGA2560 Analog Pin 15
120+
#define PROBE_MASK (1<<PROBE_BIT)
121+
122+
// Start of PWM & Stepper Enabled Spindle
123+
#ifdef VARIABLE_SPINDLE
124+
// Advanced Configuration Below You should not need to touch these variables
125+
// Set Timer up to use TIMER4B which is attached to Digital Pin 7
126+
#define PWM_MAX_VALUE 65535.0
127+
#define TCCRA_REGISTER TCCR4A
128+
#define TCCRB_REGISTER TCCR4B
129+
#define OCR_REGISTER OCR4B
130+
131+
#define COMB_BIT COM4B1
132+
#define WAVE0_REGISTER WGM40
133+
#define WAVE1_REGISTER WGM41
134+
#define WAVE2_REGISTER WGM42
135+
#define WAVE3_REGISTER WGM43
136+
137+
#define SPINDLE_PWM_DDR DDRA
138+
#define SPINDLE_PWM_PORT PORTA
139+
#define SPINDLE_PWM_BIT 4 // MEGA2560 Digital Pin 97
140+
#endif // End of VARIABLE_SPINDLE
141+
142+
143+
// ARML <--> grbl x axis
144+
#define ARML_STEP_DDR DDRF
145+
#define ARML_STEP_PORT PORTF
146+
#define ARML_STEP_PIN 6 //PF6
147+
#define ARML_STEP_MASK (1<<ARML_STEP_PIN)
148+
#define ARML_STEP_BIT 0
149+
150+
//ARMR <--> grbl y axis
151+
#define ARMR_STEP_DDR DDRL
152+
#define ARMR_STEP_PORT PORTL
153+
#define ARMR_STEP_PIN 3 // PL3
154+
#define ARMR_STEP_MASK (1<<ARMR_STEP_PIN)
155+
#define ARMR_STEP_BIT 1
156+
157+
//BASE <--> grbl z axis
158+
#define BASE_STEP_DDR DDRF
159+
#define BASE_STEP_PORT PORTF
160+
#define BASE_STEP_PIN 0 // PF0
161+
#define BASE_STEP_MASK (1<<BASE_STEP_PIN)
162+
#define BASE_STEP_BIT 2
163+
164+
#define ARML_DIRECTION_DDR DDRF
165+
#define ARML_DIRECTION_PORT PORTF
166+
#define ARML_DIRECTION_PIN 7 //PF7
167+
#define ARML_DIRECTION_MASK (1<<ARML_DIRECTION_PIN)
168+
#define ARML_DIRECTION_BIT 0
169+
170+
171+
#define ARMR_DIRECTION_DDR DDRL
172+
#define ARMR_DIRECTION_PORT PORTL
173+
#define ARMR_DIRECTION_PIN 1 //PL1
174+
#define ARMR_DIRECTION_MASK (1<<ARMR_DIRECTION_PIN)
175+
#define ARMR_DIRECTION_BIT 1
176+
177+
178+
#define BASE_DIRECTION_DDR DDRF
179+
#define BASE_DIRECTION_PORT PORTF
180+
#define BASE_DIRECTION_PIN 1 //PF1
181+
#define BASE_DIRECTION_MASK (1<<BASE_DIRECTION_PIN)
182+
#define BASE_DIRECTION_BIT 2
183+
184+
#define ARML_STEPPERS_DISABLE_DDR DDRF
185+
#define ARML_STEPPERS_DISABLE_PORT PORTF
186+
#define ARML_STEPPERS_DISABLE_BIT 2 //PF2
187+
#define ARML_STEPPERS_DISABLE_MASK (1<<ARML_STEPPERS_DISABLE_BIT)
188+
189+
#define ARMR_STEPPERS_DISABLE_DDR DDRK
190+
#define ARMR_STEPPERS_DISABLE_PORT PORTK
191+
#define ARMR_STEPPERS_DISABLE_BIT 0 //PK0
192+
#define ARMR_STEPPERS_DISABLE_MASK (1<<ARMR_STEPPERS_DISABLE_BIT)
193+
194+
#define BASE_STEPPERS_DISABLE_DDR DDRD
195+
#define BASE_STEPPERS_DISABLE_PORT PORTD
196+
#define BASE_STEPPERS_DISABLE_BIT 7 //PD7
197+
#define BASE_STEPPERS_DISABLE_MASK (1<<BASE_STEPPERS_DISABLE_BIT)
198+
199+
200+
#define MS3_DDRD DDRK
201+
#define MS3_PORT PORTK
202+
#define MS3_PIN 4
203+
#define MS3_MASK (1<<MS3_PIN)
204+
205+
#define MS2_DDRD DDRK
206+
#define MS2_PORT PORTK
207+
#define MS2_PIN 3
208+
#define MS2_MASK (1<<MS2_PIN)
209+
210+
#define MS1_DDRD DDRK
211+
#define MS1_PORT PORTK
212+
#define MS1_PIN 2
213+
#define MS1_MASK (1<<MS1_PIN)
214+
215+
216+
217+

0 commit comments

Comments
 (0)