<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[SoliForum - 3D Printing Community — Combining Marlin firmware with my own code for stepper control]]></title>
		<link>https://www.soliforum.com/topic/13773/combining-marlin-firmware-with-my-own-code-for-stepper-control/</link>
		<atom:link href="https://www.soliforum.com/feed/rss/topic/13773/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Combining Marlin firmware with my own code for stepper control.]]></description>
		<lastBuildDate>Thu, 18 Feb 2016 12:06:20 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Combining Marlin firmware with my own code for stepper control]]></title>
			<link>https://www.soliforum.com/post/116832/#p116832</link>
			<description><![CDATA[<p>Hi all,</p><p>Firstly, apologies if what I&#039;m going to ask here seems really obvious or stupid - it isn&#039;t to me! I&#039;ve been struggling with this for a while and have come here as a last resort.</p><p>I&#039;m working on a project to make a 2D printer for printing ink onto powder spread on a heated bed. I have virtually no experience with electronics or coding so I feel pretty spectacularly out of my depth!</p><p>My setup involves an Arduino Mega2560, RAMPS 1.4 with stepper drivers, control system for inkjet printhead and a RepRap mk3 PCB heatbed.</p><p>So far I have successfully got the stepper motors to actuate as desired to cause the powder bed to move in the required pattern in the XY plane. This moving bed is positioned underneath the printhead which prints just whilst the bed is moving. This is all encoded in a simple Arduino sketch, using the AccelStepper library. A basic version of the code (without the printhead stuff) is shown below:</p><div class="codebox"><pre><code>#include &lt;AccelStepper.h&gt;

#define X_STEP_PIN 54

#define X_DIR_PIN 55

#define X_ENABLE_PIN 38

#define Y_STEP_PIN 60

#define Y_DIR_PIN 61

#define Y_ENABLE_PIN 56

#define Y_MIN_PIN 14

#define Y_MAX_PIN 15

AccelStepper Xaxis(1, X_STEP_PIN, X_DIR_PIN);

AccelStepper Yaxis(1, Y_STEP_PIN, Y_DIR_PIN);

void setup() {

  Xaxis.setMaxSpeed(1000);

  Xaxis.setAcceleration(10000);

  Xaxis.moveTo(660);

  Xaxis.setEnablePin(X_ENABLE_PIN);

  Xaxis.setPinsInverted(false,false,true);

  Xaxis.enableOutputs();

  Yaxis.setMaxSpeed(10000);

  Yaxis.setAcceleration(10000);

  Yaxis.setEnablePin(Y_ENABLE_PIN);

  Yaxis.setPinsInverted(false,false,true);

  Yaxis.enableOutputs();

}

void loop() {

  while (Yaxis.currentPosition() == 660)

  Yaxis.stop();

  while (Yaxis.currentPosition() == 660)

  Xaxis.stop();

  if (Xaxis.distanceToGo() == 0)

  Yaxis.move(66);

  if (Xaxis.distanceToGo() == 0)

  Xaxis.moveTo(-Xaxis.currentPosition());

  Xaxis.run();

  Yaxis.run();

}</code></pre></div><p>Now, I need to connect up the heatbed and control its temperature so that the above printing operation is occurring onto the heated powder. I discovered the Marlin firmware to use for this purpose, however it seems vastly overcomplicated when all I need it for is to set the heated bed temperature - ie I don&#039;t want to use all the stepper control stuff in there as I have my own code for that part. It seems like Marlin is set up to be controlled by Repetier or similar instead.</p><p>Could anyone advise whether it is possible to insert my own sketch for the motor and printhead control into Marlin, and if so how this would be achieved? I&#039;m guessing this would involve editing of the &#039;planner&#039; and &#039;stepper&#039; sections of Marlin?</p><p>I appreciate that this probably sounds like I&#039;m just asking you to do my work for me but I&#039;ve had a few stabs in the dark at trying to get this to work, with no success. I suppose it all comes down to my complete lack of coding experience and no other help available to me!</p><p>Thanks in advance,</p><p>Michael</p>]]></description>
			<author><![CDATA[null@example.com (mcaley)]]></author>
			<pubDate>Thu, 18 Feb 2016 12:06:20 +0000</pubDate>
			<guid>https://www.soliforum.com/post/116832/#p116832</guid>
		</item>
	</channel>
</rss>
