Hello Guest it is March 28, 2024, 04:31:12 PM

Author Topic: Copy DRO to external display  (Read 2654 times)

0 Members and 1 Guest are viewing this topic.

Copy DRO to external display
« on: December 04, 2016, 11:39:10 AM »
Guys,

I have a few questions.  I am attempting to copy the current DROs for X,Y,Z,A to an external LCD display.

I have looked in the Wx4 screenset and see the dro name in the screenset is droCurrentX for the X axis.

I also looked at #variables and there seems to be several with the DRO contents.  5221,5222,5223,5224 appear to hold the G54 DROs, and I think the Machine coordinates are held in 5021,5022,5023,5024

What I really want is whatever is displayed in the droCurrentX or whatever axis to get copied to a plugin register.

Each LCD line on the display has a plugin register as follows:
Pokeys Plugin Registers
PoKeys_32062/LCD Line1:
PoKeys_32062/LCD Line2:
PoKeys_32062/LCD Line3:
PoKeys_32062/LCD Line4:

I can look under Diagnostics/Regfile/Pokey_32062 and look at the various registers.  I can click on those register and it opens a value screen and I can key in a number and the display updates.

The display is 4x20

Then I decided can I actually read the register and display it in LUA code, after reviewing the scripting manual.  I have many switches and MPG, etc. all work fine in the LUA code.

local pval, hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line1:/%s", regname))

pval = mc.mcRegGetValueString(hreg)
wx.wxMessageBox(pval)

I tried something like this and got nothing.  I am sure the way you access register must be wrong or something.  I just followed the example but nothing seems to work.

Is there a better way to do what I want to accomplish?  Thanks

Russ








Offline Pedio

*
  •  200 200
    • View Profile
Re: Copy DRO to external display
« Reply #1 on: December 04, 2016, 12:29:30 PM »
I forgot who did it but they made a separate jog panel for a second display. I think it had DROs on the jog panel. You might want to look through the forum.
Re: Copy DRO to external display
« Reply #2 on: December 04, 2016, 12:52:28 PM »
Yeah, I have been looking for hours but have not found a good example.  Accessing the plugin registers is an example but I can't seem to get that to work.

Russ

Offline Pedio

*
  •  200 200
    • View Profile
Re: Copy DRO to external display
« Reply #3 on: December 04, 2016, 01:16:48 PM »
I was wrong - it did not have a DRO. Here is the separate jog window. I don't use this any more since I have the ShuttlePro over by the machine. Also, I installed a separate touch screen monitor ($99 on ebay) by the machine and I use actual multiple monitors to use a key stroke to move the M4 screen over to the second screen. I programed the ShuttlePro with the keystorke combo and now I can move the M4 screen between monitors. Actual Multiple Monitors resizes the screen to the monitor when it moves it.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Copy DRO to external display
« Reply #4 on: December 05, 2016, 04:39:18 AM »
I you go into the screen editor and highlight the dro you want to copy then highlight the events tab you will find a script section with onUpdate script.

Something like this should be ok.

Code: [Select]
local inst = mc.mcGetInstance()
local Xcoords = scr.GetProperty("droCurrentX","Value")
local hreg = mc.mcRegGetHandle(inst, string.format("Sim0/test0")) -- this line will need changing to the register you want to update IE "PoKeys_32062/LCD Line1"
mc.mcRegSetValueString(hreg, tostring(Xcoords))

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Copy DRO to external display
« Reply #5 on: December 05, 2016, 09:33:34 AM »
Daz,

Thank you so much for your help.  A few more questions to clean this up a bit.

The LCD display is 4x20, so when I do the following code it does copy the DROs to the LCD, but copies a given DRO with too much precision meaning the following.

If the DRO on the display reads 12.2345, the LCD will ready 12.234567, so I need the display to be formatted similar to what you might do in a formatted Printf in C language.

The DRO uses %4.4f, so up to four leading digits and four trailing digits after the decimal point.

I would like to have the display read something like this and ensure there is no text after the coordinate.  The LCD display is updated when it start with Pokeys information.

X: 23.1234
Y: 12.4567
Z: -2.5678
A: 0.0000


local inst = mc.mcGetInstance()
local Xcoords = scr.GetProperty("droCurrentX","Value")
local Ycoords = scr.GetProperty("droCurrentY","Value")
local Zcoords = scr.GetProperty("droCurrentZ","Value")
local Acoords = scr.GetProperty("droCurrentA","Value")
local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 1"))
mc.mcRegSetValueString(hreg, tostring(Xcoords))
local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 2"))
mc.mcRegSetValueString(hreg, tostring(Ycoords))
local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 3"))
mc.mcRegSetValueString(hreg, tostring(Zcoords))
local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 4"))
mc.mcRegSetValueString(hreg, tostring(Acoords))

Really appreciate all you help, Daz your AWESOME.  :)


Re: Copy DRO to external display
« Reply #6 on: December 07, 2016, 12:39:06 PM »
Guys,
With lots of help here is a routine that will let you update an LCD display with the current DRO readings in MACH4.
In the screen load script you need this function, which really clears the Pokeys startup message and then puts the X,Y,Z,A axis all at 0.0000

The droCurrentX or given axis scripts will update the LCD display with each change.

Thanks go out to DazTheGas, Chaoticone who helped get me get this pulled together.

Enjoy.... Russ


--------------------------------------------------------------
-- Yaskawa Pendant Clear LCD Display
--------------------------------------------------------------
function YPenLCD()
        local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 1"))
        mc.mcRegSetValueString(hreg, "X:  0.0000          ")  -- X zero display
        local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 2"))
        mc.mcRegSetValueString(hreg, "Y:  0.0000          ")  -- Y zero display
        --mc.mcRegSetValueString(hreg, "                    ")  -- 20 spaces
        local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 3"))
        mc.mcRegSetValueString(hreg, "Z:  0.0000          ")  -- Z zero display
        --mc.mcRegSetValueString(hreg, "                    ")  -- 20 spaces
        local hreg = mc.mcRegGetHandle(inst, string.format("PoKeys_32062/LCD Line 4"))
        mc.mcRegSetValueString(hreg, "A:  0.0000          ")  -- A zero display
        --mc.mcRegSetValueString(hreg, "                    ")  -- 20 spaces
end

Then at the end of the loop in the PLC script that runs one time you add a call to this function.

YPenLCD()

Now you need to update droCurrentX, droCurrentY, droCurrentZ, droCurrentA in the events tab with the following LUA codes.  There will be four scripts make sure you adjust the Axis and the LCD line numbers in each of the four scripts. 

local inst = mc.mcGetInstance()
local Xcoords = scr.GetProperty("droCurrentX","Value")
cal hreg = mc.mcRelogGetHandle(inst, string.format("PoKeys_32062/LCD Line 1"))
Xcoords = string.format("%4.4f", Xcoords)
mc.mcRegSetValueString(hreg, tostring(Xcoords))