SvenH wrote:With the use of M-code I could tell the controler to use a different setting, actually turning the position guided axis in to a velocity axis and turning it back in to position if I need it.
I have the 4 axis setup working, is there any info available on how I can set up and use M100 codes for the purpose of setting the 4th to spin?
This is all guesswork, as I don't have LinuxCNC here, I will try to find the time to have a fiddle with both methods tonight.
However, it is likely to involve a script something like:
File M100:
#! /bin/bash
halcmd unlinkp parport.0.pin-01-out
halcmd unlinkp parport.0.pin-02-out
halcmd net vel-mode-step => parport.0.pin-01-out
halcmd net vel-mode-dir => parport.0.pin-02-out
and
File M101:
#! /bin/bash
halcmd unlinkp parport.0.pin-01-out
halcmd unlinkp parport.0.pin-02-out
halcmd net pos-mode-step => parport.0.pin-01-out
halcmd net pos-mode-dir => parport.0.pin-02-out
I think that doing it this way avoids following-errors. You would use M101 in the G-code to set one mode, and M100 to set the other.
Alternatively it is probably possible to build a structure of AND and OR gates in HAL to do it:
In this case you would use M64 P0 to set one mode, and M65 P0 to set the other. (M64 / m65 turn on and off the HAL pins called motion.digital-out-NN where NN is the P-number)
(This is done blind with no LinuxCNC to check with, you might want to draw out the logic diagram
loadrt and2 count=4
loadrt or2 count=2
loadrt not count=1
addf and2.0 base-thread
addf and2.1 base-thread
addf and2.2 base-thread
addf and2.3 base-thread
addf or2.0 base-thread
addf or2.1 base-thread
addf not.0 base-thread
net lathe-mode motion.digital-out-00 => not.0.in and2.0.in0 and2.1.in0
net lathe-mode-not not.0.out => and2.2.in0 and2.3.in0
net rot-mode-step stepgen.3.step => and2.2.in1
net rot-mode-dir stepgen.3.dir => and2.3.in1
net lathe-mode-step stepgen.4.step => and2.0.in1
net lathe-mode-dir stepgen.4.step => and2.1.in1
net rot-mode-step-switched and2.2.out => or2.0.in0
net lathe-mode-step-switched and2.0.out => or2.0.in1
net step-out or2.0.out => parport.0.pin-00-out
net rot-mode-dir-switched and2.3.out => or2.1.in0
net lathe-mode-dir-switched and2.1.out => or2.1.in1
net dir-out or2.1.out => parport.0.pin-01-out
References:
www.linuxcnc.org/docview/html/man/man9/and2.9.html
www.linuxcnc.org/docview/html/man/man9/or2.9.html
www.linuxcnc.org/docview/html/man/man9/not.9.html
www.linuxcnc.org/docview/html/man/man9/motion.9.html
www.linuxcnc.org/docview/html/hal/basic_hal.html