Modbus VFD startup delay?

More
02 Sep 2024 11:40 #309205 by Aciera
Replied by Aciera on topic Modbus VFD startup delay?
Just to demonstrate a way to start a component through a custom Mcode which could then be called as a [HALUI] MDI_COMMAND with a hal signal, (Note this uses 'hal_input' component to connect the volume_up function key to the 'axisui.notifications-clear' pin so this may not run on your hardware as is but you get the idea):

1. I save this as 'M123' in the USER_M_PATH and mark as executable:
#!/bin/bash
halcmd loadusr -W hal_input -K +Keyboard:0 
halcmd source myhal.hal
exit 0

2. I save this as 'myhal.hal' in your config folder:
net test-signal  <= input.0.key-volumeup  => axisui.notifications-clear

3. I start the config, home and after I run 'M123' in the MDI command line I can delete notifications by pressing <Fn>+'F3'

Might also work with your 'gs2_vfd' component
The following user(s) said Thank You: spumco

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

More
02 Sep 2024 15:34 #309215 by spumco
Replied by spumco on topic Modbus VFD startup delay?
@Aciera -

That's what I was looking for.

I'll have to turn off forced-homing so LCNC can run an M-code after machine-on but before homing... but that should be fairly simple.

Thanks much!

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

More
02 Sep 2024 16:28 - 02 Sep 2024 16:30 #309218 by Aciera
Replied by Aciera on topic Modbus VFD startup delay?

I'll have to turn off forced-homing so LCNC can run an M-code after machine-on but before homing... but that should be fairly simple.

Ah, forgot about that. Here is a solution with a python component that does not rely on MDI:

1.  Save this as 'py2bash.py' to a folder called 'python' in your config folder and mark executable (You should not need to modify this):
#!/usr/bin/env python3
import os
import hal
import linuxcnc

h = hal.component("py2bash")
h.newpin("run-script", hal.HAL_BIT, hal.HAL_IN)
h.ready()
# create a connection to the status channel
s = linuxcnc.stat()

print("py2bash: Started")

script_has_run = False

try:
    while 1:
        if h['run-script'] == True and script_has_run == False:
            print("py2bash: Running bash script now.")
            os.system('bash ./script.sh')
            script_has_run = True
except KeyboardInterrupt:
    raise SystemExit

2. Save this as 'script.sh' to your config folder and mark as executable (you will need to change 'halcmd loadusr -W hal_input -K +Keyboard:0 ' to load your component)
#!/bin/bash
halcmd loadusr -W hal_input -K +Keyboard:0
halcmd source myhal.hal
exit 0

3. Add this to [HAL] section in your ini (No need to change this):
HALCMD = loadusr -W ./python/py2bash.py


4. Run your config and check for a pin 'py2bash.start-script':
 

5. If you force this pin HIGH the python component should run 'script.sh'
Attachments:
Last edit: 02 Sep 2024 16:30 by Aciera.
The following user(s) said Thank You: spumco

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

Time to create page: 0.283 seconds
Powered by Kunena Forum