Hello Guest it is April 25, 2024, 07:45:31 PM

Author Topic: analog input to file while running GCODE  (Read 597 times)

0 Members and 1 Guest are viewing this topic.

analog input to file while running GCODE
« on: June 21, 2022, 06:20:11 AM »
hey guys
i am trying to write a file that logs an analog input value for each point on my GCODE while it is running.
i thought that i could use the probe logging example but i don't know how to access and alter the G31 command.
does someone know? or have a better idea on how to go about this issue?

thanks
ido

Re: analog input to file while running GCODE
« Reply #1 on: June 23, 2022, 01:18:57 AM »
Hi,

Quote
i thought that i could use the probe logging example but i don't know how to access and alter the G31 command.

You can't alter the g31 command, you can use its features, but you can't change it.

Analogue values are in registers, so if you want to save a value just write the register value to an open file.
I have a file browser/dialog that would allow you to open a file in a manner analgous to m40/m41 pair used to open and close data file
for probe data which you could adapt.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: analog input to file while running GCODE
« Reply #2 on: June 23, 2022, 01:26:50 AM »
thanks!
that sounds exactly like what i am trying to do!
could you post that example?
Re: analog input to file while running GCODE
« Reply #3 on: June 24, 2022, 10:16:10 PM »
Hi,
I wrote an m40 and an m41 specifically to work with Autoleveller, a software utility that probes a nominally flat surface to determine
small deviations from flat and thereafter manipulate the Gcode to follow the contour. I use this for making circuit boards.
The full story about how and why I came to write the macros is here:

http://www.cncsoftwaretools.com/forum/viewtopic.php?f=4&t=336

You will note that the file dialog I used as the basis for my macros is included in Mach4Hobby release:

C:\Mach4Hobby\LuaExamples\ProbeToFile\m401.

The m401 macro is to open a probe file while m400 closes it. I copy m401 here, but you have it on your PC already:

Code: [Select]
function m401()
inst = mc.mcGetInstance();
    -- create the wxFrame window
    mainframe = wx.wxFrame( wx.NULL,          -- no parent
                        wx.wxID_ANY,          -- whatever for wxWindow ID
                        "DummyFrame", -- frame caption
                        wx.wxDefaultPosition, -- place the frame in default position
                        wx.wxDefaultSize,     -- default frame size
                        wx.wxDEFAULT_FRAME_STYLE ) -- use default frame styles

    -- create a panel in the frame
    panel = wx.wxPanel(mainframe, wx.wxID_ANY)--We are not going to show it but we need to have this to use the File dialog

local file = wx.wxFileDialog(panel, "Select Probe File", "", "", "Text files (*.txt)|*.txt|Tap files (*.tap)|*.tap",
                             wx.wxFD_SAVE,wx.wxDefaultPosition,wx.wxDefaultSize, "File Dialog" );
        if(file:ShowModal() == wx.wxID_OK)then
            local path = file:GetPath()   
--wx.wxMessageBox(tostring(path))
--[[
Set the output of the probe points with the format String
Example:
X%.3AXIS_X
will output X<xprobevalue>
]]--
mc.mcCntlProbeFileOpen(inst, path, "X%.3AXIS_X Y%.3AXIS_Y Z%.3AXIS_Z A%.3AXIS_A\r\n", true);
        end

end

if (mc.mcInEditor() == 1) then
    m401()
end

This file dialog will need to be edited for yor purpose. A g31 automatically writes to this file in append mode, but you wish to write values you will
have to write to the file using the formal Lua procedures, and you'll find examples in my m40/m41 macros.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: analog input to file while running GCODE
« Reply #4 on: June 26, 2022, 07:16:10 AM »
thank you for taking the time to explain,
this has been extremely helpful!