Skip to content

Commit

Permalink
Add new board - CNC_3040 based on ESP32 module (#82)
Browse files Browse the repository at this point in the history
* Add new board - CNC_3040

* fix name mixup
  • Loading branch information
shaise authored Sep 17, 2023
1 parent 17f1fbf commit e75e546
Show file tree
Hide file tree
Showing 7 changed files with 1,591 additions and 1 deletion.
20 changes: 20 additions & 0 deletions driver.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,26 @@
"fram": 1,
"i2c": 1
}
},
{
"name": "CNC 3040",
"symbol": "BOARD_CNC3040",
"URL": "https://github.com/shaise/grblHAL_CNC3040",
"MAP": "main/cnc3040_map.h",
"caps": {
"axes": 4,
"serial_ports": 2,
"eeprom": 1,
"digital_in": 0,
"digital_out": 0,
"probe": 1,
"safety_door": 1,
"mpg_mode": 0,
"sdcard": 0,
"wifi": 1,
"fram": 1,
"i2c": 0
}
}
]
}
3 changes: 3 additions & 0 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ OPTION(BOARD_FYSETC_E4 "Compile for Fysetc E4 v1.0 board" OFF)
OPTION(BOARD_XPRO_V5 "Compile for xPro v5 board - untested!" OFF)
OPTION(BOARD_MKS_DLC32_V2P0 "Compile for MKS DLC2" OFF)
OPTION(BOARD_MKS_TINYBEE_V1 "Compile for MKS Tinybee v1" OFF)
OPTION(BOARD_CNC3040 "Compile for CNC3040 controller" OFF)
OPTION(BOARD_MY_MACHINE "Compile for my_machine_map.h" OFF)

OPTION(X_AXIS_GANGED "Compile with ganged X axis" OFF)
Expand Down Expand Up @@ -399,6 +400,8 @@ elseif(BOARD_MKS_DLC32_V2P0)
target_compile_definitions("${COMPONENT_LIB}" PUBLIC BOARD_MKS_DLC32_V2P0)
elseif(BOARD_MKS_TINYBEE_V1)
target_compile_definitions("${COMPONENT_LIB}" PUBLIC BOARD_MKS_TINYBEE_V1)
elseif(BOARD_CNC3040)
target_compile_definitions("${COMPONENT_LIB}" PUBLIC BOARD_CNC3040)
elseif(BOARD_MY_MACHINE)
target_compile_definitions("${COMPONENT_LIB}" PUBLIC BOARD_MY_MACHINE)
endif()
Expand Down
98 changes: 98 additions & 0 deletions main/cnc3040_map.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
cnc3040.h - An embedded CNC Controller with rs274/ngc (g-code) support
Driver code for ESP32
Part of grblHAL
Copyright (c) 2021-2022 Terje Io
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/

#if N_ABC_MOTORS > 1
#error "Axis configuration is not supported!"
#endif

#define BOARD_NAME "CNC3040 4-axis CNC"
#define BOARD_URL "https://github.com/shaise/GrblCNC/tree/master/Hardware/GrblCnc3040"

// timer definitions
#define STEP_TIMER_GROUP TIMER_GROUP_0
#define STEP_TIMER_INDEX TIMER_0

#if MODBUS_ENABLE
#error VFD Spindle not supported!
#endif

#if KEYPAD_ENABLE == 2
#define UART2_TX_PIN GPIO_NUM_17
#define UART2_RX_PIN GPIO_NUM_16
#elif KEYPAD_ENABLE == 1
#error I2C Keypad not supported!
#endif

#if SDCARD_ENABLE
#error SD card not supported!
#endif

// Define step pulse output pins.
#define X_STEP_PIN GPIO_NUM_32
#define Y_STEP_PIN GPIO_NUM_25
#define Z_STEP_PIN GPIO_NUM_27

// Define step direction output pins. NOTE: All direction pins must be on the same port.
#define X_DIRECTION_PIN GPIO_NUM_33
#define Y_DIRECTION_PIN GPIO_NUM_26
#define Z_DIRECTION_PIN GPIO_NUM_18

// Define stepper driver enable/disable output pin(s).
#define STEPPERS_ENABLE_PIN GPIO_NUM_15

// Define homing/hard limit switch input pins and limit interrupt vectors.
#define X_LIMIT_PIN GPIO_NUM_36 // VP
#define Y_LIMIT_PIN GPIO_NUM_39 // VN
#define Z_LIMIT_PIN GPIO_NUM_34

// Define ganged axis or A axis step pulse and step direction output pins.
#if N_ABC_MOTORS > 0
#define M3_AVAILABLE
#define M3_STEP_PIN GPIO_NUM_5
#define M3_DIRECTION_PIN GPIO_NUM_4
#endif

// Define spindle enable and spindle direction output pins.

#define SPINDLE_ENABLE_PIN GPIO_NUM_2
#define SPINDLEPWMPIN GPIO_NUM_21

// Define flood and mist coolant enable output pins.

#define COOLANT_FLOOD_PIN GPIO_NUM_22
#define COOLANT_MIST_PIN GPIO_NUM_23

// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
// N/A

// Define probe switch input pin.
#if PROBE_ENABLE
#define PROBE_PIN GPIO_NUM_19
#endif

#if SAFETY_DOOR_ENABLE
#define SAFETY_DOOR_PIN GPIO_NUM_35 // ATC Door
#else
#define AUXINPUT0_PIN GPIO_NUM_35 // ATC Door
#endif

6 changes: 6 additions & 0 deletions main/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2374,8 +2374,14 @@ bool driver_init (void)
fs_littlefs_mount("/littlefs", esp32_littlefs_hal());
#endif

#if KEYPAD_ENABLE == 2
stream_open_instance(KEYPAD_STREAM, 115200, keypad_enqueue_keycode);
#endif


#include "grbl/plugins_init.h"


// no need to move version check before init - compiler will fail any mismatch for existing entries
return hal.version == 10;
}
Expand Down
4 changes: 3 additions & 1 deletion main/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ typedef struct {
#include "mks_tinybee_1_0_map.h"
#elif defined(BOARD_BLACKBOX_X32)
#include "BlackBoxX32_map.h"
#elif defined(BOARD_CNC3040)
#include "cnc3040_map.h"
#elif defined(BOARD_MY_MACHINE)
#include "my_machine_map.h"
#else // default board - NOTE: NOT FINAL VERSION!
Expand Down Expand Up @@ -200,7 +202,7 @@ extern SemaphoreHandle_t i2cBusy;
#error "I2C port not available!"
#endif

#if MPG_MODE_ENABLE || (MODBUS_ENABLE & MODBUS_RTU_ENABLED) || TRINAMIC_UART_ENABLE || defined(DEBUGOUT)
#if MPG_MODE_ENABLE || (MODBUS_ENABLE & MODBUS_RTU_ENABLED) || TRINAMIC_UART_ENABLE || defined(DEBUGOUT) || KEYPAD_ENABLE == 2
#define SERIAL2_ENABLE 1
#else
#define SERIAL2_ENABLE 0
Expand Down
53 changes: 53 additions & 0 deletions platformio.cnc3040.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
src_dir = main
include_dir = main

[wifi_networking]
build_flags =

[env:esp32doit-devkit-v1]
platform = espressif32 @ ~3.4.0
framework = espidf
board = esp32doit-devkit-v1
board_build.partitions = partitions.csv
board_build.cmake_extra_args =
-DWIFI_ENABLE=1
-DSDKCONFIG_DEFAULTS="sdkconfig.cnc3040"
-DKEYPAD_ENABLE=1
-DmDNS=ON
board_build.embed_files =
main/embedded/favicon.ico
main/embedded/ap_login.html
main/embedded/index.html.gz
build_flags =
-Wimplicit-fallthrough=1
-Wno-missing-field-initializers
-Wno-maybe-uninitialized
-Wno-stringop-truncation
-DBOARD_CNC3040=1
-DN_AXIS=4
-DWIFI_ENABLE=1
-DN_AXIS=4
-DPROBE_ENABLE=1
-DBLUETOOTH_ENABLE=0
-DWIFI_ENABLE=1
-DTELNET_ENABLE=1
-DWIFI_SOFTAP=0
-DSAFETY_DOOR_ENABLE=1
-DKEYPAD_ENABLE=2
-DMDNS_ENABLE=1
; -DCONFIG_IDF_TARGET_ESP32=1
; -DSPI_FLASH_SEC_SIZE=4096
monitor_speed=115200

lib_compat_mode = off
Loading

0 comments on commit e75e546

Please sign in to comment.