<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>5D stepping DC extruder</title>
        <description> I&#039;m kinda stuck till I return to work and earn some more money, so i&#039;ve decided to work on getting the extruder board to step my Tamiya extruder, and I have a feeling that it was done once before with DC extruders in general, but I don&#039;t remember the hack that is needed to the code to step a DC motor in an open loop system.

The MakerBot firmware does work, for about 0.5 seconds when the arcing of the commutator brushes generating too much noise.

I need the the extruder to run at about 40% PWM or 102/255

I&#039;m now back to the 5D firmware as its fairly modulated in code to be readable and thus maybe hackable for me.

I believe I need to adjust the switch statement cases, but am really unsure how.
 
Can someone please help?


void extruder::sStep()
{
  byte pwm;
  
  if(usePot)
    pwm = potVal;
  else
    pwm = pwmValue;

  // This increments or decrements coilPosition then writes the appropriate pattern to the output pins.

  if(digitalRead(E_DIR_PIN))
    coilPosition++;
  else
    coilPosition--;
  coilPosition &amp;amp;= 7;

  // Which of the 8 possible patterns do we want?
  // The pwm = (pwm &amp;gt;&amp;gt; 1) + (pwm &amp;gt;&amp;gt; 3); lines
  // ensure (roughly) equal power on the half-steps

#ifdef FULL_STEP
  switch((coilPosition&amp;amp;3) &amp;lt;&amp;lt; 1)
#else
  switch(coilPosition)
#endif 
  {
  case 7:
    pwm = (pwm &amp;gt;&amp;gt; 1) + (pwm &amp;gt;&amp;gt; 3);
    digitalWrite(H1D, 1);    
    digitalWrite(H2D, 1);
    analogWrite(H1E, pwm);
    analogWrite(H2E, pwm);    
    break;

  case 6:
    digitalWrite(H1D, 1);    
    digitalWrite(H2D, 1);
    analogWrite(H1E, pwm);
    analogWrite(H2E, 0);   
    break; 

  case 5:
    pwm = (pwm &amp;gt;&amp;gt; 1) + (pwm &amp;gt;&amp;gt; 3);
    digitalWrite(H1D, 1);
    digitalWrite(H2D, 0);
    analogWrite(H1E, pwm);
    analogWrite(H2E, pwm); 
    break;

  case 4:
    digitalWrite(H1D, 1);
    digitalWrite(H2D, 0);
    analogWrite(H1E, 0);
    analogWrite(H2E, pwm); 
    break;

  case 3:
    pwm = (pwm &amp;gt;&amp;gt; 1) + (pwm &amp;gt;&amp;gt; 3);
    digitalWrite(H1D, 0);
    digitalWrite(H2D, 0);
    analogWrite(H1E, pwm);
    analogWrite(H2E, pwm); 
    break; 

  case 2:
    digitalWrite(H1D, 0);
    digitalWrite(H2D, 0);
    analogWrite(H1E, pwm);
    analogWrite(H2E, 0); 
    break;

  case 1:
    pwm = (pwm &amp;gt;&amp;gt; 1) + (pwm &amp;gt;&amp;gt; 3);
    digitalWrite(H1D, 0);
    digitalWrite(H2D, 1);
    analogWrite(H1E, pwm);
    analogWrite(H2E, pwm); 
    break;

  case 0:
    digitalWrite(H1D, 0);
    digitalWrite(H2D, 1);
    analogWrite(H1E, 0);
    analogWrite(H2E, pwm); 
    break; 

  }

}
</description>
        <link>https://reprap.org/forum/read.php?12,32413,32413#msg-32413</link>
        <lastBuildDate>Sun, 15 Mar 2026 13:17:20 -0400</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://reprap.org/forum/read.php?12,32413,32442#msg-32442</guid>
            <title>Re: 5D stepping DC extruder</title>
            <link>https://reprap.org/forum/read.php?12,32413,32442#msg-32442</link>
            <description><![CDATA[ Ok, that definitely answers the why not use PWM to control it open loop.<br />
<br />
I have an old computer mouse that I can use its encoders, for the extruder.<br />
But am I right that this is the function that does step it?<br />
<br />
If it is I might have to rewrite it so that it uses the encoder for its feedback system.<br />
I just thought someone would have done it before, so that it was a simple mod.]]></description>
            <dc:creator>Grogyan</dc:creator>
            <category>RepRap Host</category>
            <pubDate>Sat, 09 Jan 2010 15:32:26 -0500</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?12,32413,32424#msg-32424</guid>
            <title>Re: 5D stepping DC extruder</title>
            <link>https://reprap.org/forum/read.php?12,32413,32424#msg-32424</link>
            <description><![CDATA[ With the 5D code the speed of the extruder varies along the line so I don't think you can do it with an open loop DC motor.<br />
<br />
To do it closed loop you would change the coil position variable to an axis position. You would then compare that with a position from a shaft encoder and then use the PID algorithm to work out the PWM value for the DC motor.<br />
<br />
Not trivial, but I think somebody has done it already.]]></description>
            <dc:creator>nophead</dc:creator>
            <category>RepRap Host</category>
            <pubDate>Sat, 09 Jan 2010 08:01:15 -0500</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?12,32413,32413#msg-32413</guid>
            <title>5D stepping DC extruder</title>
            <link>https://reprap.org/forum/read.php?12,32413,32413#msg-32413</link>
            <description><![CDATA[ I'm kinda stuck till I return to work and earn some more money, so i've decided to work on getting the extruder board to step my Tamiya extruder, and I have a feeling that it was done once before with DC extruders in general, but I don't remember the hack that is needed to the code to step a DC motor in an open loop system.<br />
<br />
The MakerBot firmware does work, for about 0.5 seconds when the arcing of the commutator brushes generating too much noise.<br />
<br />
I need the the extruder to run at about 40% PWM or 102/255<br />
<br />
I'm now back to the 5D firmware as its fairly modulated in code to be readable and thus maybe hackable for me.<br />
<br />
I believe I need to adjust the switch statement cases, but am really unsure how.<br />
 <br />
Can someone please help?<br />
<br />
<pre class="bbcode">
void extruder::sStep()
{
  byte pwm;
  
  if(usePot)
    pwm = potVal;
  else
    pwm = pwmValue;

  // This increments or decrements coilPosition then writes the appropriate pattern to the output pins.

  if(digitalRead(E_DIR_PIN))
    coilPosition++;
  else
    coilPosition--;
  coilPosition &amp;= 7;

  // Which of the 8 possible patterns do we want?
  // The pwm = (pwm &gt;&gt; 1) + (pwm &gt;&gt; 3); lines
  // ensure (roughly) equal power on the half-steps

#ifdef FULL_STEP
  switch((coilPosition&amp;3) &lt;&lt; 1)
#else
  switch(coilPosition)
#endif 
  {
  case 7:
    pwm = (pwm &gt;&gt; 1) + (pwm &gt;&gt; 3);
    digitalWrite(H1D, 1);    
    digitalWrite(H2D, 1);
    analogWrite(H1E, pwm);
    analogWrite(H2E, pwm);    
    break;

  case 6:
    digitalWrite(H1D, 1);    
    digitalWrite(H2D, 1);
    analogWrite(H1E, pwm);
    analogWrite(H2E, 0);   
    break; 

  case 5:
    pwm = (pwm &gt;&gt; 1) + (pwm &gt;&gt; 3);
    digitalWrite(H1D, 1);
    digitalWrite(H2D, 0);
    analogWrite(H1E, pwm);
    analogWrite(H2E, pwm); 
    break;

  case 4:
    digitalWrite(H1D, 1);
    digitalWrite(H2D, 0);
    analogWrite(H1E, 0);
    analogWrite(H2E, pwm); 
    break;

  case 3:
    pwm = (pwm &gt;&gt; 1) + (pwm &gt;&gt; 3);
    digitalWrite(H1D, 0);
    digitalWrite(H2D, 0);
    analogWrite(H1E, pwm);
    analogWrite(H2E, pwm); 
    break; 

  case 2:
    digitalWrite(H1D, 0);
    digitalWrite(H2D, 0);
    analogWrite(H1E, pwm);
    analogWrite(H2E, 0); 
    break;

  case 1:
    pwm = (pwm &gt;&gt; 1) + (pwm &gt;&gt; 3);
    digitalWrite(H1D, 0);
    digitalWrite(H2D, 1);
    analogWrite(H1E, pwm);
    analogWrite(H2E, pwm); 
    break;

  case 0:
    digitalWrite(H1D, 0);
    digitalWrite(H2D, 1);
    analogWrite(H1E, 0);
    analogWrite(H2E, pwm); 
    break; 

  }

}
</pre>]]></description>
            <dc:creator>Grogyan</dc:creator>
            <category>RepRap Host</category>
            <pubDate>Fri, 08 Jan 2010 20:38:03 -0500</pubDate>
        </item>
    </channel>
</rss>
