Python Help - Keep track of tool in spindle.

More
11 Jul 2021 17:48 #214302 by CNC4Life
Hi All,

I'm trying to get this python script to work so that I can keep track of the tool in the spindle and if Linuxcnc closes for whatever reason the information is retained.

My issue is despite commanding the offset using:
cmd.tool_offset(old_tool,
                    s.tool_table[old_tool].zoffset,
                    s.tool_table[old_tool].xoffset,
                    s.tool_table[old_tool].diameter,
                    s.tool_table[old_tool].frontangle,
                    s.tool_table[old_tool].backangle,
                    s.tool_table[old_tool].orientation)

Linuxcnc is reporting s.tool_in_spindle = 0, despite at the bottom edge of the screen in axis it shows the correct tool, offset, and diameter. and I need something like an M61 Qxx for the tool_in_spindle to show a value. What is also weird is if I do an ATC change my GCode based changer is able to find the correct tool using #<_current_tool>.

Thanks in advance.
(Linux CNC 2.8.1)
 
Attachments:

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

More
11 Jul 2021 23:11 - 11 Jul 2021 23:13 #214339 by BigJohnT
Replied by BigJohnT on topic Python Help - Keep track of tool in spindle.
Seems to be working for me or I don't understand the problem.
 
I changed tools in Axis a couple of times and it showed up the next time sleep ran out.
And the program did the correct thing and shut down when I shut down Axis. Code looks good to me.

JT
Attachments:
Last edit: 11 Jul 2021 23:13 by BigJohnT.

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

More
12 Jul 2021 01:08 - 12 Jul 2021 01:27 #214344 by CNC4Life
Replied by CNC4Life on topic Python Help - Keep track of tool in spindle.
Close Linuxcnc, with a tool loaded.

When you re-open Linuxcnc you will see it will set the tool in axis. Then once it enters the loop it will write tool 0 to the file because despite axis showing a tool loaded offsets and all. The tool in spindle value is 0.

That or open and close linuxcnc 3 times in a row. The third opening tool will always be 0.

Last edit: 12 Jul 2021 01:27 by CNC4Life.

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

More
12 Jul 2021 03:46 #214354 by cmorley
Replied by cmorley on topic Python Help - Keep track of tool in spindle.
I'm not sure if this is related or not.
in qtvcp and gladevcp we manipulate the tool file outside of linuxcnc.
When we saved the tool file - some times the OS will not save it right away - it caches it.
os.fsync() can force the OS to save the file right away.

also to update the VAR file, we needed to to a switch to Manual mode then back to MDI mode

Both of these created hard to track down, inconsistent errors.

Chris

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

More
12 Jul 2021 10:26 #214382 by CNC4Life
Replied by CNC4Life on topic Python Help - Keep track of tool in spindle.
Thanks for your feedback Chris, in this case the status.tool_in_spindle is returning 0 even though linuxcnc accepted the command to update the tool info.

I’d just MDI up a M61 but it can’t issue MDI commands until the user homes the machine.

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

More
12 Jul 2021 11:57 #214389 by cmorley
Replied by cmorley on topic Python Help - Keep track of tool in spindle.
try
NO_FORCE_HOMING = 1

in the TRAJ section

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

More
12 Jul 2021 12:51 - 12 Jul 2021 12:52 #214392 by CNC4Life
Replied by CNC4Life on topic Python Help - Keep track of tool in spindle.
No, I need it to force homing. If the user forgets it will crash the ATC into the side of the spindle. 

I wish certain MDI Commands didn’t require homing, or there was a force MDI switch. 
Last edit: 12 Jul 2021 12:52 by CNC4Life.

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

More
12 Jul 2021 13:47 #214395 by anfänger
Replied by anfänger on topic Python Help - Keep track of tool in spindle.
You can home the machine on shutdown or save the machine position ny butting a POSITION_FILE = position.txt in the [Traj] section

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

More
13 Jul 2021 00:45 - 13 Jul 2021 00:58 #214464 by CNC4Life
Replied by CNC4Life on topic Python Help - Keep track of tool in spindle.
Unfortunately, I don't think that would work with the mesa 7i40 drivers, as the encoder counts are cleared from the FPGA at startup. Plus there is no way to be 100% sure the machine didn't move while being powered down. It's not a big piece of iron so someone could definitely bump the table .010"-.020". I'm trying to hold .001" +/- between homes.

Does anyone know if this is a bug or is my implementation wrong? I guess I could wait for the machine to be homed and then issue a G61 to finish the job. Then update the text file. Seems a little wonky...
Last edit: 13 Jul 2021 00:58 by CNC4Life.

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

More
13 Jul 2021 04:45 - 13 Jul 2021 11:33 #214476 by anfänger
Replied by anfänger on topic Python Help - Keep track of tool in spindle.
Why don’t you just remap m6?
and write an simple mcode in bash to write the new tool in a file
or save it in an persistent parameter. 
Last edit: 13 Jul 2021 11:33 by anfänger.

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

Time to create page: 0.088 seconds
Powered by Kunena Forum