Hello Guest it is March 28, 2024, 06:40:35 PM

Author Topic: Creating a function for the Screen Load Script  (Read 11619 times)

0 Members and 1 Guest are viewing this topic.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Creating a function for the Screen Load Script
« on: December 13, 2016, 03:54:53 PM »
Ever wanted a function to run in the PLC but not sure how to do it well try this way.

Click Here For Video




Code: [Select]
local inst = mc.mcGetInstance()

mc.MC_ALL = 20

function SetSoftLimits(axis, state)
    local m_axis = 0
if axis == mc.MC_ALL then
repeat
enabled = mc.mcAxisIsEnabled(inst, m_axis)
if enabled == 1 then
mc.mcSoftLimitSetState(inst, m_axis, state)
end
m_axis = m_axis + 1
        until(m_axis == 6)
    else
        mc.mcSoftLimitSetState(inst, axis, state)
    end
end

SetSoftLimits(mc.MC_ALL, mc.MC_ON)

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Creating a function for the Screen Load Script
« Reply #1 on: December 13, 2016, 07:46:24 PM »
DaztheGas,

I tried your nice script in the screen load and in the PLC script but nothing happens.  Not sure why.

 My version placed in the PLC script works.
 
     mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_ON);

     mc.mcSoftLimitSetState(inst, mc.Y_AXIS, mc.MC_ON);

     mc.mcSoftLimitSetState(inst, mc.X_AXIS, mc.MC_ON);
Re: Creating a function for the Screen Load Script
« Reply #2 on: December 13, 2016, 08:17:08 PM »
Sure helped to watch the video.  I learned so much!  Thanks for the time you spent to make the video!

Keith
Re: Creating a function for the Screen Load Script
« Reply #3 on: December 14, 2016, 07:16:09 AM »
Great video Daz.

A point I havn't seen mentioned is that soft limits are defined as machine coordinates. Consequently, if the machine has not been homed these values will be incorrect and may not afford the expected protection. For this reason, I set soft limits on within the signal table, on receipt of  the signal that the axis has been homed. Just another way to skin that cat.

Allan

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #4 on: December 14, 2016, 07:45:16 AM »
Thats a good point, prob could do with another if statement in the function like mcAxisIsHomed.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Creating a function for the Screen Load Script
« Reply #5 on: December 14, 2016, 09:59:50 AM »
This is an interesting issue of ref axes vs soft limits.  I feel that we don't need to look for referencing of axes because no machining should be done before referencing all axes.  I don't feel it would be safe to automatically ref the axes at startup and prefer to turn on the machine then reference as a purposeful move myself, if all is well.  So there never would be a time when there would be a conflict.  Therefore it seems unnecessary to look for referencing before applying soft limits.  Does that make sense?  Am I missing a condition where as an OEM developer that my users are going to get into trouble?  Thanks!

Keith

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #6 on: December 14, 2016, 10:01:11 AM »
Could you run the soft limits enable function from the Ref All home function? Maybe twice........... once at beginning to disable then again after motion stops to enable?
;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!

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #7 on: December 14, 2016, 10:10:37 AM »
If I was selling machines I would force a reference when needed, no doubt about it. Reset would force a dereference and only slow jogging would be allowed until referenced. Soft limimts would be active at all times........ unless referencing.
;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: Creating a function for the Screen Load Script
« Reply #8 on: December 14, 2016, 10:46:50 AM »
I like the idea of referencing first then forcing soft limits and some way to disable the machine until referencing is done.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Creating a function for the Screen Load Script
« Reply #9 on: December 14, 2016, 10:58:49 AM »
Quote
no machining should be done before referencing all axes.

Well I have to admit, the fact that I know I have proximity switches kind of makes me lazy and dont always home the machine as small parts I just zero the axis. This being said it is good practice to home the machine.

I like Chaoticone`s idea of using the ref home btn as this would benefit those who use softlimits whether it be just for max limit - min limit - or home in place even, this combined with the ref home button flashing in red if any defined axis is not homed.

DazTheGas
New For 2022 - Instagram: dazthegas