-
Notifications
You must be signed in to change notification settings - Fork 49
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
Can't make simple example work #34
Comments
I have different microcontrollers, motors only one driver of this type. (have many other DriverSticks) So I could troubleshoot with those, but I don't feel it's where the problem. =\ |
Try switching the driver to another one, like A4988. That way you can test if the issue is with SPI or the rest of the wiring. |
it's 1.0 |
Exactly. Disconnect the SPI wires though. |
It took me some time to remember to connect Sleep to Reset as on this diagram: I've used the simplest program to run it: // defines pins numbers
const int stepPin = 8;
const int dirPin = 7;
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
}
void loop() {
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 200; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000); // One second delay
digitalWrite(dirPin,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int x = 0; x < 400; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000);
} With all that I was able to make it run (using A4988)! But when I switched to your simple script: #define DIR_PIN 7
#define STEP_PIN 8
#define EN_PIN 9
#define CS_PIN 17
bool dir = true;
#include <TMC2130Stepper.h>
TMC2130Stepper driver = TMC2130Stepper(EN_PIN, DIR_PIN, STEP_PIN, CS_PIN);
void setup() {
Serial.begin(9600);
while(!Serial);
Serial.println("Start...");
driver.begin(); // Initiate pins and registeries
driver.rms_current(1000); // Set stepper current to 600mA. The command is the same as command TMC2130.setCurrent(600, 0.11, 0.5);
driver.stealthChop(0); // Enable extremely quiet stepping
digitalWrite(EN_PIN, LOW);
}
void loop() {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(10);
uint32_t ms = millis();
static uint32_t last_time = 0;
if ((ms - last_time) > 2000) {
if (dir) {
Serial.println("Dir -> 0");
driver.shaft_dir(0);
} else {
Serial.println("Dir -> 1");
driver.shaft_dir(1);
}
dir = !dir;
last_time = ms;
}
} With EN_PIN, CS_PIN not connected. |
Update: Ok. I've changed |
I've added 1 second delay before each of |
Ok. I've looked what shat_dir is doing. It relies on TMC_MOD_REG, which is SPI way of controlling direction. So I assume test has succeeded - it works with A4988. Kinda. |
No idea how continue debugging? |
Can this stepper motor library be used with the accel stepper library? |
@prathameshj There was an issue about that #33 Btw, The movement in one direction I've described was about trying this lib with classic pololu stick Edit: |
Ok. Here is what I've done:
I also added |
I don't know how SPI works exactly, but I would assume SCK should have a constant frequency. I am not sure what it should be, but I assume anything lower than my Arduino internal clock, which is 16MHz. |
Maybe ISP doesn't clock on SCK between transactions? I couldn't find a definite answer anywhere. In this case, it's ok I don't see any signal there since this only happens during setup. I guess another option would be to use software SPI. Just because I don't have any other idea. . + I will order some other stepper driver with v1.1. Maybe I have busted driver 🤷♂️ |
That would be intentional.
I was testing some new driver last night and had communication issues with the driver as well. I'm not sure what would have changed but the commands sent were not correct. I'll be looking more closely into this so stay tuned. Maybe it affected TMC2130Stepper as well. |
I tested the "Simple" example from library version 2.3.0 and after setting up the correct pins, the code worked as expected. Your driver actually does look a bit smudged but it's hard to tell. pinMode(CS_PIN, OUTPUT);
digitalWrite(CS_PIN, HIGH);
Serial.print("DRV_STATUS=0x");
Serial.println(driver.DRV_STATUS(), HEX); Then report back with the response. EDIT: Another suggestion would be to try software SPI. |
I've tried prev. version of library. Didn't help. When I had DRV_STATUS=0x0 But after turning power line on and restarting I get this: DRV_STATUS=0x60000000
# 0110000000 0000000000000000000000 I switched on DRV_STATUS=0x81090000 # On initial start up with motor power on already
# 1000000100 00100 1 0000000000000000
# ^ full step active indicator, which is correct. I have driver.microsteps(0);
DRV_STATUS=0xE0090000 # On each consequative restart
# 1110000000 00100 1 0000000000000000 I have unused mega and RAMPS laying around. I can try with them. I just thought my setup with breadboard has less variables. I guess I would need to resolder headers for that. Next thing I try is software SPI |
I've tried Software SPI. IT already had status printout (but after With # 0b1100000000 00100 1 0000000000000000
# 0xD8090000 With # 0b1110100000 00100 1 00000 000 0 0 0 1 0 1 1 0
# ^ short to ground? :-\
# 0xE8090016 |
The Simple sketch was meant to be ran with native 256 microstepping, so when you're switching to fullsteps you're also asking the driver to run 256 times faster. Try increasing step delays 2560. The driver needs to be fully powered on from +12V as well for communication to work. |
Ok. I c. That makes sense. I can just leave it as is without full step. For some reason I thought full step will make it cleaner experiment. Does my debugging report tells you anything? I didn't understand from docs what first 10 bits represent. If first in order is 0th one |
When reading the register output, the first number on the left, is the most significant bit. |
I tried new delay. No spinning, but it got louder and vibrates a lot now. I will attach video in next post. Current status is this.
Is this how I should read it then?
with no noise and no movement. I am still using SW SPI, but I didn't change pins for it SPI cabels. I hope it's ok. |
They look like valid responses but you still have some error flags. |
Ignore that. I'll figure this out. |
Oh, that's the video I promised before https://photos.app.goo.gl/uXvsUa5BhQqL4dRf2 |
Holly shit. It works!With Mega and ramps! Now I need to figure out what's the difference between this and my previous setups. Power is the same. It's just another Microcontroller =\ |
Thank you @teemuatlut ! Let me close this issue since I made it work. But I will report when I figure out what was wrong. |
@soswow I'm trying a UNO right now and I'm unsuccessful, did you find the difference ? |
I know it's a horrible title. Feel free to change it.
Here is my setup:
Initially, I didn't know about Chinese clones having this non-SPI soldered bridge thing. It didn't work and the motor was making high pitch noises. I've desoldered one resistor and connected two other bridges according to instructions in one of Merlin issues.
It still doesn't work 😢Simple example doesn't work as is. Nothing happens. I can turn rotator with my fingers. When I disabled stealthChop motor starting vibrating making sound, but not turning.
I am not sure if I was able to kill the driver or I am missing anything else =( Thought maybe you have some ideas on how to debug this thing. I don't have a good scope, though I have a simple logic analyser and a good multimeter.
The text was updated successfully, but these errors were encountered: