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

Multiple instances with SW serial read issue #19

Open
ACE1046 opened this issue Aug 21, 2018 · 2 comments
Open

Multiple instances with SW serial read issue #19

ACE1046 opened this issue Aug 21, 2018 · 2 comments

Comments

@ACE1046
Copy link

ACE1046 commented Aug 21, 2018

Thanks for library!
I'm trying to setup TMC2208 drivers on all axis on my RAMPS 1.4.
I'm connected all drivers with RX & TX, set correct pins in config, using software serial pins.
Problem is M122 command writes 0xC0:0C:00:00 for all axis even if I disconnect all pdn_uart pins except X axis. And I get 0x00:00:00:00 an all axis if I disconnect pdn_uart from X driver.
I wrote a simple sketch to check with.

#include <TMC2208Stepper.h>             // Include library
TMC2208Stepper driver1 = TMC2208Stepper(63, 40, 1);  // Create driver and use
TMC2208Stepper driver2 = TMC2208Stepper(66, 44, 1);  // Create driver and use

void setup() {
  Serial.begin(115200);             // Init used serial port

  driver1.beginSerial(115200);
  driver2.beginSerial(115200);
}

void loop() {
  uint32_t g;
  driver1.GCONF(&g);
  Serial.println(g);
  delay(1000);
  driver2.GCONF(&g);
  Serial.println(g);
  delay(1000);
}

Real values a read from port, witch driver created first. If I disconnect wire for first driver, I get zeros for both.

Looks like changing this 2 lines in TMC2208Stepper::TMC2208Stepper fixes problem:

-static SoftwareSerial mySWSerial = SoftwareSerial(SW_RX_pin, SW_TX_pin);
-SWSerial = &mySWSerial;
+SoftwareSerial *mySWSerial = new SoftwareSerial(SW_RX_pin, SW_TX_pin);
+SWSerial = mySWSerial;

After this fix, I get correct (different) status for different axis in marlin. Disconnecting individual driver results in correct M122 details.

I'm just a n00b, may be I didn't understand something, sorry.

@teemuatlut
Copy link
Owner

teemuatlut commented Aug 21, 2018

Alright thanks. If this works, it may be the answer to some of the error reports that were reported from Marlin users.

I edited your comment a bit with styling for clarity. Please do correct if I mistakenly changed something I shouldn't have.

I'm supposed to be debugging the TMC2208 today so I'll be able to test this as well.

@teemuatlut
Copy link
Owner

The fix is looking good on my end. Many thanks!
I'd still like to verify from a few sources that it's working now before creating a new release but the fix itself is online already.
I'll make sure to credit you if this goes through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants