Skip to content

Commit

Permalink
Merge branch 'v1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Paciente8159 committed Jul 30, 2021
2 parents 7132c6f + 447476f commit 2f7a9c4
Show file tree
Hide file tree
Showing 229 changed files with 176,531 additions and 13,958 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ build/
*.x86_64
*.hex
*.lst
*.lss
*.bin
*.elf

Expand Down
52 changes: 48 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,54 @@

# Changelog

## [1.1.2] - 2021-06-23
## [1.2.0] - 2021-08-01

Version 1.2.0 is a major revision from the previous version that packs lots of new features and bug fixes.
Some of the major new features of this version are:
- the new HAL configuration file that introduces a more flexible way to modify the HAL and give customization power of LinuxCNC.
- the addition off new PID and encoder modules to be used by the new HAL config, powered by an internal RTC clock.
- integration [tinyUSB](https://github.com/hathach/tinyusb), a complete USB stack frame that simplifies the creation of HAL code for new MCU.
- the addition of an option for a 16-bit version of the bresenham line algorithm that can improve step rate for weak 8-bit processors or for specific applications like laser engraving.
- several revisions, improvements and important bug fixes in the core of µCNC to generate reliable stepping code.

Version 1.1.2 fixes an critical error on the STM32 HAL that cause several IO problems:
### Added
- added basic settings for Grbl if startup emulation enabled (this includes $1-it's not used and always returns 0 and $11-that sets the G64-cosine factor. This value should be between -1 and 1. If 0 it acts as G61-exact path mode and -1 acts as G61.1 exact stop mode) (#55)
- $0-max step rate is now used to top limit stepping frequency (#55)
- implemented stm32f1 EEPROM emulation in flash (with limitations) (#54)
- added new option for the 16-bit bresenham (instead of the 32-bit) version of the stepping generator algorithm (#49)
- added new PID and encoder modules. PID parameters can be stored via commands $2x0 - Kp, $2x1 - Ki and $2x2 - Kd (#42)
- integrated [tinyUSB](https://github.com/hathach/tinyusb) and adapted the core to use it (optional) (#41)
- new HAL configuration file
- added internal RTC (#38)

### Changed
- cleaned code, redundant function call, unnecessary volatile attributes from variables and unused variable in the motion control, planner and interpolator stages of the core code (#52)
- modified planner paths of motion and motionless actions (#51)
- added main stepping and idle information to speed up general stepping calculations in the stepping ISR (#51)
- optimization for synchronous serial TX with direct serial output without buffer (#50)
- modified ring buffer in TX to consume chars without waiting for a CR or LF (#49)
- modified motion control to reduce number of planner blocks for motions of length 0 (#49)
- improved real time status report (?) (no longer needing and empty buffer to send report-more responsive) (#48)
- response protocol collisions avoidance (#48)
- report will now always report at least 3 axis even if less than 3 are configured (to keep report structure needed by interface softwares) (#48)
- virtual MCU update to reflect current µCNC interface (#47)
- added option to disable controls or limits IO globally (#45)
- completely new file structure

### Fixed
- fixed STM32 HAL pin configuration macros caused bad pin configurations leading to unpredictable behavior. (#40)
- fixed planner speed profile calculations that was missing speed change between blocks and was causing random miss stepping calculations (#52)
- added initial NULL char sending after configuration of UART to force TXE hardware set for STM32 and deleted duplicate SYNC TX config for STM32 (#50)
- fixed inch report mode setting that was hidden (#49)
- fixed error message on disabling soft limits command with homing disabled (#49)
- small step ISR code fixing (#46)
- fixed stepper enable pin set/reset to match most stepper drivers (negative logic) (#42)

## [1.1.2] - 2021-06-23

Version 1.1.2 fixes a critical error on the STM32 HAL that cause several IO problems. µCNC core and AVR have no changes from the previous version:

### Changed
- fixed STM32 HAL pin configuration macros caused bad pin configurations leading to unpredictable behavior. (#40)

## [1.1.1] - 2021-06-17

Expand Down Expand Up @@ -81,7 +123,7 @@ Version 1.1.0 comes with many added features and improvements over the previous
## [1.0.0-rc] - 2020-07-11

### Added
- added possibility of changing values og G28 and G30 commands via G10 L2 P28 and G10 L2 P30.
- added possibility of changing values of G28 and G30 commands via G10 L2 P28 and G10 L2 P30.
- added configuration for using software pulling input limit/control pins

### Changed
Expand Down Expand Up @@ -197,6 +239,8 @@ Version 1.1.0 comes with many added features and improvements over the previous

### Initial release

[1.2.0]: https://github.com/Paciente8159/uCNC/releases/tag/v1.2.0
[1.1.2]: https://github.com/Paciente8159/uCNC/releases/tag/v1.1.2
[1.1.1]: https://github.com/Paciente8159/uCNC/releases/tag/v1.1.1
[1.1.0]: https://github.com/Paciente8159/uCNC/releases/tag/v1.1.0
[1.0.0]: https://github.com/Paciente8159/uCNC/releases/tag/v1.0.0
Expand Down
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@ Heavily inspired by the by [Grbl](https://github.com/gnea/grbl) and [LinuxCNC](h
1. µCNC is written in C (GNU99 compliant). This gives the advantage of being supported for a large number of CPU/MCU and compilers available.
2. Modular library based:
- Independent hardware. All MCU/hardware operations are written in a single translation unit that acts like a standardized HAL interface, leaving the CNC controlling code independent of the MCU architecture has long has it has the necessary abilities to execute code and respond to interrupts in a predictable. Porting µCNC for a different MCU should be fairly straight forward.
- Independent kinematics. Another dimension of the HAL is the possibility of defining how the translation between machine coordinates and the motions is translated back and forth. This should theoretically allow µCNC to be easily adaptable to several types of machines like cartesian, corexy, deltas and others. µCNC supports up to 6 axis.
- Independent kinematics. Another dimension of the HAL is the possibility of defining how the translation between machine coordinates and the motions is translated back and forth. This should theoretically allow µCNC to be easily adaptable to several types of machines like cartesian, coreXY, deltas and others. µCNC supports up to 6 axis.
- Has of version 1.2.0 the addition of a HAL config that allow the user to build link inputs and outputs of the controller to specific functions or modules (like using a generic input has an encoder input or a PWM output has a servo controller with a PID module)
3. Compatible with already existing tools and software for Grbl. There is no point in trying to reinvent the wheel (the hole wheel at least :-P). For that reason µCNC (tries) to use the exact same protocol has Grbl. This allows it to easily integrate with Grbl ecosystem.

## Supporting the project
µCNC is a completely free software. It took me a considerable amount of hours and effort to develop and debug so any help is appreciated. Building docs, testing and debugging, whatever. Also if you really like it and want help me keep the project running, you can help me to buy more equipment or simply buy me a coffee or two ;-)
µCNC is a completely free software. It took me a considerable amount of hours and effort to develop and debug so any help is appreciated. Building docs, testing and debugging, whatever. Also if you really like it and want help me keep the project running, you can help me to buy more equipment. Recently I have saved some extra money and bought a laser engraver. This hardware was fundamental to develop and testing version 1.2.0. Currently this machine is being used to work on other projects and is running µCNC smoothly. Or you may just want to simply buy me a coffee or two for those extra long nights putting out code ;-)

[![paypal](https://www.paypalobjects.com/webstatic/en_US/i/buttons/PP_logo_h_100x26.png)](https://www.paypal.me/paciente8159)

## Current µCNC status
µCNC current version is v1.1.x. This update added a few new features needed for the (near) future upgrade and some more bug fixes.
µCNC current version is v1.2.0. This update added lot of new features needed for the future hardware/features support and some important bug fixes.
These include:

- Added and RTC to the µCNC mcu HAL
- Software configurable debounce delay for homming switches
- Additional (configurable via build) option to emulate Grbl startup message to improve software compatibility (like Candle and others)
- Some important bug fixes in for the STM32F1 HAL
- the new HAL configuration file that introduces a more flexible way to modify the HAL and give customization power of LinuxCNC.
- the addition off new PID and encoder modules to be used by the new HAL config, powered by an internal RTC clock.
- integration [tinyUSB](https://github.com/hathach/tinyusb), a complete USB stack frame that simplifies the creation of HAL code for new MCU.
- the addition of an option for a 16bit version of the bresenham line algorithm that can improve step rate for weak 8bit processors or for specific applications like laser engraving.

### G-Codes support
µCNC for now supports most of the RS274NGC v3:
Expand All @@ -50,12 +51,12 @@ List of Supported G-Codes since µCNC 1.0.0-beta.2:
- Valid Non-Command Words: A, B, C, F, I, J, K, L, N, P, R, S, T, X, Y, Z
- Valid Non-Command Words: E (used by 3D printing firmwares like [Marlin](https://github.com/MarlinFirmware/Marlin)) (currently not used)
_* also G10 L2 P28 and P30 to set homming coordinates_
_* also G10 L2 P28 and P30 to set homing coordinates_
```

TODO List of G-Codes in µCNC future releases:
- Program Flow: M0, M1
- PID control
- Program Flow: M0, M1 with the new HAL config
- extending the capabilities and functions of the new HAL config

### µCNC capabilities
µCNC currently supports up to (depending on the MCU/board capabilities):
Expand All @@ -72,7 +73,7 @@ TODO List of G-Codes in µCNC future releases:
- 16 generic digital inputs
- 16 generic digital outputs

µCNC with a configuration similar to Grbl is be able to keep up to 30Khz step rate for a 3 axis machine on an Arduino Uno at 16Mhz. (the stated rate depends on the lenght of the segments too, since many short length segments don't allow full speed to be achieved)
µCNC with a configuration similar to Grbl is be able to keep up to 30KHz step rate for a 3 axis machine on an Arduino Uno at 16Mhz. (the stated rate depends on the length of the segments too, since many short length segments don't allow full speed to be achieved). For this specific type of use (like in laser engraving) a 16bit version of stepping algorithm is possible pushing the theoretical step rate limit to 40KHz on a single UNO board.

### Current µCNC supported hardware
µCNC initial development was done both around Arduino UNO board just like GRBL. But µCNC can also be installed in other AVR boards like Arduino Mega (for Ramps), or similar boards (like Rambo). With v1.1.0 STM32F10x was added.
Expand All @@ -81,20 +82,19 @@ I used several UNO emulators but debugging was not easy. So a kind of virtual bo
It can run on:
- Arduino UNO
- Arduino MEGA
- STM32F1 Blue Pill (with some limitations)
- STM32F1 Blue Pill
- Windows PC (used for simulation only - ISR on Windows doesn't allow to use it a real alternative)

### µCNC roadmap
Right now a couple of changes are being staged in µCNC to prepare for future and easier expansions.
A couple were introduced with version 1.2.0 of µCNC to prepare for future and easier expansions.
These changes are:
- Add some extra functionalities like tool speed encoding, positional encoders, etc...
- Improvements to the HAL
- Change the files path structure to be more organic and well organized (this is already implemented for the next release)
- Possibly integrate µCNC with Arduino IDE across all platforms
- Move all USB stack related functionalities to a third-party library called [tinyUSB](https://github.com/hathach/tinyusb) (this is already implemented for the next release)
- Add more hardware configurations (SAMD21 developement has started)

### Building µCNC
For building µCNC go ahead to the [mcus](https://github.com/Paciente8159/uCNC/blob/master/uCNC/mcus) folder of the target MCU and follow the instructions specific to your device.
- Change the files path structure to be more organic and well organized
- Move all USB stack related functionalities to a third-party library called [tinyUSB](https://github.com/hathach/tinyusb), opening the possibilities and speed development for new MCU's

Future versions are in plan for:
- Possibly integrate µCNC with Arduino IDE across all platforms (in study)
- Add more hardware configurations (SAMD21 development has started)

### Building µCNC
For building µCNC go ahead to the [makefiles](https://github.com/Paciente8159/uCNC/blob/master/makefiles) folder of the target MCU and follow the instructions specific to your device.
Binary file modified docs/avr_mcumap_gen.xlsx
Binary file not shown.
19 changes: 0 additions & 19 deletions docs/clocks.txt

This file was deleted.

Binary file modified docs/stm32f1_mcumap_gen.xlsx
Binary file not shown.
Binary file added docs/~$avr_mcumap_gen.xlsx
Binary file not shown.
13 changes: 13 additions & 0 deletions examples/uCNC/uCNC.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <cnc.h>

void setup()
{
// put your setup code here, to run once:
cnc_init();
}

void loop()
{
// put your main code here, to run repeatedly:
cnc_run();
}
11 changes: 11 additions & 0 deletions library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name=uCNC
version=1.1.1
author=João Martins
maintainer=João Martins
sentence=µCNC - A universal CNC firmware for microcontrollers
paragraph=Heavily inspired by the by Grbl and LinuxCNC, µCNC started to take shape in the second half of 2019 in an attempt to come out with a G-Code interpreter/controller software/firmware that is both compact and powerful as Grbl and flexible and modular as LinuxCNC.
category=Other
url=https://github.com/Paciente8159/uCNC/
architectures=*
includes=boards.h,kinematics.h,cnc.h
depends=
3 changes: 1 addition & 2 deletions uCNC/mcus/avr/main.c → makefiles/avr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ void main(void)
//initializes all systems
cnc_init();

for(;;)
for (;;)
{
cnc_run();
}

}
10 changes: 6 additions & 4 deletions uCNC/mcus/avr/makefile → makefiles/avr/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
MCU = atmega328p
CC = avr-gcc
LIBS = -w -Os -gdwarf-2 -flto -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=$(MCU)
CFLAGS = -I"../../" -Os -Wall -Wextra -D__DEBUG__ -Os -gdwarf-2 -w -std=gnu99 -ffunction-sections -fdata-sections -mcall-prologues -mrelax -MMD -flto -fno-fat-lto-objects -mmcu=$(MCU) -DF_CPU=16000000L
CFLAGS = -I"../../src/" -Os -Wall -Wextra -gdwarf-2 -w -std=gnu99 -ffunction-sections -fdata-sections -mcall-prologues -mrelax -MMD -flto -fno-fat-lto-objects -mmcu=$(MCU) -DF_CPU=16000000L
BIN = $(BUILDDIR)/uCNC.elf
HEX = $(BIN:.elf=.hex)
SOURCEDIR= ../..
SOURCEDIR= ../../src
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
SOURCE = $(wildcard *.c)\
$(wildcard $(SOURCEDIR)/*.c)
$(call rwildcard,$(SOURCEDIR)/,*.c)

BUILDDIR = build
OBJ = $(SOURCE:.c=.o)
LINKOBJ = $(addprefix $(BUILDDIR)/,$(notdir $(OBJ)))
Expand All @@ -20,7 +22,7 @@ RM = rm -f
all: all-before $(BIN) all-after

clean: clean-custom
${RM} $(LINKOBJ) $(DOBJ) $(BIN) $(HEX)
-rm -fR $(BUILDDIR)

all-before:
-mkdir build
Expand Down
93 changes: 37 additions & 56 deletions uCNC/mcus/stm32f10x/Makefile → makefiles/stm32f103/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# target
######################################
TARGET = uCNC

USE_USB = TRUE

######################################
# building variables
Expand All @@ -24,62 +24,33 @@ DEBUG = 0
# optimization
OPT = -Os


#######################################
# paths
#######################################
# Build path
BUILD_DIR = build

######################################
# helper
######################################
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))

######################################
# source
######################################
# C sources
C_SOURCES = \
Src/main.c \
Src/usb_device.c \
Src/usbd_conf.c \
Src/usbd_desc.c \
Src/usbd_cdc_if.c \
Src/stm32f1xx_it.c \
Src/stm32f1xx_hal_msp.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
Src/system_stm32f1xx.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c \
mcu_stm32f10x.c \
../../settings.c \
../../cnc.c \
../../interpolator.c \
../../io_control.c \
../../kinematics_cartesian.c \
../../kinematics_corexy.c \
../../motion_control.c \
../../parser.c \
../../planner.c \
../../protocol.c \
../../serial.c
stm32f103.c \
main.c \
$(call rwildcard,../../src,*.c)

ifdef USE_USB
C_SOURCES += $(call rwildcard,../../tinyusb/src/,*.c)
endif

# ASM sources
ASM_SOURCES = \
startup_stm32f103xb.s
#ASM_SOURCES = \
#startup_stm32f103xb.s


#######################################
Expand Down Expand Up @@ -123,24 +94,34 @@ AS_DEFS =

# C defines
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32F103xB \
-DBOARD=BOARD_BLUEPILL
-DSTM32F103x6 \
-DSTM32F10X_MD \
-DBOARD=BOARD_BLUEPILL

ifdef USE_USB
C_DEFS += -DCFG_TUSB_MCU=OPT_MCU_STM32F1 \
-DUSB_VCP
endif

# AS includes
AS_INCLUDES =

# C includes
ifdef USE_USB
C_HEADERS = $(call rwildcard,../../tinyusb/src/,*.h)
C_HEADERS += $(call rwildcard,../../tinyusb/hw/mcu/st/cmsis_device_f1/Include/,*.h)
endif


# C includes
C_INCLUDES = \
-IInc \
-IDrivers/STM32F1xx_HAL_Driver/Inc \
-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
-IMiddlewares/ST/STM32_USB_Device_Library/Core/Inc \
-IMiddlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc \
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
-IDrivers/CMSIS/Include \
-I"../../"
-I"./" \
-Idrivers \
-I"../../src/"

ifdef USE_USB
C_INCLUDES += $(foreach d,$(C_HEADERS),$(addsuffix $(dir $(d)),"-I"))
endif

# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
Expand All @@ -160,7 +141,7 @@ CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32F103C8Tx_FLASH.ld
LDSCRIPT = stm32f103.ld

# libraries
LIBS = -lc -lm -lnosys
Expand Down
Loading

0 comments on commit 2f7a9c4

Please sign in to comment.