Hello Guest it is May 23, 2024, 07:37:05 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 - striplar

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 »
111
Hi Allan,
No, that one's new to me, I see that now. I've just tried that and it seems to work fine, so I'll put that in all of the button scripts.


Anyway, I've raised a support ticket asking for an explanation as to why the JogIncX variable set by the mcJogSetInc() function has no effect on the actual jog it does using the X- button. I mean, what's the point in having those registers if they don't do anything useful.

Although I can sort of get my code to work, I still can't set the initial conditions to whatever the true jog increment is, unless I somehow force the ScreenScript to set it initially. We know you can't use mcJogSetInc() for that, so maybe you can call the Action function that you can select from the drop down list of Actions in the button event tab?

I'm also surprised that there's no mcJogGetType. Again, there are individual Type variables for each axis, but those don't follow the Incremental/Continuous modes of the actual machine either! It's frankly bizarre.

Hopefully someone at Mach will be able to explain all of this.
 


112
I think the error is actually that I'm testing for mc.MERROR_NOERROR and not MERROR_NOERROR, so that's probably a syntax mistake.

It still doesn't resolve the fundamental issue of the JogIncX variable in the RegFile changing but having no effect on the actual amount the jog increments by when I press the X- button for example.

113
I can go into the Debug->RegFile and see the JogIncX variable which does follow the JogSetInc even though that returns an error, assuming the error testing is correct of course. I'm using the following suggested code...

if (rc ~= mc.MERROR_NOERROR) then
    mc.mcCntlSetLastError(inst, 'JogGetInc failed')
    return;
end

... which says it's failed.

Now if I leave out the error checking, it does save and retrieve the value set, but that has NO effect on the amount it actually jogs.

As it happens, I can just use that stored information to set the colour of the Radio buttons in the PLC, but it doesn't explain why this has absolutely no effect on the jog increment it actually uses!

114
Sorry guys, but it's not as simple as you are trying to make out from a position of knowledge. I've been programming in all manner of languages for forty years, I've written my own CNC control from scratch, so I' think it's fair to say that I'm not new to this lark.

The problem is that there's no joined up easy to understand way to find out about how Mach4 hangs together. I don't ask questions because I'm lazy or stupid, I ask them because they aren't obvious.

So far, I've not made any sense of how Mach4 decides what size jog increment to use, how to set that with a script and how to read it back. That's not for lack of trying, it just doesn't appear to work. Maybe I'm missing something that's blindingly obvious, but mcJogSetInc() returns an error and mcJogGetInc() doesn't return the value of the increment it's currently jogging at.

Do put me straight as to where I'm going wrong if this is all so easy?

115
Hi Allan,
Can you point me to where I can see the RegFile diagnostics? I don't know where to look.

It seems to me that the SetJogInc and GetJogInc aren't related to what's used when you tell the system to set the jog increment based on what's in the table. These things seem so basic, I'm stunned that all this stuff isn't sorted out and made clear. Everyone who attempts to change the way the jog works is going to go through these mental gymnastics.

Can someone close to the code answer these questions? I've posted a request to the page indicated in the Mach 4 Bug Reports thread in the hope of getting a definitive answer.

116
Hi,

Quote
button is calling "Job X-" action, but I've searched through the screen script and that's not in there
While some buttons have 'left down' scripts for instance however others have an 'action' That action is programmed within Machs core where you cant see it or edit it,
and they're probably all in C++ anyway.

Craig

Fair enough, so what variable is being used by that routine so that the incremental jog knows how far to move? I've read back the value from mc.mcJogGetInc(inst, mc.X_AXIS) and it doesn't match the amount it actually jogs, so it's not using whatever is being read by that function

It seems to me that what it uses is always the value that's currently being pointed to in the table that you populate in the config for the different step.

Maybe I'm using the wrong approach and I should be trying to change that variable.

117
Hi,
I'm a bit confused myself.

Quote
however, it does appear to have changed the mc.X_AXIS variable because now I can read back that value using GetJogInc() and it shows me 0.001mm!
mc.X_AXIS is NOT a variable, it is an ENUM, it is the number of the X axis. Its defined within Machs core and you cant change it.

Quote
In other words, mc.X_AXIS can't be the value it's using when it actually goes to jog.
That is correct, mc.X_AXIS is of type number, I suspect its value is one, it is not a jog increment,

Craig



Ok, not well phrased. The variable that the function is directed to by mc.X_AXIS doesn't get updated. I'm trying to both set and read the jog increment variable, wherever that is, and whatever that's called, and the mc.mcJogSetInc(inst, mc.X_AXIS, 0.001) throws an error when I try to do that.

When I read back the value given by mc.mcJogGetInc(inst, mc.X_AXIS), if that happens to be say 0.001mm that's not what it jogs by.

The conclusion is that whatever is being used by the jog button to incrementally move the axis is not the value that's being read by mc.mcJogGetInc(inst, mc.X_AXIS)

118
There's something definitley screwy going on. As an experiment, I put the following code into the button script that should set the increment to 0.001mm

It fails on the SetJogInc() function..... however, it does appear to have changed the mc.X_AXIS variable because now I can read back that value using GetJogInc() and it shows me 0.001mm!

However, the amount it actually jogs is unaffected by this. In other words, mc.X_AXIS can't be the value it's using when it actually goes to jog.

Any ideas what the actual variable used is called? Perhaps it is mc.X_AXIS but I'm not using the right syntax


local inst = mc.mcGetInstance()
local increment
local rc

increment, rc = mc.mcJogSetInc(inst, mc.X_AXIS, 0.001)

if (rc ~= mc.MERROR_NOERROR) then
    mc.mcCntlSetLastError(inst, 'JogSetInc failed')
   return;
end

increment, rc = mc.mcJogGetInc(inst, mc.X_AXIS)
if (rc ~= mc.MERROR_NOERROR) then
    mc.mcCntlSetLastError(inst, 'JogGetInc failed')
    return;
end

    mc.mcCntlSetLastError(inst, "increment=" .. tostring(increment))

Another thought is that the MachMill screen is using something else for the jogging increments. I see that the Left Dow Action for the X- button is calling "Job X-" action, but I've searched through the screen script and that's not in there. I can't see that anywhere listed in any of the help or scripting documents so I have no idea how it work and what it affects.
It certainly doesn't take any notice of the value in mc.X_AXIS

Any ideas?


119
Hi Craig,
Point taken, I can see how useful that mcCntlSetLastError() function is.

I've now moved the code called from the PLC to the Screen Load Script as shown below and incorporated the error function to show me what's going on.
The global variable to track the changed in the increment was borrowed from a previous example shown me in this thread. It makes sense to only update screen properties when they change so as to save time, and it also reduced the number of errors in the log so it's more readable.

What this has confirmed is that it all works except that the increment value read using...     increment, rc = mc.mcJogGetInc(inst, mc.X_AXIS)   ... always returns the value 1, regardless of the actual jog increment that is set using the buttons. I know they are doing their job because the jog does move the selected amount.

So the question is, why does that function not return the value that's set by the button when the button for 0.1mm for example calls the.... Jog Inc. 2 function from the Left Up Action button event? It seems to me that the variable used for jogging is cannot be mc.X_AXIS or it's somehow not available for some reason. Perhaps it's an error in the syntax?

----------------------------------------------------------------------------
--   Handle the radio button action of the Jog increment buttons - My code!
----------------------------------------------------------------------------
function UpdateJogRadioButtons()  --called from the PLC script
--currentInc = 0 -- my global var to track the current increment defined above

--local inst = mc.mcGetInstance() --apparently not required
local increment
local rc
increment, rc = mc.mcJogGetInc(inst, mc.X_AXIS)
if (rc ~= mc.MERROR_NOERROR) then
    mc.mcCntlSetLastError(inst, 'JogGetInc failed')
    return;
end

if (increment ~= currentInc) then   --so we don't unnecessarily update anything
    mc.mcCntlSetLastError(inst, "currentInc=" .. tostring(currentInc))
    mc.mcCntlSetLastError(inst, "increment=" .. tostring(increment))
   
   if (increment == 1) then
      mc.mcCntlSetLastError(inst,'Jog Increment=1')
      scr.SetProperty("btn1000micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   elseif (increment == 0.1) then
      mc.mcCntlSetLastError(inst,'Jog Increment=0.1')
      scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn100micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   elseif (increment == 0.01) then
      mc.mcCntlSetLastError(inst,'Jog Increment=0.01')
      scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn10micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   elseif (increment == 0.001) then
      mc.mcCntlSetLastError(inst,'Jog Increment=0.001')
      scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
      scr.SetProperty("btn1micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
   end
      
   --scr.SetProperty("btnContinuousMode", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   currentInc = increment   --remember what the new increment is
end
end

120
ok, I've added this in the PLC script but it always turns the btn1000micron button green, regardless of the increment that I know is working correctly because it jogs the amount that it should.

So it looks like the line "increment, rc = mc.mcJogGetInc(inst, mc.X_AXIS)" always returns 1.
Can you see what I'm doing wrong? In a previous example you set up the function in the screen script and called that from the PLC. Maybe you can't access the increment from the PLC script directly?

Also, I'm not sure about that line in the error checking that says "return" I think that needs to go.

-------------------------------------------------------
--   Handle the radio button action of the Jog increment buttons
-------------------------------------------------------

local increment
local rc
increment, rc = mc.mcJogGetInc(inst, mc.X_AXIS)
if (rc ~= mc.MERROR_NOERROR) then
    mc.mcCntlSetLastError(inst, "JogGetInc failed")
    return;  --???????
end

if (increment == 1) then
   scr.SetProperty("btn1000micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"    ????? this line always executed
   scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
elseif (increment == 0.1) then
   scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn100micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
elseif (increment == 0.01) then
   scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn10micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
elseif (increment == 0.001) then
   scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
   scr.SetProperty("btn1micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
end

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 »