Tuesday, February 1, 2011

Extruder Update

The new extruder parts have arrived and I have built up my new extruder. The build was uneventful, which was nice. Initial tests show that it works reliably, but I still have to dial-in all the settings again as the nozzle appears to be marginally bigger than the previous one. Once I've got it dialed back in I'll be able to continue experimenting with the various skeinforge settings.

I'll document the dial-in process but there is something that's going to interrupt that process. An upcoming house move that is going to disrupt my workshop for a few weeks while it gets packed, moved and unpacked.

PreprocessGcodes.py

import sys


# Preferred Start Codes
startCode = [
'G21\n'
'G90\n'
'T0\n'
'G28 Z0\n'
'G28 X0 Y0\n'
'G92 E0\n'
]


def AppendCode(fh, codes):
   for code in codes:
      fh.write(code)




def Main(fileName):
   # Counters   
   M101Cnt = 0
   M103Cnt = 0


   # Open Input File
   try:
      fh = open(fileName, 'r')
   except:
      print 'Cannot open file: %s' % (fileName)
   
   print '\nProcessing %s' % (fileName)
   
   # Create Output Filename
   name, ext = fileName.split('.')
   name = name+'_mod'
   opFile = name+'.'+ext
   
   # Open Output File
   op = open(opFile, 'w')
   


   # Add preferred Start-up code
   AppendCode(op, startCode)


   # Remove first X lines
   # Skeinforge produces strange start-up code that isn't useful.
   X = 12
   for i in range(X):
      fh.readline()
      
   # Process remaining lines in turn
   for line in fh:
      # Remove 'M101' and 'M103' commands, Mendel doesn't use these.
      if line.find('M101')==0:
         M101Cnt +=1
         line = ''
      if line.find('M103')==0:
         M103Cnt+=1
         line = ''
      # Remove 'M113' command, stepper based extruder doesn't use this
      if line.find('M113')==0:
         M101Cnt +=1
         line = ''
         
      # Write to output file
      op.write(line)


   print 'Generated file: %s' % (opFile)
   print 
   print 'Removed %s old M101 Codes' % (M101Cnt)
   print 'Removed %s old M103 Codes' % (M103Cnt)
   
if __name__ == '__main__':
   Main(sys.argv[1])