About Cycle Lock

More
18 Oct 2021 12:52 #223451 by marq_torque
About Cycle Lock was created by marq_torque
Dear Everyone,

At present I'm retrofitting one Manual Lathe machine, for that i need Cycle/User Disable option after certain defined number of cycles. Which disables EMC to perform Any operation something like "Permanent Emergency" or "Permanent Power Off"

Can it be done?


Thanks in Advance,

Please Log in or Create an account to join the conversation.

More
18 Oct 2021 16:13 #223472 by aleksamc
Replied by aleksamc on topic About Cycle Lock
It's not clear your main aim.
What cycle does mean? Does it one line from G-code?
Than you can use pause in g-code, it's M0 or M1.

Or you mean something inside HAL?

Please Log in or Create an account to join the conversation.

More
19 Oct 2021 07:49 - 19 Oct 2021 07:51 #223529 by marq_torque
Replied by marq_torque on topic About Cycle Lock
I want to disable function/operation of cnc control completely, in case of scam/cheater/fraud user/customer. Something like putting a license code/activation code in some software.

So yes, i believe it needed to be done in Hal or some core files?
Last edit: 19 Oct 2021 07:51 by marq_torque.

Please Log in or Create an account to join the conversation.

More
20 Oct 2021 07:00 #223636 by aleksamc
Replied by aleksamc on topic About Cycle Lock
I'm not helper in such questions because I'm not developper. I think you need to change source code for this reason. For example - to make some encryption to the settings hal and ini files.

As for me one time setting "demo mode" to my plc program saved me some money to be paid )))

But linuxcnc license is complitly goes in other direction you need - to the opennes and free.

As easy solvement - you can take money before make job and to hide configuration files.

Please Log in or Create an account to join the conversation.

More
20 Oct 2021 11:20 #223655 by marq_torque
Replied by marq_torque on topic About Cycle Lock
Got your point, Yes I'm referring that demo mode for EMC.

I believe it can be achieved with some Axis or Gmoccapy lines.

Yes taking advance money is always safer. I'm in such eco-system where this practice will take time to establish.

Please Log in or Create an account to join the conversation.

More
20 Oct 2021 12:35 #223661 by andypugh
Replied by andypugh on topic About Cycle Lock
The answer is probably a "RS274_STARTUP_CODE" in the INI
linuxcnc.org/docs/2.6/html/config/ini_co...sub:RS274NGC-section
And possibly a new persistent parameter in the .vars file.

I think I would use a custom M-code in the 100-199 range which was a Python script.
linuxcnc.org/docs/html/gcode/m-code.html#mcode:m100-m199

A few ideas for the counter here
stackoverflow.com/questions/44012748/how...ipt-is-run-in-python
(I think this is probably simpler than an additional persistent G-code parameter)
Then the Python script can do anything. Simplest might be
import hal
hal.set_p("motion.enable", 0)
But I have not tested this.

To make it harder to bypass, you could add your cycle counter to the linuxcnc startup script.

Please Log in or Create an account to join the conversation.

More
25 Oct 2021 07:01 #224229 by marq_torque
Replied by marq_torque on topic About Cycle Lock
Andypugh, Thanks for This!

But i didnt understood the first RS274_STARTUP_CODE, M-CODE

Can you share Any examples for startup script, i'm noob at coding, i can just modify values or copy paste... i can't create any code :(

Please Log in or Create an account to join the conversation.

More
01 Nov 2021 13:11 #224873 by andypugh
Replied by andypugh on topic About Cycle Lock
Working backwards

Any Linux text file beginning with #! and made executable (can be done via the gui) can be called as a programme.
the M-codes from M10 to M199 can call any executable programme of the same name.
The codes in [RS274NGC]RS274_STARTUP_CODE are run every time LinuxCNC starts.

So, first save this with a text editor as "m100" and make it executable (right-click it in the file manager, properties, "allow to run as a program" or some other gui-dependant phrase.
import hal

def get_var_value(filename="varstore.dat"):
    with open(filename, "a+") as f:
        f.seek(0)
        val = int(f.read() or 0) + 1
        f.seek(0)
        f.truncate()
        f.write(str(val))
        return val

your_counter = get_var_value()

if your_counter > 10:
        hal.set_p("motion.enable", 0)

Then check that it works by running it from the command line

./m100

You should be able to see a varstore.dat file appear. And that should contain a number that increases by one each time you run m100

Then check that after 5 runs it disables LinuxCNC motion (you need LinuxCNC running at the same time)

Then add the STARTUP_GCODE to the INI and see what happens.

You probably want a different threshold, and I would suggest a different filename, probably a hidden file such as .my_sekrit_counter
The following user(s) said Thank You: aleksamc

Please Log in or Create an account to join the conversation.

More
14 Nov 2021 16:54 #226492 by marq_torque
Replied by marq_torque on topic About Cycle Lock
Woah!
Andy, As usual This is genius :)

One question, does this counter store cycle count and does not reset itself with system restart?

Will try it today and revert.

Thanks,
Ankit

Please Log in or Create an account to join the conversation.

Time to create page: 0.205 seconds
Powered by Kunena Forum