Author Topic: Insert spindle speed as Qx  (Read 1618 times)

Offline Mark81

  • Wookie
  • ****
  • Posts: 329
    • View Profile
Insert spindle speed as Qx
« on: February 23, 2019, 12:57:18 pm »
My new machine controller has a dedicated laser macro: M10 Qx, where x is the PWM settings 0..255.
I usually set the spindle speed to decide the power of my laser for each MOP, but now I need to place this value after Q, instead of S like $s would do.

I didn't find anything in the post-processor documentation. Is it possible to do it?

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8277
    • View Profile
Re: Insert spindle speed as Qx
« Reply #1 on: February 23, 2019, 14:58:37 pm »
Yup, but I'll be tied up with a legal matter for three or four hours.  If someone else doesn't get back to you on it, I'll describe how later.

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8277
    • View Profile
Re: Insert spindle speed as Qx
« Reply #2 on: February 24, 2019, 01:51:00 am »
Just try this:

Instead of <$spindle><$s>, try,
Q<$s)

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline Mark81

  • Wookie
  • ****
  • Posts: 329
    • View Profile
Re: Insert spindle speed as Qx
« Reply #3 on: February 24, 2019, 08:20:40 am »
Q<$s)

Unfortunately, It says "Unexpected token '<' at line 5" and it exports it literally in the g-code.

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4378
    • View Profile
Re: Insert spindle speed as Qx
« Reply #4 on: February 24, 2019, 09:17:52 am »
I think Lloyd made a typo and meant this;

{$spindle} Q{$s}


Unfortunately the $s macro also adds an 'S' character in front of the speed number which produces;

e.g. QS1000

It looks like a post build processor is required to change the S into Q
« Last Edit: February 24, 2019, 09:30:46 am by EddyCurrent »
Made in England

Offline Mark81

  • Wookie
  • ****
  • Posts: 329
    • View Profile
Re: Insert spindle speed as Qx
« Reply #5 on: February 24, 2019, 09:32:39 am »
Hi Eddy,
yer, perhaps my question wasn't so clear. I meant exactly how to rid the 'S' char that {$s} prints out.

"It looks like a post build processor is required to change the S into Q". Is something built-in in CamBam or I have to write my own? It's just to understand, because it's something very easy to do in any programming language.

Right now I ended up with just:

Code: [Select]
M10 {$s}
and than I replace "M10 S" with "M10 Q".

Offline Mark81

  • Wookie
  • ****
  • Posts: 329
    • View Profile
Re: Insert spindle speed as Qx
« Reply #6 on: February 24, 2019, 10:04:07 am »
Done.
I've just wrote a simple application "PostBuildReplace":

https://drive.google.com/open?id=18-zrTLDg-J6_aVBenjyifkNjAngwNqIn

It needs three arguments: "filename" "before" "after".
Here what it does:
  • opens the "filename" file
  • reads the contents and replace "before" with "after"
  • writes again the same file with the new contents

You have to configure CamBam PP as follow:

Post-Build Command: path/to/PostBuildReplace.exe
Post-Build Command Args: "{$outfile}" "M10 S" "M10 Q"

That's it.
Extremely simple, without much error handling (it just checks if you passed 3 args and if it cannot open the file exits), but it does what I need. Right now it reads all the content in RAM. For very big files it will be better to read line-by-line, replace and write in another file. I will do it next time :-)
« Last Edit: February 24, 2019, 10:05:48 am by Mark81 »

Offline Mark81

  • Wookie
  • ****
  • Posts: 329
    • View Profile
Re: Insert spindle speed as Qx
« Reply #7 on: February 24, 2019, 10:31:01 am »
Right now it reads all the content in RAM. For very big files it will be better to read line-by-line, replace and write in another file. I will do it next time :-)

Ok this version does what I suggested above:

https://drive.google.com/open?id=1xTIyz7675QnDEGTWkdNaPO2GnbfBkU3N

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4378
    • View Profile
Re: Insert spindle speed as Qx
« Reply #8 on: February 24, 2019, 10:43:34 am »
Excellent job !
Made in England