Use normal TMC2590 configuration, separate enable pins, disable FTP because there's no SD card right now
This commit is contained in:
parent
05b29a54d1
commit
a0e5e5dcab
|
@ -1,6 +1,7 @@
|
||||||
#include "init_tmc2590.h"
|
#include "init_tmc2590.h"
|
||||||
|
|
||||||
#include "grbl/hal.h"
|
#include "grbl/hal.h"
|
||||||
|
#include "grbl/protocol.h"
|
||||||
|
|
||||||
#define TMC_SCK_PIN (27)
|
#define TMC_SCK_PIN (27)
|
||||||
#define TMC_CSN_PIN (28)
|
#define TMC_CSN_PIN (28)
|
||||||
|
@ -30,8 +31,14 @@ const static struct tmc2590_config {
|
||||||
{ DRVCONF, REPEAT3(SLPH(3)|SLPL(3)|SLP2(0)|VSENSE(1)|EN_PFD(1)|EN_S2VS(1)) },
|
{ DRVCONF, REPEAT3(SLPH(3)|SLPL(3)|SLP2(0)|VSENSE(1)|EN_PFD(1)|EN_S2VS(1)) },
|
||||||
// no step interpolation
|
// no step interpolation
|
||||||
// rising edge only
|
// rising edge only
|
||||||
// 1/64 microstepping
|
// 1/16 microstepping
|
||||||
{ DRVCTRL_SDOFF0, REPEAT3(MRES(2)) }
|
{ DRVCTRL_SDOFF0, REPEAT3(MRES(4)) }
|
||||||
|
/*
|
||||||
|
{CHOPCONF, REPEAT3(0x901b4)},
|
||||||
|
{SGCSCONF, REPEAT3(0xd001f)},
|
||||||
|
{DRVCONF, REPEAT3(0xef013)},
|
||||||
|
{DRVCTRL_SDOFF0, REPEAT3(0x0000)},
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint32_t tmc2590_mask_addr(uint32_t v, enum tmc2590_reg reg) {
|
static uint32_t tmc2590_mask_addr(uint32_t v, enum tmc2590_reg reg) {
|
||||||
|
@ -63,6 +70,8 @@ static uint32_t tmc2590_mask_addr(uint32_t v, enum tmc2590_reg reg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tmc2590_csn_enable(void) {
|
static void tmc2590_csn_enable(void) {
|
||||||
|
digitalWrite(TMC_CSN_PIN, HIGH);
|
||||||
|
delayMicroseconds(1);
|
||||||
digitalWrite(TMC_SCK_PIN, HIGH);
|
digitalWrite(TMC_SCK_PIN, HIGH);
|
||||||
delayMicroseconds(TMC2590_TCC_US);
|
delayMicroseconds(TMC2590_TCC_US);
|
||||||
|
|
||||||
|
@ -79,12 +88,12 @@ static void tmc2590_csn_disable(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tmc2590_send_bit(uint32_t bit) {
|
static void tmc2590_send_bit(uint32_t bit) {
|
||||||
digitalWrite(TMC_SCK_PIN, LOW);
|
|
||||||
if (bit) {
|
if (bit) {
|
||||||
digitalWrite(TMC_SDI_PIN, HIGH);
|
digitalWrite(TMC_SDI_PIN, HIGH);
|
||||||
} else {
|
} else {
|
||||||
digitalWrite(TMC_SDI_PIN, LOW);
|
digitalWrite(TMC_SDI_PIN, LOW);
|
||||||
}
|
}
|
||||||
|
digitalWrite(TMC_SCK_PIN, LOW);
|
||||||
delayMicroseconds(TMC2590_CLK_US);
|
delayMicroseconds(TMC2590_CLK_US);
|
||||||
digitalWrite(TMC_SCK_PIN, HIGH);
|
digitalWrite(TMC_SCK_PIN, HIGH);
|
||||||
delayMicroseconds(TMC2590_CLK_US);
|
delayMicroseconds(TMC2590_CLK_US);
|
||||||
|
@ -103,14 +112,26 @@ static void tmc2590_write_reg(const struct tmc2590_config* cfg) {
|
||||||
tmc2590_csn_disable();
|
tmc2590_csn_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_message(uint_fast16_t state) {
|
||||||
|
report_message("TMC inited", Message_Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void tmc2590_init(void) {
|
static void tmc2590_init(void) {
|
||||||
|
digitalWrite(TMC_SCK_PIN, HIGH);
|
||||||
|
digitalWrite(TMC_SDI_PIN, HIGH);
|
||||||
|
digitalWrite(TMC_CSN_PIN, HIGH);
|
||||||
|
|
||||||
pinMode(TMC_SCK_PIN, OUTPUT);
|
pinMode(TMC_SCK_PIN, OUTPUT);
|
||||||
pinMode(TMC_SDI_PIN, OUTPUT);
|
pinMode(TMC_SDI_PIN, OUTPUT);
|
||||||
pinMode(TMC_CSN_PIN, OUTPUT);
|
pinMode(TMC_CSN_PIN, OUTPUT);
|
||||||
|
delayMicroseconds(1);
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(tmc_config)/sizeof(tmc_config[0]); i++) {
|
for (int i = 0; i < sizeof(tmc_config)/sizeof(tmc_config[0]); i++) {
|
||||||
tmc2590_write_reg(&tmc_config[i]);
|
tmc2590_write_reg(&tmc_config[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protocol_enqueue_rt_command(test_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static driver_reset_ptr on_reset;
|
static driver_reset_ptr on_reset;
|
||||||
|
@ -120,11 +141,15 @@ static void tmc2590_on_reset(void) {
|
||||||
on_reset();
|
on_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_plugin(void) {
|
void my_plugin_init(void) {
|
||||||
|
// 100 ms delay to let the stepper controllers get situated
|
||||||
|
delay(100);
|
||||||
// TODO add message
|
// TODO add message
|
||||||
tmc2590_init();
|
tmc2590_init();
|
||||||
|
|
||||||
// hook into soft reset
|
// hook into soft reset
|
||||||
on_reset = hal.driver_reset;
|
on_reset = hal.driver_reset;
|
||||||
hal.driver_reset = tmc2590_on_reset;
|
hal.driver_reset = tmc2590_on_reset;
|
||||||
|
|
||||||
|
//protocol_enqueue_rt_command(test_message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ enum tmc2590_reg {
|
||||||
#define SEMIN_SIZE (4)
|
#define SEMIN_SIZE (4)
|
||||||
|
|
||||||
#define SEIMIN_SHIFT (15)
|
#define SEIMIN_SHIFT (15)
|
||||||
#define SEDN_SHIFT (2)
|
#define SEDN_SHIFT (13)
|
||||||
#define SEMAX_SHIFT (8)
|
#define SEMAX_SHIFT (8)
|
||||||
#define SEUP_SHIFT (5)
|
#define SEUP_SHIFT (5)
|
||||||
#define SEMIN_SHIFT (0)
|
#define SEMIN_SHIFT (0)
|
||||||
|
|
|
@ -54,7 +54,7 @@ N_AXIS has a default value of 3, edit grbl\config.h to increase.
|
||||||
//#define BLUETOOTH_ENABLE 1 // Set to 1 for HC-05 module. Requires Bluetooth plugin.
|
//#define BLUETOOTH_ENABLE 1 // Set to 1 for HC-05 module. Requires Bluetooth plugin.
|
||||||
//#define SPINDLE_HUANYANG 1 // Set to 1 or 2 for Huanyang VFD spindle. Requires spindle plugin.
|
//#define SPINDLE_HUANYANG 1 // Set to 1 or 2 for Huanyang VFD spindle. Requires spindle plugin.
|
||||||
//#define QEI_ENABLE 1 // Enable quadrature encoder interfaces. Max value is 1. Requires encoder plugin.
|
//#define QEI_ENABLE 1 // Enable quadrature encoder interfaces. Max value is 1. Requires encoder plugin.
|
||||||
//#define ETHERNET_ENABLE 1 // Ethernet streaming. Requires networking plugin.
|
#define ETHERNET_ENABLE 1 // Ethernet streaming. Requires networking plugin.
|
||||||
//#define SDCARD_ENABLE 1 // Run gcode programs from SD card, requires sdcard plugin.
|
//#define SDCARD_ENABLE 1 // Run gcode programs from SD card, requires sdcard plugin.
|
||||||
//#define KEYPAD_ENABLE 1 // I2C keypad for jogging etc., requires keypad plugin.
|
//#define KEYPAD_ENABLE 1 // I2C keypad for jogging etc., requires keypad plugin.
|
||||||
//#define PLASMA_ENABLE 1 // Plasma/THC plugin. To be completed.
|
//#define PLASMA_ENABLE 1 // Plasma/THC plugin. To be completed.
|
||||||
|
@ -87,7 +87,7 @@ N_AXIS has a default value of 3, edit grbl\config.h to increase.
|
||||||
|
|
||||||
#if ETHERNET_ENABLE > 0
|
#if ETHERNET_ENABLE > 0
|
||||||
#define TELNET_ENABLE 1 // Telnet daemon - requires Ethernet streaming enabled.
|
#define TELNET_ENABLE 1 // Telnet daemon - requires Ethernet streaming enabled.
|
||||||
#define FTP_ENABLE 1 // Ftp daemon - requires SD card enabled.
|
#define FTP_ENABLE 0 // Ftp daemon - requires SD card enabled.
|
||||||
#define WEBSOCKET_ENABLE 1 // Websocket daemon - requires Ethernet streaming enabled.
|
#define WEBSOCKET_ENABLE 1 // Websocket daemon - requires Ethernet streaming enabled.
|
||||||
#define NETWORK_HOSTNAME "GRBL"
|
#define NETWORK_HOSTNAME "GRBL"
|
||||||
#define NETWORK_IPMODE 1 // 0 = static, 1 = DHCP, 2 = AutoIP
|
#define NETWORK_IPMODE 1 // 0 = static, 1 = DHCP, 2 = AutoIP
|
||||||
|
|
|
@ -25,7 +25,9 @@
|
||||||
#define Z_DIRECTION_PIN (7u)
|
#define Z_DIRECTION_PIN (7u)
|
||||||
|
|
||||||
// Define stepper driver enable/disable output pin(s).
|
// Define stepper driver enable/disable output pin(s).
|
||||||
#define STEPPERS_ENABLE_PIN (10u)
|
#define X_ENABLE_PIN (10u)
|
||||||
|
#define Y_ENABLE_PIN (40u)
|
||||||
|
#define Z_ENABLE_PIN (39u)
|
||||||
|
|
||||||
// Define homing/hard limit switch input pins.
|
// Define homing/hard limit switch input pins.
|
||||||
#define X_LIMIT_PIN (20u)
|
#define X_LIMIT_PIN (20u)
|
||||||
|
|
Loading…
Reference in New Issue