g2 icon indicating copy to clipboard operation
g2 copied to clipboard

Switching motor axis on the fly makes the motor lose power in some conditions

Open hidoba opened this issue 6 years ago • 0 comments

I was trying to home a machine which has two motors on Y axis. As opposed to #418 and #359, I wrote a homing code where I keep both motors powered on during the whole cycle:

; motors 2,4 are connected to Y axis.
; there are two hall sensors connected to the same input

G28.2 Y0 ; initial homing
M100 ({4ma:0, 2ma:1}) ; disconnect motor 4 from Y and connect it to X; keep motor 2 connected to Y
G28.2 Y0 ; home motor 2
M100 ({4ma:1, 2ma:0}) ; connect motor 4 back to Y and disconnect motor 2 from Y (by connecting to X)
G28.2 Y0 ; home motor 4
M100 ({4ma:1, 2ma:1}) ; connect both motors back to Y

however, it turned out that if you do a homing of an axis and then mess up with motors, at the beginning of the next motion command one of the motors involved (or both) will be disabled for a very short time and enabled again. During that time the machine can lose the position.

Temporary fix, for the unknown reasons making the code above work properly (not disabling motors anymore):

; motors 2,4 are connected to Y axis.
; there are two hall sensors connected to the same input

G28.2 Y0 ; initial homing
	M100 ({4ma:0, 2ma:0}) ; disconnect both motors from Y, connect to X
	G90 G0 Y50 ; do fake motion
	G4 P0.1
	G90 G0 Y0 ; and come back
M100 ({4ma:0, 2ma:1}) ; disconnect motor 4 from Y and connect it to X; keep motor 2 connected to Y
G28.2 Y0 ; home motor 2
	M100 ({4ma:0, 2ma:0})
	G90 G0 Y50
	G4 P0.1
	G90 G0 Y0
M100 ({4ma:1, 2ma:0}) ; connect motor 4 back to Y and disconnect motor 2 from Y (by connecting to X)
G28.2 Y0 ; home motor 4
	M100 ({4ma:0, 2ma:0})
	G90 G0 Y50
	G4 P0.1
	G90 G0 Y0
M100 ({4ma:1, 2ma:1}) ; connect both motors back to Y

hidoba avatar Dec 05 '19 20:12 hidoba