Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature esc support #115

Open
wants to merge 5 commits into
base: edge
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix macro name
  • Loading branch information
mikro64 committed Dec 22, 2019
commit 39ca1b4e43311b0322018c1174245a40dcfe07ad
2 changes: 1 addition & 1 deletion grbl/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@

// Enable spindle control using servo signal. Timer generate 50 Hz PWM signal, positive pulse width 1ms
// for stopped spindle and 2 ms for full speed of servo. It's suitable for ESC using.
// #define ENABLE_SPINDLE_ESC // Default disabled. Uncomment to enable.
// #define ENABLE_ESC_SPINDLE // Default disabled. Uncomment to enable.

// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
// for some pre-built electronic boards.
Expand Down
6 changes: 3 additions & 3 deletions grbl/cpu_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

// Advanced Configuration Below You should not need to touch these variables
// Set Timer up to use TIMER4B which is attached to Digital Pin 7
#ifdef ENABLE_SPINDLE_ESC
#ifdef ENABLE_ESC_SPINDLE
#define SPINDLE_PWM_MIN_VALUE 2000 // 1 ms
#define SPINDLE_PWM_MAX_VALUE 4000 // 2 ms
#else
Expand All @@ -118,7 +118,7 @@
#define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif

#ifdef ENABLE_SPINDLE_ESC
#ifdef ENABLE_ESC_SPINDLE
#define SPINDLE_PWM_OFF_VALUE 2000
#else
#define SPINDLE_PWM_OFF_VALUE 0
Expand All @@ -133,7 +133,7 @@
#define SPINDLE_TCCRA_INIT_MASK ((1<<WGM40) | (1<<WGM41))
#define SPINDLE_TCCRB_INIT_MASK ((1<<WGM42) | (1<<WGM43) | (1<<CS41))
#define SPINDLE_OCRA_REGISTER OCR4A // 16-bit Fast PWM mode requires top reset value stored here.
#ifdef ENABLE_SPINDLE_ESC
#ifdef ENABLE_ESC_SPINDLE
#define SPINDLE_OCRA_TOP_VALUE 0x9C40 // PWM counter reset value for ESC. Should be the same as PWM_MAX_VALUE in hex.
#else
#define SPINDLE_OCRA_TOP_VALUE 0x0400 // PWM counter reset value. Should be the same as PWM_MAX_VALUE in hex.
Expand Down
4 changes: 2 additions & 2 deletions grbl/spindle_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ uint8_t spindle_get_state()
// Called by spindle_init(), spindle_set_speed(), spindle_set_state(), and mc_reset().
void spindle_stop()
{
#ifdef ENABLE_SPINDLE_ESC
#ifdef ENABLE_ESC_SPINDLE
SPINDLE_OCR_REGISTER = SPINDLE_PWM_OFF_VALUE; // Set off value of PWM.
SPINDLE_TCCRA_REGISTER |= (1 << SPINDLE_COMB_BIT); // Ensure PWM output is enabled.
#else
Expand Down Expand Up @@ -89,7 +89,7 @@ void spindle_set_speed(uint16_t pwm_value)
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
#endif
}
#elif defined(ENABLE_SPINDLE_ESC)
#elif defined(ENABLE_ESC_SPINDLE)
SPINDLE_TCCRA_REGISTER |= (1 << SPINDLE_COMB_BIT); // Ensure PWM output is enabled.
#else
if (pwm_value == SPINDLE_PWM_OFF_VALUE) {
Expand Down