Run M code on/after startup from HAL

More
12 Nov 2020 22:47 - 12 Nov 2020 22:48 #189160 by Nitram
Hi.

After I start LCNC I would like to run an M code. Specifically, this is to run pneumatics to the actuator applying tension to the spindle drive belt. In other words, overnight, air pressure reduces to zero, and thus after re-starting the machine I would like it to open the air valve to that actuator to ensure the drive belt is tight before operating the machine.

To achieve this, I have placed the pin "halui.mdi-command-00" alongside the "Z axis is homed" pin, so that it gets done during homing. Problem is that when NO_FORCE_HOMING is active it works fine, but when homing is forced, I get the message "Cannot change to MDI mode at this time". In other words, LCNC wants to change to MDI mode to run the M code, but cannot until the entire homing sequence is finished, and therefore it doesn't happen.

Thus, is there a better pin to attach the "mdi-command" pin to? For example, is there a pin which signals when ALL joints/axis are homed? I am guessing that as this pin defines the end of the homing cycle, this would then allow a transition to MDI mode to run the M code at that time.

Any other thoughts on a simple solution to this??

Many thanks,
Marty.
Last edit: 12 Nov 2020 22:48 by Nitram.

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

More
13 Nov 2020 07:44 #189184 by Aciera
Is there a specific reason for using an M code to tension the spindle belt?
I think an M code makes sense if you want to start a certain sequence of things while running G-Code. If the belt needs to be tensioned whenever the machine is on why not activate the pneumatic valve whenever the halui.machine.is-on pin comes on?

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

More
13 Nov 2020 08:24 #189188 by Nitram
Good question.
As background, there is a high range and a low range belt but I never use the low range.
The reason for the M code is that it runs a macro. Incumbent in that macro is simply to check that as it is actuating the high belt tensioner, that the sensor on the low belt is not active as having both engaged at the same time would not be pretty.
If not for this check, as you say, I could simply activate the high belt HAL pin on its own.
The M code and its encumbent check is a good precautionary measure.

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

More
13 Nov 2020 09:23 #189190 by rodw

Is there a specific reason for using an M code to tension the spindle belt?
I think an M code makes sense if you want to start a certain sequence of things while running G-Code. If the belt needs to be tensioned whenever the machine is on why not activate the pneumatic valve whenever the halui.machine.is-on pin comes on?


x2, a custom component that receives halui.machine.is-on could solve all your problems by dealing with whatever logic is required before turning on your solenoid. Gcode commands should never be used for hardware configuration in my view.

Or you could invert your low ratio belt signal (or use the not pin) and then and then use and2 so that the solenoid is not opened until you are in high range and halui.machine.is-on is true.

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

Time to create page: 0.121 seconds
Powered by Kunena Forum