Forum Header

Reversing Spindle Direction for Machine Tapping

More
7 years 9 months ago #123622 by andypugh

waynegramlich wrote: I've done some digging around with halscope, and it looks like the problem is that my version of LinuxCNC probably has a bug when it come to the M4 command. When I run "M4 S500", the Axis GUI says the spindle is spinning at 500, but halscope shows no PWM signal on the Spindle_PWM signal. For `M3 S500` the PWM signal is present.


Using "halmeter" from the "machine" menu have a look at the input to the spindle PWM generator.

Also check what type of PWM generator is being used (look in the HAL file with a text editor to find this)

It might be that negative spindle speed values are not getting to the PWM generator, or it could be that you are using a "type 2" PWM where reverse direction PWM is on a separate HAL pin. You probably need "type 1"

linuxcnc.org/docs/2.7/html/man/man9/pwmgen.9.html

Also, the spindle control docs are here:
linuxcnc.org/docs/2.7/html/man/man9/motion.9.html

Please Log in or Create an account to join the conversation.

More
7 years 9 months ago #123626 by waynegramlich
I made huge progress yesterday figuring this out. The issue is that the spindle speed value comes out a floating point number that is positive for normal rotation and negative for reverse rotation. The stepconf wizard for LinuxCNC 2.4 does not generate HAL code that properly deals with negative spindle values.

There are two basic solutions:

1. In LinuxCNC 2.7 there is motion.spindle-speed-out-abs which outputs the absolute value of the spindle speed. If that is fed into pwmgen.value, everything would work. Alas, I am running LinuxCNC 2.4 does not have motion.spindle-speed-out-abs. I can work around this by using the abs module to take +/- spindle speed value and make it positive. That works.

2. The other strategy is to switch from type 0 on the `pwmgen` module to type 1. For type 1, it outputs a pwm signal that is based on the absolute value of the input value and a direction signal. The direction signal can be fed to signal-cw. The signal-cw needs to be derived from signal-ccw through a `not` module.

Of the two solutions, the 2nd one is probably better because the `abs` module needs to run in a floating point enabled thread (i.e. server-thread) whereas the `not` module can be run in a non-floating point thread (i.e. base-thread.)

The bottom line is that I've got it working and I really, really appreciate the helpful comments I got on this forum that pointed me in the correct direction.

Please Log in or Create an account to join the conversation.

Time to create page: 0.215 seconds
Powered by Kunena Forum