Hello Guest it is September 19, 2019, 06:07:54 PM

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 - smurph

Mach4 General Discussion / Re: MACH4 - Modbus
« on: May 14, 2014, 01:28:07 PM »
If the macro script is not wrapped in a function, then that is what you will get.

This is what a macro should look like.  Notice at the bottom it has code that detects the editor so that it will actually run the M40 function.

Code: [Select]
function m40()
    mc.mcCntlSetLastError(inst, 'I'm in M40!!!!')

if (mc.mcInEditor() == 1) then


There is a new 1767 out there now.  It should be better.  There were some "issues" in the original.  

Also, the greyed out screen buttons were testing the "Enabled States" property.  There is still a slight issue with that which I'm working on now.  Just clear the Enabled States property on the controls that are not working correctly and that should clear them up.


Mach4 General Discussion / Re: ScreenSet Question
« on: May 13, 2014, 06:17:43 PM »
Ok, to answer some questions...

Eventually, I had in mind the ability to shuffle the screen objects via drag and drop in the screen tree.  But in the interest in actually getting Mach 4 done, that went away for a future project.  The idea is to actually USE Mach 4 at some point for it's intended purpose!  :)  So we got the screen editor "functional".  And I have seen some AWESOME screens, so it is indeed quite functional.  Yes, it can stand some more bells and whistles, but they will come in time.  The motion plugins are the focus now though.

Also, there will be an import and export functionality.  The code is stubbed in right now.  I just have not turned it on or tested it.  But what that will allow you to do is export Group Boxes or pages.  Say a developer of some specialized hardware has a screen page that works with all of his gadgets on his device.  He can export that page and the user of said hardware can import that page into his screen set.  That is one example.  Another would be copying a page between two screen sets because we don't allow running multiple instances of the GUI.

Same thing for group boxes.  This is probably the better approach to use for "sharing" controls and functionality.  Because some screen sets (like the current Mach screen set) don't have multiple pages.

But like I said...  We are trying to get the motion controllers going at this time.  So all this may be a while.  But just to let you know where it will get to one day.


Mach4 General Discussion / Re: MACH4 - Modbus
« on: May 13, 2014, 05:56:43 PM »

You are adding two handles that sum to a number larger than a 16 bit register will take.  The internal Mach register can store that number easily.  But the 16 bit register in the PLC cannot.  It also looks like the Rhr3 is also part of a read function.  The internal Mach register will not get updated unless the value ON the PLC changes.  Yet is it possible to SET the value internally from the Mach side.  So if you wrote a number in the simulator register 40003, it would have changed the value in the Register Diagnostics window.

The correct way to do the register read is with two API calls.

local hRhr1 = mc.mcRegGetHandle(inst, "modbud0/Rhr1");
local valRhr1 = mc.mcRegGetValue(hRhr1);
local hRhr2 = mc.mcRegGetHandle(inst, "modbud0/Rhr2");
local valRhr2 = mc.mcRegGetValue(hRhr2);
local hRhr3 = mc.mcRegGetHandle(inst, "modbud0/Rhr3");
mc.mcRegSetValue(hRhr3, valRhr1 + valRhr2);

Rhr3 should == 24564 which is within the 16 bit range.

An enterprising LUA programmer can shorten the 2 API calls with something like this:

function ReadReg(regName)
    local inst = mc.GetInstance();
    local hReg = mc.mcRegGetHandle(inst, regname);
    local val = mc.mcRegGetValue(hReg);

function WriteReg(regName, val)
    local inst = mc.GetInstance();
    local hReg = mc.mcRegGetHandle(inst, regname);
    mc.mcRegSetValue(hReg, val);

Those are hand written on-the-fly functions so they may not be totally correct.  But put something like them in the Screen load script and you can access them from any screen/object script. This will make things a bit easier in the code like:

local valRhr1 = ReadReg("modbud0/Rhr1");
local valRhr2 = ReadReg("modbud0/Rhr2");
WriteReg("modbud0/Rhr3" valRhr1 + valRhr2);


Mach4 General Discussion / Re: ScreenSet Question
« on: May 13, 2014, 02:49:42 AM »
The "Default" page is page 0.  The wxMach.set is not really designed to have multiple pages.  It uses tabs.  If you shrunk the tab(notebook) control down a bit and put buttons up there, you would see them on all of your pages.  But you would also see the notebook control so the screen design is not going to be what you want at all. 

I would start out with a new screen if you wanted "pages" in the Mach 3 sense.


Build 1767:


The plugin file extensions have been changed from "dll" to "mp4w".
The keyboard plugin has been reworked to only affect the Mach GUI.  If Mach loses focus, the keyboard driven action/input will stop.  


Mach4 General Discussion / Re: Mach 4 Bug Reports
« on: May 13, 2014, 02:06:43 AM »
We are working on a shortest path provision for rotary.  Eventually tied into the Fanuc RINC parameter.  Looks like that code is switched on.  I'll turn it off in the next update.


Mach4 General Discussion / Re: MACH4 - Modbus
« on: May 12, 2014, 08:17:37 PM »
Here is a screen shot of where to put the register number.  It is the highlighted text field.  If you need to read multiple consecutive registers, then use a function that reads multiple regs.  Input the starting register in the highlighted field and then enter the number of regs to read in the count field.  The count includes the register defined in the register field.

If you don't need consecutive registers, then do separate single register functions.


Mach4 General Discussion / Re: Mach 4 Feature Request
« on: May 12, 2014, 03:39:23 PM »
I always set up the tools in the order that I use them.  My machine has a 16 pod Geneva.  So the most frequently used tools are entered from 1 to 16.  Then, my manual change tools are numbered 17 and up.  In my tool change script, if any tool is greater than 16, it goes into manual mode.  Is that not sufficient?


Mach4 General Discussion / Re: MACH4 - Modbus
« on: May 12, 2014, 12:40:40 PM »
1)  What config?  Modbus or Mach?
2)  Use the PLC script and scr.* API.
3)  I'm not getting this one.  Can you explain what you are wanting to do?
4)  Can you provide and example?  With say the Mod_RSSim modbus simulator?  I can set up connections to the simulator, not run the simulator (like the PLC is off) and it works fine.  
5)  I have never seen this!  I will try and find it.

BTW, some of the bug stuff needs to be posted in the bugs thread.  That way we can track it.