Hello Guest it is March 29, 2024, 01:01:45 AM

Author Topic: Pokeys Mach4 plugin LUA reference for LCD  (Read 26590 times)

0 Members and 1 Guest are viewing this topic.

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #30 on: December 15, 2016, 04:47:42 PM »
Where your calling the function try putting the axis letter and line number in double quotes........ like this.

YPenLCD("X", "1")

I would just try in the plc scripts first run to start with. If when mach opens the LCD displays right (before any axis moves) you got it.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #31 on: December 15, 2016, 05:17:28 PM »
That fixed part of it, then I also did that same thing in the update scripts for each DRO.

Now it almost works correctly,

now I get 6 digits after the decimal point where I had four previously. 

So like

X:  12.123456     instead of  X:  12.1234

must need to put the %4.4f somewhere...

Russ

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #32 on: December 15, 2016, 05:30:20 PM »
Try replacing your function with this..........

function YPenLCD(Axis, Line)
    local CurPos = scr.GetProperty("droCurrent" .. Axis, "Value")
    CurPos = string.format("%4.4f", CurPos)
    local hreg = mc.mcRegGetHandle(inst, "PoKeys_32062/LCD Line" .. Line)
    mc.mcRegSetValueString(hreg, Axis .. ":  " .. CurPos .. "          ")
end
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #33 on: December 15, 2016, 06:43:04 PM »
I actually replaced the code with the following, which just added one line, which seemed to work but it broke other things.

function YPenLCD(Axis, Line)
    local CurPos = scr.GetProperty("droCurrent" .. tostring(Axis), "Value")
    CurPos = string.format("%4.4f", CurPos)
    local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line " .. tostring(Line)))
    mc.mcRegSetValueString(hreg, string.format(tostring(Axis) .. ":  " .. tostring(CurPos) .. "          "))
end


Now if I try and load a gcode file and start it seems to go and then will just get hung.  Z also updated very slow, very strange.

Russ
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #34 on: December 16, 2016, 10:15:58 AM »
Very strange,

With the latest change to put everything in a function to clean it up, sudden Mach4 would star trek.  I tried to run gcode file like the roadrunner and it would just sit and never start.  It is like one of t he functions would send it to never never land, but this makes no sense.  I commented out all the code and and Mach4 works again.  Then I removed the comments from the original codes prior to turning it into a function and everything worked again.  This is very bizarre.

Looking at the code nothing in there should have caused Mach4 to crash.  I rebooted and tried it several times with the same results.  One time the LCD went totally blank so I power cycled the LCD display and the ESS and got everything back but the problem reoccurred.  I will have to study this again to determine why this happens.

I still do not really understand the method to run the debugger when you are working with the screen load script.  I debug it and it starts but many of the variables just show errors when you step through the codes start at the very top of the screen load script the first few variables all show a value, but as you do down further they all show errors.  Nothing has changed in the upper section of the screen load script so clearly I am doing something wrong when running the debugger.  I have used C debuggers and assembly debuggers and this debugger seemed to work similar but must be something I am not doing to get it to work correctly.

Russ
 

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #35 on: December 16, 2016, 04:15:45 PM »
Sounds like there is something wrong in some of your script somewhere.

You can take the script that's in the function and put it in a wizard........... then open that wizard and step through it to debug. That's usually what I do. I keep a wizard named test in my wizards directory just to play in.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #36 on: December 16, 2016, 04:58:17 PM »
Chaoticone,

Thanks for the suggestion on using a wizard.  I will try that to get to the bottom of this issue.  Very strange everything was getting better and better but when I adjusted the DRO value and put it into the 4.4f format that for some strange reason seemed to cause it to star trek.  The strange part is it actually did adjust the DRO output correctly but somehow seemed to get MACH4 is a strange state where nothing would work correctly.  Never got any errors from the LUA code, so does not seem to be associated with a typo or something.  I will test in a wizard to see what might be wrong.

CurPos = string.format("%4.4f", CurPos)

Russ

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #37 on: December 16, 2016, 05:02:25 PM »
Would be interesting to see if replacing your function with the last I posted fixes it.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #38 on: December 17, 2016, 09:05:48 AM »
Chaoticone,

I will give that a go today.  LUA seems pretty touchy on some things and very forgiving on other aspects.  That single line only replaced a sting value with a formatted string value.  That line by itself should not have done anything that would allow MACH4 to crash.  I am learning as I go with this LUA stuff.  I was a C programmer for years, and this is similar to C, with the lack of Switch/Case and others but it does have other attributes.  Oh well always good to learn new things.  Thanks for all your help and suggestions.

Russ
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #39 on: December 31, 2017, 08:49:55 PM »
Any more progress on this? a final working code/setup for the LCD on Pokeys57CNC?