MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.29k stars 19.24k forks source link

TMC262 BOB40 support and code changes #10531

Closed chriscg9 closed 5 years ago

chriscg9 commented 6 years ago

TMC262BOB40 does not to function. Link to product page https://www.digikey.com/product-detail/en/trinamic-motion-control-gmbh/TMC262-BOB40/1460-1243-ND/8037670 When configured in the firmware the drivers do not work

I decided to do some digging and found somethings that once changed allowed this driver to function. stepper_indirection.cpp Was (Enable is done via spi not pins so why is enable pin set here?)

#define _TMC_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_ENABLE_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR)

Fixed (changed the order and switched enable with CS)

#define _TMC_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_DIR_PIN, ST##_STEP_PIN, ST##_MAX_CURRENT)

With this changed i noticed that once the board booted up the motor would enable and hold rotor position and when told to move it would stop holding rotor position. So it would seem the logic is reversed for enable in SPI or just this BOB is different than the normal 26x boards.

I found what i was looking for and changed them see comment for what it was

#elif HAS_X_ENABLE //1134 find my changes
  #define  enable_X() X_ENABLE_WRITE( !X_ENABLE_ON) //X_ENABLE_ON
  #define disable_X() do{ X_ENABLE_WRITE(X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)//!X_ENABLE_ON

So i am unsure if the changes i have made will have any ill consequences down the road. But for the moment i am able to run the motors and power some very big steppers considering i get a full 2.8A at 40V

Any thoughts on the changes?

Picture of rough setup for bench testing before being put into a Stratasys FDM 20180425_223507

thinkyhead commented 6 years ago

I think you're onto something. This is the constructor for TMC26XStepper

TMC26XStepper(int number_of_steps, int cs_pin, int dir_pin, int step_pin, unsigned int current, unsigned int resistor=150);
thinkyhead commented 6 years ago

Any thoughts on the changes?

The initializer change in stepper_indirection.h fixes a bug, so that's a good start!

But the change to Marlin.h is not needed, because we have these in Configuration.h:

// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
// :{ 0:'Low', 1:'High' }
#define X_ENABLE_ON 0
#define Y_ENABLE_ON 0
#define Z_ENABLE_ON 0
#define E_ENABLE_ON 0 // For all extruders

…and they can just be set to 1 to invert the logic.

If the entire TMC26x line consistently inverts these pins, then this is something we should alert users about in the sanity-check file. Otherwise, we'll just have to document this consideration in a comment above the HAVE_TMC26X option in Configuration_adv.h.

I'll patch the first issue in the bugfix branches now, and then check the datasheets to see what we need to do about the second issue.

thinkyhead commented 6 years ago

According to the datasheet the DRV_ENN pin is Active Low. If connecting to that pin, then the default of X_ENABLE_ON 0 should be correct, with no need to modify the code.

chriscg9 commented 6 years ago

Awesome. Would it be better i just fix my code or download the bugfix branch?

Thanks for your help. I did not see the invert enable when skimming the config file thanks.

Do you have any recommendations as to what to set the microstep amount? Will i be limited in my top speed by setting it to the full 256? vs setting it to say 64? Or will the top end not be noticeable? My machine does have a very heavy XY gantry so i cant go to any crazy speeds.

Not my picture but this is what my gantry looks like dsc_0444

thinkyhead commented 6 years ago

I recommend the latest bug fix code. It’s more mature than 1.1.8.

Don’t use direct micro-stepping over 32x with an AVR-based board, and don’t use more than 16x micro-stepping on the Z axis and extruder. Your speeds will be limited by anything over these, and can even lead to rebooting the board.

thinkyhead commented 6 years ago

If you don’t see the invert enable options by skimming, then use the Find command in your favorite multi-file text editor instead.

chriscg9 commented 6 years ago

Okay thanks for the advice on the steps.

What board would be able to handle the full 256 steps and still ramps compatible? Re-arm or due? Any one better than the other?

thinkyhead commented 6 years ago

Due runs 4-5 times faster than AVR. Re-Arm runs 6-7 times faster. Either one should be more than capable of keeping up with 256 real micro-steps at typical printing speeds.

Note that Due is not RAMPS compatible. It requires a RAMPS4DUE with 3.3v support.

boelle commented 5 years ago

@chriscg9 is this one "solved" ?

chriscg9 commented 5 years ago

Yes it is solved.

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.