Hello Guest it is April 25, 2024, 01:55:55 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 »
41
Mach4 General Discussion / Re: analog input voltage issues in Mach4
« on: April 08, 2018, 01:08:03 PM »
Reply from Polabs this is correct.  Register is fraction of total value. So 1=3.3 volts

42
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

43
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

44
Mach4 General Discussion / Re: Lua file operations
« on: April 07, 2018, 06:01:43 AM »
Here is another site with many more examples to expand on the Lua.org

http://lua-users.org/wiki/

45
Mach4 General Discussion / Re: Lua file operations
« on: April 07, 2018, 05:41:18 AM »
Hi,
this is so helpful it lives on my desktop when coding:

https://www.lua.org/manual/5.2/

The section you want is 6.8

Craig

Thanks Craig!  Sure appreciate you always trying to help!  I also spent lots of time on that site and have the physical book.  My problem has been that the methods in the lua docs sometimes don't work with Mach4 Lua.  The conventions are enough different that I spend hours with trial and error to finally come up with the sometimes subtle difference that is finally successful.  

I did learn that issuing a file:write('\n') command moves to the next line in the file to write.  At first it would not work and I don't know why.  Sometimes file writing works and sometimes it does not.  It could be that a file is left open when a bug occurs and knocks the program out before completing the close.  Sometimes restarting fixes the problem

The last pearl I discovered was from a post on another of several websites that teach lua or respond to problems.  Formatting numbers has been tricky for me.  I get long floating point numbers from the analog voltage inputs and using variable=tostring(math.floor(analogvalue+.5) worked great to round the number properly and convert it to an integer.  I could not figure out how to get an integer string from the lua docs.  Lots of trial and error to pick at each detail and technique is the only way to be successful with lua.  wx.widgets is even harder.  

Thankful for the forum!!

Keith

46
Mach4 General Discussion / Re: Lua file operations
« on: April 05, 2018, 08:45:02 AM »
How do I write to a new line?

I tried


file = io.open(FileToUse, "a+")   
file:write("test\n")
file:write("test2\n")

but it adds it to the same line

I get
test/ntest/n and I want

test
test

Thanks

47
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!

48
Mach4 General Discussion / Re: wx.widgets
« on: March 29, 2018, 12:32:21 PM »
Thanks !

49
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!


50
Mach4 General Discussion / Re: Lua file operations
« on: March 24, 2018, 11:31:41 AM »
so the correction was successfu!

file:write and file:close etc not just io.write

Thanks!

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

local stuff="--one,two,three"

local location=path .. "\\testfile.csv"
wx.wxMessageBox(location)
file = io.open(location,"a+")
file:write(stuff)
file:close()

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 »