Working XYZA positional 4th axis system: how to modify to make A a velocity axis

More
14 Jan 2019 19:29 #124178 by clunc
I've managed to get the rotary 4th axis I purchased with my gantry CNC machine to function in position mode (ctrl_type=p in the .hal). I have redd about and experimented with settings to get it to operate as a continous-velocity axis, as in a lathe.

I intend to have my spindle operate simultaneously with A.

The axis is too long to sit under the X-axis gantry so it sits along Y-. I redd here on the forum that that means it's really a B-axis. Off I went to change the wires on my 5-axis "Mach3" parallel-port-interface board from A- to B- pins, only to find out that the Bdir pin (17) is already in use to activate the spindle-on relay. So unless I figure out how to provide that spindle-power-on another way, I'll be addressing the 4th axis along Y as the A-axis.

My questions are:
1. After making a carbon copy of the working linuxcnc/config/xyza/ directory to xyzl/ ('ell' as in 'lathe'), and renaming the .ini and .hal files to match, how do those two files need to be modified to run the A-axis in constant-velocity mode? [1]
2. What G-code commands will I need to address the A-axis, as a lathe spindle? For example, how would I command it to rotate at 10rpm?

I'll attach the, working, xyza.ini and xyza.hal, files, and my thanks for your looking them over.

[1] the only thing I think I know is that I have to change the 4th/A axis control_type to 'v', velocity. After that, cluelessness closes over me.
--
CluNC
Attachments:
More
14 Jan 2019 20:05 - 14 Jan 2019 20:20 #124182 by clunc
I took another swing at it and linuxcnc loads the new xyzl configuration after these edits of the base xyza files:
xyzl.ini
* change 'xyza' to 'xyzl' everywhere (2 places)
xyzl.hal
* change 'p,p,p,p' in the "loadrt stepgen" line to 'p,p,p,v'
* comment-out "net apos-cmd axis.3.motor-pos-cmd => stepgen.3.position-cmd" because of error thrown:
("stepgen.3.position-cmd does not exist")
* add new line "net apos-cmd axis.3.joint-vel-cmd => stepgen.3.velocity-cmd"

Result:
* after homing, G1 A5 F10 moves A-axis to 5 degrees, so A-axis positioning still works
* this reflects my confusion about how to command A to rotate at a particular angular velocity (as well as my confusion about whether signal 'names', like 'apos-cmd' are signficant; after it was defined by the 'net' command, I found no other reference to 'apos-cmd' in the .hal and guessed that it might be tied, somehow, to the G-code "A" command), so I left it rather than rename it to, say, 'avel-cmd'.
EDIT: I also tried renaming it with no change in behavior of the "A" command.
Last edit: 14 Jan 2019 20:20 by clunc. Reason: add a bit
More
14 Jan 2019 20:38 #124183 by clunc
Please someone, relocate this topic out of General LinuxCNC to:
Configuring LinuxCNC->Basic Configuration?

I apologize to have paid no attention to this at the outset.

Thank you.
CluNC
More
14 Jan 2019 23:12 - 14 Jan 2019 23:13 #124195 by clunc
Following the suggestions in:
forum.linuxcnc.org/forum/49-basic-config...-a-2nd-spindle#33080

I've tried another version of the xyzl_2ndpwm.hal [attached] creating a second pwmgen to connect to the A-axis.

I now get a buzzing sound[1] on the A-axis stepper, which is either the sound of steps too fast to be acted on, or alternate steps being in opposite directions.

I have tried:
setp pwmgen.1.scale 1000.0
to
setp pwmgen.1.scale 0.001

I have
setp pwmgen.1.pwm-freq 100.0
simply duplicated from the cutting spindle's entry.

[1] e.g., with M68 E0 Q50
Attachments:
Last edit: 14 Jan 2019 23:13 by clunc. Reason: add detail
More
14 Jan 2019 23:41 #124198 by tommylight
Stepper drives can not be controlled by PWM, they need step pulses and direction signal to work.
To put it in velocity mode, there should be an entry in the hal file with something like:
stepgen_mode = p,p,p,v
after the
stepgen_type = 0,0,0,0
or something similar, i can not recall as it has been over 5 years since i used it.
More
15 Jan 2019 01:35 #124212 by clunc
Thanks for that correction. I had started out trying stepgen, but then ventured a try on pwmgen, figuring that, a pulse-width modulated waveform is still a train of pulses. I'll stick to stepgen.
More
15 Jan 2019 23:37 #124276 by clunc
I've got it working, thanks to PietVR's (craftsmancnc) post of working config files and M-scripts. Thank goodness, and Piet! Some of what I saw was counter-intuitive, or would have been if I'd actually had any intuition about HAL's and INI's in the first place.

I'm still puzzling over what seems to be changing meaning of "velocity" when I switch between "position" and "velocity" modes on the A-axis. For example, I can issue "G1 F21000 A300" in position mode with no problem, but a similar "M100 P21000" (using the associated M100 (bash-shell script) to poke values into the .HAL file while the machine is running, causes a joint-3-following error.

I suspect it's in the units: steps/second for position-mode? degrees/sec for velocity-mode?

I'm also looking into replacing the M100/M101 pair of user-m-code scripts with a single, M133, (3 for axis_3) using two arguments, P<mode> Q<dps>, <dps> to set velocity in degrees/sec(?), <mode> to toggle between position and velocity.
More
16 Jan 2019 20:08 - 16 Jan 2019 20:14 #124302 by clunc
Here's an attempt at a single user-m-script in Perl to toggle between Position (P0) and Velocity (P1) modes.

Save it to your macros directory, rename it back to M133.pl and make it executable, and make a symlink there with no file extension (LinuxCNC expects M commands to be named "Mnnn").

Usage:
M133 P1 Q30 ; set velocity-mode and rotation to 30deg/sec
M133 P0 ; set position mode--abruptly stops rotation, may be preferable to lower velocity first, for fast rotations; e.g.,
M133 P1 Q0
M133 P0
Attachments:
Last edit: 16 Jan 2019 20:14 by clunc. Reason: add usage
More
17 Jan 2019 13:30 #124347 by andypugh

clunc wrote: I'm still puzzling over what seems to be changing meaning of "velocity" when I switch between "position" and "velocity" modes on the A-axis. For example, I can issue "G1 F21000 A300" in position mode with no problem, but a similar "M100 P21000" (using the associated M100 (bash-shell script) to poke values into the .HAL file while the machine is running, causes a joint-3-following error.

I suspect it's in the units: steps/second for position-mode? degrees/sec for velocity-mode?.


F21000 probably means 21,000 degrees/minute or 58 rpm. M100 P21000 might mean 21000 rpm...
More
17 Jan 2019 13:32 #124348 by andypugh
I will also add that, personally, I don't really like linking and unlinking pins in HAL to switch between modes. I much prefer the approach of switching between two separate PID controllers in the HAL layer.
Time to create page: 0.094 seconds
Powered by Kunena Forum