Cannot control the spindle speed.

More
13 Oct 2023 10:18 #282881 by star-traveler
Cannot control the spindle speed. was created by star-traveler
Hi All!
I'm writing this topic after exhausting all other options and I'm growing a bit desperate.
It would be easier for me to explain may problem if I go in chronological fashion.
So after installing the standard linuxcnc image (2.8.4) I started researching how to make linuxcnc control the spindle: Speeds, On/Off, CW/CCW - the usual stuff. The best way for me, as it turned out, was to control it through a RS485 interface. After doing all the research and setup (electrical, configurations etc.) I got to the point where I could turn the spindle on or off from the linuxcnc software, spin it clockwise/counterclockwise, but at a minimal speed. I couldn't control the spindle speed. (even the +/- buttons in linuxcnc GUI were missing). At the time my custom.hal file looked like this:

loadusr -Wn vfd hy_vfd -n vfd -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0 -p none -r 9600

net spindle-cmd-rpm-abs           => vfd.speed-command
net spindle-cw spindle.0.forward => vfd.spindle-forward
net spindle-ccw spindle.0.reverse => vfd.spindle-reverse
net on          spindle.0.on      => vfd.spindle-on

My troubleshooting/research turned nothing. I absolutely could not find any information as to why I'm able to turn the spindle on or off but not control it's speed.
Then I decided just for shits and giggles to change the net spindle-cw/ccw to net spindle-fwd/rev making the custom.hal look like this:
 
loadusr -Wn vfd hy_vfd -n vfd -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0 -p none -r 9600

net spindle-cmd-rpm-abs           => vfd.speed-command
net spindle-fwd spindle.0.forward => vfd.spindle-forward
net spindle-rev spindle.0.reverse => vfd.spindle-reverse
net on          spindle.0.on      => vfd.spindle-on

And Oh Miracle! It worked! I could control the speed of the spindle no problem.
So far so good. I worked with my machine like that for years.

However it was crashing. The linuxcnc software was crashing randomly with the stated cause 'Out of Memory'. That's what the crash report was stating. It was annoying since I had to recalibrate the machine all over again every time, but for a time I was putting up with this.

However my workload increased recently and I started experiencing crashes virtually in every job. Due to the nature of my work process the linuxcnc machine that controls my router had to be running for 12, 20, 30 hours at a time. With the linuxcnc software not being shut down the entire time. And I noticed that sometimes the software would crash even though it wasn't doing anything. Just idle, waiting for me to secure the next piece into the machine.

So recently I decided enough is enough and since 2.8.4 clearly crashes in my case I decided to go up in version. So I installed a standard Debian 12, built kernel from source, patching it with the preempt-rt patch before that, built the latest linuxcnc (2.10.0) form source, installed it - and started my test run. Without an actual machine working I ran some of my longest g-code programs. For 72 hours straight. It DID NOT CRASH! It worked like a charm. The latency is a bit worse but it still works for me.

Except, since I had the actual router detached form my linuxcnc computer I ran a linuxcnc configuration that doesn't spindle control. When I hooked the computer back to my router, I realized I don't have speed control again. Turns on or off. CW/CCW control is there - but at a minimal speed. Except my configuration didn't change. my custom.hal was still with spindle-fwd/rev and not spindle-cw/ccw. But now even that wasn't working anymore. I tried to return it back to spindle-cw/ccw but there was no change in behavior. the [+/-] buttons are not present again.

When I try to execute the cusotn.hal script comand by command in the halrun this is the result:
ivan@router-control:~$ halrun 
halcmd: loadusr -Wn vfd hy_vfd -n vfd -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0 -p none -r 9600
halcmd: net spindle-cmd-rpm-abs           => vfd.speed-command
halcmd: net spindle-fwd spindle.0.forward => vfd.spindle-forward
<stdin>:3: Pin 'spindle.0.forward' does not exist
halcmd: net spindle-rev spindle.0.reverse => vfd.spindle-reverse
<stdin>:4: Pin 'spindle.0.reverse' does not exist
halcmd: net on          spindle.0.on      => vfd.spindle-on
<stdin>:5: Pin 'spindle.0.on' does not exist
halcmd:

The problem with this is that if I run linuxcnc using this same custom.hal file, it launches up seemingly normally. If linuxcnc wasn't able to see spindle.0.forward it would've crashed with the same message: "<stdin>:3: Pin 'spindle.0.forward' does not exist" in the crash report. I know this because I tried editing custom.hal by replacing spindle.0.forward with: spindle.forward, motion.spindle.forward, spindle.1.forward and more. And every time linuxcnc would crash saying any of those "does not exist". but with spindle.0.forward in the custom.hal it launches normally .

Any help would be greatly appreciated. I like LinuxCNC but I'm beginning to get fed up with it's buggyness.
Best regards
Ivan

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

More
13 Oct 2023 13:35 #282891 by PCW
Replied by PCW on topic Cannot control the spindle speed.
Not sure about the spindle control issue but this would not be
expected to work as the hal spindle pins (like spindle.0.forward)
are created by the motion module (motmod) which you have not
loaded:

ivan@router-control:~$ halrun 
halcmd: loadusr -Wn vfd hy_vfd -n vfd -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0 -p none -r 9600
halcmd: net spindle-cmd-rpm-abs           => vfd.speed-command
halcmd: net spindle-fwd spindle.0.forward => vfd.spindle-forward
<stdin>:3: Pin 'spindle.0.forward' does not exist
halcmd: net spindle-rev spindle.0.reverse => vfd.spindle-reverse
<stdin>:4: Pin 'spindle.0.reverse' does not exist
halcmd: net on          spindle.0.on      => vfd.spindle-on
<stdin>:5: Pin 'spindle.0.on' does not exist
halcmd:

The following user(s) said Thank You: star-traveler

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

More
13 Oct 2023 14:56 #282895 by star-traveler
Replied by star-traveler on topic Cannot control the spindle speed.
Thank you very very much! Your comment helped me continue my troubleshooting. So you mentioned that I haven't loaded motmod and this is why those identifiers are not found. so I decided to load it and see what happens. And this is what happened:

ivan@router-control:~$ halrun 
halcmd: loadrt motmod
Note: Using POSIX realtime
motmod: dlopen: /usr/lib/linuxcnc/modules/motmod.so: undefined symbol: update_joint_homing_params
<stdin>:1: waitpid failed /usr/bin/rtapi_app motmod
<stdin>:1: /usr/bin/rtapi_app exited without becoming ready
<stdin>:1: insmod for motmod failed, returned -1
halcmd: 

To be honest when I posted this topic, I fully expected the community to blast me for installing a bleeding edge linuxcnc, since I basically took the master and built it. If I do something like that I shouldn't be surprised by problems. In fact if that's the only problem I should be happy.

So as I see it now, I don't have control over my spindle speed because the motmod module fails to load. but then again when linuxcnc loads it doesn't throw any such error messages which means it manages to load it, but it's probably not fully functional.

I'd greatly appreciate it if you have any more ideas as to how can I fix my issue given the new information I provided :)
Thanks again!
Ivan

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

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
13 Oct 2023 16:03 #282901 by tommylight
Replied by tommylight on topic Cannot control the spindle speed.

To be honest when I posted this topic, I fully expected the community to blast me for installing a bleeding edge linuxcnc, since I basically took the master and built it. If I do something like that I shouldn't be surprised by problems. In fact if that's the only problem I should be happy.

Here you get respect for that, going all in into the unknown and testing new stuff, and finding any issues with it.
:)
Oh yeah, and reporting back if/when you do find issues!
The following user(s) said Thank You: star-traveler

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

More
13 Oct 2023 17:12 #282912 by PCW
Replied by PCW on topic Cannot control the spindle speed.
Yeah, I think motion requires kins to be loaded
but, if just testing the modbus interface, you don't
need any motion pins as you should be able to load the
modbus driver and directly manipulate the vfd.xxxx pins
The following user(s) said Thank You: star-traveler

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

More
14 Oct 2023 07:15 - 14 Oct 2023 07:18 #282964 by star-traveler
Replied by star-traveler on topic Cannot control the spindle speed.
So I was hoping if I get all modules loaded in halrun I could manually execute the custom.hal script and see if it gives some error messages that would point me at what needs fixing. But to no avail. I loaded all the modules, executed every line in the hal script and it gave me no indication. everything went smoothly:

halcmd: loadrt tpmod 
Note: Using POSIX realtime
halcmd: loadrt homemod 
halcmd: loadrt maxkins 
halcmd: loadrt motmod
halcmd: loadusr -Wn vfd hy_vfd -n vfd -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0 -p none -r 9600
halcmd: net spindle-cmd-rpm-abs           => vfd.speed-command
halcmd: net spindle-fwd spindle.0.forward => vfd.spindle-forward
halcmd: net spindle-rev spindle.0.reverse => vfd.spindle-reverse
halcmd: net on          spindle.0.on      => vfd.spindle-on

As you can see no error messages, not failures, everything seems to work fine.
maybe I'm not loading the right kins module?
I'm starting to suspect that once more the names spindle-fwd and spindle-rev are the culprits. Maybe they were changed again.

Now I'm going to turn my research towards learing how to send commands to the VFD through halrun.
 
Last edit: 14 Oct 2023 07:18 by star-traveler.

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

More
14 Oct 2023 08:04 #282966 by Hakan
Replied by Hakan on topic Cannot control the spindle speed.
Looking at what's in my hal files, you also need to enable the spindle
custom.hal:net machine-is-on             => spindle-vfd.enable
custom.hal:net spindle-cw                => spindle-vfd.spindle-forward
custom.hal:net spindle-ccw               => spindle-vfd.spindle-reverse
custom.hal:net spindle-enable            => spindle-vfd.spindle-on
custom.hal:net spindle-at-speed          <= spindle-vfd.spindle-at-speed
custom.hal:net spindle-vel-cmd-rpm-abs   => spindle-vfd.speed-command 
 
The following user(s) said Thank You: star-traveler

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

More
14 Oct 2023 09:55 #282973 by andypugh
Replied by andypugh on topic Cannot control the spindle speed.
In the very latest master there have been changes that move iocontrol into task. This means that things load a bit quicker, and on some machines this can lead to a race condition between motion and task.
It is possible that this is what you are seeing, that pins don't _quite_ exist when the HAL tries to link them.

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

More
14 Oct 2023 11:18 #282983 by star-traveler
Replied by star-traveler on topic Cannot control the spindle speed.
YESSSS !!! I GOT IT RUNNING !!!

I used an ancient spell, called: Looking at the documentation. XD Gee, who knew the documentation might have some answers for me. XD
So now that I got the self deprecating humor out of the way let me describe how I got it to work:
Firs my old custom.hal:

loadusr -Wn vfd hy_vfd -n vfd -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0 -p none -r 9600

net spindle-cmd-rpm-abs               => vfd.speed-command
net spindle-fwd spindle.0.forward => vfd.spindle-forward
net spindle-rev spindle.0.reverse  => vfd.spindle-reverse
net on                spindle.0.on          => vfd.spindle-on


those net things are actually variables of type net. So lets take the second line: We have a variable of type net with name spindle-fwd and since net means connection the value of this variable is going to be two things: connecting what to what. In this case, the source signal spindle.0.forward to (=>) the VFD component vfd.spindle-forward. Notice however the first line does not follow this format. It seems that spindle-cmd-rpm-abs is both the name of the variable and the source signal?! I don't know how that worked before but apparently it doesn't any more. So after consulting with the documentation I tried replacing the first net with:

net spindle-speed-cmd spindle.0.speed-out => vfd.speed-command

this worked, the +/- buttons appeared and they were correctly controlling the speed. Also the spindle started responding to the MDI commands in linuxcnc. One small hick up was that the RPM panel that I've setup in linuxcnc didn't show the RPM. But I knew why. The GUI panel is an XML script that indirectly depends on the variable spindle-cmd-rpm-abs which in this case is replaced by spindle-speed-cmd so I either had to change the name of the variable in two different files or just:

loadusr -Wn vfd hy_vfd -n vfd -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0 -p none -r 9600

#type, name                            val: source                ->  destiantion
net      spindle-cmd-rpm-abs spindle.0.speed-out => vfd.speed-command
net      spindle-fwd                  spindle.0.forward     => vfd.spindle-forward
net      spindle-rev                   spindle.0.reverse     => vfd.spindle-reverse
net      on                                  spindle.0.on             => vfd.spindle-on


As you can see I just plugged the spindle.0.speed-out at the appropriate place in the old line that was controlling the spindle speed.
And that fixed it!
Hope that helps!
:)
The following user(s) said Thank You: tommylight

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

Time to create page: 0.070 seconds
Powered by Kunena Forum