Welcome! Log In Create A New Profile

Advanced

How to integrate "own" code into firmware like repetier/marlin?

Posted by Skimmy 
How to integrate "own" code into firmware like repetier/marlin?
June 04, 2015 11:32AM
Hi!

I have an idea on my mind and want to add a specific function to my 3D-printer.
I have coded many "simple stuff" in C and pearl and I'm confident to get my idea working.

But I have questions, because I don't know exactly how to integrate my code into the existing firmware. What do I need to google or learn or read to know about this?

Edit: Maybe my question isn't clear to understand?! Let's say I want to integratey my own function when "printjob done". Do I need to call it via interrupt? Or do I need to find the specific point in the firmware and add it there? Or both? Is there any example to read?

Edited 1 time(s). Last edit at 06/04/2015 12:40PM by Skimmy.


Der 3D-Druck ist tot, lang lebe der 3D-Druck!

Schreibt mich nicht mehr an, ich hab das drucken an den Nagel gehängt.
Re: How to integrate "own" code into firmware like repetier/marlin?
June 11, 2015 08:26AM
Open the Marlin code in the Arduino IDE (the PDE is provided). At the top you will have a list off all the different marlin modules represented as tabs. Edit the code, re flash and test. Marlin_Main,cpp is where the setup and main loop occur. So everything stems from those two functions.

EDIT:
Assuming you're using marlin, for other firmware it's the same idea- download the code, modify, compile, re flash and test.

Edited 2 time(s). Last edit at 06/11/2015 08:28AM by eci22.
Re: How to integrate "own" code into firmware like repetier/marlin?
June 12, 2015 08:14AM
Thx for the hint to get started.

I am currently looking into repetier. Am I right if I put my own function into "commands.h / commands.cpp" as a new method of the Commands-class?

Like:

void Commands :: ownMethod()  // spaces to avoid smilies in Bulletin-Code...
{
bla bla...
}

As i figured out the class Commands is the repeating main-loop?!

Edited 1 time(s). Last edit at 06/12/2015 08:15AM by Skimmy.


Der 3D-Druck ist tot, lang lebe der 3D-Druck!

Schreibt mich nicht mehr an, ich hab das drucken an den Nagel gehängt.
Re: How to integrate "own" code into firmware like repetier/marlin?
June 12, 2015 11:06AM
As long as the declaration has been added in the header file for the Commands class.

You will then have to decide where the most appropriate place to make your new function call would be.

Edited 1 time(s). Last edit at 06/12/2015 11:06AM by eci22.
Re: How to integrate "own" code into firmware like repetier/marlin?
June 12, 2015 11:26AM
Sometimes the main loop is split in several subloops because not every subroutine has to run that often.
You´ll have a part that runs every loop and then comes a case/switch split with other subroutines.

You´d check, if this is the case with the program you want to change and where is the best place to put your code.

Worst case, it makes the whole program unusable, because it suddenly misses some interupt service routines or other important stuff.
-Olaf
Re: How to integrate "own" code into firmware like repetier/marlin?
June 12, 2015 11:45AM
Thx guys, this helps me understand the "big thing" better thumbs up

This interupt service routines stuff and all what has to do with interrupts is something I never put attention to. I tried it a few times to understand how interrupts work but never got it. I know what they are for, but... I just don't get, how it works -.- Probably, this will break my neck grinning smiley Maybe I just try to have my stuff as small as possible...

But: Any nice tutorial over interrupts on hand, that I didn't already watched or read?

Edited 1 time(s). Last edit at 06/12/2015 11:45AM by Skimmy.


Der 3D-Druck ist tot, lang lebe der 3D-Druck!

Schreibt mich nicht mehr an, ich hab das drucken an den Nagel gehängt.
Re: How to integrate "own" code into firmware like repetier/marlin?
June 12, 2015 04:56PM
In simple words,
an interupt routine is like asking your assistant to get you coffee and donuts instead of going yourself.
While the assistant is gone, you can work on the important stuff.
When he/she returns, she will give you notice ( the interupt)

If you don´t have the time ( because of your extra code ) or don´t hear the message, the coffe is cold and the donuts eaten before you accidently stumble across it...
-Olaf
Re: How to integrate "own" code into firmware like repetier/marlin?
June 13, 2015 11:23AM
Yeah, thats the part I already understand grinning smiley Anyways: Watching youtube-explanations right now grinning smiley


Der 3D-Druck ist tot, lang lebe der 3D-Druck!

Schreibt mich nicht mehr an, ich hab das drucken an den Nagel gehängt.
Sorry, only registered users may post in this forum.

Click here to login