Schaublin 125-CNC retrofit.

  • RotarySMP
  • RotarySMP's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
30 Mar 2026 16:09 #344959 by RotarySMP
Replied by RotarySMP on topic Schaublin 125-CNC retrofit.
Hi Andy,

I got the Schaublin updated to Trixie and 2.9.8.

I really like the update you did to the look and button layout of Lathe macros. Thanks.

I was trying to work out how to address not having any feedback on the turret arriving in position. Because I am a shit programmer, I tried Chat GPT yesterday.

 

This is the set of requirements I gave:

 

The AI summary is rather accurate.

 

 

After a couple of back and forth, adding requirements, and accepting some AI suggestions, the result is the attached files.
Scary good how fast and efficient this is for a small project with very limited requirements, and how well it documents and explains the code. It would have taken me a few evening to get to this level, and my code would have been a mess of half-arsed work-around to avoid the gaping holes in my programming knowledge.

It failed to compile yesterday, due to some unknown character. I suspect the apple text editor has added some hidden ascii code. The attached files I cut paste into a different text editor. Off to test them now.
Cheers,
Mark

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

  • RotarySMP
  • RotarySMP's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
30 Mar 2026 18:01 #344964 by RotarySMP
Replied by RotarySMP on topic Schaublin 125-CNC retrofit.
Okay, now I am understanding the pain of AI. I went in circles with compiling errors and format.

Now it compiles, but I get
hal:turret:1: character unknown '  '
and the invisible character search didn't turn up anything.

Any ideas what I have wrong in this comp appreciated...
Attachments:

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

More
30 Mar 2026 20:19 #344971 by JacobRush
Replied by JacobRush on topic Schaublin 125-CNC retrofit.
I asked my imaganiry AI friend to take a look at it thusly:

"A friend of mine is trying to get a custom linuxcnc HAL component up and running and he's getting an odd runtime error of "hal:turret:1: character unknown ' '"

The documentation for hal stuff is here:http://linuxcnc.org/docs/html/hal/comp.html take a look and see if you see anything out of place."

While sending the comp file along.
The replies seem pretty reasonable:



I see two issues:

1. The actual error (line 1) — almost certainly smart quotes

The "character unknown ' '" error on line 1 means the halcompile lexer is hitting a byte it doesn't recognize. Line 1 has a doc string:

component turret "4-position pneumatic...";

Those " " quotes are probably Unicode smart/curly quotes (U+201C/U+201D) instead of plain ASCII double quotes (U+0022). Super common when the file was written or pasted through a rich text editor, Google Docs, macOS Notes, Word, etc.

Fix: Have him run this to check:

cat -A turret.comp | head -1

If he sees M-bM-^@M-^\ or any multi-byte sequences where the quotes are, that's the culprit. Replace all smart quotes with plain ASCII " quotes. Quick fix:

sed -i 's/[\xe2\x80\x9c\xe2\x80\x9d]/"/g' turret.comp

2. Secondary bug — FUNCTION name mismatch

He declared function _; (underscore = unnamed/default) but then used FUNCTION(turret) in the C section. Those have to match. Should be either:

FUNCTION(_) {

Or better yet since it's a single-function component, just skip the FUNCTION() wrapper entirely and put bare C after ;; — like the ddt example in the docs.

3. Minor — int diff inside switch/case

case 0:
...
int diff = target - position;

Declaring a variable inside a case without braces can choke some C standards. Wrap it:

case 0: {
...
int diff = target - position;
...
break;
}

The smart quotes are almost guaranteed to be the "character unknown" error. The FUNCTION mismatch will bite him right after he fixes that.
The following user(s) said Thank You: RotarySMP

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

  • RotarySMP
  • RotarySMP's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
02 Apr 2026 20:16 #345076 by RotarySMP
Replied by RotarySMP on topic Schaublin 125-CNC retrofit.
Thanks for that, I was not able to get into the forum for the last couple of days.

I had similar advice from AI, and tried both the solution yours and mine gave and it has not corrected it.

I even used visual code studio, and rewrote the whole program be hand, to ensure there were no secret character codes in there. (See attached file)But the result is still the same.
hal:turret:1: character unknown '  '

Any other suggestions much appreciated. 
Cheers,
Mark
Attachments:

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

More
02 Apr 2026 20:54 #345081 by andypugh
Replied by andypugh on topic Schaublin 125-CNC retrofit.

I got the Schaublin updated to Trixie and 2.9.8.

I really like the update you did to the look and button layout of Lathe macros. Thanks.

 

Be a bit careful with them, I found a bug with my system (which uses Touchy, so may be different). 
Pressing the hardware "go" button was running the lathe macro even when the MDI window or Auto (G-code) window were at the front. 
This might not happen with Gmoccapy. 
It was previously prevented by code in the GUI telling the Glade panel when it had focus, but the signalling method used is't available in GTK3. 

Also, the problem went away after a restart, so I haven't been able to work out the cause. 

I may be the only one using the macros with Touchy...
The following user(s) said Thank You: RotarySMP

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

  • RotarySMP
  • RotarySMP's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
02 Apr 2026 21:19 #345084 by RotarySMP
Replied by RotarySMP on topic Schaublin 125-CNC retrofit.
Thanks Andy, I'll test that tomorrow to see if it happens in other screens.

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

More
03 Apr 2026 00:49 #345090 by andypugh
Replied by andypugh on topic Schaublin 125-CNC retrofit.

hal:turret:1: character unknown '  '

 

Unhelpfully, it works for me...
andypugh@Boookworm:~/linuxcnc-dev$ halcompile --install ../turret.comp
Compiling realtime turret.c
Linking turret.so
cp turret.so /home/andypugh/linuxcnc-dev/rtlib/


 
The following user(s) said Thank You: RotarySMP

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

  • RotarySMP
  • RotarySMP's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
03 Apr 2026 04:44 - 03 Apr 2026 04:45 #345093 by RotarySMP
Replied by RotarySMP on topic Schaublin 125-CNC retrofit.
Thanks Andy, It compiles for me as well. I get the error when I have linuxnc load it.
Last edit: 03 Apr 2026 04:45 by RotarySMP.

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

More
03 Apr 2026 10:50 #345101 by andypugh
Replied by andypugh on topic Schaublin 125-CNC retrofit.

Thanks Andy, It compiles for me as well. I get the error when I have linuxnc load it.
 

That's working for me too:
andypugh@Boookworm:~/linuxcnc-dev$ halrun
halcmd: show pin
Component Pins:
Owner   Type  Dir         Value  Name

halcmd: loadrt turret
Note: Using POSIX realtime
halcmd: show pin
Component Pins:
Owner   Type  Dir         Value  Name
     4  bit   OUT         FALSE  turret.0.busy
     4  bit   OUT         FALSE  turret.0.done
     4  bit   OUT         FALSE  turret.0.error
     4  s32   OUT             0  turret.0.position
     4  bit   IN          FALSE  turret.0.sensor0
     4  bit   IN          FALSE  turret.0.sensor1
     4  bit   IN          FALSE  turret.0.sensor2
     4  bit   IN          FALSE  turret.0.sensor3
     4  bit   IN          FALSE  turret.0.start
     4  s32   IN              0  turret.0.target
     4  s32   OUT             0  turret.0.time
     4  bit   OUT         FALSE  turret.0.valve

I have taken the liberty of changing the function name to "_" so that the addf line is "addf turret.0" not "addf turret.0.turret"

 
Attachments:

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

  • RotarySMP
  • RotarySMP's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
03 Apr 2026 13:49 - 03 Apr 2026 13:57 #345105 by RotarySMP
Replied by RotarySMP on topic Schaublin 125-CNC retrofit.
Thanks a lot for trying that Andy. I'll compile your correction this evening. I will probably have to put the 2.8.2 SSD back in the machine, and I can also see if this works there without error.

If I fall back on somehing like 2.8.4 buster ISO, do I loose your latest macros layout?
Last edit: 03 Apr 2026 13:57 by RotarySMP.

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

Moderators: piasdom
Time to create page: 0.207 seconds
Powered by Kunena Forum