-
Notifications
You must be signed in to change notification settings - Fork 23
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
Function shaft not working to change motor direction #23
Comments
I do have the same problem setting up on Atmega328p MCU Hopefully someone will put together the solution Thanks for posting |
Spent sometime trying to move a different direction and no luck. it seems not much support or resource available on TMC2208. Too bad! |
Tried it and it works. // Author Teemu Mäntykallio, 2017-04-07
// Define pins
#define EN_PIN 38 // LOW: Driver enabled. HIGH: Driver disabled
#define STEP_PIN 54 // Step on rising edge
#define RX_PIN 63 // SoftwareSerial pins
#define TX_PIN 40 //
#include <TMC2208Stepper.h>
// Create driver that uses SoftwareSerial for communication
TMC2208Stepper driver = TMC2208Stepper(RX_PIN, TX_PIN);
bool dir = true;
void setup() {
Serial.begin(250000);
while(!Serial);
driver.beginSerial(115200);
// Push at the start of setting up the driver resets the register to default
driver.push();
// Prepare pins
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
driver.pdn_disable(true); // Use PDN/UART pin for communication
driver.I_scale_analog(false); // Use internal voltage reference
driver.rms_current(500); // Set driver current = 500mA, 0.5 multiplier for hold current and RSENSE = 0.11.
driver.toff(2); // Enable driver in software
uint32_t drv_status;
driver.DRV_STATUS(&drv_status);
Serial.print("drv_status=");
Serial.println(drv_status, HEX);
switch (driver.test_connection()) {
case 1: Serial.println("Connection error: F");
case 2: Serial.println("Connection error: 0");
default: Serial.println("Connection OK");
}
digitalWrite(EN_PIN, LOW); // Enable driver in hardware
}
void loop() {
digitalWrite(STEP_PIN, HIGH);
delay(1);
digitalWrite(STEP_PIN, LOW);
delay(1);
uint32_t ms = millis();
static uint32_t last_time = 0;
if ((ms - last_time) > 2000) {
if (dir) {
Serial.println("Dir -> 0");
driver.shaft(0);
} else {
Serial.println("Dir -> 1");
driver.shaft(1);
}
dir = !dir;
last_time = ms;
}
} |
Thanks for replying
I am using Atmega328p MCU
I need to change the STEP and DIR and PDU , EN pins to match the MCU
correct.
Those pins assigned to a different MCU or CPu board
…On Sat, Dec 1, 2018, 3:44 AM teemuatlut ***@***.*** wrote:
Tried it and it works.
// Author Teemu Mäntykallio, 2017-04-07
// Define pins
#define EN_PIN 38 // LOW: Driver enabled. HIGH: Driver disabled
#define STEP_PIN 54 // Step on rising edge
#define RX_PIN 63 // SoftwareSerial pins
#define TX_PIN 40 //
#include <TMC2208Stepper.h>
// Create driver that uses SoftwareSerial for communication
TMC2208Stepper driver = TMC2208Stepper(RX_PIN, TX_PIN);
bool dir = true;
void setup() {
Serial.begin(250000);
while(!Serial);
driver.beginSerial(115200);
// Push at the start of setting up the driver resets the register to default
driver.push();
// Prepare pins
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
driver.pdn_disable(true); // Use PDN/UART pin for communication
driver.I_scale_analog(false); // Use internal voltage reference
driver.rms_current(500); // Set driver current = 500mA, 0.5 multiplier for hold current and RSENSE = 0.11.
driver.toff(2); // Enable driver in software
uint32_t drv_status;
driver.DRV_STATUS(&drv_status);
Serial.print("drv_status=");
Serial.println(drv_status, HEX);
switch (driver.test_connection()) {
case 1: Serial.println("Connection error: F");
case 2: Serial.println("Connection error: 0");
default: Serial.println("Connection OK");
}
digitalWrite(EN_PIN, LOW); // Enable driver in hardware
}
void loop() {
digitalWrite(STEP_PIN, HIGH);
delay(1);
digitalWrite(STEP_PIN, LOW);
delay(1);
uint32_t ms = millis();
static uint32_t last_time = 0;
if ((ms - last_time) > 2000) {
if (dir) {
Serial.println("Dir -> 0");
driver.shaft(0);
} else {
Serial.println("Dir -> 1");
driver.shaft(1);
}
dir = !dir;
last_time = ms;
}
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#23 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Ai_TjsYRuZ9K0dbsdvKZThjZgwROC1usks5u0muugaJpZM4YYEZz>
.
|
I am also facing the same issue with MKS Monster 8 V2.0.3 and BigTreeTech TMC2208. I have placed the jumpers correctly on Monster, i.e. Second from the left, yet I am not being able to change the direction. And yes, I also have changed the Pins Definitions as per the Monster8. |
I develop on Wemos Lolin32 lite board and manage to drive the TMC2208 driver. I can communicate with the driver but I can't manage to make the shaft function work. It should make the motor change direction but it doesn't on my setup.
Here is the code that I use to make the direction change :
The text was updated successfully, but these errors were encountered: