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

Ganging using 4 drivers #13

Closed
timm052 opened this issue Dec 11, 2021 · 21 comments
Closed

Ganging using 4 drivers #13

timm052 opened this issue Dec 11, 2021 · 21 comments

Comments

@timm052
Copy link

timm052 commented Dec 11, 2021

How would i go about configuring a XYYZ set up using an individual driver for each motor. I'm trying to create a board board profile for the CNC xPro V5 based on this GRBL-ESP32 file. https://github.com/Spark-Concepts/xPro-V5-Firmware

@terjeio
Copy link
Contributor

terjeio commented Dec 13, 2021

I now have added a board profile and tentative support for both ganged/auto squared axes and TMC5160 stepper drivers. Since I do not have the hardware to verify these changes with I'll have to ask you to do that.
Build configuration is in CMakeLists.txt.

Note that I have not added support for enabling SD Card and Trinamic drivers at the same time, try with Trinamic drivers first.

@timm052
Copy link
Author

timm052 commented Dec 14, 2021

Thank so much i'll get this tested in the next few days

@timm052
Copy link
Author

timm052 commented Dec 16, 2021

Got it compiled and flashed everything works except i cannot get the steppers to move. They seem to be recognized and i was able to change the amount of current going to them but I cannot get them to move at all. I've messed around with inverting the direction pins but that doesn't seem to be having an effect. Although i found if i enabled a pull-up on the reset button the steppers would move very slightly when i pressed the reset button. I could be missing some super obvious setting though. i've included the setting i have currently below

%
; grblHAL
; 1.1f.20211209
; [OPT:VNMSL2,35,1024,3,0]
; [NEWOPT:ENUMS,RT+,HOME,TC,SED,TMC=7]
; [MSG:Caution: Unlocked]
;
$N0=
$N1=
; 0 - Step pulse time
$0=10.0
; 1 - Step idle delay
$1=25
; 2 - Step pulse invert
$2=0
; 3 - Step direction invert
$3=0
; 4 - Invert stepper enable pin(s)
$4=4
; 5 - Invert limit pins
$5=7
; 6 - Invert probe pin
$6=1
; 7 - Disable spindle with zero speed
$7=0
; 8 - Ganged axes direction invert
$8=0
; 10 - Status report options
$10=4095
; 11 - Junction deviation
$11=0.010
; 12 - Arc tolerance
$12=0.002
; 13 - Report in inches
$13=0
; 14 - Invert control pins
$14=1
; 15 - Invert coolant pins
$15=0
; 16 - Invert spindle signals
$16=0
; 17 - Pullup disable control pins
$17=0
; 18 - Pullup disable limit pins
$18=7
; 19 - Pullup disable probe pin
$19=0
; 20 - Soft limits enable
$20=0
; 21 - Hard limits enable
$21=0
; 22 - Homing cycle
$22=1
; 23 - Homing direction invert
$23=0
; 24 - Homing locate feed rate
$24=25.0
; 25 - Homing search seek rate
$25=500.0
; 26 - Homing switch debounce delay
$26=250
; 27 - Homing switch pull-off distance
$27=1.000
; 28 - G73 Retract distance
$28=0.100
; 29 - Pulse delay
$29=0.0
; 30 - Maximum spindle speed
$30=1000.000
; 31 - Minimum spindle speed
$31=0.000
; 32 - Mode of operation
$32=0
; 33 - Spindle PWM frequency
$33=5000
; 34 - Spindle PWM off value
$34=0.0
; 35 - Spindle PWM min value
$35=0.0
; 36 - Spindle PWM max value
$36=100.0
; 37 - Steppers deenergize
$37=0
; 39 - Enable legacy RT commands
$39=1
; 40 - Limit jog commands
$40=0
; 43 - Homing passes
$43=1
; 44 - Axes homing, first pass
$44=4
; 45 - Axes homing, second pass
$45=3
; 46 - Axes homing, third pass
$46=0
; 62 - Sleep enable
$62=0
; 63 - Feed hold actions
$63=2
; 64 - Force init alarm
$64=0
; 65 - Probing feed override
$65=0
; 100 - X-axis travel resolution
$100=200.000
; 101 - Y-axis travel resolution
$101=200.000
; 102 - Z-axis travel resolution
$102=200.000
; 110 - X-axis maximum rate
$110=4000.000
; 111 - Y-axis maximum rate
$111=4000.000
; 112 - Z-axis maximum rate
$112=2500.000
; 120 - X-axis acceleration
$120=150.000
; 121 - Y-axis acceleration
$121=150.000
; 122 - Z-axis acceleration
$122=150.000
; 130 - X-axis maximum travel
$130=550.000
; 131 - Y-axis maximum travel
$131=720.000
; 132 - Z-axis maximum travel
$132=806.000
; 140 - X-axis motor current
$140=1950
; 141 - Y-axis motor current
$141=1950
; 142 - Z-axis motor current
$142=1950
; 150 - X-axis microsteps
$150=8
; 151 - Y-axis microsteps
$151=8
; 152 - Z-axis microsteps
$152=8
; 200 - X-axis StallGuard2 fast threshold
$200=22
; 201 - Y-axis StallGuard2 fast threshold
$201=22
; 202 - Z-axis StallGuard2 fast threshold
$202=23
; 210 - X-axis hold current
$210=60
; 211 - Y-axis hold current
$211=50
; 212 - Z-axis hold current
$212=60
; 220 - X-axis stallGuard2 slow threshold
$220=22
; 221 - Y-axis stallGuard2 slow threshold
$221=22
; 222 - Z-axis stallGuard2 slow threshold
$222=22
; 338 - Trinamic driver
$338=7
; 339 - Sensorless homing
$339=0
; 341 - Tool change mode
$341=0
; 342 - Tool change probing distance
$342=30.0
; 343 - Tool change locate feed rate
$343=25.0
; 344 - Tool change search seek rate
$344=200.0
; 345 - Tool change probe pull-off rate
$345=100.0
; 384 - Disable G92 persistence
$384=0
%

@terjeio
Copy link
Contributor

terjeio commented Dec 16, 2021

Try $4=7

@timm052
Copy link
Author

timm052 commented Dec 16, 2021

That appears to have done it. What setting does that change?

@terjeio
Copy link
Contributor

terjeio commented Dec 16, 2021

Motor enable signals - opposite of legacy Grbl where it is motor disable.
Send $$=4 for info.

@timm052
Copy link
Author

timm052 commented Dec 16, 2021

Okay so i it seems to all be working except the motor ganging Y2 will only move in one direction no matter which button is pressed it always moves the same way, Y1 behaves normally.

@terjeio
Copy link
Contributor

terjeio commented Dec 16, 2021

Is the pin definition for the Y2 motor direction correct?
#define M3_DIRECTION_PIN GPIO_NUM_32

@timm052
Copy link
Author

timm052 commented Dec 16, 2021

Yep just double checked against the default firmware and the grblHAL pins and they're all correct should be 32 for direction and 33 for step.

@terjeio
Copy link
Contributor

terjeio commented Dec 16, 2021

Setting direction is done here:

ESP32/main/driver.c

Lines 761 to 788 in 0f64293

inline IRAM_ATTR static void set_dir_outputs (axes_signals_t dir_outbits)
{
dir_outbits.value ^= settings.steppers.dir_invert.mask;
DIGITAL_OUT(X_DIRECTION_PIN, dir_outbits.x);
DIGITAL_OUT(Y_DIRECTION_PIN, dir_outbits.y);
DIGITAL_OUT(Z_DIRECTION_PIN, dir_outbits.z);
#ifdef A_AXIS
DIGITAL_OUT(A_DIRECTION_PIN, dir_outbits.a);
#endif
#ifdef B_AXIS
DIGITAL_OUT(B_DIRECTION_PIN, dir_outbits.b);
#endif
#ifdef C_AXIS
DIGITAL_OUT(C_DIRECTION_PIN, dir_outbits.c);
#endif
#ifdef GANGING_ENABLED
dir_outbits.mask ^= settings.steppers.ganged_dir_invert.mask;
#ifdef X2_DIRECTION_PIN
DIGITAL_OUT(X2_DIRECTION_PIN, dir_outbits.x);
#endif
#ifdef Y2_DIRECTION_PIN
DIGITAL_OUT(Y2_DIRECTION_PIN, dir_outbits.y);
#endif
#ifdef Z2_DIRECTION_PIN
DIGITAL_OUT(Z2_DIRECTION_PIN, dir_outbits.z);
#endif
#endif
}

Can you copy line 782 to below line 766 and try again? If not working then the pin is likely not set as output at startup as it should.

@timm052
Copy link
Author

timm052 commented Dec 17, 2021

Yeah no luck on copying the 786 to 766 had a shot at switching the driver pins to see if the issues move to the other driver it seems they always stay on that driver even if it's assigned to Y1. So yeah I guess it's likey the output pin is not set correctly at start up. Is there anything i can try to rectify that?

@timm052
Copy link
Author

timm052 commented Dec 18, 2021

Went back to GRBL ESP32 and the direction pin is working there so i assume there is some weird software thing going on somewhere.

@terjeio
Copy link
Contributor

terjeio commented Dec 18, 2021

The pin is set as input due to an incorrectly sized variable, replace these lines with:

    for(idx = 0; idx < (N_AXIS + N_ABC_MOTORS); idx++)
        rmt_set_source_clk(idx, RMT_BASECLK_APB);

    uint64_t mask = 0;

I guess I should make a "motherboard" for my Nucleo-64 BOB for testing...

@timm052
Copy link
Author

timm052 commented Dec 19, 2021

Works thanks so much. The Y2/A driver, however, seems to not like resetting after a reset the other drivers all work but the Y2 fails to come back up and needs to reset the controller too. Not a huge issue but i thought I'd mention it. Also is there any way to disable stealth chop which seems to be on by default on ZY1Y2 but not X

@terjeio
Copy link
Contributor

terjeio commented Dec 19, 2021

the Y2 fails to come back up and needs to reset the controller too.

It does not turn anymore?

Also is there any way to disable stealth chop ...

Yes, basic configuration is in trinamic.h.

... which seems to be on by default on ZY1Y2 but not X

Did you see that in the Trinamic tuner tab in ioSender when querying the driver status? If so it disables StealthChop for the selected axis and reenables it when leaving the tab.

@timm052
Copy link
Author

timm052 commented Dec 19, 2021

It does not turn anymore?

It fails to respond to commands after a reset either manual or caused by an alarm and requires a full power cycle to bring it back online

@terjeio
Copy link
Contributor

terjeio commented Dec 19, 2021

Ok, what happens if you send M122I to reinitialize the drivers?

@timm052
Copy link
Author

timm052 commented Dec 19, 2021

Yes, basic configuration is in trinamic.h.

Got it disabled but i had to go into the tmc5160.h file to do it

@timm052
Copy link
Author

timm052 commented Dec 19, 2021

Ok, what happens if you send M122I to reinitialize the drivers?

hmmm that brings them back but they have extreme vibrations and run terribly until i do a full reset

@terjeio
Copy link
Contributor

terjeio commented Dec 19, 2021

I have fixed a number of bugs in the Trinamic code and just committed an update, hopefully this will fix your problems.

@timm052
Copy link
Author

timm052 commented Dec 20, 2021

That seems to have resolved all outstanding issues. Thanks so much for the help is there anywhere i can donate to support this project?

@timm052 timm052 closed this as completed Dec 20, 2021
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