Welcome! Log In Create A New Profile

Advanced

5D stepping DC extruder

Posted by Grogyan 
5D stepping DC extruder
January 08, 2010 08:38PM
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.

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'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 &= 7;

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

#ifdef FULL_STEP
  switch((coilPosition&3) << 1)
#else
  switch(coilPosition)
#endif 
  {
  case 7:
    pwm = (pwm >> 1) + (pwm >> 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 >> 1) + (pwm >> 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 >> 1) + (pwm >> 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 >> 1) + (pwm >> 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; 

  }

}
Re: 5D stepping DC extruder
January 09, 2010 08:01AM
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.

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.

Not trivial, but I think somebody has done it already.


[www.hydraraptor.blogspot.com]
Re: 5D stepping DC extruder
January 09, 2010 03:32PM
Ok, that definitely answers the why not use PWM to control it open loop.

I have an old computer mouse that I can use its encoders, for the extruder.
But am I right that this is the function that does step it?

If it is I might have to rewrite it so that it uses the encoder for its feedback system.
I just thought someone would have done it before, so that it was a simple mod.
Sorry, only registered users may post in this forum.

Click here to login