Hello Guest it is March 28, 2024, 05:43:27 AM

Author Topic: Pokeys Mach4 plugin LUA reference for LCD  (Read 26573 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 #10 on: December 05, 2016, 05:08:54 PM »
I have another idea that I think will work better all around. Let me know if your interested.
;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 #11 on: December 05, 2016, 05:40:10 PM »
Chaoticone,

Thanks for your comments, yes I had it all in xDRO, moved it to each did not realize each DRO had a separate update script.  That works.

I will have to search how to concatenate strings so I can get the AXIS: with a couple spaces before it prints out the coordinates.

Another thing I notice is when you start up Mach4, this never updates the LCD display.  If you enable Mach4 it does not update the LCD display.

If you jog it updates the LCD display immediately, if you load a gcode file and start to run it updates the LCD display immediately.

I have not been able to find a command to send via the POKEYS unit to clear the LCD display in the very beginning so the POKEYS on MACH4 message gets erased prior to the coordinates getting display, but I will keep looking.  I know I can build a string of "   " 20 spaces and send that which might be a work around.

Much much closer and thank you very much Chaoticone, I knew I was missing several things so between you and DazTheGas I am getting much much closer.


Russ
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #12 on: December 05, 2016, 05:41:12 PM »
YES, I am very interested.  Any suggestions are totally welcome.  I know many people have tried to get this kind of stuff working so hopefully this study will help many others struggling with some of these same issues. 

Let me know what you have and I will give it a try.

Russ

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #13 on: December 05, 2016, 06:03:23 PM »
OK, the reason the LCD does not update when Mach starts up is because the DROs are not updating and that script only runs when the DROs update (value changes). Anything that changes the value of the DROs should update the LCD.

Quote
I have not been able to find a command to send via the POKEYS unit to clear the LCD display in the very beginning so the POKEYS on MACH4 message gets erased prior to the coordinates getting display, but I will keep looking.  I know I can build a string of "   " 20 spaces and send that which might be a work around.

Not familiar with it but yes, sending an empty string should clear it.

OK, my idea is to build a function that updates the LCD. It would basically be all of the script you put in each dro combined into a single function in the screen load script. Then in the PLC script check to see if the DROs have changed and if they have, run the function. Also, to initialize the LCD when Mach starts run the function once in first run of PLC script. Look in the router screen sets PLC script for the Update fractional DROs section to see how it would work.

Another option that may be even better is to update the LCD to the values in the DROs in the first run of the PLC script and leave the onupdate scripts where they are (no need for a function in the screen load script then and will only run once when Mach is launched).

This should have put an X in front of the X value in the LCD display..........
Xcoords = string.format("X%4.4f", Xcoords)

This should put a X, a : and a space..........
Xcoords = string.format("X: %4.4f", Xcoords)
« Last Edit: December 05, 2016, 06:08:23 PM by Chaoticone »
;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 #14 on: December 05, 2016, 06:23:20 PM »
Thank you for the suggestions.  I will play a while and let you know what happens.  Think I tried the "X: %4.4f" but got an error, will try it again.

Russ
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #15 on: December 05, 2016, 06:29:59 PM »
Just tried to update the Xcoords = string.format("X:  %4.4f",Xcoords)

That worked this time because it was working with the string not a value so thanks that works perfect.  I will work on the function you suggest and look at the other suggestion as well.  YOU ARE AWESOME...  Thank You so Much

Russ


Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #16 on: December 06, 2016, 04:41:16 PM »
Chaoticone,

I tried to send the clear charter 0x01 to the LCD screen but that does not work, it just outputs a decimal 1.

Then I tried 0x20 which is HEX for a space, and what comes out on the LCD is 32.  So apparently writing to registers in Hex they get converted to decimal?

local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 1"))
                 mc.mcRegSetValue(number hReg, 0x01)


Then I tried to send a string of 20 spaces, like clr = "               "
but that pukes as well.  Still searching the LUA manuals must be some trick I am missing somewhere.

Russ




Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #17 on: December 06, 2016, 05:13:31 PM »
After playing, my guess is the Plugin has defined these LCD registers as ASCII, so when you send HEX they get converted to DECIMAL ASCII

0x20 which is traditionally a space comes out as 32, which is decimal conversion of the hex number.  But clearly that is not ASCII number so this must happen automatically due to the plugin defines.

Will play again after I think about this a while.  LOL

Russ

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Pokeys Mach4 plugin LUA reference for LCD
« Reply #18 on: December 06, 2016, 07:13:10 PM »
local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 1"))
                 mc.mcRegSetValue(number hReg, 0x01)

In line 2, is "number hReg" right? Shouldn't it just be hReg?

Seems to me this should clear it.........

local hreg = mc.mcRegGetHandle(inst, "PoKeys_32062/LCD Line 1")
mc.mcRegSetValue(hReg, "                    ")
;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 #19 on: December 06, 2016, 08:15:38 PM »
Nope, but that is because setvalue is expecting a value not a string.  I also tried setstringvalue which should work, but I got and error.  Will test this again in the morning

Russ