Hello Guest it is April 24, 2024, 12:49:35 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 - thespindoctor

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 »
51
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!

52
Mach4 General Discussion / Re: meters stopped working
« on: March 14, 2018, 06:56:41 PM »
Fixed it!  Just during a copy the meter names changed...  escy fix difficukt to see

53
Mach4 General Discussion / Re: meters stopped working
« on: March 14, 2018, 05:55:57 PM »
Yes that was my posting to set this all up but now it has stopped working for no apparent reason...

54
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

55
Mach4 General Discussion / Re: Lua programming of voltage meter
« on: February 19, 2018, 05:40:56 PM »
Thanks Mike but it works! ~~~ but I had to use the num pad.  It does not work using the number keys across the top of the keyboard though.

56
Mach4 General Discussion / Re: Lua programming of voltage meter
« on: February 19, 2018, 05:13:56 PM »
Now it is working great with the mc.SignalSetState method per Daz assigning an unused input to the LED such as input63 as he suggested.
For those trying trying to use this, note the change to ISIG_INPUT from OSIG_OUTPUT ( 1=on 0=off)  This code is in my PLC script.
As Daz suggested, I tried but do not have a ~ sign on my keyboard so stuck with >=.1 instead of ~= 0.  It works better because there is noise below .1v

  if tonumber(regval) >.1 then
        mc.mcSignalSetState (mc.mcSignalGetHandle ( inst ,mc.ISIG_INPUT63  ), 1)
    else
        mc.mcSignalSetState (mc.mcSignalGetHandle ( inst,mc.ISIG_INPUT63  ), 0)
    end
    --

I could not get reliable function with the scr.SetProperty method.  Sometimes it would work and sometimes it would switch to off and stay off. 

57
Mach4 General Discussion / Re: Lua programming of voltage meter
« on: February 19, 2018, 10:58:19 AM »
So nice to solve this, thanks!

58
Mach4 General Discussion / Re: Lua programming of voltage meter
« on: February 19, 2018, 09:42:58 AM »
No matter what I do I can’t get an Led to turn on.  I am trying to set property value to “On” even with a separate button. I believe I saw a past discussion in the past about Leds being difficult.

I am happy with my new command of meters and guages though!  Thanks for the help!

59
Mach4 General Discussion / Re: Lua programming of voltage meter
« on: February 19, 2018, 07:14:11 AM »
Ok, that makes sense.  I will try a work around to turn on the led if the value of the input is over 0.

Thanks!

60
Mach4 General Discussion / Re: Lua programming of voltage meter
« on: February 19, 2018, 06:48:10 AM »
Having trouble with getting an LED to light up with these analog inputs.
Is there a trick here?

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 »