Hello Guest it is April 24, 2024, 04:31:42 PM

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.


Topics - thespindoctor

Pages: « 1 2 3 4 5 6 7 »
11
Mach4 General Discussion / analog input voltage issues in Mach4
« on: April 08, 2018, 11:47:37 AM »
Having trouble getting the correct voltage values in Mach4 from a Pokeys57E.

I measure voltage at the analog input pins up to 3 volts max but Mach4 registers only see about .8 volts max.

Does anyone have an idea what is going wrong.  Tech support has not responded with anything helpful yet.

Not sure if this is a Pokeys issue or a Mach4 issue.

Thanks so much.   Up against a deadline so getting panicked....

Keith

12
PoKeys / help with analog voltage inputs
« on: April 08, 2018, 11:46:03 AM »
Having trouble getting the correct voltage values in Mach4 from a Pokeys57E.

I measure voltage at the analog input pins up to 3 volts max but Mach4 registers only see about .8 volts

Does anyone have an idea what is going wrong.  Tech support has not responded with anything helpful yet.

Thanks so much.   Up against a deadline so getting panicked....

Keith

13
Mach4 General Discussion / plc vs screenload script programming
« on: April 04, 2018, 09:22:03 AM »
I am collecting 4 analog input voltages with programming in the PLC script.  Each sweep of the PLC reads the analog voltage and it displays on a meter.   

I would like to turn on recording to collect these values for 5 seconds. 

 I am thinking of a global variable startrecording = "on" could be set with the down script of a button on the screen.  Then the PLC script would be checking for the "on" state of that variable and begin building an array with the voltages for 5 seconds when "on". Then after 5 seconds, the PLC script would change the startrecording to "off". 

Now I would have the array ready to write to a file.  Is there a problem doing this all in the PLC script?  Should I put the file operations in the script of a button on the screen?  Can I pick up the array as a global variable from that button or should I create a function to pass the array?  Not sure just how to sort through all the possibilities to decide what is the best method.  It does not seem like a good idea to potentially slow down the PLC script doing file operations.

Thanks!

14
Mach4 General Discussion / wx.widgets
« on: March 29, 2018, 07:49:27 AM »
Really having trouble getting started with wx.widgets

I can handle a message box and number from user but am not able to get text input from user at this point.  Figuring out much from the documentation is difficult.

I would like to collect a word from the user like filename, or username etc.  1 is minimum # characters and 3 is max I think.

This does not work. 
Code: [Select]
local newname = wx.wxGetTextFromUser("Enter a name","Name Entry Screen",name,1,3)
What have I done wrong?  Has anyone found a good source for learning this stuff...  I sure would like some getting started when you know nothing examples for wx.widgets

Thanks!


15
Mach4 General Discussion / Lua file operations
« on: March 24, 2018, 09:31:04 AM »
Hoping for some help on basic file operations in Lua.

Is there a reference for how to modify the code for file operations from the lua.org/manual information to get it to work in Mach4Lua?
It does not seem to recognize the io.write and io.code but recognized io.open

Here is the simple version I am trying.

Code: [Select]
inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)

stuff="--one,two,three"

filetoget=path .. "\\testfile.csv"

io.output=io.open(filetoget,"a+")
io.write(stuff)
io.close()

Thanks!

16
Mach4 General Discussion / meters stopped working
« on: March 14, 2018, 05:09:51 PM »
I had a great setup with several meters displaying voltages from 4 analog inputs.  I was changing the ticks and max value on one of the meters and they all stopped working.  Then I reverted back to the original settings but no matter what I do, the meters are silent.  However, one meter showing an average/sec of voltage is working fine.  The registers for these analog inputs show the proper voltages.  I have the code in the PLC script and was wondering "are if then statements in the PLC a problem"?  Would it be better to do this in the signal script?  Does the signal script scan just like the PLC so I could basically use the same code there?

Thanks

17
Mach4 General Discussion / Lua programming of voltage meter
« on: February 13, 2018, 11:32:48 AM »
Is it possible to use LUA to program a graphic voltmeter in Mach 4?  I am trying to visualize voltage output from 4 piezoelectric weight sensors, using Mach 4 as a data acquisition system.
I have a Pokeys57U and a breakout board so I know the 4 analog inputs are there but I am not sure how to make the software side work. Any suggestions would be appreciated.

Thanks

18
Hope this can help some of you learning to work with Lua.  Several issues are addressed for the beginners like me.
This is a single probe move in Y to identify the coordinates at a probe strike and store the coordinates in a file I created and in the registry.
The probing in G31 or G31.1 etc automatically loads the #variables with the x,y,and z coordinates of the probe strike,
I have tried to document the file for descriptions of what is happening.


Code: [Select]


----------------------
--CHECK diameter of a grinding WHEEL
--I have a grinding wheel in the chuck of a Z axis spindle motor.  It is moving toward a switch.
--  The switch is wired as a second probe in my setup
--    so I am using G31.1  It you are only using a single probe then use G31
--This program is to help learn how to probe as well as some basics of using Lua in Mach4
--I am just learning as well and I hope this can help other Mach4 users
----------------------

local inst = mc.mcGetInstance();

wx.wxMessageBox("Ready for zeroing all axes?")

--xero all axes
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 Y0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 X0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 Z0.0")

--this path business is TRICKY   notice the double \\ and the .. 
--the path that the Lua code sees will be c:\Mach4Hobby\GcodeFiles\KFCProbeWheel.csv
--notice the formatting  the probing routine will automatically load the probe file
-- with coordinates of the probe eg.: -.4657,-.8949,9.000

local path = wx.wxGetCwd() .. "\\GcodeFiles\\KFCProbeWheel.csv"--this file is where I store the probed coordinates of the grinding wheel
mc.mcCntlProbeFileOpen(inst, path, "%.4AXIS_X,%.4AXIS_Y,%.4AXIS_Z", true);

---------Set up for 31.1 only  Using probe #2
local ProbeCode=31.1

------------- Check Probe -------------
--This is the function from the probing module Called CheckProbe that I just copied, renamed and put in my screen load script
-- it is not really mandatory to use this but it checks to see which probe and if the probe is working properly
-- to find the source look at the mcProbing.lua file in the Modules directory.  Look for the function called Probing.CheckProbe

local rc = KFCCheckProbe(1, ProbeCode); if not rc then; do return end; end

--move to set position near limit switch to check diameter
    rc=mc.mcCntlGcodeExecuteWait(inst,"G90 G01 X-.3652 Z-.6170 Y-.25 F30.0")
        mm.ReturnCode(rc)
        rc = KFCCheckProbe(1, ProbeCode); if not rc then; do return end; end

-- probe 31.1 for probe1 (limit switch which is the SECOND probe in my system)
-- Mach4 - IMPORTANT TO REALIZE THAT Mach4 USES "probe" for the first probe.  If you have a second probe it will be "probe1")   
-- G31 or G31.0 if you have a single probe.  G31.1 for the second probe called probe1, G31.2 for a third probe called probe2)

rc=mc.mcCntlGcodeExecuteWait(inst,"G31.1 Y-.525 F10.0")
        mm.ReturnCode(rc)
        rc = KFCCheckProbe(0, ProbeCode); if not rc then; do return end; end

--the probing routine places the machine coordinates in these #variables  5071 for x, 5072 for y, 5073 for z
local ProbedMeasXAbs1 = mc.mcCntlGetPoundVar(inst, 5071)
local ProbedMeasYAbs1 = mc.mcCntlGetPoundVar(inst, 5072)
local ProbedMeasZAbs1 = mc.mcCntlGetPoundVar(inst, 5073)

--position near the switch and aligned with the switch so it can probe
mc.mcCntlGcodeExecuteWait(inst,"G91G01 Y.05 F10.0")
mc.mcCntlGcodeExecuteWait(inst,"G90")

    mc.mcCntlSetLastError(inst,string.format("%1.4f:%1.4f:%1.4f",ProbedMeasXAbs1,ProbedMeasYAbs1,ProbedMeasZAbs1))

--I am putting the coordinates into the registry file
-- write to ireg0 in register
WriteRegister("Probe2XWheel",ProbedMeasXAbs1)
WriteRegister("Probe2YWheel",ProbedMeasYAbs1)
WriteRegister("Probe2ZWheel",ProbedMeasZAbs1)

--move all axes to zero
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 Y0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 X0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G00 Z0.0")

 --close the probe file   
mc.mcCntlProbeFileClose(inst)



19
I have probed a single surface and am able to get x,y,z positions stored in a probe file.  The next step is to be able to read this one line .csv file and retrieve the x,y,z values.  Other ways to handle the information would be writing registers and then saving to the .ini file or obtaining the variable 5071,5072, and 5072.  i would like to learn to work with the file operations at this point.  Of course the Lua learning curve is still holding me down but I have been able to cut and paste and make a lot of progress.  Properly getting the path listed and working with tables is tricky.   I though I was understanding how it is done but no joy.  The code posted here seems correct to me but it is providing a nil value for the CSVpath to start with.  This is about as simple as it gets and I can't get it done...
Thanks for any suggestions.

Keith
Code: [Select]
--program to retrieve one line of probe data from a prob file
--and display the x,y,z positions in the error line
-- it does not seem to work and I am not sure why

local ProbeYWheel={}
local inst = mc.mcGetInstance()

local CSVPath= wx.wxGetCwd() .. "\\GcodeFiles\\KFCProbeWheelFLAT.csv" --1 line .csv file with x,y,z position from probing one time

--open file and read out the data

io.input(io.open(CSVPath, "r"))

local line;
for line in io.lines(CSVPath) do
tkz=wx.wxStringTokenizer(line,",");
ProbeYWheel["0"]={}--make blank table to hold the data - Should this be "0"??
local token=tkz:GetNextToken();

ProbeYWheel["0"] ["X_Position"]=Token; --i assume the first line is line 0??
ProbeYWheel["0"] ["y_Position"]=tkz:GetNextToken();
ProbeYWheel["0"] ["Z_Position"]=tkz:GetNextToken();
end
io.close()

--read data
local XPos = ProbeYWheel["0"].X_Position --should this be "0" ??
local YPos = ProbeYWheel["0"].Y_Position
local ZPos = ProbeYWheel["0"].Z_Position

    mc.mcCntlSetLastError(inst,string.format(" X: %.4f | Y: %.4f | Z: %.4f", XPos, YPos, ZPos))


20
Figured out how to load a gcode file with wx.widgets and it shows up in the other gcode windows on the stock tabs in Mach4-Mill.  However, when I add a gcode window to the tab I have created, the window is loaded with the code from the file but when I either hit the cycle start button or try to program a cycle start, it says nothing to run.  When I switch to another tab, the gcode is properly listed and will run with cycle start.  How do I link the new gcode window to the loaded code?  I cannot see any difference on the lua scripts or the properties of the other gcode windows.  Seems odd that is would not work.  I see the Lua code necessary to make an MDI window run code, but is there something not stated that I have not done?

Thanks
Keith

Pages: « 1 2 3 4 5 6 7 »