Custom feature in Marlin
January 21, 2021 11:35PM
Hello everyone,
I'm new to this(so please bear with me). I am trying to add my own features to Marlin and would like to know how and where I can add the following features. These features are for a Laser cutter I'm trying to build with the marlin firmware on an mks gen v1.4 board. The software upgrades will be mainly for automatically controlling the cooling system.

1. The first feature is to switch on and off the cooling circuit using a 5V relay, connected to one of the digital pins and controlled based on the temperature of the water or other part using a thermistor to read the current temperature.
2. To switch on the air assist pump during the laser running time or print time.
3. To switch on the exhaust fans and to leave them on till 10 mins after the final cut has been completed.

Thanks in advance

Edited 1 time(s). Last edit at 01/21/2021 11:36PM by Shakthi.
VDX
Re: Custom feature in Marlin
January 22, 2021 02:13AM
... this is mostly done per G-code "M42 P.. S.." where the dots represent the pin number and set status (0 or 255) ...

Viktor


Viktor
--------
Aufruf zum Projekt "Müll-freie Meere" - [reprap.org] -- Deutsche Facebook-Gruppe - [www.facebook.com]

Call for the project "garbage-free seas" - [reprap.org]
Re: Custom feature in Marlin
January 22, 2021 05:53AM
I understand how the M42 Gcode works. I want to write the code in the firmware itself so that it works without the host having to intervene to start and stop these devices. The thermistor assigned for the function should be reading the values based on which the pins get triggered ON/OFF based on the temperature reading. Thanks
Shakthi
VDX
Re: Custom feature in Marlin
January 22, 2021 07:53AM
... then you have to modify the related routines on your own.

I've done this for some M-codes and added new M-codes too for some "special" functions for specific problems (mostly dispenser or laser related) ...


Viktor
--------
Aufruf zum Projekt "Müll-freie Meere" - [reprap.org] -- Deutsche Facebook-Gruppe - [www.facebook.com]

Call for the project "garbage-free seas" - [reprap.org]
Re: Custom feature in Marlin
January 22, 2021 08:51AM
Yes, I know I need to alter the code itself, and add new features as they are called my marlin but I do not know where to add my code, as in the file to add them in. I do not want to change the G or M codes themselves but want to add functionality that the machine would enact on their own. It should be a background task that is on from the moment the machine is switched on.

Shakthi
Re: Custom feature in Marlin
January 22, 2021 01:23PM
Quote
Shakthi
I understand how the M42 Gcode works. I want to write the code in the firmware itself so that it works without the host having to intervene to start and stop these devices. The thermistor assigned for the function should be reading the values based on which the pins get triggered ON/OFF based on the temperature reading. Thanks
Shakthi

Marlin is not the only firmware. Have you considered RepRapFirmware instead? RRF can do this without you even having to recompile the firmware.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Custom feature in Marlin
January 22, 2021 03:05PM
@dc42

stop being a used car sales man.

please stop using [reprap.org] as your adverting platform.

The answer to everything is NOT RRF
Re: Custom feature in Marlin
January 22, 2021 05:07PM
@Dust, please stop pretending that there is only one open source firmware that runs on most modern 3D printer electronics.

No firmware has a monopoly on all the best features. For example, currently only RRF has conditional Gcode, but the input shaping of Klipper beats the DAA implemented by RRF. Marlin may have some features not offered by either. Smootheware is likely better than all three for CNC machines. Competition is good, it drives innovation.

Edited 5 time(s). Last edit at 01/22/2021 05:18PM by dc42.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Custom feature in Marlin
January 22, 2021 05:57PM
@dc42
The user asked "I am trying to add my own features to Marlin "

RRF is not relevant here.

You are just spamming!

Edited 1 time(s). Last edit at 01/22/2021 05:57PM by Dust.
Re: Custom feature in Marlin
January 22, 2021 06:30PM
@Dust, why don't you offer a solution to the OP's problem instead of just criticising me?



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
VDX
Re: Custom feature in Marlin
January 22, 2021 06:54PM
... please stop! you both have valid points, but this is not the place to battle about ...


Viktor
--------
Aufruf zum Projekt "Müll-freie Meere" - [reprap.org] -- Deutsche Facebook-Gruppe - [www.facebook.com]

Call for the project "garbage-free seas" - [reprap.org]
Re: Custom feature in Marlin
January 25, 2021 10:26PM
Hello, Yes any information from some one who has already modified or has written the code would help. I would mainly like to know where the functions are written so that I could add my own into marlin.

Shakthi
Re: Custom feature in Marlin
January 26, 2021 03:48AM
for 1)take a look at how autofans work. you can probably just use CHAMBER_AUTO_FAN for this feature.

2) and 3) should probably be done in gcode

ie in your gcode start turn on air assist and exhaust fans, use M42 to control a non marlin allocated IO pin connected to what ever electronics you have to turn these on and off
same with the gcode end file. Turn off air assist and as the last two commands G4 S600 (wait 10 mins) then the final turn off exhaust fans command.

Edited 1 time(s). Last edit at 01/26/2021 03:54AM by Dust.
Re: Custom feature in Marlin
January 27, 2021 06:57AM
Thanks a lot @Dust, I will look into this.

Shakthi
Sorry, only registered users may post in this forum.

Click here to login