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