Showing posts with label Scripts. Show all posts
Showing posts with label Scripts. Show all posts

Wednesday, June 8, 2011

Bed Mapper Application and STL Files

I've finally got round to publishing the Bed Calibration Application that I discussed in this post.


The calibration application is now available, along with the STL for the bracket here.



This series of scripts requires the Python libraries: PySerial, Matplotlib and NumPy


Note: This script banks on the Mendel firmware supporting the M117 GCode. Without it, it won't work!


RepRapComms.py: Comms library for communicating with a Mendel.
ZCal.py: Main calibration routines.
PlotBed.py: Bed plotting routines.
gui.py: A GUI to make calibration easier.


To use the GUI:



  • Use the Printer Menu tab to configure the various settings to match your printer.
  • Calibrate Button, will perform a series of measurements across the whole bed at the specified X & Y step size.
  • Quick Cal Button, will perform a quick test at four specified points across the bed.
  • Variance Button, will perform a repeated measurement at a specified point to see what the variance is for the microswitch.

Thursday, April 21, 2011

SkeinArchiver

One of the problems I have regularly with Skeinforge is that after tweaking some settings and getting everything just how I want it, I go and modify something for another print and forget to go and save the contents of the '.skeinforge' directory as a back-up. Then I can't remember what settings I had before.


I decided to write a simple program that makes it easy to quickly archive the settings once you have them dialed-in. Allowing you to keep them safe and then restore them at a later date.


The result is SkeinArchiver, it's very simple to use and I've already found it to be beneficial. I have several profiles archived and my first task during each printing session is to restore the most appropriate saved archive before I start making any tweaks. That way I always start from a known point and don't accidentally have an old setting lingering around from one of my experiments (multiply is a favorite or printing at the wrong layer height).


SkeinArchiver


SkeinArchive
Save - Prompts the user to name the new archive. It suggests a name based around the days date. Then it saves the Skeinforge settings files in a Zip file in the local script directory.


Restore - Prompts the user to pick an archive to restore. This will overwrite the existing Skeinforge settings, so if you have something useful configured, save it first.


Dir to Arch - This allows the user to select the Skeinforge settings directory to archive. By default the program assumes the directory is under '~/.skeinforge', which is where Skeinforge prefers to put it. If you haven't moved it, you don't need to worry about this button.


About - Provides useful information about this version of the tool.


Quit - Pretty self explanatory.


If anyone else fancies using this tool, they can find it here: SkeinArchiver

Hopefully others will find it useful too.

Tuesday, February 1, 2011

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])