Modbus VFD startup delay?

More
2 years 1 month ago #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:
Code:
#!/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:
Code:
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

Please Log in to join the conversation.

More
2 years 1 month ago #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 to join the conversation.

More
2 years 1 month ago #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):
Code:
#!/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)
Code:
#!/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):
Code:
HALCMD = loadusr -W ./python/py2bash.py


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

Attachment not found



5. If you force this pin HIGH the python component should run 'script.sh'

Please Log in to join the conversation.

Time to create page: 0.042 seconds
Powered by Kunena Forum