Compare commits

...

57 Commits

Author SHA1 Message Date
cf6dd107c1 PWM Pin set to default P2.5 2019-12-11 08:53:21 +00:00
c284649b04 enabled PWM on P1.23 2019-12-11 08:38:07 +00:00
427943e224 „grbl/config.h“ ändern 2019-12-11 06:57:37 +00:00
d21a05192c „grbl/defaults.h“ ändern 2019-12-10 16:11:28 +00:00
035ac54393 „grbl/defaults.h“ ändern 2019-12-10 16:07:02 +00:00
4e3dd7ae0e „grbl/config.h“ ändern 2019-12-10 15:16:28 +00:00
99b0441562 „grbl/defaults.h“ ändern 2019-12-10 15:11:43 +00:00
58aead3980 disabled #define INVERT_SPINDLE_ENABLE_PIN 2019-12-10 14:54:12 +00:00
47880f153d K40 Spindle max RPM set to 300 = 5V 2019-12-10 11:19:28 +00:00
62fe6d61e3 „README.md“ ändern 2019-12-09 08:59:18 +00:00
57d4b642ab „README.md“ ändern 2019-12-08 07:54:12 +00:00
23e140075f „README.md“ ändern 2019-12-08 07:52:18 +00:00
db50f0a023 „README.md“ ändern 2019-12-08 07:51:35 +00:00
a506a8936a Dateien hochladen nach „doc/media“ 2019-12-08 07:49:07 +00:00
4e191e8679 „README.md“ ändern 2019-12-08 07:48:41 +00:00
ddb59cb335 changed to MKS board type 2019-12-08 07:47:00 +00:00
0f9c02842c max_rate and max_travel changed 2019-12-08 07:08:24 +00:00
1ae790ee6c disables safety_door_input_pin 2019-12-08 06:28:43 +00:00
cprezzi
84070bf791 Workaround for coolant mist control 2019-11-18 14:29:56 +01:00
cprezzi
843c7b01d6 Merge branch 'master' of https://github.com/cprezzi/grbl-LPC 2019-11-18 14:04:17 +01:00
Claudio Prezzi
04f8621ef9
Merge pull request #27 from tscofield/probe
changes to allow probing on pin 1.27
2019-07-26 15:17:32 +02:00
Claudio Prezzi
e21a807008
Merge pull request #28 from tscofield/build_doc
Add additional docker info to help new users
2019-07-26 15:00:32 +02:00
Scofield, Thomas
ffdd368642 Add additional info to help new users 2019-07-25 23:37:21 -04:00
Scofield, Thomas
9b6300a872 impliment changes to allow probing to work and map the probe pin to p1.27 on the sbase board 2019-07-25 23:02:51 -04:00
Claudio Prezzi
b09170d1b5
Merge pull request #21 from bkp23/master
Thanks for the helpful code comments!
2019-04-30 16:49:06 +02:00
B. Perry
8ff3d5322c Revert simple code changes so only comments have been changed 2019-04-30 08:36:30 -06:00
B. Perry
a7ba369987 Added comments throughout code 2019-04-29 13:47:11 -06:00
Claudio Prezzi
ac6817f7e2
Merge pull request #14 from bkp23/defaults_comments
Added a description to each option, including the option codes (ordered by $key).
2019-01-09 09:47:26 +01:00
bkp23
86875c21da Added a description to each option, including the option codes 2019-01-08 16:22:28 -07:00
Claudio Prezzi
fb20eeb1ea Added config option to have PWM on P1.23 for MKS SBase 2018-12-26 13:51:33 +01:00
cprezzi
0721e573ef Ported spindle enable pin + FEED_HOLD, CYCLE_START and DOOR_SWITCH pins 2018-07-05 13:03:08 +02:00
Claudio Prezzi
f1976d8726
Merge pull request #6 from jorgerobles/master
Added Dockerfile
2018-04-30 16:14:30 +02:00
Jorge Robles
97f22ffa1e Added Dockerfile 2018-04-30 15:46:21 +02:00
cprezzi
92b093ee43 Corrected G10 L20 P0 command (setZero) 2017-10-08 16:03:01 +02:00
Claudio Prezzi
5ad7af8dfb Activated HOMING_FORCE_POSITIVE_SPACE and added SPINDLE_PWM_PIN_2_4 param 2017-10-08 13:55:39 +02:00
cprezzi
96ad0afdda Set coolant pins for all supported boards in cpu-map.h 2017-08-03 16:00:15 +02:00
cprezzi
4252f75a84 Merge branch 'more-axis' 2017-08-03 15:07:11 +02:00
cprezzi
dc92bf565e Support coolant flood and mist for remix board 2017-08-03 15:01:34 +02:00
cprezzi
436615095f Always use MIN endstop pins (independant of board!) 2017-07-12 19:01:01 +02:00
cprezzi
a661778252 Made board switchable in config.h 2017-07-12 18:34:50 +02:00
cprezzi
54ae403094 Made A-Axis switchable in config.h 2017-07-12 17:56:46 +02:00
cprezzi
06e9bf8f82 Made CPU-MAP per Board instead of MCU 2017-07-12 17:45:06 +02:00
Claudio Prezzi
f904fff7ba Highlight make as command. 2017-06-21 09:06:55 +02:00
Claudio Prezzi
b24e01d588 Merge branch 'master' of https://github.com/cprezzi/grbl-LPC 2017-06-21 09:04:30 +02:00
Claudio Prezzi
ba4e83723f Added Links for Make Tool and ARM Toolchain. 2017-06-21 09:01:12 +02:00
Claudio Prezzi
14983881ee Added Links for Make and ARM Toolchain. 2017-06-21 08:58:57 +02:00
Claudio Prezzi
eeb206ec97 Adjusted config.h 2017-06-21 08:32:02 +02:00
cprezzi
83c1b57c41 Merge branch 'master' into more-axis 2017-05-26 20:23:51 +02:00
cprezzi
50c13a1868 Moved homing origin to bottom/left instead of top/right 2017-05-18 23:10:44 +02:00
cprezzi
8856b3fef4 Corrected K40 defaults 2017-05-18 16:45:59 +02:00
cprezzi
73cdb2f722 Corrected stepper invert mask for K40 2017-05-18 14:47:53 +02:00
cprezzi
b28fd39e7d Merge branch 'master' into more-axis 2017-05-18 12:51:28 +02:00
cprezzi
1f0ab33787 Merged new $ params 2017-05-18 12:47:37 +02:00
cprezzi
d85bfa8c83 Added default settings for PWM_OFF_VALUE, PWM_MIN_VALUE and PMW_MAX_VALUE 2017-05-18 11:51:16 +02:00
cprezzi
da946353c8 Merge remote-tracking branch 'upstream/master' 2017-05-16 15:03:18 +02:00
Todd Fleming
b1ecb47bec #4: PWM $ settings 2017-05-13 13:54:50 -04:00
cprezzi
f7083b9491 Added 4.axes (A) and moved default settings to defaults.h and cpu-map.h 2017-05-11 19:58:41 +02:00
33 changed files with 1335 additions and 662 deletions

21
DOCKER_LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Ryan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

32
DOCKER_README.md Normal file
View File

@ -0,0 +1,32 @@
# Arm Embedded Docker Environment
Minimal docker environment for building arm-embedded projects
## Usage
Run interactively with ```docker run -it --rm -v `pwd`:/root ryankurte/docker-arm-embedded /bin/bash```.
This will create a temporal instance (changes will be dropped on exit) with a binding from the current directory to the root user home directory.
If you are using selinux you may need to add a ```:z``` to the end of the -v parameter to indicate the mount is shared.
```docker run -it --rm -v `pwd`:/root:z ryankurte/docker-arm-embedded /bin/bash```
https://docs.docker.com/storage/bind-mounts/
### Building grbl-LPC
Update the grbl/config.h and uncomment the CPU_MAP define statement for the board you are compiling for
```
git submodule init
git submodule update
make
```
The resulting firmware file is build/firmware.bin
## Includes:
- build-essential (native)
- make, cmake
- gawk, genromfs, ccache
- arm-none-eabi from [launchpad.net](https://launchpad.net/~terry.guo/+archive/ubuntu/gcc-arm-embedded)
- [Yotta](http://yotta.mbed.com/)

62
Dockerfile Normal file
View File

@ -0,0 +1,62 @@
FROM ubuntu:latest
MAINTAINER Ryan Kurte <ryankurte@gmail.com>
LABEL Description="Docker image for building arm-embedded projects"
# General dependencies
RUN apt-get update && apt-get install -y \
git \
subversion \
curl \
cmake \
make \
automake \
autoconf \
python-setuptools \
ninja-build \
python-dev \
libtool \
unzip \
libffi-dev \
libssl-dev \
libusb-1.0.0 \
libusb-1.0.0-dev \
software-properties-common \
python-software-properties \
gawk \
genromfs \
ccache \
clang \
build-essential \
python3 \
python3-dev \
python3-pip \
libprotobuf-dev \
protobuf-compiler \
libprotobuf-c-dev \
protobuf-c-compiler \
python-protobuf
# arm-none-eabi custom ppa
RUN add-apt-repository ppa:team-gcc-arm-embedded/ppa && \
apt-get update && \
apt-get install -y gcc-arm-embedded
# Yotta
RUN easy_install pip && \
pip install yotta && \
mkdir -p /usr/local/lib/yotta_modules \
chown $USER /usr/local/lib/yotta_modules \
chmod 755 /usr/local/lib/yotta_modules
# Pyserial for serial programming
RUN pip install pyserial
# STLink util
RUN git clone https://github.com/texane/stlink.git && \
cd stlink && mkdir build && cd build && \
cmake .. && make && make install
# Cleanup
RUN apt-get clean && \
rm -rf /var/lib/apt

121
README.md
View File

@ -1,124 +1,17 @@
![GitHub Logo](https://github.com/gnea/gnea-Media/blob/master/Grbl%20Logo/Grbl%20Logo%20250px.png?raw=true)
***
_Click the `Release` tab to download pre-compiled `.bin` files or just [click here](https://github.com/cprezzi/grbl-LPC/releases)_
Old releases are in the `Release` tab. See [cprezzi's branch](https://github.com/cprezzi/grbl-LPC) for more recent releases.
Note: cprezzi's branch disables current control and has defaults more suitable for other boards.
***
This is GRBL 1.1 ported to the LPC1769. It can run on Smoothieboard.
Usage notes:
* This uses a different usb-serial driver than Smoothieware. Windows 10 should recognize it automatically.
If it doesn't, try installing VCOM_lib/usbser.inf.
* This doesn't pass the sdcard to the host. Once installed you need to use a micro sdcard adaptor to replace or change it.
* Only tested with lasers with PWM. Non-PWM spindle control not ported.
* This special version supports setting PWM frequency by $33. Default is 5000 Hz. Pin can only be changes in config.h.
* Pin 2.5
* 5 kHz
* PWM off value: 0%
* Mimimum PWM value: 0%
* Maximum PWM value: 100%
* These are defaults for easy-to-change config values.
* Maximum S value: 1000.0 ($30)
* Minimum S value: 0.0 ($31)
* Laser mode: 1 ($32)
* Laser PWM frequency: 5000 ($33)
* Hard limits not yet ported
* Control inputs not yet ported (e.g. Cycle Start and Safety Door switches)
-----
New configuration settings
* $33 is PWM frequency in Hz
* $140, $141, $142 are X, Y, Z current (amps)
* Default to 0.0 A to avoid burning out your motors
* Your motors will likely stall if you don't set these!
**Settings for MKS sbase 1.3 and CoreXY**
Build notes:
* Include ```make``` and the ```arm-none-eabi-*``` tools in your path.
* Run ```git submodule init``` and ```git submodule update``` before building.
* Make produces 2 files:
* ```build/firmware.bin```: this is compatible with the sdcard bootloader.
* ```build/grbl.hex```: this is not compatible with the sdcard bootloader. It loads using Flash Magic
and is primarilly for developers who don't want to keep swapping sdcards. If you flash this,
then you'll have to reflash the bootloader if you want to go back.
![Wiring 1](./doc/media/48491571-d99a3080-e862-11e8-8367-4408a5589503.png)
***
Grbl is a no-compromise, high performance, low cost alternative to parallel-port-based motion control for CNC milling. This version of Grbl runs on an Arduino with a 328p processor (Uno, Duemilanove, Nano, Micro, etc).
![Wiring 2](./doc/media/49279485-9aa2e680-f4c2-11e8-98bd-cce3caf5c8dd.jpeg)
The controller is written in highly optimized C utilizing every clever feature of the AVR-chips to achieve precise timing and asynchronous operation. It is able to maintain up to 30kHz of stable, jitter free control pulses.
It accepts standards-compliant g-code and has been tested with the output of several CAM tools with no problems. Arcs, circles and helical motion are fully supported, as well as, all other primary g-code commands. Macro functions, variables, and most canned cycles are not supported, but we think GUIs can do a much better job at translating them into straight g-code anyhow.
Grbl includes full acceleration management with look ahead. That means the controller will look up to 16 motions into the future and plan its velocities ahead to deliver smooth acceleration and jerk-free cornering.
* [Licensing](https://github.com/gnea/grbl/wiki/Licensing): Grbl is free software, released under the GPLv3 license.
* For more information and help, check out our **[Wiki pages!](https://github.com/gnea/grbl/wiki)** If you find that the information is out-dated, please to help us keep it updated by editing it or notifying our community! Thanks!
* Lead Developer: Sungeun "Sonny" Jeon, Ph.D. (USA) aka @chamnit
* Built on the wonderful Grbl v0.6 (2011) firmware written by Simen Svale Skogsrud (Norway).
***
### Official Supporters of the Grbl CNC Project
![Official Supporters](https://github.com/gnea/gnea-Media/blob/master/Contributors.png?raw=true)
***
## Update Summary for v1.1
- **IMPORTANT:** Your EEPROM will be wiped and restored with new settings. This is due to the addition of two new spindle speed '$' settings.
- **Real-time Overrides** : Alters the machine running state immediately with feed, rapid, spindle speed, spindle stop, and coolant toggle controls. This awesome new feature is common only on industrial machines, often used to optimize speeds and feeds while a job is running. Most hobby CNC's try to mimic this behavior, but usually have large amounts of lag. Grbl executes overrides in realtime and within tens of milliseconds.
- **Jogging Mode** : The new jogging commands are independent of the g-code parser, so that the parser state doesn't get altered and cause a potential crash if not restored properly. Documentation is included on how this works and how it can be used to control your machine via a joystick or rotary dial with a low-latency, satisfying response.
- **Laser Mode** : The new "laser" mode will cause Grbl to move continuously through consecutive G1, G2, and G3 commands with spindle speed changes. When "laser" mode is disabled, Grbl will instead come to a stop to ensure a spindle comes up to speed properly. Spindle speed overrides also work with laser mode so you can tweak the laser power, if you need to during the job. Switch between "laser" mode and "normal" mode via a `$` setting.
- **Dynamic Laser Power Scaling with Speed** : If your machine has low accelerations, Grbl will automagically scale the laser power based on how fast Grbl is traveling, so you won't have burnt corners when your CNC has to make a turn! Enabled by the `M4` spindle CCW command when laser mode is enabled!
- **Sleep Mode** : Grbl may now be put to "sleep" via a `$SLP` command. This will disable everything, including the stepper drivers. Nice to have when you are leaving your machine unattended and want to power down everything automatically. Only a reset exits the sleep state.
- **Significant Interface Improvements**: Tweaked to increase overall performance, include lots more real-time data, and to simplify maintaining and writing GUIs. Based on direct feedback from multiple GUI developers and bench performance testing. _NOTE: GUIs need to specifically update their code to be compatible with v1.1 and later._
- **New Status Reports**: To account for the additional override data, status reports have been tweaked to cram more data into it, while still being smaller than before. Documentation is included, outlining how it has been changed.
- **Improved Error/Alarm Feedback** : All Grbl error and alarm messages have been changed to providing a code. Each code is associated with a specific problem, so users will know exactly what is wrong without having to guess. Documentation and an easy to parse CSV is included in the repo.
- **Extended-ASCII realtime commands** : All overrides and future real-time commands are defined in the extended-ASCII character space. Unfortunately not easily type-able on a keyboard, but helps prevent accidental commands from a g-code file having these characters and gives lots of space for future expansion.
- **Message Prefixes** : Every message type from Grbl has a unique prefix to help GUIs immediately determine what the message is and parse it accordingly without having to know context. The prior interface had several instances of GUIs having to figure out the meaning of a message, which made everything more complicated than it needed to be.
- New OEM specific features, such as safety door parking, single configuration file build option, EEPROM restrictions and restoring controls, and storing product data information.
- New safety door parking motion as a compile-option. Grbl will retract, disable the spindle/coolant, and park near Z max. When resumed, it will perform these task in reverse order and continue the program. Highly configurable, even to add more than one parking motion. See config.h for details.
- New '$' Grbl settings for max and min spindle rpm. Allows for tweaking the PWM output to more closely match true spindle rpm. When max rpm is set to zero or less than min rpm, the PWM pin D11 will act like a simple enable on/off output.
- Updated G28 and G30 behavior from NIST to LinuxCNC g-code description. In short, if a intermediate motion is specified, only the axes specified will move to the stored coordinates, not all axes as before.
- Lots of minor bug fixes and refactoring to make the code more efficient and flexible.
- **NOTE:** Arduino Mega2560 support has been moved to an active, official Grbl-Mega [project](http://www.github.com/gnea/grbl-Mega/). All new developments here and there will be synced when it makes sense to.
-
```
List of Supported G-Codes in Grbl v1.1:
- Non-Modal Commands: G4, G10L2, G10L20, G28, G30, G28.1, G30.1, G53, G92, G92.1
- Motion Modes: G0, G1, G2, G3, G38.2, G38.3, G38.4, G38.5, G80
- Feed Rate Modes: G93, G94
- Unit Modes: G20, G21
- Distance Modes: G90, G91
- Arc IJK Distance Modes: G91.1
- Plane Select Modes: G17, G18, G19
- Tool Length Offset Modes: G43.1, G49
- Cutter Compensation Modes: G40
- Coordinate System Modes: G54, G55, G56, G57, G58, G59
- Control Modes: G61
- Program Flow: M0, M1, M2, M30*
- Coolant Control: M7*, M8, M9
- Spindle Control: M3, M4, M5
- Valid Non-Command Words: F, I, J, K, L, N, P, R, S, T, X, Y, Z
```
-------------
Grbl is an open-source project and fueled by the free-time of our intrepid administrators and altruistic users. If you'd like to donate, all proceeds will be used to help fund supporting hardware and testing equipment. Thank you!
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CUGXJHXA36BYW)
[Laser4Web .env Settings](https://github.com/LaserWeb/lw.comm-server/wiki/Environment-File-(.env))

View File

@ -51,6 +51,7 @@ $27=1.000
$30=1000.
$31=0.
$32=0
$33=5000
$100=250.000
$101=250.000
$102=250.000
@ -63,6 +64,9 @@ $122=10.000
$130=200.000
$131=200.000
$132=200.000
$140=0.000
$141=0.000
$142=0.000
```
#### $x=val - Save Grbl setting
@ -227,6 +231,10 @@ When enabled, Grbl will move continuously through consecutive `G1`, `G2`, or `G3
When disabled, Grbl will operate as it always has, stopping motion with every `S` spindle speed command. This is the default operation of a milling machine to allow a pause to let the spindle change speeds.
#### $33 - Spindle/Laser PWM frequency
This sets the PWM frequency.
#### $100, $101 and $102 [X,Y,Z] steps/mm
Grbl needs to know how far each step will take the tool in reality. To calculate steps/mm for an axis of your machine you need to know:

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
doc/media/Thumbs.db Normal file

Binary file not shown.

View File

@ -55,7 +55,7 @@ void current_init()
set_current(0, settings.current[0]);
set_current(1, settings.current[1]);
set_current(2, settings.current[2]);
set_current(3, DEFAULT_A_CURRENT);
set_current(3, settings.current[3]);
#endif
}

View File

@ -22,11 +22,11 @@
void delay_init()
{
LPC_TIM3->CTCR = 0; // timer mode
LPC_TIM3->PR = 0; // no prescale
LPC_TIM3->MCR = 0; // no MR actions
LPC_TIM3->CCR = 0; // no capture
LPC_TIM3->EMR = 0; // no external match
LPC_TIM3->TCR = 0b10; // reset
LPC_TIM3->TCR = 0b01; // enable
LPC_TIM3->CTCR = 0; // Count Control (0=TimerMode, 1-3=EdgeCounterMode)
LPC_TIM3->PR = 0; // no Prescale (TC increments ever PR+1 clocks)
LPC_TIM3->MCR = 0; // no Match Control actions
LPC_TIM3->CCR = 0; // no Capture Control actions
LPC_TIM3->EMR = 0; // no External Match (controls external match pins)
LPC_TIM3->TCR = 0b10; // reset Timer Control (0b10=Reset, 0b01=Enable)
LPC_TIM3->TCR = 0b01; // enable Timer Control (0b10=Reset, 0b01=Enable)
}

View File

@ -25,37 +25,38 @@ static constexpr unsigned flash_addr = 0xF000; // Last 4k sec
static constexpr unsigned flash_size = 1024; // Only using 1k of a 4k sector
static char *flash_memory = (char *)flash_addr; // Flash memory
static char flash_buffer[flash_size] __attribute__((aligned(4))); // Copy of flash memory
using Iap = void(unsigned[], unsigned[]); // IAP entry point
static const Iap *iap = (Iap *)0x1FFF1FF1; // IAP entry point
using Iap = void(unsigned[], unsigned[]); // IAP entry point function
static const Iap *iap = (Iap *)0x1FFF1FF1; // IAP entry point address
void eeprom_init()
{
memcpy(flash_buffer, flash_memory, flash_size);
memcpy(flash_buffer, flash_memory, flash_size); // Copy flash memory into local flash buffer
}
void eeprom_commit()
{
if (!memcmp(flash_buffer, flash_memory, flash_size))
return;
return; // No changes to commit
unsigned prepCommand[5] = {
50,
flash_sector,
flash_sector,
50, // Prepare sector(s) for write operation
flash_sector, // Start sector
flash_sector, // End sector
};
unsigned eraseCommand[5] = {
52,
flash_sector,
flash_sector,
SystemCoreClock / 1000,
52, // Erase sector(s)
flash_sector, // Start sector
flash_sector, // End sector
SystemCoreClock / 1000, // CPU clock frequency in kHz
};
unsigned writeCommand[5] = {
51,
flash_addr,
(unsigned)flash_buffer,
flash_size,
SystemCoreClock / 1000,
51, // Copy RAM to Flash
flash_addr, // Destination flash address (256-byte boundary)
(unsigned)flash_buffer, // Source RAM address (word boundary)
flash_size, // Number of bytes to write (must be: 256, 512, 1024, 4096)
SystemCoreClock / 1000, // CPU clock frequency in kHz
};
unsigned output[5];
// Run In-Application Programming (IAP) routines
iap(prepCommand, output);
iap(eraseCommand, output);
iap(prepCommand, output);

View File

@ -31,12 +31,22 @@
#include "LPC17xx.h"
// Define CPU pin map and default settings.
// NOTE: OEMs can avoid the need to maintain/update the defaults.h and cpu_map.h files and use only
// one configuration file by placing their specific defaults and pin map at the bottom of this file.
// If doing so, simply comment out these two defines and see instructions below.
// #define DEFAULTS_GENERIC
// #define CPU_MAP_ATMEGA328P // Arduino Uno CPU
// Define board type for pin map and default settings.
//#define CPU_MAP_SMOOTHIEBOARD // Smoothieboard (NXP LPC1769 MCU)
//#define CPU_MAP_C3D_REMIX // Cohesion3D Remix (NXP LPC1769 MCU)
//#define CPU_MAP_C3D_MINI // Cohesion3D Mini (NXP LPC1769 MCU)
#define CPU_MAP_MKS_SBASE // MKS SBASE Board (NXP LPC1768 MCU)
//#define CPU_MAP_AZTEEG_X5 // Azteeg X5 Board (NXP LPC1769 MCU)
// Force other Spindle PWM Pin (default is P2.5)
//#define SPINDLE_PWM_PIN_1_23
//#define SPINDLE_PWM_PIN_2_4
// Define machine type for machine specific defaults
//#define DEFAULTS_GENERIC
#define DEFAULTS_K40
//#define DEFAULTS_FABKIT
//#define DEFAULTS_JONAS
// Serial baud rate
// #define BAUD_RATE 230400
@ -103,18 +113,19 @@
// on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits
// will not be affected by pin sharing.
// NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y.
//#define HOMING_CYCLE_0 (1<<Z_AXIS) // REQUIRED: First move Z to clear workspace.
//#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) // OPTIONAL: Then move X,Y at the same time.
// NOTE: Homing cycle pattern is defined in Machine defaults!!!
// #define HOMING_CYCLE_0 (1<<Z_AXIS) // REQUIRED: First move Z to clear workspace.
// #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) // OPTIONAL: Then move X,Y at the same time.
// #define HOMING_CYCLE_2 // OPTIONAL: Uncomment and add axes mask to enable
// NOTE: The following are two examples to setup homing for 2-axis machines.
#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS)) // NOT COMPATIBLE WITH COREXY: Homes both X-Y in one cycle.
// #define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS)) // NOT COMPATIBLE WITH COREXY: Homes both X-Y in one cycle.
// #define HOMING_CYCLE_0 (1<<X_AXIS) // COREXY COMPATIBLE: First home X
// #define HOMING_CYCLE_1 (1<<Y_AXIS) // COREXY COMPATIBLE: Then home Y
// Number of homing cycles performed after when the machine initially jogs to limit switches.
// This help in preventing overshoot and should improve repeatability. This value should be one or
// This helps in preventing overshoot and should improve repeatability. This value should be one or
// greater.
#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128)
@ -129,6 +140,9 @@
// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
// Uncomment this define to force Grbl to always set the machine origin at bottom left.
#define HOMING_FORCE_POSITIVE_SPACE // Uncomment to enable.
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
// be stored and executed in order. These startup blocks would typically be used to set the g-code
@ -167,13 +181,13 @@
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
// analog pin 4. Only use this option if you require a second coolant control pin.
// NOTE: The M8 flood coolant control pin on analog pin 3 will still be functional regardless.
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
//#define ENABLE_M7 // Disabled by default. Uncomment to enable.
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
// previous tool path, as if nothing happened.
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
//#define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
// After the safety door switch has been toggled and restored, this setting sets the power-up delay
// between restoring the spindle and coolant and resuming the cycle.
@ -187,7 +201,7 @@
// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as
// described, if not, motions may move in strange directions. Grbl requires the CoreXY A and B motors
// have the same steps per mm internally.
// #define COREXY // Default disabled. Uncomment to enable.
#define COREXY // Default disabled. Uncomment to enable.
// Inverts pin logic of the control command pins based on a mask. This essentially means you can use
// normally-closed switches on the specified pins, rather than the default normally-open switches.
@ -209,7 +223,7 @@
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
// not ported #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
#define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.
// Inverts the selected coolant pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
// for some pre-built electronic boards.
@ -359,11 +373,6 @@
// pwm = scaled value. settings.rpm_min scales to SPINDLE_PWM_MIN_VALUE. settings.rpm_max
// scales to SPINDLE_PWM_MAX_VALUE.
//#define SPINDLE_PWM_PERIOD (SystemCoreClock / 40000) // SystemCoreClock / frequency
#define SPINDLE_PWM_OFF_VALUE 0.0 // SPINDLE_PWM_PERIOD * fraction
//#define SPINDLE_PWM_MIN_VALUE (SPINDLE_PWM_PERIOD * 0.0) // SPINDLE_PWM_PERIOD * fraction
//#define SPINDLE_PWM_MAX_VALUE (SPINDLE_PWM_PERIOD * 1.0) // SPINDLE_PWM_PERIOD * fraction
// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled.
// The PWM pin will still read 0V when the spindle is disabled. Most users will not need this option, but
// it may be useful in certain scenarios. This minimum PWM settings coincides with the spindle rpm minimum
@ -377,13 +386,13 @@
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
// NOTE: Without a direction pin, M4 will not have a pin output to indicate a difference with M3.
// the spindle direction pin (defined in cpu-map.h) as a separate spindle enable pin along with spindle speed PWM pin.
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled.
// NOTE: Without a direction pin, M4 will not have a pin output to indicate a difference with M3.
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
// not ported #define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
#define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.
// Alters the behavior of the spindle enable pin with the USE_SPINDLE_DIR_AS_ENABLE_PIN option . By default,
// Grbl will not disable the enable pin if spindle speed is zero and M3/4 is active, but still sets the PWM
@ -565,7 +574,7 @@
// LPC176x flash blocks have a rating of 10,000 write cycles. To prevent excess wear, we don't
// write G10, G28.1, and G30.1. Uncomment to enable these writes.
// #define STORE_COORD_DATA // Default disabled. Uncomment to enable.
#define STORE_COORD_DATA // Default disabled. Uncomment to enable.
// In Grbl v0.9 and prior, there is an old outstanding bug where the `WPos:` work position reported
// may not correlate to what is executing, because `WPos:` is based on the g-code parser state, which
@ -629,154 +638,5 @@
below.
*/
// Paste CPU_MAP definitions here.
// Define serial port pins and interrupt vectors.
#define SERIAL_RX USART_RX_vect
#define SERIAL_UDRE USART_UDRE_vect
// Define step pulse output pins. NOTE: All step bit pins must be on the same port.
#define STEP_DDR LPC_GPIO2->FIODIR
#define STEP_PORT LPC_GPIO2->FIOPIN
#define X_STEP_BIT 0
#define Y_STEP_BIT 1
#define Z_STEP_BIT 2
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)) // All step bits
// Define step direction output pins. NOTE: All direction pins must be on the same port.
#define DIRECTION_DDR LPC_GPIO0->FIODIR
#define DIRECTION_PORT LPC_GPIO0->FIOPIN
#define X_DIRECTION_BIT 5
#define Y_DIRECTION_BIT 11
#define Z_DIRECTION_BIT 20
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) // All direction bits
// Define stepper driver enable/disable output pin.
#define STEPPERS_DISABLE_DDR LPC_GPIO0->FIODIR
#define STEPPERS_DISABLE_PORT LPC_GPIO0->FIOPIN
#define X_DISABLE_BIT 4
#define Y_DISABLE_BIT 10
#define Z_DISABLE_BIT 19
#define STEPPERS_DISABLE_MASK ((1<<X_DISABLE_BIT)|(1<<Y_DISABLE_BIT)|(1<<Z_DISABLE_BIT))
// Define homing/hard limit switch input pins and limit interrupt vectors.
// NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (CONTROL).
#define LIMIT_DDR LPC_GPIO1->FIODIR
#define LIMIT_PIN LPC_GPIO1->FIOPIN
#define LIMIT_PORT LPC_GPIO1->FIOPIN
#define X_LIMIT_BIT 24 // X-MIN=24, X-MAX=25
#define Y_LIMIT_BIT 27 // Y-MIN=26, Y-MAX=27
#define Z_LIMIT_BIT 29 // Z-MIN=28, Z-MAX=29
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)) //|(1<<Z_LIMIT_BIT)) // All limit bits
// hard limits not ported #define LIMIT_INT PCIE0 // Pin change interrupt enable pin
// hard limits not ported #define LIMIT_INT_vect PCINT0_vect
// hard limits not ported #define LIMIT_PCMSK PCMSK0 // Pin change interrupt register
// Define spindle enable and spindle direction output pins.
/* not ported
#define SPINDLE_ENABLE_DDR DDRB
#define SPINDLE_ENABLE_PORT PORTB
// Z Limit pin and spindle PWM/enable pin swapped to access hardware PWM on Pin 11.
#ifdef VARIABLE_SPINDLE
#ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
// If enabled, spindle direction pin now used as spindle enable, while PWM remains on D11.
#define SPINDLE_ENABLE_BIT 5 // Uno Digital Pin 13 (NOTE: D13 can't be pulled-high input due to LED.)
#else
#define SPINDLE_ENABLE_BIT 3 // Uno Digital Pin 11
#endif
#else
#define SPINDLE_ENABLE_BIT 4 // Uno Digital Pin 12
#endif
#ifndef USE_SPINDLE_DIR_AS_ENABLE_PIN
#define SPINDLE_DIRECTION_DDR DDRB
#define SPINDLE_DIRECTION_PORT PORTB
#define SPINDLE_DIRECTION_BIT 5 // Uno Digital Pin 13 (NOTE: D13 can't be pulled-high input due to LED.)
#endif
*/
// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_DDR NotUsed
#define COOLANT_FLOOD_PORT NotUsed
#define COOLANT_FLOOD_BIT 3 // Uno Analog Pin 3
#define COOLANT_MIST_DDR NotUsed
#define COOLANT_MIST_PORT NotUsed
#define COOLANT_MIST_BIT 4 // Uno Analog Pin 3
// Define user-control controls (cycle start, reset, feed hold) input pins.
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
#define CONTROL_DDR NotUsed
#define CONTROL_PIN NotUsed
#define CONTROL_PORT NotUsed
#define CONTROL_RESET_BIT 0 // Uno Analog Pin 0
#define CONTROL_FEED_HOLD_BIT 1 // Uno Analog Pin 1
#define CONTROL_CYCLE_START_BIT 2 // Uno Analog Pin 2
#define CONTROL_SAFETY_DOOR_BIT 1 // Uno Analog Pin 1 NOTE: Safety door is shared with feed hold. Enabled by config define.
#define CONTROL_INT PCIE1 // Pin change interrupt enable pin
#define CONTROL_INT_vect PCINT1_vect
#define CONTROL_PCMSK NotUsed // Pin change interrupt register
#define CONTROL_MASK ((1<<CONTROL_RESET_BIT)|(1<<CONTROL_FEED_HOLD_BIT)|(1<<CONTROL_CYCLE_START_BIT)|(1<<CONTROL_SAFETY_DOOR_BIT))
#define CONTROL_INVERT_MASK CONTROL_MASK // May be re-defined to only invert certain control pins.
// Define probe switch input pin.
#define PROBE_DDR NotUsed
#define PROBE_PIN NotUsed
#define PROBE_PORT NotUsed
#define PROBE_BIT 5 // Uno Analog Pin 5
#define PROBE_MASK (1<<PROBE_BIT)
// The LPC17xx has 6 PWM channels. Each channel has 2 pins. It can drive both pins simultaneously to the same value.
//
// PWM Channel PWM1_CH1 PWM1_CH2 PWM1_CH3 PWM1_CH4 PWM1_CH5 PWM1_CH6
// Primary pin P1.18 P1.20 P1.21 P1.23 P1.24 P1.26
// Secondary pin P2.0 P2.1 P2.2 P2.3 P2.4 P2.5
#define SPINDLE_PWM_CHANNEL PWM1_CH6
#define SPINDLE_PWM_USE_PRIMARY_PIN false
#define SPINDLE_PWM_USE_SECONDARY_PIN true
// Stepper current control
//#define CURRENT_I2C Driver_I2C1 // I2C driver for current control. Comment out to disable.
#define CURRENT_MCP44XX_ADDR 0b0101100 // Address of MCP44XX
#define CURRENT_WIPERS {0, 1, 6, 7}; // Wiper registers (X, Y, Z, A)
#define CURRENT_FACTOR 113.33 // Convert amps to digipot value
// Paste default settings definitions here.
#define DEFAULT_X_STEPS_PER_MM 160.0
#define DEFAULT_Y_STEPS_PER_MM 160.0
#define DEFAULT_Z_STEPS_PER_MM 160.0
#define DEFAULT_X_MAX_RATE 24000 // mm/min
#define DEFAULT_Y_MAX_RATE 24000 // mm/min
#define DEFAULT_Z_MAX_RATE 24000 // mm/min
#define DEFAULT_X_ACCELERATION (2500.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2
#define DEFAULT_Y_ACCELERATION (2500.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2
#define DEFAULT_Z_ACCELERATION (2500.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2
#define DEFAULT_X_CURRENT 0.0 // amps
#define DEFAULT_Y_CURRENT 0.0 // amps
#define DEFAULT_Z_CURRENT 0.0 // amps
#define DEFAULT_A_CURRENT 0.0 // amps
#define DEFAULT_X_MAX_TRAVEL 300.0 // mm
#define DEFAULT_Y_MAX_TRAVEL 200.0 // mm
#define DEFAULT_Z_MAX_TRAVEL 50.0 // mm
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
#define DEFAULT_STEPPING_INVERT_MASK 0
#define DEFAULT_DIRECTION_INVERT_MASK 0
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 0 // WPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
#define DEFAULT_INVERT_ST_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 1 // false
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_PROBE_PIN 0 // false
#define DEFAULT_LASER_MODE 1 // true
#define DEFAULT_HOMING_ENABLE 0 // false
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
#define DEFAULT_HOMING_FEED_RATE 50.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 6000.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif

View File

@ -64,6 +64,7 @@ void coolant_stop()
#else
COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT);
#endif
delay_ms(1); // workaround for toolchain error
#ifdef ENABLE_M7
#ifdef INVERT_COOLANT_MIST_PIN
COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT);
@ -95,6 +96,7 @@ void coolant_set_state(uint8_t mode)
COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT);
#endif
}
delay_ms(1); // workaround for toolchain error
#ifdef ENABLE_M7
if (mode & COOLANT_MIST_ENABLE) {

View File

@ -63,7 +63,7 @@
#define X_LIMIT_BIT 1 // Uno Digital Pin 9
#define Y_LIMIT_BIT 2 // Uno Digital Pin 10
#ifdef VARIABLE_SPINDLE // Z Limit pin and spindle enabled swapped to access hardware PWM on Pin 11.
#define Z_LIMIT_BIT 4 // Uno Digital Pin 12
#define Z_LIMIT_BIT 4 // Uno Digital Pin 12
#else
#define Z_LIMIT_BIT 3 // Uno Digital Pin 11
#endif
@ -96,9 +96,9 @@
#define COOLANT_FLOOD_DDR DDRC
#define COOLANT_FLOOD_PORT PORTC
#define COOLANT_FLOOD_BIT 3 // Uno Analog Pin 3
#define COOLANT_MIST_DDR DDRC
#define COOLANT_MIST_PORT PORTC
#define COOLANT_MIST_BIT 4 // Uno Analog Pin 4
#define COOLANT_MIST_DDR DDRC
#define COOLANT_MIST_PORT PORTC
#define COOLANT_MIST_BIT 4 // Uno Analog Pin 4
// Define user-control controls (cycle start, reset, feed hold) input pins.
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
@ -130,10 +130,10 @@
#endif
#define SPINDLE_PWM_OFF_VALUE 0
#define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)
#define SPINDLE_TCCRA_REGISTER TCCR2A
#define SPINDLE_TCCRB_REGISTER TCCR2B
#define SPINDLE_TCCRA_REGISTER TCCR2A
#define SPINDLE_TCCRB_REGISTER TCCR2B
#define SPINDLE_OCR_REGISTER OCR2A
#define SPINDLE_COMB_BIT COM2A1
#define SPINDLE_COMB_BIT COM2A1
// Prescaled, 8-bit Fast PWM mode.
#define SPINDLE_TCCRA_INIT_MASK ((1<<WGM20) | (1<<WGM21)) // Configures fast PWM mode.
@ -143,11 +143,567 @@
#define SPINDLE_TCCRB_INIT_MASK (1<<CS22) // 1/64 prescaler -> 0.98kHz (J-tech laser)
// NOTE: On the 328p, these must be the same as the SPINDLE_ENABLE settings.
#define SPINDLE_PWM_DDR DDRB
#define SPINDLE_PWM_PORT PORTB
#define SPINDLE_PWM_BIT 3 // Uno Digital Pin 11
#define SPINDLE_PWM_DDR DDRB
#define SPINDLE_PWM_PORT PORTB
#define SPINDLE_PWM_BIT 3 // Uno Digital Pin 11
#endif // end of CPU_MAP_ATMEGA328P
#ifdef CPU_MAP_SMOOTHIEBOARD // (Smoothieboards)
// Define serial port pins and interrupt vectors.
#define SERIAL_RX USART_RX_vect
#define SERIAL_UDRE USART_UDRE_vect
// Define step pulse output pins. NOTE: All step bit pins must be on the same port.
#define STEP_DDR LPC_GPIO2->FIODIR
#define STEP_PORT LPC_GPIO2->FIOPIN
#define X_STEP_BIT 0
#define Y_STEP_BIT 1
#define Z_STEP_BIT 2
#define A_STEP_BIT 3
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)|(1<<A_STEP_BIT)) // All step bits
// Define step direction output pins. NOTE: All direction pins must be on the same port.
#define DIRECTION_DDR LPC_GPIO0->FIODIR
#define DIRECTION_PORT LPC_GPIO0->FIOPIN
#define X_DIRECTION_BIT 5
#define Y_DIRECTION_BIT 11
#define Z_DIRECTION_BIT 20
#define A_DIRECTION_BIT 22
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)|(1<<A_DIRECTION_BIT)) // All direction bits
// Define stepper driver enable/disable output pin.
#define STEPPERS_DISABLE_DDR LPC_GPIO0->FIODIR
#define STEPPERS_DISABLE_PORT LPC_GPIO0->FIOPIN
#define X_DISABLE_BIT 4
#define Y_DISABLE_BIT 10
#define Z_DISABLE_BIT 19
#define A_DISABLE_BIT 21
#define STEPPERS_DISABLE_MASK ((1<<X_DISABLE_BIT)|(1<<Y_DISABLE_BIT)|(1<<Z_DISABLE_BIT)|(1<<A_DISABLE_BIT))
// Define homing/hard limit switch input pins and limit interrupt vectors.
// NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (CONTROL).
#define LIMIT_DDR LPC_GPIO1->FIODIR
#define LIMIT_PIN LPC_GPIO1->FIOPIN
#define LIMIT_PORT LPC_GPIO1->FIOPIN
#define X_LIMIT_BIT 24 // X-MIN=24, X-MAX=25
#define Y_LIMIT_BIT 26 // Y-MIN=26, Y-MAX=27
#define Z_LIMIT_BIT 28 // Z-MIN=28, Z-MAX=29
#define A_LIMIT_BIT 29 // reuse Z-MAX (P1.29)
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)|(1<<A_LIMIT_BIT)) // All limit bits
// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_DDR LPC_GPIO1->FIODIR
#define SPINDLE_ENABLE_PORT LPC_GPIO1->FIOPIN
#define SPINDLE_ENABLE_BIT 30 // P1.30
#define SPINDLE_DIRECTION_DDR LPC_GPIO1->FIODIR
#define SPINDLE_DIRECTION_PORT LPC_GPIO1->FIOPIN
#define SPINDLE_DIRECTION_BIT 31 // P1.31
// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_DDR LPC_GPIO2->FIODIR
#define COOLANT_FLOOD_PORT LPC_GPIO2->FIOPIN
#ifndef SPINDLE_PWM_PIN_2_4
#define COOLANT_FLOOD_BIT 4 // SMALL MOSFET Q8 (P2.4)
#else
#define COOLANT_FLOOD_BIT 5 // SMALL MOSFET Q8 (P2.5)
#endif
#define COOLANT_MIST_DDR LPC_GPIO2->FIODIR
#define COOLANT_MIST_PORT LPC_GPIO2->FIOPIN
#define COOLANT_MIST_BIT 6 // SMALL MOSFET Q9 (P2.6)
#define ENABLE_M7 // enables COOLANT MIST
// Define user-control controls (cycle start, reset, feed hold) input pins.
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
#define CONTROL_DDR LPC_GPIO1->FIODIR
#define CONTROL_PIN LPC_GPIO1->FIOPIN
#define CONTROL_PORT LPC_GPIO1->FIOPIN
#define CONTROL_RESET_BIT NotUsed // Not needed as there is a special RESET pin on the Smoothiebaord
#define CONTROL_FEED_HOLD_BIT 22 // P1.22
#define CONTROL_CYCLE_START_BIT 23 // P1.23
#define CONTROL_SAFETY_DOOR_BIT 22 // P1.22 NOTE: Safety door is shared with feed hold. Enabled by config define.
#define CONTROL_INT PCIE1 // Pin change interrupt enable pin
#define CONTROL_INT_vect PCINT1_vect
#define CONTROL_PCMSK NotUsed // Pin change interrupt register
#define CONTROL_MASK ((1<<CONTROL_RESET_BIT)|(1<<CONTROL_FEED_HOLD_BIT)|(1<<CONTROL_CYCLE_START_BIT)|(1<<CONTROL_SAFETY_DOOR_BIT))
#define CONTROL_INVERT_MASK CONTROL_MASK // May be re-defined to only invert certain control pins.
// Define probe switch input pin.
#define PROBE_DDR LPC_GPIO2->FIODIR
#define PROBE_PIN LPC_GPIO2->FIOPIN
#define PROBE_PORT LPC_GPIO2->FIOPIN
#define PROBE_BIT 11 // P2.11
#define PROBE_MASK (1<<PROBE_BIT)
// The LPC17xx has 6 PWM channels. Each channel has 2 pins. It can drive both pins simultaneously to the same value.
//
// PWM Channel PWM1_CH1 PWM1_CH2 PWM1_CH3 PWM1_CH4 PWM1_CH5 PWM1_CH6
// Primary pin P1.18 P1.20 P1.21 P1.23 P1.24 P1.26
// Secondary pin P2.0 P2.1 P2.2 P2.3 P2.4 P2.5
#ifdef SPINDLE_PWM_PIN_2_4
#define SPINDLE_PWM_CHANNEL PWM1_CH5 // MOSFET3 (P2.4)
#else
#define SPINDLE_PWM_CHANNEL PWM1_CH6 // BED MOSFET (P2.5)
#endif
#define SPINDLE_PWM_USE_PRIMARY_PIN false
#define SPINDLE_PWM_USE_SECONDARY_PIN true
// Stepper current control
#define CURRENT_I2C Driver_I2C1 // I2C driver for current control. Comment out to disable (for C3d boards!)
#define CURRENT_MCP44XX_ADDR 0b0101100 // Address of MCP44XX
#define CURRENT_WIPERS {0, 1, 6, 7}; // Wiper registers (X, Y, Z, A)
#define CURRENT_FACTOR 113.33 // Convert amps to digipot value
// Variable spindle configuration below. Do not change unless you know what you are doing.
// NOTE: Only used when variable spindle is enabled.
#define SPINDLE_PWM_MAX_VALUE 255 // Don't change. 328p fast PWM mode fixes top value as 255.
#ifndef SPINDLE_PWM_MIN_VALUE
#define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif
//#define SPINDLE_PWM_OFF_VALUE 0 // Defined in config.h
#define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)
#define SPINDLE_TCCRA_REGISTER TCCR2A
#define SPINDLE_TCCRB_REGISTER TCCR2B
#define SPINDLE_OCR_REGISTER OCR2A
#define SPINDLE_COMB_BIT COM2A1
#endif // end of CPU_MAP_SMOOTHIEBOARD
#ifdef CPU_MAP_C3D_REMIX // (Cohesion3D Remix Boards)
// Define serial port pins and interrupt vectors.
#define SERIAL_RX USART_RX_vect
#define SERIAL_UDRE USART_UDRE_vect
// Define step pulse output pins. NOTE: All step bit pins must be on the same port.
#define STEP_DDR LPC_GPIO2->FIODIR
#define STEP_PORT LPC_GPIO2->FIOPIN
#define X_STEP_BIT 0
#define Y_STEP_BIT 1
#define Z_STEP_BIT 2
#define A_STEP_BIT 3
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)|(1<<A_STEP_BIT)) // All step bits
// Define step direction output pins. NOTE: All direction pins must be on the same port.
#define DIRECTION_DDR LPC_GPIO0->FIODIR
#define DIRECTION_PORT LPC_GPIO0->FIOPIN
#define X_DIRECTION_BIT 5
#define Y_DIRECTION_BIT 11
#define Z_DIRECTION_BIT 20
#define A_DIRECTION_BIT 22
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)|(1<<A_DIRECTION_BIT)) // All direction bits
// Define stepper driver enable/disable output pin.
#define STEPPERS_DISABLE_DDR LPC_GPIO0->FIODIR
#define STEPPERS_DISABLE_PORT LPC_GPIO0->FIOPIN
#define X_DISABLE_BIT 4
#define Y_DISABLE_BIT 10
#define Z_DISABLE_BIT 19
#define A_DISABLE_BIT 21
#define STEPPERS_DISABLE_MASK ((1<<X_DISABLE_BIT)|(1<<Y_DISABLE_BIT)|(1<<Z_DISABLE_BIT)|(1<<A_DISABLE_BIT))
// Define homing/hard limit switch input pins and limit interrupt vectors.
// NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (CONTROL).
#define LIMIT_DDR LPC_GPIO1->FIODIR
#define LIMIT_PIN LPC_GPIO1->FIOPIN
#define LIMIT_PORT LPC_GPIO1->FIOPIN
#define X_LIMIT_BIT 24 // X-MIN=24, X-MAX=25
#define Y_LIMIT_BIT 26 // Y-MIN=26, Y-MAX=27
#define Z_LIMIT_BIT 28 // Z-MIN=28, Z-MAX=29
#define A_LIMIT_BIT 29 // reuse p1.29 from Z-MAX
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)|(1<<A_LIMIT_BIT)) // All limit bits
// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_DDR LPC_GPIO2->FIODIR
#define COOLANT_FLOOD_PORT LPC_GPIO2->FIOPIN
#define COOLANT_FLOOD_BIT 6 // MOSFET 2.6
#define COOLANT_MIST_DDR LPC_GPIO2->FIODIR
#define COOLANT_MIST_PORT LPC_GPIO2->FIOPIN
#define COOLANT_MIST_BIT 7 // MOSFET 2.7
#define ENABLE_M7 // enables COOLANT MIST
// Define user-control controls (cycle start, reset, feed hold) input pins.
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
#define CONTROL_DDR NotUsed
#define CONTROL_PIN NotUsed
#define CONTROL_PORT NotUsed
#define CONTROL_RESET_BIT 0 // Uno Analog Pin 0
#define CONTROL_FEED_HOLD_BIT 1 // Uno Analog Pin 1
#define CONTROL_CYCLE_START_BIT 2 // Uno Analog Pin 2
#define CONTROL_SAFETY_DOOR_BIT 1 // Uno Analog Pin 1 NOTE: Safety door is shared with feed hold. Enabled by config define.
#define CONTROL_INT PCIE1 // Pin change interrupt enable pin
#define CONTROL_INT_vect PCINT1_vect
#define CONTROL_PCMSK NotUsed // Pin change interrupt register
#define CONTROL_MASK ((1<<CONTROL_RESET_BIT)|(1<<CONTROL_FEED_HOLD_BIT)|(1<<CONTROL_CYCLE_START_BIT)|(1<<CONTROL_SAFETY_DOOR_BIT))
#define CONTROL_INVERT_MASK CONTROL_MASK // May be re-defined to only invert certain control pins.
// Define probe switch input pin.
#define PROBE_DDR NotUsed
#define PROBE_PIN NotUsed
#define PROBE_PORT NotUsed
#define PROBE_BIT 5 // Uno Analog Pin 5
#define PROBE_MASK (1<<PROBE_BIT)
// The LPC17xx has 6 PWM channels. Each channel has 2 pins. It can drive both pins simultaneously to the same value.
//
// PWM Channel PWM1_CH1 PWM1_CH2 PWM1_CH3 PWM1_CH4 PWM1_CH5 PWM1_CH6
// Primary pin P1.18 P1.20 P1.21 P1.23 P1.24 P1.26
// Secondary pin P2.0 P2.1 P2.2 P2.3 P2.4 P2.5
#ifdef SPINDLE_PWM_PIN_2_4
#define SPINDLE_PWM_CHANNEL PWM1_CH5 // MOSFET3 (P2.4)
#else
#define SPINDLE_PWM_CHANNEL PWM1_CH6 // BED MOSFET (P2.5)
#endif
#define SPINDLE_PWM_USE_PRIMARY_PIN false
#define SPINDLE_PWM_USE_SECONDARY_PIN true
// Variable spindle configuration below. Do not change unless you know what you are doing.
// NOTE: Only used when variable spindle is enabled.
#define SPINDLE_PWM_MAX_VALUE 255 // Don't change. 328p fast PWM mode fixes top value as 255.
#ifndef SPINDLE_PWM_MIN_VALUE
#define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif
//#define SPINDLE_PWM_OFF_VALUE 0 // Defined in config.h
#define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)
#define SPINDLE_TCCRA_REGISTER TCCR2A
#define SPINDLE_TCCRB_REGISTER TCCR2B
#define SPINDLE_OCR_REGISTER OCR2A
#define SPINDLE_COMB_BIT COM2A1
#endif // end of CPU_MAP_C3D_REMIX
#ifdef CPU_MAP_C3D_MINI // (Cohesion3D Mini Boards)
// Define serial port pins and interrupt vectors.
#define SERIAL_RX USART_RX_vect
#define SERIAL_UDRE USART_UDRE_vect
// Define step pulse output pins. NOTE: All step bit pins must be on the same port.
#define STEP_DDR LPC_GPIO2->FIODIR
#define STEP_PORT LPC_GPIO2->FIOPIN
#define X_STEP_BIT 0
#define Y_STEP_BIT 1
#define Z_STEP_BIT 2
#define A_STEP_BIT 3
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)|(1<<A_STEP_BIT)) // All step bits
// Define step direction output pins. NOTE: All direction pins must be on the same port.
#define DIRECTION_DDR LPC_GPIO0->FIODIR
#define DIRECTION_PORT LPC_GPIO0->FIOPIN
#define X_DIRECTION_BIT 5
#define Y_DIRECTION_BIT 11
#define Z_DIRECTION_BIT 20
#define A_DIRECTION_BIT 22
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)|(1<<A_DIRECTION_BIT)) // All direction bits
// Define stepper driver enable/disable output pin.
#define STEPPERS_DISABLE_DDR LPC_GPIO0->FIODIR
#define STEPPERS_DISABLE_PORT LPC_GPIO0->FIOPIN
#define X_DISABLE_BIT 4
#define Y_DISABLE_BIT 10
#define Z_DISABLE_BIT 19
#define A_DISABLE_BIT 21
#define STEPPERS_DISABLE_MASK ((1<<X_DISABLE_BIT)|(1<<Y_DISABLE_BIT)|(1<<Z_DISABLE_BIT)|(1<<A_DISABLE_BIT))
// Define homing/hard limit switch input pins and limit interrupt vectors.
// NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (CONTROL).
#define LIMIT_DDR LPC_GPIO1->FIODIR
#define LIMIT_PIN LPC_GPIO1->FIOPIN
#define LIMIT_PORT LPC_GPIO1->FIOPIN
#define X_LIMIT_BIT 24 // X-MIN=24, X-MAX=25
#define Y_LIMIT_BIT 26 // Y-MIN=26, Y-MAX=27
#define Z_LIMIT_BIT 28 // Z-MIN=28, Z-MAX=29
#define A_LIMIT_BIT 29 // reuse p1.29 from Z-MAX
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)|(1<<A_LIMIT_BIT)) // All limit bits
// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_DDR NotUsed
#define COOLANT_FLOOD_PORT NotUsed
#define COOLANT_FLOOD_BIT 6 // MOSFET 3 (P2.6)
#define COOLANT_MIST_DDR LPC_GPIO2->FIODIR
#define COOLANT_MIST_PORT LPC_GPIO2->FIOPIN
#define COOLANT_MIST_BIT 7 // MOSFET 2 (P2.7)
#define ENABLE_M7 // enables COOLANT MIST
// Define user-control controls (cycle start, reset, feed hold) input pins.
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
#define CONTROL_DDR NotUsed
#define CONTROL_PIN NotUsed
#define CONTROL_PORT NotUsed
#define CONTROL_RESET_BIT 0 // Uno Analog Pin 0
#define CONTROL_FEED_HOLD_BIT 1 // Uno Analog Pin 1
#define CONTROL_CYCLE_START_BIT 2 // Uno Analog Pin 2
#define CONTROL_SAFETY_DOOR_BIT 1 // Uno Analog Pin 1 NOTE: Safety door is shared with feed hold. Enabled by config define.
#define CONTROL_INT PCIE1 // Pin change interrupt enable pin
#define CONTROL_INT_vect PCINT1_vect
#define CONTROL_PCMSK NotUsed // Pin change interrupt register
#define CONTROL_MASK ((1<<CONTROL_RESET_BIT)|(1<<CONTROL_FEED_HOLD_BIT)|(1<<CONTROL_CYCLE_START_BIT)|(1<<CONTROL_SAFETY_DOOR_BIT))
#define CONTROL_INVERT_MASK CONTROL_MASK // May be re-defined to only invert certain control pins.
// Define probe switch input pin.
#define PROBE_DDR NotUsed
#define PROBE_PIN NotUsed
#define PROBE_PORT NotUsed
#define PROBE_BIT 5 // Uno Analog Pin 5
#define PROBE_MASK (1<<PROBE_BIT)
// The LPC17xx has 6 PWM channels. Each channel has 2 pins. It can drive both pins simultaneously to the same value.
//
// PWM Channel PWM1_CH1 PWM1_CH2 PWM1_CH3 PWM1_CH4 PWM1_CH5 PWM1_CH6
// Primary pin P1.18 P1.20 P1.21 P1.23 P1.24 P1.26
// Secondary pin P2.0 P2.1 P2.2 P2.3 P2.4 P2.5
#ifdef SPINDLE_PWM_PIN_2_4
#define SPINDLE_PWM_CHANNEL PWM1_CH5 // MOSFET3 (P2.4)
#else
#define SPINDLE_PWM_CHANNEL PWM1_CH6 // BED MOSFET (P2.5)
#endif
#define SPINDLE_PWM_USE_PRIMARY_PIN false
#define SPINDLE_PWM_USE_SECONDARY_PIN true
// Variable spindle configuration below. Do not change unless you know what you are doing.
// NOTE: Only used when variable spindle is enabled.
#define SPINDLE_PWM_MAX_VALUE 255 // Don't change. 328p fast PWM mode fixes top value as 255.
#ifndef SPINDLE_PWM_MIN_VALUE
#define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif
//#define SPINDLE_PWM_OFF_VALUE 0 // Defined in config.h
#define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)
#define SPINDLE_TCCRA_REGISTER TCCR2A
#define SPINDLE_TCCRB_REGISTER TCCR2B
#define SPINDLE_OCR_REGISTER OCR2A
#define SPINDLE_COMB_BIT COM2A1
#endif // end of CPU_MAP_C3D_MINI
#ifdef CPU_MAP_MKS_SBASE // (MKS SBASE Boards)
// Define serial port pins and interrupt vectors.
#define SERIAL_RX USART_RX_vect
#define SERIAL_UDRE USART_UDRE_vect
// Define step pulse output pins. NOTE: All step bit pins must be on the same port.
#define STEP_DDR LPC_GPIO2->FIODIR
#define STEP_PORT LPC_GPIO2->FIOPIN
#define X_STEP_BIT 0
#define Y_STEP_BIT 1
#define Z_STEP_BIT 2
#define A_STEP_BIT 3
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)|(1<<A_STEP_BIT)) // All step bits
// Define step direction output pins. NOTE: All direction pins must be on the same port.
#define DIRECTION_DDR LPC_GPIO0->FIODIR
#define DIRECTION_PORT LPC_GPIO0->FIOPIN
#define X_DIRECTION_BIT 5
#define Y_DIRECTION_BIT 11
#define Z_DIRECTION_BIT 20
#define A_DIRECTION_BIT 22
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)|(1<<A_DIRECTION_BIT)) // All direction bits
// Define stepper driver enable/disable output pin.
#define STEPPERS_DISABLE_DDR LPC_GPIO0->FIODIR
#define STEPPERS_DISABLE_PORT LPC_GPIO0->FIOPIN
#define X_DISABLE_BIT 4
#define Y_DISABLE_BIT 10
#define Z_DISABLE_BIT 19
#define A_DISABLE_BIT 21
#define STEPPERS_DISABLE_MASK ((1<<X_DISABLE_BIT)|(1<<Y_DISABLE_BIT)|(1<<Z_DISABLE_BIT)|(1<<A_DISABLE_BIT))
// Define homing/hard limit switch input pins and limit interrupt vectors.
// NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (CONTROL).
#define LIMIT_DDR LPC_GPIO1->FIODIR
#define LIMIT_PIN LPC_GPIO1->FIOPIN
#define LIMIT_PORT LPC_GPIO1->FIOPIN
#define X_LIMIT_BIT 24 // X-MIN=24, X-MAX=25
#define Y_LIMIT_BIT 26 // Y-MIN=26, Y-MAX=27
#define Z_LIMIT_BIT 28 // Z-MIN=28, Z-MAX=29
#define A_LIMIT_BIT 29 // reuse p1.29
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)|(1<<A_LIMIT_BIT)) // All limit bits
// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_DDR LPC_GPIO1->FIODIR
#define SPINDLE_ENABLE_PORT LPC_GPIO1->FIOPIN
#define SPINDLE_ENABLE_BIT 30 // P1.30
#define SPINDLE_DIRECTION_DDR LPC_GPIO1->FIODIR
#define SPINDLE_DIRECTION_PORT LPC_GPIO1->FIOPIN
#define SPINDLE_DIRECTION_BIT 31 // P1.31
// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_DDR LPC_GPIO2->FIODIR
#define COOLANT_FLOOD_PORT LPC_GPIO2->FIOPIN
#define COOLANT_FLOOD_BIT 6 // MOSFET 2.6
#define COOLANT_MIST_DDR LPC_GPIO2->FIODIR
#define COOLANT_MIST_PORT LPC_GPIO2->FIOPIN
#define COOLANT_MIST_BIT 7 // MOSFET 2.7
#define ENABLE_M7 // enables COOLANT MIST
// Define user-control controls (cycle start, reset, feed hold) input pins.
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
#define CONTROL_DDR LPC_GPIO1->FIODIR
#define CONTROL_PIN LPC_GPIO1->FIOPIN
#define CONTROL_PORT LPC_GPIO1->FIOPIN
#define CONTROL_RESET_BIT NotUsed // Not needed as there is a special RESET pin on the Smoothiebaord
#define CONTROL_FEED_HOLD_BIT 22 // P1.22
#define CONTROL_CYCLE_START_BIT 23 // P1.23
#define CONTROL_SAFETY_DOOR_BIT 22 // P1.22 NOTE: Safety door is shared with feed hold. Enabled by config define.
#define CONTROL_INT PCIE1 // Pin change interrupt enable pin
#define CONTROL_INT_vect PCINT1_vect
#define CONTROL_PCMSK NotUsed // Pin change interrupt register
#define CONTROL_MASK ((1<<CONTROL_RESET_BIT)|(1<<CONTROL_FEED_HOLD_BIT)|(1<<CONTROL_CYCLE_START_BIT)|(1<<CONTROL_SAFETY_DOOR_BIT))
#define CONTROL_INVERT_MASK CONTROL_MASK // May be re-defined to only invert certain control pins.
// Define probe switch input pin.
#define PROBE_DDR LPC_GPIO2->FIODIR
#define PROBE_PIN LPC_GPIO2->FIOPIN
#define PROBE_PORT LPC_GPIO2->FIOPIN
#define PROBE_BIT 11 // P2.11
#define PROBE_MASK (1<<PROBE_BIT)
// The LPC17xx has 6 PWM channels. Each channel has 2 pins. It can drive both pins simultaneously to the same value.
//
// PWM Channel PWM1_CH1 PWM1_CH2 PWM1_CH3 PWM1_CH4 PWM1_CH5 PWM1_CH6
// Primary pin P1.18 P1.20 P1.21 P1.23 P1.24 P1.26
// Secondary pin P2.0 P2.1 P2.2 P2.3 P2.4 P2.5
#define SPINDLE_PWM_CHANNEL PWM1_CH6 // BED MOSFET (P2.5)
#define SPINDLE_PWM_USE_PRIMARY_PIN false
#define SPINDLE_PWM_USE_SECONDARY_PIN true
#ifdef SPINDLE_PWM_PIN_1_23
#define SPINDLE_PWM_CHANNEL PWM1_CH4 // MOSFET3 (P1.23)
#define SPINDLE_PWM_USE_PRIMARY_PIN true
#define SPINDLE_PWM_USE_SECONDARY_PIN false
#endif
#ifdef SPINDLE_PWM_PIN_2_4
#define SPINDLE_PWM_CHANNEL PWM1_CH5 // MOSFET3 (P1.23)
#define SPINDLE_PWM_USE_PRIMARY_PIN false
#define SPINDLE_PWM_USE_SECONDARY_PIN true
#endif
// Stepper current control
#define CURRENT_I2C Driver_I2C1 // I2C driver for current control. Comment out to disable (for C3d boards!)
#define CURRENT_MCP44XX_ADDR 0b0101100 // Address of MCP44XX
#define CURRENT_WIPERS {0, 1, 6, 7}; // Wiper registers (X, Y, Z, A)
#define CURRENT_FACTOR 113.33 // Convert amps to digipot value
// Variable spindle configuration below. Do not change unless you know what you are doing.
// NOTE: Only used when variable spindle is enabled.
#define SPINDLE_PWM_MAX_VALUE 255 // Don't change. 328p fast PWM mode fixes top value as 255.
#ifndef SPINDLE_PWM_MIN_VALUE
#define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif
//#define SPINDLE_PWM_OFF_VALUE 0 // Defined in config.h
#define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)
#define SPINDLE_TCCRA_REGISTER TCCR2A
#define SPINDLE_TCCRB_REGISTER TCCR2B
#define SPINDLE_OCR_REGISTER OCR2A
#define SPINDLE_COMB_BIT COM2A1
#endif // end of CPU_MAP_MKS_SBASE
#ifdef CPU_MAP_AZTEEG_X5 // (Azteeg X5 Boards) not tested yet!
// Define serial port pins and interrupt vectors.
#define SERIAL_RX USART_RX_vect
#define SERIAL_UDRE USART_UDRE_vect
// Define step pulse output pins. NOTE: All step bit pins must be on the same port.
#define STEP_DDR LPC_GPIO2->FIODIR
#define STEP_PORT LPC_GPIO2->FIOPIN
#define X_STEP_BIT 1
#define Y_STEP_BIT 2
#define Z_STEP_BIT 3
#define A_STEP_BIT 0
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)|(1<<A_STEP_BIT)) // All step bits
// Define step direction output pins. NOTE: All direction pins must be on the same port.
#define DIRECTION_DDR LPC_GPIO0->FIODIR
#define DIRECTION_PORT LPC_GPIO0->FIOPIN
#define X_DIRECTION_BIT 11
#define Y_DIRECTION_BIT 20
#define Z_DIRECTION_BIT 22
#define A_DIRECTION_BIT 5
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)|(1<<A_DIRECTION_BIT)) // All direction bits
// Define stepper driver enable/disable output pin.
#define STEPPERS_DISABLE_DDR LPC_GPIO0->FIODIR
#define STEPPERS_DISABLE_PORT LPC_GPIO0->FIOPIN
#define X_DISABLE_BIT 10
#define Y_DISABLE_BIT 19
#define Z_DISABLE_BIT 21
#define A_DISABLE_BIT 4
#define STEPPERS_DISABLE_MASK ((1<<X_DISABLE_BIT)|(1<<Y_DISABLE_BIT)|(1<<Z_DISABLE_BIT)|(1<<A_DISABLE_BIT))
// Define homing/hard limit switch input pins and limit interrupt vectors.
// NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (CONTROL).
#define LIMIT_DDR LPC_GPIO1->FIODIR
#define LIMIT_PIN LPC_GPIO1->FIOPIN
#define LIMIT_PORT LPC_GPIO1->FIOPIN
#define X_LIMIT_BIT 24 // X-MIN=24, X-MAX=27
#define Y_LIMIT_BIT 25 // Y-MIN=25, Y-MAX=28
#define Z_LIMIT_BIT 26 // Z-MIN=26, Z-MAX=29
#define A_LIMIT_BIT 27 // reuse p1.27, as X-MAX is not used
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)|(1<<A_LIMIT_BIT)) // All limit bits
// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_DDR LPC_GPIO2->FIODIR
#define COOLANT_FLOOD_PORT LPC_GPIO2->FIOPIN
#define COOLANT_FLOOD_BIT 4 // FAN MOSFET (P2.4)
#define COOLANT_MIST_DDR LPC_GPIO2->FIODIR
#define COOLANT_MIST_PORT LPC_GPIO2->FIOPIN
#define COOLANT_MIST_BIT 7 // BED MOSFET (P2.7)
#define ENABLE_M7 // enables COOLANT MIST
// Define user-control controls (cycle start, reset, feed hold) input pins.
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
#define CONTROL_DDR NotUsed
#define CONTROL_PIN NotUsed
#define CONTROL_PORT NotUsed
#define CONTROL_RESET_BIT 0 // Uno Analog Pin 0
#define CONTROL_FEED_HOLD_BIT 1 // Uno Analog Pin 1
#define CONTROL_CYCLE_START_BIT 2 // Uno Analog Pin 2
#define CONTROL_SAFETY_DOOR_BIT 1 // Uno Analog Pin 1 NOTE: Safety door is shared with feed hold. Enabled by config define.
#define CONTROL_INT PCIE1 // Pin change interrupt enable pin
#define CONTROL_INT_vect PCINT1_vect
#define CONTROL_PCMSK NotUsed // Pin change interrupt register
#define CONTROL_MASK ((1<<CONTROL_RESET_BIT)|(1<<CONTROL_FEED_HOLD_BIT)|(1<<CONTROL_CYCLE_START_BIT)|(1<<CONTROL_SAFETY_DOOR_BIT))
#define CONTROL_INVERT_MASK CONTROL_MASK // May be re-defined to only invert certain control pins.
// Define probe switch input pin.
#define PROBE_DDR NotUsed
#define PROBE_PIN NotUsed
#define PROBE_PORT NotUsed
#define PROBE_BIT 5 // Uno Analog Pin 5
#define PROBE_MASK (1<<PROBE_BIT)
// The LPC17xx has 6 PWM channels. Each channel has 2 pins. It can drive both pins simultaneously to the same value.
//
// PWM Channel PWM1_CH1 PWM1_CH2 PWM1_CH3 PWM1_CH4 PWM1_CH5 PWM1_CH6
// Primary pin P1.18 P1.20 P1.21 P1.23 P1.24 P1.26
// Secondary pin P2.0 P2.1 P2.2 P2.3 P2.4 P2.5
#ifdef SPINDLE_PWM_PIN_2_4
#define SPINDLE_PWM_CHANNEL PWM1_CH5 // MOSFET3 (P2.4)
#else
#define SPINDLE_PWM_CHANNEL PWM1_CH6 // BED MOSFET (P2.5)
#endif
#define SPINDLE_PWM_USE_PRIMARY_PIN false
#define SPINDLE_PWM_USE_SECONDARY_PIN true
// Stepper current control via SPI not ported yet!
// Variable spindle configuration below. Do not change unless you know what you are doing.
// NOTE: Only used when variable spindle is enabled.
#define SPINDLE_PWM_MAX_VALUE 255 // Don't change. 328p fast PWM mode fixes top value as 255.
#ifndef SPINDLE_PWM_MIN_VALUE
#define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif
//#define SPINDLE_PWM_OFF_VALUE 0 // Defined in config.h
#define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)
#define SPINDLE_TCCRA_REGISTER TCCR2A
#define SPINDLE_TCCRB_REGISTER TCCR2B
#define SPINDLE_OCR_REGISTER OCR2A
#define SPINDLE_COMB_BIT COM2A1
#endif // end of CPU_MAP_AZTEEG_X5
#endif
/*
#ifdef CPU_MAP_CUSTOM_PROC

View File

@ -29,85 +29,160 @@
#ifdef DEFAULTS_GENERIC
// Grbl generic default settings. Should work across different machines.
#define DEFAULT_X_STEPS_PER_MM 250.0
#define DEFAULT_Y_STEPS_PER_MM 250.0
#define DEFAULT_Z_STEPS_PER_MM 250.0
#define DEFAULT_X_MAX_RATE 500.0 // mm/min
#define DEFAULT_Y_MAX_RATE 500.0 // mm/min
#define DEFAULT_Z_MAX_RATE 500.0 // mm/min
#define DEFAULT_X_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Y_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Z_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_X_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
#define DEFAULT_STEPPING_INVERT_MASK 0
#define DEFAULT_DIRECTION_INVERT_MASK 0
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 1 // MPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
#define DEFAULT_INVERT_ST_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 0 // false
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_PROBE_PIN 0 // false
#define DEFAULT_LASER_MODE 0 // false
#define DEFAULT_HOMING_ENABLE 0 // false
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
#define DEFAULT_HOMING_FEED_RATE 25.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
// See https://github.com/gnea/grbl/wiki/Grbl-v1.1-Configuration for setting descriptions.
#define DEFAULT_X_STEPS_PER_MM 160.0 // $100 steps (X steps per mm)
#define DEFAULT_Y_STEPS_PER_MM 160.0 // $101 steps (Y steps per mm)
#define DEFAULT_Z_STEPS_PER_MM 160.0 // $102 steps (Z steps per mm)
#define DEFAULT_A_STEPS_PER_MM 160.0 // $103 steps (A steps per mm)
#define DEFAULT_X_MAX_RATE 30000.0 // $110 mm/min (X max speed)
#define DEFAULT_Y_MAX_RATE 30000.0 // $111 mm/min (Y max speed)
#define DEFAULT_Z_MAX_RATE 30000.0 // $112 mm/min (Z max speed)
#define DEFAULT_A_MAX_RATE 30000.0 // $113 mm/min (A max speed)
#define DEFAULT_X_ACCELERATION (10.0*60*60)// $120 mm/min^2 (X max acceleration)
#define DEFAULT_Y_ACCELERATION (10.0*60*60)// $121 mm/min^2 (Y max acceleration)
#define DEFAULT_Z_ACCELERATION (10.0*60*60)// $122 mm/min^2 (Z max acceleration)
#define DEFAULT_A_ACCELERATION (10.0*60*60)// $123 mm/min^2 (A max acceleration)
#define DEFAULT_X_MAX_TRAVEL 500.0 // $130 mm (X max travel; must be positive)
#define DEFAULT_Y_MAX_TRAVEL 500.0 // $131 mm (Y max travel; must be positive)
#define DEFAULT_Z_MAX_TRAVEL 500.0 // $132 mm (Z max travel; must be positive)
#define DEFAULT_A_MAX_TRAVEL 1.0 // $133 mm (A max travel; must be positive)
#define DEFAULT_X_CURRENT 0.7 // $140 amps (X stepper current [disabled])
#define DEFAULT_Y_CURRENT 0.7 // $141 amps (Y stepper current [disabled])
#define DEFAULT_Z_CURRENT 0.0 // $142 amps (Z stepper current [disabled])
#define DEFAULT_A_CURRENT 0.0 // $143 amps (A stepper current [disabled])
#define DEFAULT_STEP_PULSE_MICROSECONDS 10 // $0 usec (stepper pulse time)
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // $1 msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STEPPING_INVERT_MASK 0 // $2 ZYX (e.g., 0x5 inverts Z and X stepper pulses)
#define DEFAULT_DIRECTION_INVERT_MASK 0 // $3 ZYX (e.g., 0x2 inverts Y stepper direction)
#define DEFAULT_INVERT_ST_ENABLE 0 // $4 bool (inverts stepper enable pin)
#define DEFAULT_INVERT_LIMIT_PINS 0 // $5 bool (inverts limit switches to trigger on high)
#define DEFAULT_INVERT_PROBE_PIN 0 // $6 bool (inverts probe to trigger on high)
#define DEFAULT_STATUS_REPORT_MASK 0 // $10 bits (Reports: [0=WPos or 1=MPos] and [2=Buffer])
#define DEFAULT_JUNCTION_DEVIATION 0.01 // $11 mm (determines machine speed through corners)
#define DEFAULT_ARC_TOLERANCE 0.002 // $12 mm (error tolerance on arcs/cicles)
#define DEFAULT_REPORT_INCHES 0 // $13 bool (sets position reporting to inches)
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // $20 bool (prevents moves outside *_MAX_TRAVEL; requires $23=1)
#define DEFAULT_HARD_LIMIT_ENABLE 0 // $21 bool ([ignored] stops moving when limit switches triggered)
#define DEFAULT_HOMING_ENABLE 0 // $22 bool (enables homing on startup)
#define DEFAULT_HOMING_DIR_MASK 0 // $23 ZYX (e.g., 0x3 reverses XY homing to negative direction)
#define DEFAULT_HOMING_FEED_RATE 25.0 // $24 mm/min (homing precision location speed)
#define DEFAULT_HOMING_SEEK_RATE 500.0 // $25 mm/min (homing search speed)
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // $26 msec (homing switch debounce: 0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // $27 mm (retracts this far from homing switch)
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // $30 RPM (spindle speed for max 5V PWM output)
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // $31 RPM (spindle speed for min 20mV PWM output)
#define DEFAULT_LASER_MODE 0 // $32 bool (adjusts spindle power with speed for lasers)
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // $33 Hz (PWM frequency for spindle)
#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0 // $34 % (% of PWM when spindle is off)
#define DEFAULT_SPINDLE_PWM_MIN_VALUE 1 // $35 % (% of PWM when spindle is at lowest setting)
#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100 // $36 % (% of PWM when spindle is at highest setting)
// Up to 4 HOMING_CYCLE_x can be defined (0-3), specifying which axes are homed and in which order
#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS))
#endif // end of DEFAULTS_GENERIC
#ifdef DEFAULTS_K40
// Description: K40 Lasercutter (typical chinese 40W CO2 laser cutter/engraver)
#define DEFAULT_X_STEPS_PER_MM 160.0
#define DEFAULT_X_STEPS_PER_MM 160.0 // 200 stepps/rev. * 32 microstepps / 40mm/rev
#define DEFAULT_Y_STEPS_PER_MM 160.0
#define DEFAULT_Z_STEPS_PER_MM 160.0
#define DEFAULT_X_MAX_RATE 24000.0 // mm/min
#define DEFAULT_Y_MAX_RATE 24000.0 // mm/min
#define DEFAULT_Z_MAX_RATE 24000.0 // mm/min
#define DEFAULT_X_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Y_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Z_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_X_CURRENT 0.0 // amps
#define DEFAULT_Y_CURRENT 0.0 // amps
#define DEFAULT_Z_CURRENT 0.0 // amps
#define DEFAULT_A_CURRENT 0.0 // amps
#define DEFAULT_X_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 50.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_A_STEPS_PER_MM 160.0
#define DEFAULT_X_MAX_RATE 30000.0 // mm/min
#define DEFAULT_Y_MAX_RATE 30000.0 // mm/min
#define DEFAULT_Z_MAX_RATE 30000.0 // mm/min
#define DEFAULT_A_MAX_RATE 30000.0 // mm/min
#define DEFAULT_X_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_Y_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_Z_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_A_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_X_CURRENT 0.6 // amps
#define DEFAULT_Y_CURRENT 0.6 // amps
#define DEFAULT_Z_CURRENT 0.0 // amps
#define DEFAULT_A_CURRENT 0.0 // amps
#define DEFAULT_X_MAX_TRAVEL 500.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 500.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 50.0 // mm NOTE: Must be a positive value.
#define DEFAULT_A_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz (2000 - 20000)
#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0 // %
#define DEFAULT_SPINDLE_PWM_MIN_VALUE 1 // %
#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100 // %
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm (S-value)
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm (S-value)
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
#define DEFAULT_STEPPING_INVERT_MASK 0
#define DEFAULT_DIRECTION_INVERT_MASK 0
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 0 // WPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
#define DEFAULT_INVERT_ST_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 1 // false
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_PROBE_PIN 0 // false
#define DEFAULT_LASER_MODE 1 // false
#define DEFAULT_HOMING_ENABLE 0 // false
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
#define DEFAULT_HOMING_FEED_RATE 50.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 6000.0 // mm/min
#define DEFAULT_DIRECTION_INVERT_MASK 3 // 3 = invert X+Y
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255// msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 0 // WPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
#define DEFAULT_INVERT_ST_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 1 // true for microswitches / false for optical sensors
#define DEFAULT_SOFT_LIMIT_ENABLE 1 // true
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_PROBE_PIN 0 // false
#define DEFAULT_LASER_MODE 1 // true
#define DEFAULT_HOMING_ENABLE 1 // true
#define DEFAULT_HOMING_DIR_MASK 1 // move top/left
#define DEFAULT_HOMING_FEED_RATE 50.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 6000.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
#define DEFAULT_HOMING_PULLOFF 2.0 // mm
#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS))
#endif // end of DEFAULTS_K40
#ifdef DEFAULTS_FABKIT
// Paste default settings definitions here.
#define DEFAULT_X_STEPS_PER_MM 80.0
#define DEFAULT_Y_STEPS_PER_MM 80.0
#define DEFAULT_Z_STEPS_PER_MM 640.0
#define DEFAULT_A_STEPS_PER_MM 160.0
#define DEFAULT_X_MAX_RATE 30000 // mm/min
#define DEFAULT_Y_MAX_RATE 4500 // mm/min
#define DEFAULT_Z_MAX_RATE 1200 // mm/min
#define DEFAULT_A_MAX_RATE 24000.0 // mm/min
#define DEFAULT_X_ACCELERATION (4000.0*60*60) // 4000*60*60 mm/min^2 = 4000 mm/sec^2
#define DEFAULT_Y_ACCELERATION (250.0*60*60) // 250*60*60 mm/min^2 = 250 mm/sec^2
#define DEFAULT_Z_ACCELERATION (150.0*60*60) // 150*60*60 mm/min^2 = 150 mm/sec^2
#define DEFAULT_A_ACCELERATION (150.0*60*60) // 150*60*60 mm/min^2 = 150 mm/sec^2
#define DEFAULT_X_CURRENT 1.5 // amps
#define DEFAULT_Y_CURRENT 1.5 // amps
#define DEFAULT_Z_CURRENT 1.5 // amps
#define DEFAULT_A_CURRENT 0.0 // amps
#define DEFAULT_X_MAX_TRAVEL 680.0 // mm
#define DEFAULT_Y_MAX_TRAVEL 460.0 // mm
#define DEFAULT_Z_MAX_TRAVEL 150.0 // mm
#define DEFAULT_A_MAX_TRAVEL 150.0 // mm
#define DEFAULT_SPINDLE_PWM_FREQ 50000 // Hz
#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0 // %
#define DEFAULT_SPINDLE_PWM_MIN_VALUE 0 // %
#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100 // %
#define DEFAULT_SPINDLE_RPM_MAX 0.7 // rpm (S-value)
#define DEFAULT_SPINDLE_RPM_MIN 0.08 // rpm (S-value)
#define DEFAULT_STEP_PULSE_MICROSECONDS 1
#define DEFAULT_STEPPING_INVERT_MASK 0
#define DEFAULT_DIRECTION_INVERT_MASK 2 // 2 = invert Y
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255// msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 0 // WPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
#define DEFAULT_INVERT_ST_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 1 // true
#define DEFAULT_SOFT_LIMIT_ENABLE 1 // true
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_PROBE_PIN 0 // false
#define DEFAULT_LASER_MODE 1 // true
#define DEFAULT_HOMING_ENABLE 1 // true
#define DEFAULT_HOMING_DIR_MASK 1 // move top/left
#define DEFAULT_HOMING_FEED_RATE 60.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 6000.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 2.0 // mm
#define HOMING_CYCLE_0 (1<<Z_AXIS)
#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))
#endif // end of DEFAULTS_FABKIT
#ifdef DEFAULTS_SHERLINE_5400
// Description: Sherline 5400 mill with three NEMA 23 Keling KL23H256-21-8B 185 oz-in stepper motors,
@ -127,6 +202,7 @@
#define DEFAULT_X_MAX_TRAVEL 225.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 125.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 170.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 2800.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
@ -149,7 +225,7 @@
#define DEFAULT_HOMING_SEEK_RATE 635.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
#endif // end of DEFAULTS_SHERLINE_5400
#ifdef DEFAULTS_SHAPEOKO
// Description: Shapeoko CNC mill with three NEMA 17 stepper motors, driven by Synthetos
@ -172,6 +248,7 @@
#define DEFAULT_X_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
@ -194,7 +271,7 @@
#define DEFAULT_HOMING_SEEK_RATE 250.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
#endif // end of DEFAULTS_SHAPEOKO
#ifdef DEFAULTS_SHAPEOKO_2
// Description: Shapeoko CNC mill with three NEMA 17 stepper motors, driven by Synthetos
@ -217,6 +294,7 @@
#define DEFAULT_X_MAX_TRAVEL 290.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 290.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
@ -239,7 +317,7 @@
#define DEFAULT_HOMING_SEEK_RATE 250.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
#endif // end of DEFAULTS_SHAPEOKO_2
#ifdef DEFAULTS_SHAPEOKO_3
// Description: Shapeoko CNC mill with three NEMA 23 stepper motors, driven by CarbideMotion
@ -261,6 +339,7 @@
#define DEFAULT_X_MAX_TRAVEL 425.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 465.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 80.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
@ -283,7 +362,7 @@
#define DEFAULT_HOMING_SEEK_RATE 1000.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 25 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 5.0 // mm
#endif
#endif // end of DEFAULTS_SHAPEOKO_3
#ifdef DEFAULTS_X_CARVE_500MM
// Description: X-Carve 3D Carver CNC mill with three 200 step/rev motors driven by Synthetos
@ -306,6 +385,7 @@
#define DEFAULT_X_MAX_TRAVEL 290.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 290.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
@ -328,7 +408,7 @@
#define DEFAULT_HOMING_SEEK_RATE 750.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
#endif // end of DEFAULTS_X_CARVE_500MM
#ifdef DEFAULTS_X_CARVE_1000MM
// Description: X-Carve 3D Carver CNC mill with three 200 step/rev motors driven by Synthetos
@ -351,6 +431,7 @@
#define DEFAULT_X_MAX_TRAVEL 740.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 790.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
@ -373,7 +454,7 @@
#define DEFAULT_HOMING_SEEK_RATE 750.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
#endif // end of DEFAULTS_X_CARVE_1000MM
#ifdef DEFAULTS_ZEN_TOOLWORKS_7x7
// Description: Zen Toolworks 7x7 mill with three Shinano SST43D2121 65oz-in NEMA 17 stepper motors.
@ -394,6 +475,7 @@
#define DEFAULT_X_MAX_TRAVEL 190.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 180.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 150.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
@ -416,7 +498,7 @@
#define DEFAULT_HOMING_SEEK_RATE 250.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
#endif // end of DEFAULTS_ZEN_TOOLWORKS_7x7
#ifdef DEFAULTS_OXCNC
// Grbl settings for OpenBuilds OX CNC Machine
@ -433,6 +515,7 @@
#define DEFAULT_X_MAX_TRAVEL 500.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 750.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 80.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
@ -455,7 +538,7 @@
#define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
#endif // end of DEFAULTS_OXCNC
#ifdef DEFAULTS_SIMULATOR
// Settings only for Grbl Simulator (www.github.com/grbl/grbl-sim)
@ -472,6 +555,7 @@
#define DEFAULT_X_MAX_TRAVEL 1000.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 1000.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 1000.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
@ -494,6 +578,59 @@
#define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif
#endif // end of DEFAULTS_SIMULATOR
#ifdef DEFAULTS_JONAS
// Description: K40 Lasercutter (typical chinese 40W CO2 laser cutter/engraver)
#define DEFAULT_X_STEPS_PER_MM 160.0 // 200 stepps/rev. * 32 microstepps / 40mm/rev
#define DEFAULT_Y_STEPS_PER_MM 160.0
#define DEFAULT_Z_STEPS_PER_MM 160.0
#define DEFAULT_A_STEPS_PER_MM 160.0
#define DEFAULT_X_MAX_RATE 24000.0 // mm/min
#define DEFAULT_Y_MAX_RATE 24000.0 // mm/min
#define DEFAULT_Z_MAX_RATE 24000.0 // mm/min
#define DEFAULT_A_MAX_RATE 24000.0 // mm/min
#define DEFAULT_X_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_Y_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_Z_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_A_ACCELERATION (2500.0*60*60) // 2500*60*60 mm/min^2 = 2500 mm/sec^2
#define DEFAULT_X_CURRENT 0.6 // amps
#define DEFAULT_Y_CURRENT 0.6 // amps
#define DEFAULT_Z_CURRENT 0.0 // amps
#define DEFAULT_A_CURRENT 0.0 // amps
#define DEFAULT_X_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 50.0 // mm NOTE: Must be a positive value.
#define DEFAULT_A_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value.
#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz (2000 - 20000)
#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0 // %
#define DEFAULT_SPINDLE_PWM_MIN_VALUE 1 // %
#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100 // %
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm (S-value)
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm (S-value)
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
#define DEFAULT_STEPPING_INVERT_MASK 0
#define DEFAULT_DIRECTION_INVERT_MASK 3 // 3 = invert X+Y
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255// msec (0-254, 255 keeps steppers enabled)
#define DEFAULT_STATUS_REPORT_MASK 0 // WPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
#define DEFAULT_REPORT_INCHES 0 // false
#define DEFAULT_INVERT_ST_ENABLE 0 // false
#define DEFAULT_INVERT_LIMIT_PINS 1 // true for microswitches / false for optical sensors
#define DEFAULT_SOFT_LIMIT_ENABLE 1 // true
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
#define DEFAULT_INVERT_PROBE_PIN 0 // false
#define DEFAULT_LASER_MODE 1 // true
#define DEFAULT_HOMING_ENABLE 1 // true
#define DEFAULT_HOMING_DIR_MASK 1 // move top/left
#define DEFAULT_HOMING_FEED_RATE 50.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 6000.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 2.0 // mm
#define HOMING_CYCLE_0 (1<<Z_AXIS) // First home Z to clear workspace
#define HOMING_CYCLE_1 (1<<X_AXIS) // Then home X
#define HOMING_CYCLE_2 (1<<Y_AXIS) // Then home Y
#endif // end of DEFAULTS_JONAS
#endif

View File

@ -80,7 +80,7 @@ uint8_t gc_execute_line(char *line)
uint8_t coord_select = 0; // Tracks G10 P coordinate selection for execution
// Initialize bitflag tracking variables for axis indices compatible operations.
uint8_t axis_words = 0; // XYZ tracking
uint8_t axis_words = 0; // XYZA tracking
uint8_t ijk_words = 0; // IJK tracking
// Initialize command and value words and parser flags variables.
@ -296,7 +296,7 @@ uint8_t gc_execute_line(char *line)
legal g-code words and stores their value. Error-checking is performed later since some
words (I,J,K,L,P,R) have multiple connotations and/or depend on the issued commands. */
switch(letter){
// case 'A': // Not supported
case 'A': word_bit = WORD_A; gc_block.values.xyza[A_AXIS] = value; axis_words |= (1<<A_AXIS); break;
// case 'B': // Not supported
// case 'C': // Not supported
// case 'D': // Not supported
@ -313,12 +313,12 @@ uint8_t gc_execute_line(char *line)
case 'R': word_bit = WORD_R; gc_block.values.r = value; break;
case 'S': word_bit = WORD_S; gc_block.values.s = value; break;
case 'T': word_bit = WORD_T;
if (value > MAX_TOOL_NUMBER) { FAIL(STATUS_GCODE_MAX_VALUE_EXCEEDED); }
if (value > MAX_TOOL_NUMBER) { FAIL(STATUS_GCODE_MAX_VALUE_EXCEEDED); }
gc_block.values.t = int_value;
break;
case 'X': word_bit = WORD_X; gc_block.values.xyz[X_AXIS] = value; axis_words |= (1<<X_AXIS); break;
case 'Y': word_bit = WORD_Y; gc_block.values.xyz[Y_AXIS] = value; axis_words |= (1<<Y_AXIS); break;
case 'Z': word_bit = WORD_Z; gc_block.values.xyz[Z_AXIS] = value; axis_words |= (1<<Z_AXIS); break;
break;
case 'X': word_bit = WORD_X; gc_block.values.xyza[X_AXIS] = value; axis_words |= (1<<X_AXIS); break;
case 'Y': word_bit = WORD_Y; gc_block.values.xyza[Y_AXIS] = value; axis_words |= (1<<Y_AXIS); break;
case 'Z': word_bit = WORD_Z; gc_block.values.xyza[Z_AXIS] = value; axis_words |= (1<<Z_AXIS); break;
default: FAIL(STATUS_GCODE_UNSUPPORTED_COMMAND);
}
@ -475,7 +475,7 @@ uint8_t gc_execute_line(char *line)
if (gc_block.modal.units == UNITS_MODE_INCHES) {
for (idx=0; idx<N_AXIS; idx++) { // Axes indices are consistent, so loop may be used.
if (bit_istrue(axis_words,bit(idx)) ) {
gc_block.values.xyz[idx] *= MM_PER_INCH;
gc_block.values.xyza[idx] *= MM_PER_INCH;
}
}
}
@ -549,11 +549,11 @@ uint8_t gc_execute_line(char *line)
if (gc_block.values.l == 20) {
// L20: Update coordinate system axis at current position (with modifiers) with programmed value
// WPos = MPos - WCS - G92 - TLO -> WCS = MPos - G92 - TLO - WPos
gc_block.values.ijk[idx] = gc_state.position[idx]-gc_state.coord_offset[idx]-gc_block.values.xyz[idx];
gc_block.values.ijk[idx] = gc_state.position[idx]-gc_state.coord_offset[idx]-gc_block.values.xyza[idx];
if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.ijk[idx] -= gc_state.tool_length_offset; }
} else {
// L2: Update coordinate system axis to programmed value.
gc_block.values.ijk[idx] = gc_block.values.xyz[idx];
gc_block.values.ijk[idx] = gc_block.values.xyza[idx];
}
} // Else, keep current stored value.
}
@ -567,10 +567,10 @@ uint8_t gc_execute_line(char *line)
for (idx=0; idx<N_AXIS; idx++) { // Axes indices are consistent, so loop may be used.
if (bit_istrue(axis_words,bit(idx)) ) {
// WPos = MPos - WCS - G92 - TLO -> G92 = MPos - WCS - TLO - WPos
gc_block.values.xyz[idx] = gc_state.position[idx]-block_coord_system[idx]-gc_block.values.xyz[idx];
if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.xyz[idx] -= gc_state.tool_length_offset; }
gc_block.values.xyza[idx] = gc_state.position[idx]-block_coord_system[idx]-gc_block.values.xyza[idx];
if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.xyza[idx] -= gc_state.tool_length_offset; }
} else {
gc_block.values.xyz[idx] = gc_state.coord_offset[idx];
gc_block.values.xyza[idx] = gc_state.coord_offset[idx];
}
}
break;
@ -585,17 +585,17 @@ uint8_t gc_execute_line(char *line)
if (axis_words) {
for (idx=0; idx<N_AXIS; idx++) { // Axes indices are consistent, so loop may be used to save flash space.
if ( bit_isfalse(axis_words,bit(idx)) ) {
gc_block.values.xyz[idx] = gc_state.position[idx]; // No axis word in block. Keep same axis position.
gc_block.values.xyza[idx] = gc_state.position[idx]; // No axis word in block. Keep same axis position.
} else {
// Update specified value according to distance mode or ignore if absolute override is active.
// NOTE: G53 is never active with G28/30 since they are in the same modal group.
if (gc_block.non_modal_command != NON_MODAL_ABSOLUTE_OVERRIDE) {
// Apply coordinate offsets based on distance mode.
if (gc_block.modal.distance == DISTANCE_MODE_ABSOLUTE) {
gc_block.values.xyz[idx] += block_coord_system[idx] + gc_state.coord_offset[idx];
if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.xyz[idx] += gc_state.tool_length_offset; }
gc_block.values.xyza[idx] += block_coord_system[idx] + gc_state.coord_offset[idx];
if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.xyza[idx] += gc_state.tool_length_offset; }
} else { // Incremental mode
gc_block.values.xyz[idx] += gc_state.position[idx];
gc_block.values.xyza[idx] += gc_state.position[idx];
}
}
}
@ -684,12 +684,12 @@ uint8_t gc_execute_line(char *line)
// Calculate the change in position along each selected axis
float x,y;
x = gc_block.values.xyz[axis_0]-gc_state.position[axis_0]; // Delta x between current position and target
y = gc_block.values.xyz[axis_1]-gc_state.position[axis_1]; // Delta y between current position and target
x = gc_block.values.xyza[axis_0]-gc_state.position[axis_0]; // Delta x between current position and target
y = gc_block.values.xyza[axis_1]-gc_state.position[axis_1]; // Delta y between current position and target
if (value_words & bit(WORD_R)) { // Arc Radius Mode
bit_false(value_words,bit(WORD_R));
if (isequal_position_vector(gc_state.position, gc_block.values.xyz)) { FAIL(STATUS_GCODE_INVALID_TARGET); } // [Invalid target]
if (isequal_position_vector(gc_state.position, gc_block.values.xyza)) { FAIL(STATUS_GCODE_INVALID_TARGET); } // [Invalid target]
// Convert radius value to proper units.
if (gc_block.modal.units == UNITS_MODE_INCHES) { gc_block.values.r *= MM_PER_INCH; }
@ -816,7 +816,7 @@ uint8_t gc_execute_line(char *line)
// an error, it issues an alarm to prevent further motion to the probe. It's also done there to
// allow the planner buffer to empty and move off the probe trigger before another probing cycle.
if (!axis_words) { FAIL(STATUS_GCODE_NO_AXIS_WORDS); } // [No axis words]
if (isequal_position_vector(gc_state.position, gc_block.values.xyz)) { FAIL(STATUS_GCODE_INVALID_TARGET); } // [Invalid target]
if (isequal_position_vector(gc_state.position, gc_block.values.xyza)) { FAIL(STATUS_GCODE_INVALID_TARGET); } // [Invalid target]
break;
}
}
@ -832,7 +832,7 @@ uint8_t gc_execute_line(char *line)
} else {
bit_false(value_words,(bit(WORD_N)|bit(WORD_F)|bit(WORD_S)|bit(WORD_T))); // Remove single-meaning value words.
}
if (axis_command) { bit_false(value_words,(bit(WORD_X)|bit(WORD_Y)|bit(WORD_Z))); } // Remove axis words.
if (axis_command) { bit_false(value_words,(bit(WORD_X)|bit(WORD_Y)|bit(WORD_Z)|bit(WORD_A))); } // Remove axis words.
if (value_words) { FAIL(STATUS_GCODE_UNUSED_WORDS); } // [Unused words]
/* -------------------------------------------------------------------------------------
@ -861,7 +861,7 @@ uint8_t gc_execute_line(char *line)
plan_data.condition = (gc_state.modal.spindle | gc_state.modal.coolant);
uint8_t status = jog_execute(&plan_data, &gc_block);
if (status == STATUS_OK) { memcpy(gc_state.position, gc_block.values.xyz, sizeof(gc_block.values.xyz)); }
if (status == STATUS_OK) { memcpy(gc_state.position, gc_block.values.xyza, sizeof(gc_block.values.xyza)); }
return(status);
}
@ -985,10 +985,10 @@ uint8_t gc_execute_line(char *line)
if (axis_command == AXIS_COMMAND_TOOL_LENGTH_OFFSET ) { // Indicates a change.
gc_state.modal.tool_length = gc_block.modal.tool_length;
if (gc_state.modal.tool_length == TOOL_LENGTH_OFFSET_CANCEL) { // G49
gc_block.values.xyz[TOOL_LENGTH_OFFSET_AXIS] = 0.0;
gc_block.values.xyza[TOOL_LENGTH_OFFSET_AXIS] = 0.0;
} // else G43.1
if ( gc_state.tool_length_offset != gc_block.values.xyz[TOOL_LENGTH_OFFSET_AXIS] ) {
gc_state.tool_length_offset = gc_block.values.xyz[TOOL_LENGTH_OFFSET_AXIS];
if ( gc_state.tool_length_offset != gc_block.values.xyza[TOOL_LENGTH_OFFSET_AXIS] ) {
gc_state.tool_length_offset = gc_block.values.xyza[TOOL_LENGTH_OFFSET_AXIS];
system_flag_wco_change();
}
}
@ -1022,7 +1022,7 @@ uint8_t gc_execute_line(char *line)
// Move to intermediate position before going home. Obeys current coordinate system and offsets
// and absolute and incremental modes.
pl_data->condition |= PL_COND_FLAG_RAPID_MOTION; // Set rapid motion condition flag.
if (axis_command) { mc_line(gc_block.values.xyz, pl_data); }
if (axis_command) { mc_line(gc_block.values.xyza, pl_data); }
mc_line(gc_block.values.ijk, pl_data);
memcpy(gc_state.position, gc_block.values.ijk, N_AXIS*sizeof(float));
break;
@ -1033,7 +1033,7 @@ uint8_t gc_execute_line(char *line)
settings_write_coord_data(SETTING_INDEX_G30,gc_state.position,false,true);
break;
case NON_MODAL_SET_COORDINATE_OFFSET:
memcpy(gc_state.coord_offset,gc_block.values.xyz,sizeof(gc_block.values.xyz));
memcpy(gc_state.coord_offset,gc_block.values.xyza,sizeof(gc_block.values.xyza));
system_flag_wco_change();
break;
case NON_MODAL_RESET_COORDINATE_OFFSET:
@ -1051,27 +1051,27 @@ uint8_t gc_execute_line(char *line)
if (axis_command == AXIS_COMMAND_MOTION_MODE) {
uint8_t gc_update_pos = GC_UPDATE_POS_TARGET;
if (gc_state.modal.motion == MOTION_MODE_LINEAR) {
mc_line(gc_block.values.xyz, pl_data);
mc_line(gc_block.values.xyza, pl_data);
} else if (gc_state.modal.motion == MOTION_MODE_SEEK) {
pl_data->condition |= PL_COND_FLAG_RAPID_MOTION; // Set rapid motion condition flag.
mc_line(gc_block.values.xyz, pl_data);
mc_line(gc_block.values.xyza, pl_data);
} else if ((gc_state.modal.motion == MOTION_MODE_CW_ARC) || (gc_state.modal.motion == MOTION_MODE_CCW_ARC)) {
mc_arc(gc_block.values.xyz, pl_data, gc_state.position, gc_block.values.ijk, gc_block.values.r,
mc_arc(gc_block.values.xyza, pl_data, gc_state.position, gc_block.values.ijk, gc_block.values.r,
axis_0, axis_1, axis_linear, bit_istrue(gc_parser_flags,GC_PARSER_ARC_IS_CLOCKWISE));
} else {
// NOTE: gc_block.values.xyz is returned from mc_probe_cycle with the updated position value. So
// NOTE: gc_block.values.xyza is returned from mc_probe_cycle with the updated position value. So
// upon a successful probing cycle, the machine position and the returned value should be the same.
#ifndef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES
pl_data->condition |= PL_COND_FLAG_NO_FEED_OVERRIDE;
#endif
gc_update_pos = mc_probe_cycle(gc_block.values.xyz, pl_data, gc_parser_flags);
gc_update_pos = mc_probe_cycle(gc_block.values.xyza, pl_data, gc_parser_flags);
}
// As far as the parser is concerned, the position is now == target. In reality the
// motion control system might still be processing the action and the real tool position
// in any intermediate location.
if (gc_update_pos == GC_UPDATE_POS_TARGET) {
memcpy(gc_state.position, gc_block.values.xyz, sizeof(gc_block.values.xyz)); // gc_state.position[] = gc_block.values.xyz[]
memcpy(gc_state.position, gc_block.values.xyza, sizeof(gc_block.values.xyza)); // gc_state.position[] = gc_block.values.xyza[]
} else if (gc_update_pos == GC_UPDATE_POS_SYSTEM) {
gc_sync_position(); // gc_state.position[] = sys_position
} // == GC_UPDATE_POS_NONE

View File

@ -149,6 +149,7 @@
#define WORD_X 10
#define WORD_Y 11
#define WORD_Z 12
#define WORD_A 13
// Define g-code parser position updating flags
#define GC_UPDATE_POS_TARGET 0 // Must be zero
@ -198,7 +199,7 @@ typedef struct {
typedef struct {
float f; // Feed
float ijk[3]; // I,J,K Axis arc offsets
float ijk[N_AXIS]; // I,J,K Axis arc offsets
uint8_t l; // G10 or canned cycles parameters
int32_t n; // Line number
float p; // G10 or dwell parameters
@ -206,7 +207,7 @@ typedef struct {
float r; // Arc radius
float s; // Spindle speed
uint8_t t; // Tool selection
float xyz[3]; // X,Y,Z Translational axes
float xyza[N_AXIS]; // X,Y,Z,A Translational axes
} gc_values_t;

View File

@ -23,7 +23,7 @@
// Grbl versioning system
#define GRBL_VERSION "1.1f"
#define GRBL_VERSION_BUILD "20170131"
#define GRBL_VERSION_BUILD "20171008"
// Define standard libraries used by Grbl.
#include <avr/io.h>
@ -75,9 +75,11 @@
#error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
#endif
/*
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)
#error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"
#endif
*/
#if !defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && defined(SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED)
#error "SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED may only be used with USE_SPINDLE_DIR_AS_ENABLE_PIN enabled"

View File

@ -33,11 +33,11 @@ uint8_t jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block)
#endif
if (bit_istrue(settings.flags,BITFLAG_SOFT_LIMIT_ENABLE)) {
if (system_check_travel_limits(gc_block->values.xyz)) { return(STATUS_TRAVEL_EXCEEDED); }
if (system_check_travel_limits(gc_block->values.xyza)) { return(STATUS_TRAVEL_EXCEEDED); }
}
// Valid jog command. Plan, set state, and execute.
mc_line(gc_block->values.xyz,pl_data);
mc_line(gc_block->values.xyza,pl_data);
if (sys.state == STATE_IDLE) {
if (plan_get_current_block() != NULL) { // Check if there is a block to execute.
sys.state = STATE_JOG;

View File

@ -158,9 +158,9 @@ void limits_go_home(uint8_t cycle_mask)
// Initialize variables used for homing computations.
uint8_t n_cycle = (2*N_HOMING_LOCATE_CYCLE+1);
uint32_t step_pin[N_AXIS];
uint32_t step_pin[N_AXIS]; // Tracks which pins correspond to which axes (reduces calls to get_step_pin_mask())
float target[N_AXIS];
float max_travel = 0.0;
float max_travel = 0.0; // Maximum travel distance to move searching for limits
uint8_t idx;
for (idx=0; idx<N_AXIS; idx++) {
// Initialize step pin masks
@ -183,11 +183,12 @@ void limits_go_home(uint8_t cycle_mask)
uint32_t limit_state, axislock, n_active_axis;
do {
// convert current sys_position (steps) to target (mm) so unused axes remain in place
system_convert_array_steps_to_mpos(target,sys_position);
// Initialize and declare variables needed for homing routine.
axislock = 0;
n_active_axis = 0;
axislock = 0; // Track which pins still need to find limits. Lock these axes by clearing these bits.
n_active_axis = 0; // Track number of axes being homed
for (idx=0; idx<N_AXIS; idx++) {
// Set target location for active axes and setup computation for homing rate.
if (bit_istrue(cycle_mask,bit(idx))) {
@ -215,7 +216,7 @@ void limits_go_home(uint8_t cycle_mask)
if (approach) { target[idx] = max_travel; }
else { target[idx] = -max_travel; }
}
// Apply axislock to the step port pins active in this cycle.
// Apply axislock to the step port pins active in this cycle, allowing motion
axislock |= step_pin[idx];
}
@ -237,12 +238,13 @@ void limits_go_home(uint8_t cycle_mask)
for (idx=0; idx<N_AXIS; idx++) {
if (axislock & step_pin[idx]) {
if (limit_state & (1 << idx)) {
#ifdef COREXY
if (idx==Z_AXIS) { axislock &= ~(step_pin[Z_AXIS]); }
else { axislock &= ~(step_pin[A_MOTOR]|step_pin[B_MOTOR]); }
#else
axislock &= ~(step_pin[idx]);
#endif
// Clear the axislock bits to prevent axis from moving after limit is hit
#ifdef COREXY
if (idx==Z_AXIS) { axislock &= ~(step_pin[Z_AXIS]); }
else { axislock &= ~(step_pin[A_MOTOR]|step_pin[B_MOTOR]); }
#else
axislock &= ~(step_pin[idx]);
#endif
}
}
}
@ -297,7 +299,7 @@ void limits_go_home(uint8_t cycle_mask)
// can be on either side of an axes, check and set axes machine zero appropriately. Also,
// set up pull-off maneuver from axes limit switches that have been homed. This provides
// some initial clearance off the switches and should also help prevent them from falsely
// triggering when hard limits are enabled or when more than one axes shares a limit pin.
// triggering when hard limits are enabled or when more than one axis shares a limit pin.
int32_t set_axis_position;
// Set machine positions for homed limit switches. Don't update non-homed axes.
for (idx=0; idx<N_AXIS; idx++) {
@ -307,9 +309,17 @@ void limits_go_home(uint8_t cycle_mask)
set_axis_position = 0;
#else
if ( bit_istrue(settings.homing_dir_mask,bit(idx)) ) {
set_axis_position = lround((settings.max_travel[idx]+settings.homing_pulloff)*settings.steps_per_mm[idx]);
#ifdef HOMING_FORCE_POSITIVE_SPACE
set_axis_position = 0; //lround(settings.homing_pulloff*settings.steps_per_mm[idx]);
#else
set_axis_position = lround((settings.max_travel[idx]-settings.homing_pulloff)*settings.steps_per_mm[idx]);
#endif
} else {
set_axis_position = lround(-settings.homing_pulloff*settings.steps_per_mm[idx]);
#ifdef HOMING_FORCE_POSITIVE_SPACE
set_axis_position = lround(-settings.max_travel[idx]*settings.steps_per_mm[idx]);
#else
set_axis_position = lround(-settings.homing_pulloff*settings.steps_per_mm[idx]);
#endif
}
#endif

View File

@ -42,13 +42,13 @@ int main(void)
{
// Initialize system upon power-up.
debug_init(); // Initialize debug leds
isr_init(); // Set ISR priorities
delay_init(); // Setup delay timer
isr_init(); // Set ISR priorities (stepper ISR uses Timer1)
delay_init(); // Setup delay timer (uses Timer3)
serial_init(); // Setup serial baud rate and interrupts
eeprom_init(); // Init EEPROM or FLASH
eeprom_init(); // Init EEPROM or Flash
settings_init(); // Load Grbl settings from EEPROM
current_init(); // Configure stepper driver current
stepper_init(); // Configure stepper pins and interrupt timers
stepper_init(); // Configure stepper pins and interrupt timers (uses Timer1)
system_init(); // Configure pinout pins and pin-change interrupt
memset(sys_position,0,sizeof(sys_position)); // Clear machine position.
@ -61,7 +61,7 @@ int main(void)
#else
sys.state = STATE_IDLE;
#endif
// Check for power-up and set system alarm if homing is enabled to force homing cycle
// by setting Grbl's alarm state. Alarm locks out all g-code commands, including the
// startup scripts, but allows access to settings and internal commands. Only a homing
@ -84,26 +84,26 @@ int main(void)
sys.f_override = DEFAULT_FEED_OVERRIDE; // Set to 100%
sys.r_override = DEFAULT_RAPID_OVERRIDE; // Set to 100%
sys.spindle_speed_ovr = DEFAULT_SPINDLE_SPEED_OVERRIDE; // Set to 100%
memset(sys_probe_position,0,sizeof(sys_probe_position)); // Clear probe position.
sys_probe_state = 0;
sys_rt_exec_state = 0;
memset(sys_probe_position,0,sizeof(sys_probe_position)); // Clear probe position.
sys_probe_state = 0; // PROBE_OFF
sys_rt_exec_state = 0; // EXEC_STATUS_REPORT
sys_rt_exec_alarm = 0;
sys_rt_exec_motion_override = 0;
sys_rt_exec_accessory_override = 0;
// Reset Grbl primary systems.
serial_reset_read_buffer(); // Clear serial read buffer
gc_init(); // Set g-code parser to default state
spindle_init();
coolant_init();
limits_init();
probe_init();
plan_reset(); // Clear block buffer and planner variables
st_reset(); // Clear stepper subsystem variables.
gc_init(); // Set g-code parser to default state
spindle_init(); // Configure spindle pins and PWM values
coolant_init(); // Configure coolant pins
limits_init(); // Configure limit input pins and interrupts
probe_init(); // Configure probe input pin
plan_reset(); // Clear block buffer and planner variables
st_reset(); // Clear stepper subsystem variables.
// Sync cleared gcode and planner positions to current system position.
plan_sync_position();
gc_sync_position();
plan_sync_position(); // Synchronize plan position with (actual) system position
gc_sync_position(); // Synchronize g-code position with (actual) system position
// Print welcome message. Indicates an initialization has occured at power-up or with a reset.
report_init_message();

View File

@ -227,6 +227,9 @@ void mc_homing_cycle(uint8_t cycle_mask)
#ifdef HOMING_CYCLE_2
limits_go_home(HOMING_CYCLE_2); // Homing cycle 2
#endif
#ifdef HOMING_CYCLE_3
limits_go_home(HOMING_CYCLE_3); // Homing cycle 3
#endif
}
protocol_execute_realtime(); // Check for reset and set system abort.

View File

@ -31,6 +31,9 @@
#define HOMING_CYCLE_X bit(X_AXIS)
#define HOMING_CYCLE_Y bit(Y_AXIS)
#define HOMING_CYCLE_Z bit(Z_AXIS)
#define HOMING_CYCLE_A bit(A_AXIS)
//#define HOMING_CYCLE_B bit(B_AXIS)
//#define HOMING_CYCLE_C bit(C_AXIS)
// Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second

View File

@ -30,11 +30,13 @@
#define SOME_LARGE_VALUE 1.0E+38
// Axis array index values. Must start with 0 and be continuous.
#define N_AXIS 3 // Number of axes
#define N_AXIS 4 // Number of axes
#define X_AXIS 0 // Axis indexing value.
#define Y_AXIS 1
#define Z_AXIS 2
// #define A_AXIS 3
#define A_AXIS 3
//#define B_AXIS 4
//#define C_AXIS 5
// CoreXY motor assignments. DO NOT ALTER.
// NOTE: If the A and B motor axis bindings are changed, this effects the CoreXY equations.

View File

@ -336,6 +336,7 @@ uint8_t plan_buffer_line(float *target, plan_line_data_t *pl_data)
position_steps[X_AXIS] = system_convert_corexy_to_x_axis_steps(sys_position);
position_steps[Y_AXIS] = system_convert_corexy_to_y_axis_steps(sys_position);
position_steps[Z_AXIS] = sys_position[Z_AXIS];
position_steps[A_AXIS] = sys_position[A_AXIS];
#else
memcpy(position_steps, sys_position, sizeof(sys_position));
#endif

View File

@ -50,7 +50,13 @@ void probe_configure_invert_mask(uint8_t is_probe_away)
// Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor.
uint8_t probe_get_state() { return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask); }
uint8_t probe_get_state() {
if ((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask) {
return 1;
} else {
return 0;
}
}
// Monitors probe pin state and records the system position when detected. Called by the

View File

@ -71,7 +71,6 @@ static void report_util_setting_string(uint8_t n) {
case 30: printPgmString(PSTR("rpm max")); break;
case 31: printPgmString(PSTR("rpm min")); break;
case 32: printPgmString(PSTR("laser")); break;
case 33: printPgmString(PSTR("spindle_pwm_freq")); break;
default:
n -= AXIS_SETTINGS_START_VAL;
uint8_t idx = 0;
@ -97,11 +96,6 @@ static void report_util_uint8_setting(uint8_t n, int val) {
print_uint8_base10(val);
report_util_line_feed(); // report_util_setting_string(n);
}
static void report_util_uint32_setting(uint8_t n, int val) {
report_util_setting_prefix(n);
print_uint32_base10(val);
report_util_line_feed(); // report_util_setting_string(n);
}
static void report_util_float_setting(uint8_t n, float val, uint8_t n_decimal) {
report_util_setting_prefix(n);
printFloat(val,n_decimal);
@ -214,7 +208,10 @@ void report_grbl_settings() {
#else
report_util_uint8_setting(32,0);
#endif
report_util_uint32_setting(33,settings.spindle_pwm_freq);
report_util_float_setting(33,settings.spindle_pwm_freq,N_DECIMAL_SETTINGVALUE);
report_util_float_setting(34,settings.spindle_pwm_off_value,N_DECIMAL_SETTINGVALUE);
report_util_float_setting(35,settings.spindle_pwm_min_value,N_DECIMAL_SETTINGVALUE);
report_util_float_setting(36,settings.spindle_pwm_max_value,N_DECIMAL_SETTINGVALUE);
// Print axis settings
uint8_t idx, set_idx;
uint8_t val = AXIS_SETTINGS_START_VAL;
@ -578,6 +575,9 @@ void report_realtime_status()
if (bit_istrue(lim_pin_state,bit(X_AXIS))) { serial_write('X'); }
if (bit_istrue(lim_pin_state,bit(Y_AXIS))) { serial_write('Y'); }
if (bit_istrue(lim_pin_state,bit(Z_AXIS))) { serial_write('Z'); }
if (bit_istrue(lim_pin_state,bit(A_AXIS))) { serial_write('A'); }
//if (bit_istrue(lim_pin_state,bit(B_AXIS))) { serial_write('B'); }
//if (bit_istrue(lim_pin_state,bit(C_AXIS))) { serial_write('C'); }
}
if (ctrl_pin_state) {
#ifdef ENABLE_SAFETY_DOOR_INPUT_PIN

View File

@ -87,6 +87,9 @@ void settings_restore(uint8_t restore_flag) {
settings.arc_tolerance = DEFAULT_ARC_TOLERANCE;
settings.spindle_pwm_freq = DEFAULT_SPINDLE_PWM_FREQ;
settings.spindle_pwm_off_value = DEFAULT_SPINDLE_PWM_OFF_VALUE;
settings.spindle_pwm_min_value = DEFAULT_SPINDLE_PWM_MIN_VALUE;
settings.spindle_pwm_max_value = DEFAULT_SPINDLE_PWM_MAX_VALUE;
settings.rpm_max = DEFAULT_SPINDLE_RPM_MAX;
settings.rpm_min = DEFAULT_SPINDLE_RPM_MIN;
@ -97,30 +100,45 @@ void settings_restore(uint8_t restore_flag) {
settings.homing_pulloff = DEFAULT_HOMING_PULLOFF;
settings.flags = 0;
if (DEFAULT_REPORT_INCHES) { settings.flags |= BITFLAG_REPORT_INCHES; }
if (DEFAULT_LASER_MODE) { settings.flags |= BITFLAG_LASER_MODE; }
if (DEFAULT_INVERT_ST_ENABLE) { settings.flags |= BITFLAG_INVERT_ST_ENABLE; }
if (DEFAULT_REPORT_INCHES) { settings.flags |= BITFLAG_REPORT_INCHES; }
if (DEFAULT_LASER_MODE) { settings.flags |= BITFLAG_LASER_MODE; }
if (DEFAULT_INVERT_ST_ENABLE) { settings.flags |= BITFLAG_INVERT_ST_ENABLE; }
if (DEFAULT_HARD_LIMIT_ENABLE) { settings.flags |= BITFLAG_HARD_LIMIT_ENABLE; }
if (DEFAULT_HOMING_ENABLE) { settings.flags |= BITFLAG_HOMING_ENABLE; }
if (DEFAULT_HOMING_ENABLE) { settings.flags |= BITFLAG_HOMING_ENABLE; }
if (DEFAULT_SOFT_LIMIT_ENABLE) { settings.flags |= BITFLAG_SOFT_LIMIT_ENABLE; }
if (DEFAULT_INVERT_LIMIT_PINS) { settings.flags |= BITFLAG_INVERT_LIMIT_PINS; }
if (DEFAULT_INVERT_PROBE_PIN) { settings.flags |= BITFLAG_INVERT_PROBE_PIN; }
if (DEFAULT_INVERT_PROBE_PIN) { settings.flags |= BITFLAG_INVERT_PROBE_PIN; }
settings.steps_per_mm[X_AXIS] = DEFAULT_X_STEPS_PER_MM;
settings.steps_per_mm[Y_AXIS] = DEFAULT_Y_STEPS_PER_MM;
settings.steps_per_mm[Z_AXIS] = DEFAULT_Z_STEPS_PER_MM;
settings.steps_per_mm[A_AXIS] = DEFAULT_A_STEPS_PER_MM;
//settings.steps_per_mm[B_AXIS] = DEFAULT_B_STEPS_PER_MM;
//settings.steps_per_mm[C_AXIS] = DEFAULT_C_STEPS_PER_MM;
settings.max_rate[X_AXIS] = DEFAULT_X_MAX_RATE;
settings.max_rate[Y_AXIS] = DEFAULT_Y_MAX_RATE;
settings.max_rate[Z_AXIS] = DEFAULT_Z_MAX_RATE;
settings.max_rate[A_AXIS] = DEFAULT_A_MAX_RATE;
//settings.max_rate[B_AXIS] = DEFAULT_B_MAX_RATE;
//settings.max_rate[C_AXIS] = DEFAULT_C_MAX_RATE;
settings.acceleration[X_AXIS] = DEFAULT_X_ACCELERATION;
settings.acceleration[Y_AXIS] = DEFAULT_Y_ACCELERATION;
settings.acceleration[Z_AXIS] = DEFAULT_Z_ACCELERATION;
settings.acceleration[A_AXIS] = DEFAULT_A_ACCELERATION;
//settings.acceleration[B_AXIS] = DEFAULT_B_ACCELERATION;
//settings.acceleration[C_AXIS] = DEFAULT_C_ACCELERATION;
settings.max_travel[X_AXIS] = (-DEFAULT_X_MAX_TRAVEL);
settings.max_travel[Y_AXIS] = (-DEFAULT_Y_MAX_TRAVEL);
settings.max_travel[Z_AXIS] = (-DEFAULT_Z_MAX_TRAVEL);
settings.max_travel[A_AXIS] = (-DEFAULT_A_MAX_TRAVEL);
//settings.max_travel[B_AXIS] = (-DEFAULT_B_MAX_TRAVEL);
//settings.max_travel[C_AXIS] = (-DEFAULT_C_MAX_TRAVEL);
settings.current[X_AXIS] = DEFAULT_X_CURRENT;
settings.current[Y_AXIS] = DEFAULT_Y_CURRENT;
settings.current[Z_AXIS] = DEFAULT_Z_CURRENT;
settings.current[A_AXIS] = DEFAULT_A_CURRENT;
//settings.current[B_AXIS] = DEFAULT_B_CURRENT;
//settings.current[C_AXIS] = DEFAULT_C_CURRENT;
write_global_settings(false);
}
@ -159,7 +177,7 @@ uint8_t settings_read_startup_line(uint8_t n, char *line)
if (!(memcpy_from_eeprom_with_checksum((char*)line, addr, LINE_BUFFER_SIZE))) {
// Reset line with default value
line[0] = 0; // Empty line
settings_store_startup_line(n, line);
settings_store_startup_line(n, line); // Clear this startup line because it's corrupted
return(false);
}
return(true);
@ -172,7 +190,7 @@ uint8_t settings_read_build_info(char *line)
if (!(memcpy_from_eeprom_with_checksum((char*)line, EEPROM_ADDR_BUILD_INFO, LINE_BUFFER_SIZE))) {
// Reset line with default value
line[0] = 0; // Empty line
settings_store_build_info(line);
settings_store_build_info(line); // Clear out build info string because it's corrupted
return(false);
}
return(true);
@ -319,6 +337,9 @@ uint8_t settings_store_global_setting(uint8_t parameter, float value) {
#endif
break;
case 33: settings.spindle_pwm_freq = value; spindle_init(); break; // Re-initialize spindle pwm calibration
case 34: settings.spindle_pwm_off_value = value; spindle_init(); break; // Re-initialize spindle pwm calibration
case 35: settings.spindle_pwm_min_value = value; spindle_init(); break; // Re-initialize spindle pwm calibration
case 36: settings.spindle_pwm_max_value = value; spindle_init(); break; // Re-initialize spindle pwm calibration
default:
return(STATUS_INVALID_STATEMENT);
}
@ -343,7 +364,11 @@ uint32_t get_step_pin_mask(uint8_t axis_idx)
{
if ( axis_idx == X_AXIS ) { return((1<<X_STEP_BIT)); }
if ( axis_idx == Y_AXIS ) { return((1<<Y_STEP_BIT)); }
return((1<<Z_STEP_BIT));
if ( axis_idx == Z_AXIS ) { return((1<<Z_STEP_BIT)); }
return((1<<A_STEP_BIT));
//if ( axis_idx == A_AXIS ) { return((1<<A_STEP_BIT)); }
//if ( axis_idx == B_AXIS ) { return((1<<B_STEP_BIT)); }
//return((1<<C_STEP_BIT));
}
@ -352,7 +377,11 @@ uint32_t get_direction_pin_mask(uint8_t axis_idx)
{
if ( axis_idx == X_AXIS ) { return((1<<X_DIRECTION_BIT)); }
if ( axis_idx == Y_AXIS ) { return((1<<Y_DIRECTION_BIT)); }
return((1<<Z_DIRECTION_BIT));
if ( axis_idx == Z_AXIS ) { return((1<<Z_DIRECTION_BIT)); }
return((1<<A_DIRECTION_BIT));
//if ( axis_idx == A_AXIS ) { return((1<<A_DIRECTION_BIT)); }
//if ( axis_idx == B_AXIS ) { return((1<<B_DIRECTION_BIT)); }
//return((1<<C_DIRECTION_BIT));
}
@ -361,5 +390,9 @@ uint32_t get_limit_pin_mask(uint8_t axis_idx)
{
if ( axis_idx == X_AXIS ) { return((1<<X_LIMIT_BIT)); }
if ( axis_idx == Y_AXIS ) { return((1<<Y_LIMIT_BIT)); }
return((1<<Z_LIMIT_BIT));
if ( axis_idx == Z_AXIS ) { return((1<<Z_LIMIT_BIT)); }
return((1<<A_LIMIT_BIT));
//if ( axis_idx == A_AXIS ) { return((1<<A_LIMIT_BIT)); }
//if ( axis_idx == B_AXIS ) { return((1<<B_LIMIT_BIT)); }
//return((1<<C_LIMIT_BIT));
}

View File

@ -26,8 +26,8 @@
// Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl
// when firmware is upgraded. Always stored in byte 0 of eeprom
#define SETTINGS_VERSION 10 // NOTE: Check settings_reset() when moving to next version.
// when firmware is upgraded. Always stored in byte 0 of EEPROM.
#define SETTINGS_VERSION 11 // NOTE: Check settings_reset() when moving to next version.
// Define bit flag masks for the boolean settings in settings.flag.
#define BITFLAG_REPORT_INCHES bit(0)
@ -44,10 +44,10 @@
#define BITFLAG_RT_STATUS_BUFFER_STATE bit(1)
// Define settings restore bitflags.
#define SETTINGS_RESTORE_DEFAULTS bit(0)
#define SETTINGS_RESTORE_PARAMETERS bit(1)
#define SETTINGS_RESTORE_DEFAULTS bit(0)
#define SETTINGS_RESTORE_PARAMETERS bit(1)
#define SETTINGS_RESTORE_STARTUP_LINES bit(2)
#define SETTINGS_RESTORE_BUILD_INFO bit(3)
#define SETTINGS_RESTORE_BUILD_INFO bit(3)
#ifndef SETTINGS_RESTORE_ALL
#define SETTINGS_RESTORE_ALL 0xFF // All bitflags
#endif
@ -56,6 +56,7 @@
// NOTE: The Atmega328p has 1KB EEPROM. The upper half is reserved for parameters and
// the startup script. The lower half contains the global settings and space for future
// developments.
// Note: Address 0 of EEPROM is reserved for SETTINGS_VERSION.
#define EEPROM_ADDR_GLOBAL 1U
#define EEPROM_ADDR_PARAMETERS 512U
#define EEPROM_ADDR_STARTUP_BLOCK 768U
@ -80,7 +81,7 @@ typedef struct {
float steps_per_mm[N_AXIS];
float max_rate[N_AXIS];
float acceleration[N_AXIS];
float max_travel[N_AXIS];
float max_travel[N_AXIS]; // NOTE: Stored as a negative value
float current[N_AXIS];
// Remaining Grbl settings
@ -92,7 +93,10 @@ typedef struct {
float junction_deviation;
float arc_tolerance;
uint16_t spindle_pwm_freq;
float spindle_pwm_freq; // Hz
float spindle_pwm_off_value; // Percent
float spindle_pwm_min_value; // Percent
float spindle_pwm_max_value; // Percent
float rpm_max;
float rpm_min;

View File

@ -25,10 +25,10 @@
#ifdef VARIABLE_SPINDLE
static float pwm_gradient; // Precalulated value to speed up rpm to PWM conversions.
static float spindle_pwm_period;
static float spindle_pwm_off_value;
static float spindle_pwm_min_value;
static float spindle_pwm_max_value;
float spindle_pwm_period;
float spindle_pwm_off_value;
float spindle_pwm_min_value;
float spindle_pwm_max_value;
#endif
@ -36,15 +36,12 @@ void spindle_init()
{
#ifdef VARIABLE_SPINDLE
spindle_pwm_period = (SystemCoreClock / settings.spindle_pwm_freq);
spindle_pwm_off_value = (spindle_pwm_period * 0.0); // SPINDLE_PWM_PERIOD * fraction
spindle_pwm_min_value = (spindle_pwm_period * 0.0); // SPINDLE_PWM_PERIOD * fraction
spindle_pwm_max_value = (spindle_pwm_period * 1.0); // SPINDLE_PWM_PERIOD * fraction
//pwm_init(&SPINDLE_PWM_CHANNEL, SPINDLE_PWM_USE_PRIMARY_PIN, SPINDLE_PWM_USE_SECONDARY_PIN, SPINDLE_PWM_PERIOD, 0);
pwm_init(&SPINDLE_PWM_CHANNEL, SPINDLE_PWM_USE_PRIMARY_PIN, SPINDLE_PWM_USE_SECONDARY_PIN, spindle_pwm_period, 0); //SPINDLE_PWM_PERIOD
spindle_pwm_off_value = (spindle_pwm_period * settings.spindle_pwm_off_value / 100);
spindle_pwm_min_value = (spindle_pwm_period * settings.spindle_pwm_min_value / 100);
spindle_pwm_max_value = (spindle_pwm_period * settings.spindle_pwm_max_value / 100);
pwm_init(&SPINDLE_PWM_CHANNEL, SPINDLE_PWM_USE_PRIMARY_PIN, SPINDLE_PWM_USE_SECONDARY_PIN, spindle_pwm_period, 0);
pwm_enable(&SPINDLE_PWM_CHANNEL);
/* not ported
// Configure variable spindle PWM and enable pin, if requried. On the Uno, PWM and enable are
// combined unless configured otherwise.
#ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
@ -52,17 +49,13 @@ void spindle_init()
#else
SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT); // Configure as output pin.
#endif
*/
//pwm_gradient = (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)/(settings.rpm_max-settings.rpm_min);
pwm_gradient = (spindle_pwm_max_value-spindle_pwm_min_value)/(settings.rpm_max-settings.rpm_min);
#else
/* not ported
// Configure no variable spindle and only enable pin.
SPINDLE_ENABLE_DDR |= (1<<SPINDLE_ENABLE_BIT); // Configure as output pin.
SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT); // Configure as output pin.
*/
#endif
spindle_stop();
@ -71,32 +64,30 @@ void spindle_init()
uint8_t spindle_get_state()
{
/* not ported
#ifdef VARIABLE_SPINDLE
#ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
// No spindle direction output pin.
#ifdef INVERT_SPINDLE_ENABLE_PIN
if (bit_isfalse(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) { return(SPINDLE_STATE_CW); }
#else
if (bit_istrue(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) { return(SPINDLE_STATE_CW); }
#endif
#else
if (SPINDLE_TCCRA_REGISTER & (1<<SPINDLE_COMB_BIT)) { // Check if PWM is enabled.
if (SPINDLE_DIRECTION_PORT & (1<<SPINDLE_DIRECTION_BIT)) { return(SPINDLE_STATE_CCW); }
else { return(SPINDLE_STATE_CW); }
}
#endif
#ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
// No spindle direction output pin.
#ifdef INVERT_SPINDLE_ENABLE_PIN
if (bit_isfalse(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) { return(SPINDLE_STATE_CW); }
#else
if (bit_istrue(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) { return(SPINDLE_STATE_CW); }
#endif
#else
if (SPINDLE_TCCRA_REGISTER & (1<<SPINDLE_COMB_BIT)) { // Check if PWM is enabled.
if (SPINDLE_DIRECTION_PORT & (1<<SPINDLE_DIRECTION_BIT)) { return(SPINDLE_STATE_CCW); }
else { return(SPINDLE_STATE_CW); }
}
#endif
#else
#ifdef INVERT_SPINDLE_ENABLE_PIN
if (bit_isfalse(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) {
#ifdef INVERT_SPINDLE_ENABLE_PIN
if (bit_isfalse(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) {
#else
if (bit_istrue(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) {
if (bit_istrue(SPINDLE_ENABLE_PORT,(1<<SPINDLE_ENABLE_BIT))) {
#endif
if (SPINDLE_DIRECTION_PORT & (1<<SPINDLE_DIRECTION_BIT)) { return(SPINDLE_STATE_CCW); }
else { return(SPINDLE_STATE_CW); }
}
if (SPINDLE_DIRECTION_PORT & (1<<SPINDLE_DIRECTION_BIT)) { return(SPINDLE_STATE_CCW); }
else { return(SPINDLE_STATE_CW); }
}
#endif
*/
return(SPINDLE_STATE_DISABLE);
}
@ -106,26 +97,22 @@ uint8_t spindle_get_state()
// Called by spindle_init(), spindle_set_speed(), spindle_set_state(), and mc_reset().
void spindle_stop()
{
#ifdef VARIABLE_SPINDLE
pwm_set_width(&SPINDLE_PWM_CHANNEL, 0);
/* not ported
#ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
#ifdef INVERT_SPINDLE_ENABLE_PIN
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); // Set pin to high
#else
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
#endif
#endif
*/
#else
/* not ported
#ifdef INVERT_SPINDLE_ENABLE_PIN
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); // Set pin to high
#ifdef VARIABLE_SPINDLE
pwm_set_width(&SPINDLE_PWM_CHANNEL, 0);
#ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
#ifdef INVERT_SPINDLE_ENABLE_PIN
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); // Set pin to high
#else
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
#endif
#endif
#else
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
#ifdef INVERT_SPINDLE_ENABLE_PIN
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); // Set pin to high
#else
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
#endif
#endif
*/
#endif
}
@ -145,21 +132,21 @@ void spindle_stop()
rpm *= (0.010*sys.spindle_speed_ovr); // Scale by spindle speed override value.
if (rpm <= 0) {
sys.spindle_speed = 0;
pwm_value = spindle_pwm_off_value; //SPINDLE_PWM_OFF_VALUE
pwm_value = spindle_pwm_off_value;
}
else if (rpm <= settings.rpm_min) {
sys.spindle_speed = settings.rpm_min;
pwm_value = spindle_pwm_min_value; //SPINDLE_PWM_MIN_VALUE
pwm_value = spindle_pwm_min_value;
}
else if (rpm >= settings.rpm_max) {
sys.spindle_speed = settings.rpm_max;
pwm_value = spindle_pwm_max_value - 1; //SPINDLE_PWM_MAX_VALUE
pwm_value = spindle_pwm_max_value - 1;
}
else {
sys.spindle_speed = rpm;
pwm_value = floor((rpm - settings.rpm_min) * pwm_gradient) + spindle_pwm_min_value; //SPINDLE_PWM_MIN_VALUE
if(pwm_value >= spindle_pwm_max_value) //SPINDLE_PWM_MAX_VALUE
pwm_value = spindle_pwm_max_value - 1; //SPINDLE_PWM_MAX_VALUE
pwm_value = floor((rpm - settings.rpm_min) * pwm_gradient) + spindle_pwm_min_value;
if(pwm_value >= spindle_pwm_max_value)
pwm_value = spindle_pwm_max_value - 1;
}
return(pwm_value);
}
@ -186,13 +173,11 @@ void spindle_stop()
} else {
#ifndef USE_SPINDLE_DIR_AS_ENABLE_PIN
/* not ported
if (state == SPINDLE_ENABLE_CW) {
SPINDLE_DIRECTION_PORT &= ~(1<<SPINDLE_DIRECTION_BIT);
} else {
SPINDLE_DIRECTION_PORT |= (1<<SPINDLE_DIRECTION_BIT);
}
*/
#endif
#ifdef VARIABLE_SPINDLE
@ -206,13 +191,11 @@ void spindle_stop()
!defined(SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED)) || !defined(VARIABLE_SPINDLE)
// NOTE: Without variable spindle, the enable bit should just turn on or off, regardless
// if the spindle speed value is zero, as its ignored anyhow.
/* not ported
#ifdef INVERT_SPINDLE_ENABLE_PIN
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
#else
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
#endif
*/
#endif
}

View File

@ -40,6 +40,10 @@ uint8_t spindle_get_state();
// Immediately sets spindle running state with direction and spindle rpm via PWM, if enabled.
// Called by spindle_sync() after sync and parking motion/spindle stop override during restore.
#ifdef VARIABLE_SPINDLE
extern float spindle_pwm_period;
extern float spindle_pwm_off_value;
extern float spindle_pwm_min_value;
extern float spindle_pwm_max_value;
// Called by g-code parser when setting spindle state and requires a buffer sync.
void spindle_sync(uint8_t state, float rpm);

View File

@ -30,10 +30,10 @@
#define RAMP_DECEL 2
#define RAMP_DECEL_OVERRIDE 3
#define PREP_FLAG_RECALCULATE bit(0)
#define PREP_FLAG_RECALCULATE bit(0)
#define PREP_FLAG_HOLD_PARTIAL_BLOCK bit(1)
#define PREP_FLAG_PARKING bit(2)
#define PREP_FLAG_DECEL_OVERRIDE bit(3)
#define PREP_FLAG_PARKING bit(2)
#define PREP_FLAG_DECEL_OVERRIDE bit(3)
// Define Adaptive Multi-Axis Step-Smoothing(AMASS) levels and cutoff frequencies. The highest level
// frequency bin starts at 0Hz and ends at its cutoff frequency. The next lower level frequency bin
@ -45,11 +45,11 @@
// NOTE: Current settings are set to overdrive the ISR to no more than 16kHz, balancing CPU overhead
// and timer accuracy. Do not alter these settings unless you know what you are doing.
#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
#define MAX_AMASS_LEVEL 3
// AMASS_LEVEL0: Normal operation. No AMASS. No upper cutoff frequency. Starts at LEVEL1 cutoff frequency.
#define AMASS_LEVEL1 (F_CPU/8000) // Over-drives ISR (x2). Defined as F_CPU/(Cutoff frequency in Hz)
#define AMASS_LEVEL2 (F_CPU/4000) // Over-drives ISR (x4)
#define AMASS_LEVEL3 (F_CPU/2000) // Over-drives ISR (x8)
#define MAX_AMASS_LEVEL 3
// AMASS_LEVEL0: Normal operation. No AMASS. No upper cutoff frequency. Starts at LEVEL1 cutoff frequency.
#define AMASS_LEVEL1 (F_CPU/8000) // Over-drives ISR (x2). Defined as F_CPU/(Cutoff frequency in Hz)
#define AMASS_LEVEL2 (F_CPU/4000) // Over-drives ISR (x4)
#define AMASS_LEVEL3 (F_CPU/2000) // Over-drives ISR (x8)
#if MAX_AMASS_LEVEL <= 0
error "AMASS must have 1 or more levels to operate correctly."
@ -97,7 +97,10 @@ typedef struct {
// Used by the bresenham line algorithm
uint32_t counter_x, // Counter variables for the bresenham line tracer
counter_y,
counter_z;
counter_z,
counter_a;
//counter_b,
//counter_c;
#ifdef STEP_PULSE_DELAY
uint32_t step_bits; // Stores out_bits output to complete the step pulse delay
#endif
@ -164,7 +167,7 @@ typedef struct {
#ifdef VARIABLE_SPINDLE
float inv_rate; // Used by PWM laser mode to speed up segment calculations.
uint32_t current_spindle_pwm;
uint32_t current_spindle_pwm;
#endif
} st_prep_t;
static st_prep_t prep;
@ -232,9 +235,9 @@ void st_wake_up()
#endif
// Enable Stepper Driver Interrupt Timer
LPC_TIM1->TCR = 0b10; // reset
LPC_TIM1->MR0 = 4000; // Generate first interrupt soon
LPC_TIM1->TCR = 0b01; // enable
LPC_TIM1->TCR = 0b10; // reset Timer Control (0b10=Reset, 0b01=Enable)
LPC_TIM1->MR0 = 4000; // Generate first interrupt soon (Match Register for TC)
LPC_TIM1->TCR = 0b01; // enable Timer Control (0b10=Reset, 0b01=Enable)
}
@ -242,11 +245,11 @@ void st_wake_up()
void st_go_idle()
{
// Disable Stepper Driver Interrupt. Allow Stepper Port Reset Interrupt to finish, if active.
LPC_TIM1->TCR = 0; // Disable Timer1
LPC_TIM1->TCR = 0; // Disable Timer1 Control (0b10=Reset, 0b01=Enable)
busy = false;
// Set stepper driver idle state, disabled or enabled, depending on settings and circumstances.
bool pin_state = false; // Keep enabled.
bool pin_state = false; // Stepper is disabled when pin_state is true. Keep enabled by default.
if (((settings.stepper_idle_lock_time != 0xff) || sys_rt_exec_alarm || sys.state == STATE_SLEEP) && sys.state != STATE_HOMING) {
// Force stepper dwell to lock axes for a defined amount of time to ensure the axes come to a complete
// stop and not drift from residual inertial forces at the end of the last movement.
@ -352,7 +355,7 @@ extern "C" void TIMER1_IRQHandler()
#endif
// Initialize step segment timing per step and load number of steps to execute.
LPC_TIM1->MR0 = st.exec_segment->cycles_per_tick;
LPC_TIM1->MR0 = st.exec_segment->cycles_per_tick; // Set Match Register to wait one tick
st.step_count = st.exec_segment->n_step; // NOTE: Can sometimes be zero when moving slow.
// If the new segment starts a new planner block, initialize stepper variables and counters.
// NOTE: When the segment data index changes, this indicates a new planner block.
@ -370,6 +373,9 @@ extern "C" void TIMER1_IRQHandler()
st.steps[X_AXIS] = st.exec_block->steps[X_AXIS] >> st.exec_segment->amass_level;
st.steps[Y_AXIS] = st.exec_block->steps[Y_AXIS] >> st.exec_segment->amass_level;
st.steps[Z_AXIS] = st.exec_block->steps[Z_AXIS] >> st.exec_segment->amass_level;
st.steps[A_AXIS] = st.exec_block->steps[A_AXIS] >> st.exec_segment->amass_level;
//st.steps[B_AXIS] = st.exec_block->steps[B_AXIS] >> st.exec_segment->amass_level;
//st.steps[C_AXIS] = st.exec_block->steps[C_AXIS] >> st.exec_segment->amass_level;
#endif
#ifdef VARIABLE_SPINDLE
@ -385,7 +391,7 @@ extern "C" void TIMER1_IRQHandler()
st_go_idle();
#ifdef VARIABLE_SPINDLE
// Ensure pwm is set properly upon completion of rate-controlled motion.
if (st.exec_block->is_pwm_rate_adjusted) { spindle_set_speed(SPINDLE_PWM_OFF_VALUE); }
if (st.exec_block->is_pwm_rate_adjusted) { spindle_set_speed(spindle_pwm_off_value); }
#endif
system_set_exec_state_flag(EXEC_CYCLE_STOP); // Flag main program for cycle end
return; // Nothing to do but exit.
@ -433,6 +439,41 @@ extern "C" void TIMER1_IRQHandler()
if (st.exec_block->direction_bits & (1<<Z_DIRECTION_BIT)) { sys_position[Z_AXIS]--; }
else { sys_position[Z_AXIS]++; }
}
#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
st.counter_a += st.steps[A_AXIS];
#else
st.counter_a += st.exec_block->steps[A_AXIS];
#endif
if (st.counter_a > st.exec_block->step_event_count) {
st.step_outbits |= (1<<A_STEP_BIT);
st.counter_a -= st.exec_block->step_event_count;
if (st.exec_block->direction_bits & (1<<A_DIRECTION_BIT)) { sys_position[A_AXIS]--; }
else { sys_position[A_AXIS]++; }
}
/*
#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
st.counter_b += st.steps[B_AXIS];
#else
st.counter_b += st.exec_block->steps[B_AXIS];
#endif
if (st.counter_b > st.exec_block->step_event_count) {
st.step_outbits |= (1<<B_STEP_BIT);
st.counter_b -= st.exec_block->step_event_count;
if (st.exec_block->direction_bits & (1<<B_DIRECTION_BIT)) { sys_position[B_AXIS]--; }
else { sys_position[B_AXIS]++; }
}
#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
st.counter_c += st.steps[C_AXIS];
#else
st.counter_c += st.exec_block->steps[C_AXIS];
#endif
if (st.counter_c > st.exec_block->step_event_count) {
st.step_outbits |= (1<<C_STEP_BIT);
st.counter_c -= st.exec_block->step_event_count;
if (st.exec_block->direction_bits & (1<<C_DIRECTION_BIT)) { sys_position[C_AXIS]--; }
else { sys_position[C_AXIS]++; }
}
*/
// During a homing cycle, lock out and prevent desired axes from moving.
if (sys.state == STATE_HOMING) { st.step_outbits &= sys.homing_axis_lock; }
@ -462,7 +503,7 @@ extern "C" void TIMER1_IRQHandler()
cause issues at high step rates if another high frequency asynchronous interrupt is
added to Grbl.
*/
/* Not ported; the main ISR assumes short pulse widths and handles it. Stepper drivers with
/* Not ported; the main ISR assumes short pulse widths and handles it. Stepper drivers with
long pulse widths may need this instead if they cause the main ISR to consume too much time.
// This interrupt is enabled by ISR_TIMER1_COMPAREA when it sets the motor port bits to execute
// a step. This ISR resets the motor port after a short period (settings.pulse_microseconds)
@ -529,17 +570,17 @@ void st_reset()
void stepper_init()
{
// Configure step and direction interface pins
STEP_DDR |= STEP_MASK;
STEPPERS_DISABLE_DDR |= STEPPERS_DISABLE_MASK;
DIRECTION_DDR |= DIRECTION_MASK;
STEP_DDR |= STEP_MASK; // Set selected stepper step pins as outputs
STEPPERS_DISABLE_DDR |= STEPPERS_DISABLE_MASK; // Set selected stepper disable pins as outputs
DIRECTION_DDR |= DIRECTION_MASK; // Set selected stepper direction pins as outputs
// Configure Timer 1: Stepper Driver Interrupt
LPC_TIM1->TCR = 0; // disable
LPC_TIM1->CTCR = 0; // timer mode
LPC_TIM1->PR = 0; // no prescale
LPC_TIM1->MCR = 0b011; // MR0: !stop, reset, interrupt
LPC_TIM1->CCR = 0; // no capture
LPC_TIM1->EMR = 0; // no external match
LPC_TIM1->TCR = 0; // disable Timer Control (0b10=Reset, 0b01=Enable)
LPC_TIM1->CTCR = 0; // Count Control (0=TimerMode, 1-3=EdgeCounterMode)
LPC_TIM1->PR = 0; // no Prescale (TC increments every PR+1 clocks)
LPC_TIM1->MCR = 0b011; // Match Control (0b001=InterruptEnbl, 0b010=Reset_Enbl, 0b100=Stop_Enbl)
LPC_TIM1->CCR = 0; // no Capture Control actions
LPC_TIM1->EMR = 0; // no External Match (controls external match pins)
NVIC_EnableIRQ(TIMER1_IRQn); // Enable Stepper Driver Interrupt
}
@ -676,49 +717,49 @@ void st_prep_buffer()
} else {
prep.current_speed = sqrt(pl_block->entry_speed_sqr);
}
#ifdef VARIABLE_SPINDLE
// Setup laser mode variables. PWM rate adjusted motions will always complete a motion with the
// spindle off.
// spindle off.
st_prep_block->is_pwm_rate_adjusted = false;
if (settings.flags & BITFLAG_LASER_MODE) {
if (pl_block->condition & PL_COND_FLAG_SPINDLE_CCW) {
if (pl_block->condition & PL_COND_FLAG_SPINDLE_CCW) {
// Pre-compute inverse programmed rate to speed up PWM updating per step segment.
prep.inv_rate = 1.0/pl_block->programmed_rate;
st_prep_block->is_pwm_rate_adjusted = true;
st_prep_block->is_pwm_rate_adjusted = true;
}
}
#endif
}
/* ---------------------------------------------------------------------------------
Compute the velocity profile of a new planner block based on its entry and exit
speeds, or recompute the profile of a partially-completed planner block if the
planner has updated it. For a commanded forced-deceleration, such as from a feed
hold, override the planner velocities and decelerate to the target exit speed.
*/
prep.mm_complete = 0.0; // Default velocity profile complete at 0.0mm from end of block.
float inv_2_accel = 0.5/pl_block->acceleration;
if (sys.step_control & STEP_CONTROL_EXECUTE_HOLD) { // [Forced Deceleration to Zero Velocity]
// Compute velocity profile parameters for a feed hold in-progress. This profile overrides
// the planner block profile, enforcing a deceleration to zero speed.
prep.ramp_type = RAMP_DECEL;
// Compute decelerate distance relative to end of block.
float decel_dist = pl_block->millimeters - inv_2_accel*pl_block->entry_speed_sqr;
if (decel_dist < 0.0) {
// Deceleration through entire planner block. End of feed hold is not in this block.
prep.exit_speed = sqrt(pl_block->entry_speed_sqr-2*pl_block->acceleration*pl_block->millimeters);
} else {
prep.mm_complete = decel_dist; // End of feed hold.
prep.exit_speed = 0.0;
}
} else { // [Normal Operation]
// Compute or recompute velocity profile parameters of the prepped planner block.
prep.ramp_type = RAMP_ACCEL; // Initialize as acceleration ramp.
prep.accelerate_until = pl_block->millimeters;
/* ---------------------------------------------------------------------------------
Compute the velocity profile of a new planner block based on its entry and exit
speeds, or recompute the profile of a partially-completed planner block if the
planner has updated it. For a commanded forced-deceleration, such as from a feed
hold, override the planner velocities and decelerate to the target exit speed.
*/
prep.mm_complete = 0.0; // Default velocity profile complete at 0.0mm from end of block.
float inv_2_accel = 0.5/pl_block->acceleration;
if (sys.step_control & STEP_CONTROL_EXECUTE_HOLD) { // [Forced Deceleration to Zero Velocity]
// Compute velocity profile parameters for a feed hold in-progress. This profile overrides
// the planner block profile, enforcing a deceleration to zero speed.
prep.ramp_type = RAMP_DECEL;
// Compute decelerate distance relative to end of block.
float decel_dist = pl_block->millimeters - inv_2_accel*pl_block->entry_speed_sqr;
if (decel_dist < 0.0) {
// Deceleration through entire planner block. End of feed hold is not in this block.
prep.exit_speed = sqrt(pl_block->entry_speed_sqr-2*pl_block->acceleration*pl_block->millimeters);
} else {
prep.mm_complete = decel_dist; // End of feed hold.
prep.exit_speed = 0.0;
}
} else { // [Normal Operation]
// Compute or recompute velocity profile parameters of the prepped planner block.
prep.ramp_type = RAMP_ACCEL; // Initialize as acceleration ramp.
prep.accelerate_until = pl_block->millimeters;
float exit_speed_sqr;
float nominal_speed;
float exit_speed_sqr;
float nominal_speed;
if (sys.step_control & STEP_CONTROL_EXECUTE_SYS_MOTION) {
prep.exit_speed = exit_speed_sqr = 0.0; // Enforce stop at end of system motion.
} else {
@ -727,9 +768,9 @@ void st_prep_buffer()
}
nominal_speed = plan_compute_profile_nominal_speed(pl_block);
float nominal_speed_sqr = nominal_speed*nominal_speed;
float intersect_distance =
0.5*(pl_block->millimeters+inv_2_accel*(pl_block->entry_speed_sqr-exit_speed_sqr));
float nominal_speed_sqr = nominal_speed*nominal_speed;
float intersect_distance =
0.5*(pl_block->millimeters+inv_2_accel*(pl_block->entry_speed_sqr-exit_speed_sqr));
if (pl_block->entry_speed_sqr > nominal_speed_sqr) { // Only occurs during override reductions.
prep.accelerate_until = pl_block->millimeters - inv_2_accel*(pl_block->entry_speed_sqr-nominal_speed_sqr);
@ -752,41 +793,41 @@ void st_prep_buffer()
prep.maximum_speed = nominal_speed;
prep.ramp_type = RAMP_DECEL_OVERRIDE;
}
} else if (intersect_distance > 0.0) {
if (intersect_distance < pl_block->millimeters) { // Either trapezoid or triangle types
// NOTE: For acceleration-cruise and cruise-only types, following calculation will be 0.0.
prep.decelerate_after = inv_2_accel*(nominal_speed_sqr-exit_speed_sqr);
if (prep.decelerate_after < intersect_distance) { // Trapezoid type
prep.maximum_speed = nominal_speed;
if (pl_block->entry_speed_sqr == nominal_speed_sqr) {
// Cruise-deceleration or cruise-only type.
prep.ramp_type = RAMP_CRUISE;
} else {
// Full-trapezoid or acceleration-cruise types
prep.accelerate_until -= inv_2_accel*(nominal_speed_sqr-pl_block->entry_speed_sqr);
}
} else { // Triangle type
prep.accelerate_until = intersect_distance;
prep.decelerate_after = intersect_distance;
prep.maximum_speed = sqrt(2.0*pl_block->acceleration*intersect_distance+exit_speed_sqr);
}
} else { // Deceleration-only type
} else if (intersect_distance > 0.0) {
if (intersect_distance < pl_block->millimeters) { // Either trapezoid or triangle types
// NOTE: For acceleration-cruise and cruise-only types, following calculation will be 0.0.
prep.decelerate_after = inv_2_accel*(nominal_speed_sqr-exit_speed_sqr);
if (prep.decelerate_after < intersect_distance) { // Trapezoid type
prep.maximum_speed = nominal_speed;
if (pl_block->entry_speed_sqr == nominal_speed_sqr) {
// Cruise-deceleration or cruise-only type.
prep.ramp_type = RAMP_CRUISE;
} else {
// Full-trapezoid or acceleration-cruise types
prep.accelerate_until -= inv_2_accel*(nominal_speed_sqr-pl_block->entry_speed_sqr);
}
} else { // Triangle type
prep.accelerate_until = intersect_distance;
prep.decelerate_after = intersect_distance;
prep.maximum_speed = sqrt(2.0*pl_block->acceleration*intersect_distance+exit_speed_sqr);
}
} else { // Deceleration-only type
prep.ramp_type = RAMP_DECEL;
// prep.decelerate_after = pl_block->millimeters;
// prep.maximum_speed = prep.current_speed;
}
} else { // Acceleration-only type
prep.accelerate_until = 0.0;
// prep.decelerate_after = 0.0;
prep.maximum_speed = prep.exit_speed;
}
}
}
} else { // Acceleration-only type
prep.accelerate_until = 0.0;
// prep.decelerate_after = 0.0;
prep.maximum_speed = prep.exit_speed;
}
}
#ifdef VARIABLE_SPINDLE
bit_true(sys.step_control, STEP_CONTROL_UPDATE_SPINDLE_PWM); // Force update whenever updating block.
#endif
}
// Initialize new segment
segment_t *prep_segment = &segment_buffer[segment_buffer_head];
@ -896,25 +937,25 @@ void st_prep_buffer()
/* -----------------------------------------------------------------------------------
Compute spindle speed PWM output for step segment
*/
if (st_prep_block->is_pwm_rate_adjusted || (sys.step_control & STEP_CONTROL_UPDATE_SPINDLE_PWM)) {
if (pl_block->condition & (PL_COND_FLAG_SPINDLE_CW | PL_COND_FLAG_SPINDLE_CCW)) {
float rpm = pl_block->spindle_speed;
// NOTE: Feed and rapid overrides are independent of PWM value and do not alter laser power/rate.
// NOTE: Feed and rapid overrides are independent of PWM value and do not alter laser power/rate.
if (st_prep_block->is_pwm_rate_adjusted) { rpm *= (prep.current_speed * prep.inv_rate); }
// If current_speed is zero, then may need to be rpm_min*(100/MAX_SPINDLE_SPEED_OVERRIDE)
// but this would be instantaneous only and during a motion. May not matter at all.
prep.current_spindle_pwm = spindle_compute_pwm_value(rpm);
} else {
} else {
sys.spindle_speed = 0.0;
prep.current_spindle_pwm = SPINDLE_PWM_OFF_VALUE;
prep.current_spindle_pwm = spindle_pwm_off_value;
}
bit_false(sys.step_control,STEP_CONTROL_UPDATE_SPINDLE_PWM);
}
prep_segment->spindle_pwm = prep.current_spindle_pwm; // Reload segment PWM value
#endif
/* -----------------------------------------------------------------------------------
Compute segment step rate, steps to execute, and apply necessary rate corrections.
NOTE: Steps are computed by direct scalar conversion of the millimeter distance

View File

@ -23,14 +23,15 @@
void system_init()
{
// Configure user control pins (for cycle start, reset, feed hold, etc.)
CONTROL_DDR &= ~(CONTROL_MASK); // Configure as input pins
#ifdef DISABLE_CONTROL_PIN_PULL_UP
CONTROL_PORT &= ~(CONTROL_MASK); // Normal low operation. Requires external pull-down.
#else
CONTROL_PORT |= CONTROL_MASK; // Enable internal pull-up resistors. Normal high operation.
CONTROL_PORT |= CONTROL_MASK; // Enable internal pull-up resistors. Normal high operation.
#endif
CONTROL_PCMSK |= CONTROL_MASK; // Enable specific pins of the Pin Change Interrupt
PCICR |= (1 << CONTROL_INT); // Enable Pin Change Interrupt
CONTROL_PCMSK |= CONTROL_MASK; // Enable specific pins of the Pin Change Interrupt
PCICR |= (1 << CONTROL_INT); // Enable Pin Change Interrupt
}
@ -185,6 +186,9 @@ uint8_t system_execute_line(char *line)
case 'X': mc_homing_cycle(HOMING_CYCLE_X); break;
case 'Y': mc_homing_cycle(HOMING_CYCLE_Y); break;
case 'Z': mc_homing_cycle(HOMING_CYCLE_Z); break;
case 'A': mc_homing_cycle(HOMING_CYCLE_A); break;
//case 'B': mc_homing_cycle(HOMING_CYCLE_B); break;
//case 'C': mc_homing_cycle(HOMING_CYCLE_C); break;
default: return(STATUS_INVALID_STATEMENT);
}
#endif
@ -192,7 +196,7 @@ uint8_t system_execute_line(char *line)
if (!sys.abort) { // Execute startup scripts after successful homing.
sys.state = STATE_IDLE; // Set to IDLE when complete.
st_go_idle(); // Set steppers to the settings idle state before returning.
if (line[2] == 0) { system_execute_startup(line); }
if (line[2] == 0) { system_execute_startup(line); } // Execute startup script again.
}
break;
case 'S' : // Puts Grbl to sleep [IDLE/ALARM]
@ -342,7 +346,11 @@ uint8_t system_check_travel_limits(float *target)
}
#else
// NOTE: max_travel is stored as negative
if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { return(true); }
#ifdef HOMING_FORCE_POSITIVE_SPACE
if (target[idx] < 0 || target[idx] > -settings.max_travel[idx]) { return(true); }
#else
if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { return(true); }
#endif
#endif
}
return(false);