Skip to content

[2.0.x] MKS SBASE Trinamic examples/support#11402

Merged
thinkyhead merged 4 commits intoMarlinFirmware:bugfix-2.0.xfrom
forkoz:mks_trinamic
Jul 31, 2018
Merged

[2.0.x] MKS SBASE Trinamic examples/support#11402
thinkyhead merged 4 commits intoMarlinFirmware:bugfix-2.0.xfrom
forkoz:mks_trinamic

Conversation

@forkoz
Copy link
Contributor

@forkoz forkoz commented Jul 28, 2018

Description

Trinamic steppers are not easy to set up. This might help a few people in the future. Full disclosure I don't have any but read up on what they need.

Benefits

People using this stepper won't have to suffer as much configuring it.

Related Issues

Should we pull all stepper libraries for all platforms? eg. this one had 2130s but not 2208s. they are small. Already use a lot of LCD libs everywhere.

forkoz added 2 commits July 28, 2018 09:59
Put some pins that should work and successfully compile without giving up too much functionality. Should help a few peeps.
should we add all these to all platforms instead of making people hunt the libraries down? they're only a few KB and I'm already downloading libraries for LCDs I'll never use....
@p3p
Copy link
Member

p3p commented Jul 28, 2018

The LPC176x platform is not Arduino compatible, so any Arduino library that does work is just a fluke or in the case of (some of) TeemuAtLUTs libraries specifically made compatible. So we limit what is available to the build on purpose (also disable the auto library find feature), it's nice to know that the TMC2208 library is building and hopefully functional.

@forkoz
Copy link
Contributor Author

forkoz commented Jul 28, 2018

So the other platforms with HALs would also be incompatible in the same vein and would have to be tested? This should be functional as another user is rocking 2208s right now.

@p3p
Copy link
Member

p3p commented Jul 28, 2018

The other platforms are all built on top of preexisting Arduino Cores so "should" be generally compatible with Arduino libraries, but looking at the amount of ignored libraries in their builds I'm pretty sure they also have issues, rather than ignore libraries I turned the LDF off for the LPC176x build.

@hermitcrabslab
Copy link

hermitcrabslab commented Jul 28, 2018

@forkoz mine does not work yet for some reason enabling TMC2208 for testing purpose only on X and using your mks branch leads to firmware freeze on boot.
I tried the pins you defined P1_22/P2_12 for X stepper on smoothieware and it freeze too while it works with P0_27/P0_28, no way to full test since tmc_util is not implemented, the author of pull request said in description: "As soft UART stalls the whole firmware and cannot be used on a regular basis, it is just used during driver SETUP"
I am a bit lost atm sinc I didn't looked in detail on both implementation so dunno how diff are the libs but it does your branch work for you, mind to share some working firmware or other inputs so I can test?
For the reference here is the config part from smoothiware:

Motor driver configuration

motor_driver_control.driver.enable              true            # Enable motor driver module
motor_driver_control.driver.axis                X               # Axis designator on which the motor driver is set 
motor_driver_control.driver.chip                TMC2208         # Motor driver chip type
motor_driver_control.driver.sw_uart_tx_pin      0.27            # Transmitting line from the board to the driver
motor_driver_control.driver.sw_uart_rx_pin      0.28            #  Receiving line to the board
motor_driver_control.driver.sw_uart_baudrate    9600            # Software UART baudrate. Value higher than 50k is not recommended
motor_driver_control.driver.current             1000            # Motor currents in mA
motor_driver_control.driver.sense_resistor      50              # Sensing resistor value as a reference in milliohms
motor_driver_control.driver.microsteps          16              # Set microstepping value per step pulse. It can be 1, 2, 4, 8, 16, 32, 64, 128 or 256 microsteps
motor_driver_control.driver.chopper_mode        0               # 0 = spreadCycle ; 1 = stealthChop 

@forkoz
Copy link
Contributor Author

forkoz commented Jul 29, 2018

Remember, I don't have the HW. I have DRVs right now and LVs to use when I get the breakout boards and feel like wiring it all up. These are pins that make sense for the requirements. Do you have anything else on J8? You have to make sure those functions are off.

for instance, in your config you have
#define SDSUPPORT

which would use pins on J8 with custom cable.
#define SCK_PIN P1_22 // J8-2 (moved from EXP2 P0.7)
#define MISO_PIN P1_23 // J8-3 (moved from EXP2 P0.8)
#define MOSI_PIN P2_12 // J8-4 (moved from EXP2 P0.9)

On sBase there are simply not enough pins and you have to chose. We do have 1 easy hardware serial on aux1 connector where I think you have MKS tft?

Library issues could be a problem as was mentioned above. But if it works on 1 set of pins it should work on others.

**Also.. P0_27/28 are both interrupt capable. Try Pin 2.11 and 2.12 as X and see if it works.

@hermitcrabslab
Copy link

@forkoz You are correct I have MKS TFT32 on AUX1, nothing else yet, EXP1 and EXP2 are free as extra pins.
I tried without TFT and also only one motor connected to TMC2208 on X axes and one termistor just to see if i get smth from it or is freeze and made no diff, freeze no matter what pins I use.
Atm I am shooting in the dark I will look for my usb2serial adapter and see if I can get some serial debug from this thing, will keep you posted.

@forkoz
Copy link
Contributor Author

forkoz commented Jul 29, 2018

Did you try 2 interrupt capable pins? That SDSupport is only for SD on LCD thru EXP connectors. Having 2 functions on 1 pin even disconnected causes hangs like that.

EXP1/2 all the 0.X pins should be interruptible.
https://cdn.instructables.com/FGD/4GXN/IMP63RRO/FGD4GXNIMP63RRO.LARGE.jpg

@hermitcrabslab
Copy link

Yes I have looked on schematic but weird is it freeze even without y cable connected to pins, my best bet w/o proper debug is that smth is bad on TMC2208Stepper lib.

@forkoz
Copy link
Contributor Author

forkoz commented Jul 29, 2018

You can set it up as HW serial in place of MKS tft, wonder if that works.

@hermitcrabslab
Copy link

hermitcrabslab commented Jul 30, 2018

@forkoz HardwareSerial looks like it "works" https://pastebin.com/9epZqERY
For some reason I dunno it say that is not enabled in debug, also it crushed soon after debug(all leds on) and windows reinstalled the driver for smootie o_O
Next reboot no crush, so beauty..
What I did to get here was to adjust your pins_MKS_SBASE.h: https://pastebin.com/7naLyLnv
The driver has SpreadCycle set using Fysetc tool and also TOFF to 2 as per this helpful video instruction
I failed to get any debug/serial connection out using my cheap usb2serial adapters, still investigating what I do wrong. or maybe I need a better dongle...

@forkoz
Copy link
Contributor Author

forkoz commented Jul 30, 2018

I think you need TTL level serial adapter for this since its 3.3v serial. I figured the HW serial would work.
If you don't have 2nd extruder and can move the Y maybe you can get all 3 working.

port3 - sdcard
port2
0.10/0.11 - y_en/y_dir
port1
0.15/0.16 - exp1 connector
port0- you are using
port-1- usb

@hermitcrabslab
Copy link

I plan for this board a diamond hotend with 3 extruder, I want TMC 2208 only for X/Y for the rest I have some TL-Smoothers and dumpers, it will silence the 8825 enough imho...
Hope we can get SoftwareSerial to work even we are forced to implement it on boot only as is in this pull request

@forkoz
Copy link
Contributor Author

forkoz commented Jul 30, 2018

Yea, I don't know why it wouldn't work after boot. It really must be due to the library. For now I'll just add back 3 hardware serials on this one.

@p3p
Copy link
Member

p3p commented Jul 30, 2018

Our LPC176x software serial has no relation to smoothiewares implementation, I can't say why they have that problem, they will also not be using the TMC2208 Arduino Library.

For some reason I dunno it say that is not enabled in debug, also it crushed soon after debug(all leds on) and windows reinstalled the driver for smootie o_O

Not really clear, but I think you mean the hardware serial caused a watchdog reset? the board will appear as a smoothieware device because the bootloader takes control on watchdog reset.

Does the software serial cause watchdog reset or freeze?

@forkoz
Copy link
Contributor Author

forkoz commented Jul 30, 2018

Can we not use more than 2 serial ports yet for peripherals?

I also notice that if you only define 1 port, port 2 takes serial0 always. No way to have only 1 or > 2.

@p3p
Copy link
Member

p3p commented Jul 30, 2018

This is an optimisation that was necessary to only create the serial objects if they are used by Marlin, (for gcode) to save RAM, didn't matter as the platform isn't compatible with Arduino libraries anyway ;) and was an easy fix for the problem.

My branch at https://github.com/p3p/Marlin/tree/pr_bf2_pulloutlpcframework using my new external framework implements the Hardware Serial in a more Arduino compatible way, having Serial(0-3) always available, .. assuming the branch works at all (it's my working branch using an experimental framework and build platform).

@forkoz
Copy link
Contributor Author

forkoz commented Jul 31, 2018

This is good if you are using these pins for say TMC drivers... but what if you are using the USB, AUX1, EXP1 for something else?

@p3p
Copy link
Member

p3p commented Jul 31, 2018

I'm not sure what you mean,

@forkoz
Copy link
Contributor Author

forkoz commented Jul 31, 2018

If uart 1, 2, 3 is active and LCD is hooked up in EXP1 there will be a conflict, would there not?

@p3p
Copy link
Member

p3p commented Jul 31, 2018

No that's not an issue if the Serial objects are never used they are not linked into the firmware and the pins are free to be used

@thinkyhead thinkyhead changed the title Mks Sbase trinamic examples/support [2.0.x] MKS SBASE Trinamic examples/support Jul 31, 2018
@thinkyhead thinkyhead merged commit 2cc950d into MarlinFirmware:bugfix-2.0.x Jul 31, 2018
@gloomyandy
Copy link
Contributor

Looking at the datasheet for the TMC2208 it seems it is possible to just use a single TX output to talk ro multiple devices and set all of the driver operating parameters in one go (assuming you want them all to be the same). Obviously this means that you are not able to read status information back from the driver, but given that the TMC2208 does not support things like stallguard is this really an issue? Would it be possible to use this single wire mode with Marlin? I assume that if the status reports are not required then just a single pin would be required per driver to allow different parameter settings. It would not be possible to verify that the settings have been accepted, but I guess you could send the setting commands multiple times which should ensure they are received ok.

Would operating the tmc2208 in this mode work? What what be lost from not having the status information available?

@Studna3D
Copy link

Studna3D commented Aug 3, 2018

When I set default pin for MKS Sbase and define #define TMC_USE_SW_SPI in configuration_adv.h
I can't compile it. I saw that default configuration.h changed ( I am used it for compile), but preset configuration.h for MKS Sbase did not change for this:

/**
 * Specify Stepper Driver types
 * The options are used to determine driver pulse timings as well as more advanced functionality.
 * Stepper timing options can be overridden in Configuration_adv.h
 *
 * Options: A4988, DRV8825, LV8729, L6470, TB6560, TB6600, TMC2100,
 *          TMC2130, TMC2130_STANDALONE, TMC2208, TMC2208_STANDALONE,
 *          TMC26X,  TMC26X_STANDALONE,  TMC2660, TMC2660_STANDALONE,
 *          TMC5130, TMC5130_STANDALONE
 * :['A4988', 'DRV8825', 'LV8729', 'L6470', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE']
 */
#define X_DRIVER_TYPE  A4988
#define Y_DRIVER_TYPE  A4988
#define Z_DRIVER_TYPE  A4988
#define X2_DRIVER_TYPE A4988
#define Y2_DRIVER_TYPE A4988
#define Z2_DRIVER_TYPE A4988
#define E0_DRIVER_TYPE A4988
#define E1_DRIVER_TYPE A4988
#define E2_DRIVER_TYPE A4988
#define E3_DRIVER_TYPE A4988
#define E4_DRIVER_TYPE A4988

It's OK?

I use TMC2130 for SPI.

@thinkyhead
Copy link
Member

Try:

#define X_DRIVER_TYPE  TMC2130
#define Y_DRIVER_TYPE  TMC2130
#define Z_DRIVER_TYPE  TMC2130
. . .
#define E0_DRIVER_TYPE TMC2130
. . .

@hermitcrabslab
Copy link

Maybe TMC2208Pilot can be used until we have an easy to test library for soft serial thing, then once in working state we can see where is the problem in Marlin..
Now a n00b question(don't shoot!), since ethernet is not used(yet) on Marlin, and also is kinda useless in Smoothieware, can we use/hack those pins for other tasks on MKS SBase?

@thinkyhead
Copy link
Member

can we use/hack those pins for other tasks on MKS SBase

Sure. Of course, you can do whatever you like with your own board, and assign any pin to any function you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants