Hello Guest it is June 06, 2024, 09:01:45 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TTalma

Pages: 1 2 3 4 5 6 7 8 »
1
I've added some buttons for my ATC to the 'tabPositionsExtens' tab (the first one shown on startup). It populates the button labels with the tool number. The script works, but when I start mach 4 the script is not called. I need to select a different tab, then go back go back to 'tabPositionsExtens' tab and everything is correct.

Is there a way to make mach 4 call the script when it starts up?

2
In my tool changer script I need to make sure that the bottom of the spindle is above the top of the tool holders before moving to load a tool. I don't want to raise to machine coords z=0 (Z axis highest position) each time I change tools since it is 3.5" above the top of the tool holders, and this up and down movement wastes a lot of time. Most of the time this is not an issue since I will move to a safe height after dropping off a tool but there are a few situations where I manually unload the spindle and I want to ensure it's at a safe height. So I added some code to check, if it's below safe height, it should raise to a safe height.

so I use the following line to get the current position in machine coordinates:
Code: [Select]
local currentZ = mc.mcAxisGetMachinePos(inst, mc.Z_AXIS)
but about 75% of the time this call returns 0, while the dro (set to machine coords) displays a non zero number, and the dro is always correct. I can't read the DRO because most of the time it will be displaying work coords.

So is there a reliable way to read machine coordinates?

3
I like the format of the tool table, but I hate that it's a popup.  I would like to use it as is in a new tab I create. Do I need to recreate it or is it possible to just use it on a new screen?

4
I have made a module file 'PocketPositions.Lua' with a bunch of functions.

In the screen load script I added the following:
Code: [Select]
-- Pocket Positions
package.loaded.PocketPositions = nil
PocketPositions = require "PocketPositions"

From a tab On enter script I have:
Code: [Select]
local pocketNums = PocketPositions.GetUsedPocketNumbers()
if pocketNums[1] ~= nil then
wx.wxMessageBox("pocketNums[1] ="..tostring(pocketNums[1]))
table.sort(pocketNums)
local pocketStr = ""
for i=1, #pocketNums do
pocketStr = pocketStr .. pocketNums[i] .. "|"
end
wx.wxMessageBox("pocketStr="..pocketStr)
scr.SetProperty("GROUPBOX_CurrentToolPocket", "Strings", pocketStr)
else
wx.wxMessageBox("pocketStr=nil")
end

the function 'PocketPositions.GetUsedPocketNumbers()' looks like:
Code: [Select]
-- Gets a table of the pocket numbers that are configured
function PocketPositions.GetUsedPocketNumbers()
local PocketNums={}
local n=0

-- make sure the pockets have been loaded
if PocketDetails == nil or PocketDetails[0] == nil then
PocketPositions.ReadPocketData()
end

for k,v in pairs(PocketDetails) do
  n=n+1
  PocketNums[n]=k
end

return PocketNums
end

When it calls the function 'PocketPositions.ReadPocketData()' (which is also in the  'PocketPositions.Lua' file) I get an error that 'PocketPositions' is null.

If I step through 'PocketPositions.ReadPocketData()' in the script editor it works fine.

Any idea what's happening and how I fix it?


5
I messed around with it a lot and still couldn't figure out why it wasn't working. As a test I made a new profile with no edits, added the M500 from above and it worked fine.

I ended up copying my screen set in to this new profile and it worked, I can't figure out what I did to break it, It must be one of the files I was editing i made some odd mistake. But I'm moving along now.

6
I only have the m500 file in the Macros folder.

I tried upper and lower case with no difference.

I did notice something weird though with the button, When I press it it's starts the cycle and hangs like when running it in the MDI window. When I press the button again is when it executes.

The code is in the 'Button clicked' event and looks like:
Code: [Select]
local inst=mc.mcGetInstance()
mc.mcCntlGcodeExecute(inst, "m500\n")

7
I created a new m code, m500 and put it in the folder 'C:\Mach4Hobby\Profiles\AXYZ\Macros'.

The contents of the file are:
Code: [Select]
function m500()
wx.wxMessageBox("Works")
end

if (mc.mcInEditor() == 1) then
m500()
end
I'm running the profile in AXYZ and have confirmed this.

When I type 'M500' in the MDI window, or put it in a gcode file it does not execute. It just sits on the line and the cycle time counter goes up. I don't get any errors, it doesn't do anything.

I tried making a simple gcode file that looked like:
Code: [Select]
X0 Y0
m500
X1 Y1

The machine moves to 0,0 then just sits on the m500 line.

I tried calling the command from a button and it works fine

I stepped through the function and the message box pops up correctly.

What am I doing wrong?



8
Thank you the /e option worked!

Other than my M code files and other files I've created which file s should I back up?

9
I was editing a screen and added a button. I set the click script to call macro 'm500', and typed it in that way. It should be 'm500()'. But now when I load the screen it gives the error:
Lua: Script error during pre compilation
c:\mach4hobby\Screenscript.Lua:861'Syntex error near 'end'

I tried removing the line from Screenscript.lua, (I did remove the read-only status). Saved the file and and verified my change was saved. But when I restart Mach 4 I get the same error, and when I check Screenscript.lua the line with the error is back.

How do I fix this error?

10
Thank you so much for your explanation! It was nice and clear! And worked exactly like I needed it to.

Pages: 1 2 3 4 5 6 7 8 »