Skip to content

Commit

Permalink
RAMPS Support (#147)
Browse files Browse the repository at this point in the history
* RAMPS 1.4 Support

Add support for RAMPS 1.4 Arduino Mega shields.

Does not support ULN2003 drivers or un-modded 28BYJ steppers.

* Update Configuration_adv.hpp

* Version update

* Clang format

Co-authored-by: Andre Stefanov <[email protected]>
  • Loading branch information
CTetford and andre-stefanov authored Nov 28, 2021
1 parent 726faf5 commit 324543c
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**V1.9.38 - Updates**
- Add support for RAMPS 1.4 Arduino Mega shields

**V1.9.37 - Updates**
- Add HE1 to dew heater output for MKS boards

Expand Down
2 changes: 2 additions & 0 deletions Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@
// Append board specific pins data.
#if (BOARD == BOARD_AVR_MEGA2560)
#include "boards/AVR_MEGA2560/pins_MEGA2560.hpp"
#elif (BOARD == BOARD_RAMPS)
#include "boards/RAMPS/pins_RAMPS.hpp"
#elif (BOARD == BOARD_ESP32_ESP32DEV)
#include "boards/ESP32_ESP32DEV/pins_ESP32DEV.hpp"
#elif (BOARD == BOARD_AVR_MKS_GEN_L_V1)
Expand Down
6 changes: 4 additions & 2 deletions ConfigurationValidation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@
// Required pin assignments missing
#error Missing pin assignments for configured DEC DRIVER_TYPE_A4988_GENERIC or DRIVER_TYPE_TMC2209_STANDALONE driver
#endif
#if (!defined(DEC_MS0_PIN) || !defined(DEC_MS1_PIN) || !defined(DEC_MS2_PIN)) && (BOARD != BOARD_AVR_MKS_GEN_L_V1)
#if (!defined(DEC_MS0_PIN) || !defined(DEC_MS1_PIN) || !defined(DEC_MS2_PIN)) \
&& (BOARD != BOARD_AVR_MKS_GEN_L_V1 && BOARD != BOARD_AVR_RAMPS)
#warning Missing pin assignments for MS pins
#endif
#elif (DEC_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART)
Expand All @@ -268,7 +269,8 @@
// Required pin assignments missing
#error Missing pin assignments for configured RA DRIVER_TYPE_A4988_GENERIC or DRIVER_TYPE_TMC2209_STANDALONE driver
#endif
#if (!defined(RA_MS0_PIN) || !defined(RA_MS1_PIN) || !defined(RA_MS2_PIN)) && (BOARD != BOARD_AVR_MKS_GEN_L_V1)
#if (!defined(RA_MS0_PIN) || !defined(RA_MS1_PIN) || !defined(RA_MS2_PIN)) \
&& (BOARD != BOARD_AVR_MKS_GEN_L_V1 && BOARD != BOARD_AVR_RAMPS)
#warning Missing pin assignments for MS pins
#endif
#elif (RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART)
Expand Down
10 changes: 7 additions & 3 deletions Configuration_adv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@
#define RA_UART_STEALTH_MODE 0
#endif
#elif (RA_DRIVER_TYPE == DRIVER_TYPE_A4988_GENERIC) || (RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_STANDALONE)
#define RA_SLEW_MICROSTEPPING 8 // Microstep mode set by MS pin strapping. Use the same microstep mode for both slewing & tracking
#ifndef RA_SLEW_MICROSTEPPING
#define RA_SLEW_MICROSTEPPING 8 // Microstep mode set by MS pin strapping. Use the same microstep mode for both slewing & tracking
#endif
#define RA_TRACKING_MICROSTEPPING RA_SLEW_MICROSTEPPING
#elif (RA_DRIVER_TYPE == DRIVER_TYPE_ULN2003)
#define RA_SLEW_MICROSTEPPING 2 // The (default) half-step mode used for slewing RA axis
Expand All @@ -125,8 +127,10 @@
#define DEC_UART_STEALTH_MODE 0
#endif
#elif (DEC_DRIVER_TYPE == DRIVER_TYPE_A4988_GENERIC) || (DEC_DRIVER_TYPE == DRIVER_TYPE_TMC2209_STANDALONE)
#define DEC_SLEW_MICROSTEPPING \
16 // Only UART drivers support dynamic switching. Use the same microstep mode for both slewing & guiding
#ifndef DEC_SLEW_MICROSTEPPING
#define DEC_SLEW_MICROSTEPPING \
16 // Only UART drivers support dynamic switching. Use the same microstep mode for both slewing & guiding
#endif
#define DEC_GUIDE_MICROSTEPPING DEC_SLEW_MICROSTEPPING
#elif (DEC_DRIVER_TYPE == DRIVER_TYPE_ULN2003)
#define DEC_SLEW_MICROSTEPPING 2 // Runs in half-step mode always
Expand Down
2 changes: 1 addition & 1 deletion Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// So 1.8.99 is ok, but 1.8.234 is not. Neither is 1.123.22
// Also, numbers are interpreted as simple numbers. _ __ _
// So 1.8 is actually 1.08, meaning that 1.12 is a later version than 1.8. \_(..)_/
#define VERSION "V1.9.37"
#define VERSION "V1.9.38"
165 changes: 165 additions & 0 deletions boards/RAMPS/pins_RAMPS.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/**
* @brief a pins configuration file for a RAMPS 1.4 + Arduino Mega OAT.
*/

#pragma once

// DRIVER_TYPE_TMC2209_UART requires 4 digital pins in Arduino pin numbering
#ifndef RA_STEP_PIN
#define RA_STEP_PIN 54 // STEP
#endif
#ifndef RA_DIR_PIN
#define RA_DIR_PIN 55 // DIR
#endif
#ifndef RA_EN_PIN
#define RA_EN_PIN 38 // Enable
#endif
#ifndef RA_DIAG_PIN
#define RA_DIAG_PIN 43 // only needed for autohome function
#endif
// DRIVER_TYPE_TMC2209_UART requires 2 additional digital pins for SoftwareSerial, can be shared across all drivers
#ifndef RA_SERIAL_PORT_TX
#define RA_SERIAL_PORT_TX 23 // SoftwareSerial TX port
#endif
#ifndef RA_SERIAL_PORT_RX
#define RA_SERIAL_PORT_RX 25 // SoftwareSerial RX port
#endif
#ifndef RA_DRIVER_ADDRESS
#define RA_DRIVER_ADDRESS 0b00
#endif
// DRIVER_TYPE_TMC2209_UART requires 4 digital pins in Arduino pin numbering
#ifndef DEC_STEP_PIN
#define DEC_STEP_PIN 60 // STEP
#endif
#ifndef DEC_DIR_PIN
#define DEC_DIR_PIN 61 // DIR
#endif
#ifndef DEC_EN_PIN
#define DEC_EN_PIN 56 // Enable
#endif
#ifndef DEC_DIAG_PIN
#define DEC_DIAG_PIN 45 // only needed for autohome function
#endif
// DRIVER_TYPE_TMC2209_UART requires 2 additional digital pins for SoftwareSerial, can be shared across all drivers
#ifndef DEC_SERIAL_PORT_TX
#define DEC_SERIAL_PORT_TX 27 // SoftwareSerial TX port
#endif
#ifndef DEC_SERIAL_PORT_RX
#define DEC_SERIAL_PORT_RX 29 // SoftwareSerial RX port
#endif
#ifndef DEC_DRIVER_ADDRESS
#define DEC_DRIVER_ADDRESS 0b00
#endif

#define SW_SERIAL_UART 1

// DRIVER_TYPE_TMC2209_UART requires 4 digital pins in Arduino pin numbering
#ifndef AZ_STEP_PIN
#define AZ_STEP_PIN 46 // STEP
#endif
#ifndef AZ_DIR_PIN
#define AZ_DIR_PIN 48 // DIR
#endif
#ifndef AZ_EN_PIN
#define AZ_EN_PIN 62 // Enable
#endif
#ifndef AZ_DIAG_PIN
#define AZ_DIAG_PIN 47 // only needed for autohome function
#endif
// DRIVER_TYPE_TMC2209_UART requires 2 additional digital pins for SoftwareSerial, can be shared across all drivers
#ifndef AZ_SERIAL_PORT_TX
#define AZ_SERIAL_PORT_TX 31 // SoftwareSerial TX port
#endif
#ifndef AZ_SERIAL_PORT_RX
#define AZ_SERIAL_PORT_RX 33 // SoftwareSerial RX port
#endif
#ifndef AZ_DRIVER_ADDRESS
#define AZ_DRIVER_ADDRESS 0b00
#endif
// DRIVER_TYPE_TMC2209_UART requires 4 digital pins in Arduino pin numbering
#ifndef ALT_STEP_PIN
#define ALT_STEP_PIN 26 // STEP
#endif
#ifndef ALT_DIR_PIN
#define ALT_DIR_PIN 28 // DIR
#endif
#ifndef ALT_EN_PIN
#define ALT_EN_PIN 24 // Enable
#endif
#ifndef ALT_DIAG_PIN
#define ALT_DIAG_PIN 32 // only needed for autohome function
#endif
// DRIVER_TYPE_TMC2209_UART requires 2 additional digital pins for SoftwareSerial, can be shared across all drivers
#ifndef ALT_SERIAL_PORT_TX
#define ALT_SERIAL_PORT_TX 35 // SoftwareSerial TX port
#endif
#ifndef ALT_SERIAL_PORT_RX
#define ALT_SERIAL_PORT_RX 37 // SoftwareSerial RX port
#endif
#ifndef ALT_DRIVER_ADDRESS
#define ALT_DRIVER_ADDRESS 0b00
#endif

// DRIVER_TYPE_TMC2209_UART requires 4 digital pins in Arduino pin numbering. This is the E1 port.
#ifndef FOCUS_STEP_PIN
#define FOCUS_STEP_PIN 36 // STEP
#endif
#ifndef FOCUS_DIR_PIN
#define FOCUS_DIR_PIN 34 // DIR
#endif
#ifndef FOCUS_EN_PIN
#define FOCUS_EN_PIN 30 // Enable
#endif
#ifndef FOCUS_DIAG_PIN
#define FOCUS_DIAG_PIN 49 // only needed for autohome function
#endif
// DRIVER_TYPE_TMC2209_UART requires 2 additional digital pins for SoftwareSerial, can be shared across all drivers
#ifndef FOCUS_SERIAL_PORT_TX
#define FOCUS_SERIAL_PORT_TX 39 // SoftwareSerial TX port
#endif
#ifndef FOCUS_SERIAL_PORT_RX
#define FOCUS_SERIAL_PORT_RX 41 // SoftwareSerial RX port
#endif
#ifndef FOCUS_DRIVER_ADDRESS
#define FOCUS_DRIVER_ADDRESS 0b00
#endif

// RA Homing pin for Hall sensor
#ifndef RA_HOMING_SENSOR_PIN
#define RA_HOMING_SENSOR_PIN 53
#endif

//GPS pin configuration
#ifndef GPS_SERIAL_PORT
#define GPS_SERIAL_PORT Serial2 // Pins 16 and 17
#endif

// DISPLAY_TYPE_LCD_KEYPAD requires 6 digital & 1 analog output in Arduino pin numbering
#ifndef LCD_PIN4
#define LCD_PIN4 63
#endif
#ifndef LCD_PIN5
#define LCD_PIN5 40
#endif
#ifndef LCD_PIN6
#define LCD_PIN6 42
#endif
#ifndef LCD_PIN7
#define LCD_PIN7 59
#endif
#ifndef LCD_PIN8
#define LCD_PIN8 64
#endif
#ifndef LCD_PIN9
#define LCD_PIN9 44
#endif

// DISPLAY_TYPE_LCD_KEYPAD requires 1 analog input in Arduino pin numbering
#ifndef LCD_KEY_SENSE_PIN
#define LCD_KEY_SENSE_PIN 65
#endif

//Pin to turn on dew heater MOSFET
#ifndef DEW_HEATER_PIN
#define DEW_HEATER_PIN 10
#endif
24 changes: 24 additions & 0 deletions matrix_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"mksgenlv2",
"mksgenlv1",
"esp32",
"ramps",
]

STEPPER_TYPES = [
Expand Down Expand Up @@ -162,6 +163,29 @@ def update_dict(orig, patch):
"STEPPER_TYPE_NONE"
],
}),
"ramps": update_dict(BUILD_FLAGS, {
"USE_GPS": [0],
"USE_GYRO_LEVEL": [0],
"DISPLAY_TYPE": [
"DISPLAY_TYPE_NONE",
"DISPLAY_TYPE_LCD_KEYPAD"
],
"RA_STEPPER_TYPE": [
"STEPPER_TYPE_NEMA17"
],
"DEC_STEPPER_TYPE": [
"STEPPER_TYPE_NEMA17"
],
"AZ_STEPPER_TYPE": [
"STEPPER_TYPE_NEMA17"
],
"ALT_STEPPER_TYPE": [
"STEPPER_TYPE_NEMA17"
],
"FOCUS_STEPPER_TYPE": [
"STEPPER_TYPE_NEMA17"
],
}),
}

SHORT_STRINGS = {
Expand Down
6 changes: 6 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ lib_deps =
${common.lib_deps}
jdolinay/avr-debugger @ 1.2

[env:ramps]
extends = env:mega2560
build_flags =
${env.build_flags}
-D BOARD=BOARD_AVR_RAMPS

[env:mksgenlv21]
extends = env:mega2560
build_flags =
Expand Down

0 comments on commit 324543c

Please sign in to comment.