Welcome! Log In Create A New Profile

Advanced

Gen7T Step pulse width

Posted by bryanandaimee 
Gen7T Step pulse width
April 07, 2012 09:23PM
I'm testing my early beta board for the Gen7T electronics and I have found that the TB6560 drivers I am using need a longer pulse width on the step line than many firmwares supply. As a result when I try repetier firmware on this board there are many missed steps (30% or so). Step pulse width should be at least 10 us for these drivers. Is there a setting or change I can make easily that will allow me to test repetier firmware on these electronics? If not could I request that for some future version? There is no hurry as I am currently the only one with a functioning board, and I develop slowly. Teacup already works fine as it supplies longer pulses by default.

Thanks
Bryan
Re: Gen7T Step pulse width
April 08, 2012 03:00AM
10us is really long. With the 20MHz possible these are 200 ticks, which could be more then the duration of the complete isr at some times. But ok, here we go. In th eRepetier.pde line 1533 (latest version) you find the unstep command:

WRITE(X_STEP_PIN,LOW);
    WRITE(Y_STEP_PIN,LOW);
    WRITE(Z_STEP_PIN,LOW);
#if USE_OPS==0 && !defined(USE_ADVANCE)
    extruder_unstep();
#endif


move this block down just before the line (1611)
} // stepsRemaining

If you disable half stepping this should be enough, otherwise you may need a delayMicroseconds(6); before the unstep code.

If you have enabled advance support or USE_OPS 1 you also may need to change the stepper interrupt (line 1808). I have copied a modified version, where the delay is maximized but configuration dependent. If you have no software PWM or fast keyboard checks, there is no delay in retraction mode. If the extruder works slow, you have to least a complete interrupt between activation/deactivation. I added a commented explicit time delay if needed.

ISR(EXTRUDER_TIMER_VECTOR)
{
#if USE_OPS==1 || defined(USE_ADVANCE)
    extruder_unstep();
#endif
  EXTRUDER_OCR += printer_state.timer0Interval; // time to come back
  counter_periodical+= printer_state.timer0Interval; // Appxoimate a 10ms timer
  if(counter_periodical>OVERFLOW_PERIODICAL) {
    counter_periodical-=OVERFLOW_PERIODICAL;
    execute_periodical=1;
  }
#ifdef SIMULATE_PWM
  // Sanguino boards have the heater output on a pin with PWM for
  // timer 1. This software pwm solves the problem with the timer
  // already in use.
#if NUM_EXTRUDER==1
  Extruder *ext = &extruder[0];
  if(ext->heatManager) { // Extruder with pid control found
    if(ext->pwmState<=ext->pwm) {
      ext->pwmState+=printer_state.timer0Interval;
      if(ext->pwmState>=2040) {
        ext->pwmState=0;
        WRITE(EXT0_HEATER_PIN,1 );         
      } else if(ext->pwmState>ext->pwm) {
        WRITE(EXT0_HEATER_PIN,0 ); 
      }
    } else {
      ext->pwmState+=printer_state.timer0Interval;
      if(ext->pwmState>=2040) {
        ext->pwmState=0;
        if(ext->pwm>0) { // Turn only on for values > 0
          WRITE(EXT0_HEATER_PIN,1 ); 
        }
      }
    }
  }
#else
  for(byte e=0;eheatManager) { // Extruder with pid control found
      if(ext->pwmState<=ext->pwm) {
        ext->pwmState+=printer_state.timer0Interval;
        if(ext->pwmState>=2040) {
          ext->pwmState=0;
          digitalWrite(ext->heaterPin,on);
        } else if(ext->pwmState>ext->pwm) {
          digitalWrite(ext->heaterPin,off);
        }
      } else {
        ext->pwmState+=printer_state.timer0Interval;
        if(ext->pwmState>=2040) {
          ext->pwmState=0;
          if(ext->pwm) { // Turn only on for values > 0
            digitalWrite(ext->heaterPin,on);
          }
        }
      }
    }
  }
#endif
#endif // SIMULATE_PWM
#ifdef SIMULATE_FAN_PWM
  // If your fan output has no pwm or pwm is blocked by this interrupt routine
  if(fan_pwm_pos<=fan_speed) {
    fan_pwm_pos+=printer_state.timer0Interval;
    if(fan_pwm_pos>=4080) {
      fan_pwm_pos=0;
      WRITE(FAN_PIN,1 ); 
    } else if(fan_pwm_pos>fan_speed) {
      WRITE(FAN_PIN,0 ); 
    }
  } else {
    fan_pwm_pos+=printer_state.timer0Interval;
    if(fan_pwm_pos>=4080) {
      fan_pwm_pos=0;
      if(fan_speed>0) { // Turn only on for values > 0
        WRITE(FAN_PIN,1 ); 
      }
    }
  }
#endif
 UI_FAST; // Short timed user interface action
#if USE_OPS==1 || defined(USE_ADVANCE)
  // The stepper signals are in strategical positions for optimal timing. If you
  // still have timing issues, add dummy commands between.
  if(printer_state.extruderStepsNeeded) {
    if(printer_state.extruderStepsNeeded<0) { // Backward step
      extruder_set_direction(0);
      if(extruder_wait_dirchange && extruder_last_dir==-1) {
        extruder_wait_dirchange--;
        return;
      }
      extruder_last_dir = 1;
      extruder_wait_dirchange=2;
      printer_state.extruderStepsNeeded++;
    } else { // Forward step
      extruder_set_direction(1);
      if(extruder_wait_dirchange && extruder_last_dir==1) {
        extruder_wait_dirchange--;
        return;
      }
      extruder_last_dir = -1;
      extruder_wait_dirchange=2;
      printer_state.extruderStepsNeeded--;
    }
    if(current_extruder->currentTemperatureC>=MIN_EXTRUDER_TEMP<Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: Gen7T Step pulse width
April 08, 2012 04:28PM
Yes 10 us is a long time if code space is tight, but that is actually the shortest possible pulse length for these drivers. They use an external capacitor to generate the clock signal for the driver and a 100 pf cap will give a 400 kHz clock, this is the max frequency for the IC. At this clock speed the min pulse width is 10 us. If someone were to use larger caps that would slow the clock and then the min pulse width would rise accordingly.

Anyway, thanks for the quick response, I'll try that out as soon as I get the time. Hopefully tomorrow.

Bryan

Edited 1 time(s). Last edit at 04/08/2012 09:47PM by bryanandaimee.
Re: Gen7T Step pulse width
April 20, 2012 03:27PM
I'm having the same problem. Works with Teacup (60usec pulse width) but not with Marlin (1.4usec).

The TB6560AHQ datasheet [www.toshiba.com] specifies 30usec for 330pF. I'm not sure what capacitor is on my boards.
Sorry, only registered users may post in this forum.

Click here to login