My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

createSpeedLookupTable.py 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env python
  2. """ Generate the stepper delay lookup table for Marlin firmware. """
  3. import argparse
  4. __author__ = "Ben Gamari <bgamari@gmail.com>"
  5. __copyright__ = "Copyright 2012, Ben Gamari"
  6. __license__ = "GPL"
  7. parser = argparse.ArgumentParser(description=__doc__)
  8. parser.add_argument('-f', '--cpu-freq', type=int, default=16, help='CPU clockrate in MHz (default=16)')
  9. parser.add_argument('-d', '--divider', type=int, default=8, help='Timer/counter pre-scale divider (default=8)')
  10. args = parser.parse_args()
  11. cpu_freq = args.cpu_freq * 1000000
  12. timer_freq = cpu_freq / args.divider
  13. print "#ifndef SPEED_LOOKUPTABLE_H"
  14. print "#define SPEED_LOOKUPTABLE_H"
  15. print
  16. print '#include "Marlin.h"'
  17. print
  18. print "const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {"
  19. a = [ timer_freq / ((i*256)+(args.cpu_freq*2)) for i in range(256) ]
  20. b = [ a[i] - a[i+1] for i in range(255) ]
  21. b.append(b[-1])
  22. for i in range(32):
  23. print " ",
  24. for j in range(8):
  25. print "{%d, %d}," % (a[8*i+j], b[8*i+j]),
  26. print
  27. print "};"
  28. print
  29. print "const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {"
  30. a = [ timer_freq / ((i*8)+(args.cpu_freq*2)) for i in range(256) ]
  31. b = [ a[i] - a[i+1] for i in range(255) ]
  32. b.append(b[-1])
  33. for i in range(32):
  34. print " ",
  35. for j in range(8):
  36. print "{%d, %d}," % (a[8*i+j], b[8*i+j]),
  37. print
  38. print "};"
  39. print
  40. print "#endif"