tools/axis_speedtest.py

Sun, 09 Sep 2018 00:21:30 +0200

author
mdd
date
Sun, 09 Sep 2018 00:21:30 +0200
changeset 40
9cb74db14c42
child 41
08d027d2a532
permissions
-rw-r--r--

hardware axis speedtest

40
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
1 import argparse
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
2
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
3 def gen_speedtest(args):
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
4 fd = open(args.file, 'wb')
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
5
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
6 if args.axis.lowercase() == 'x':
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
7 pos = [0, args.dx]
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
8 print(fd, "G0 y%i F%i" % (
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
9 args.dy / 2, args.min * 60))
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
10 else:
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
11 pos = [0, args.dy]
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
12 print(fd, "G0 x%i F%i" % (
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
13 args.dx / 2, args.min * 60))
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
14
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
15 loops = (args.max - args.min) / args.increment
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
16 speed = args.min
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
17 for loop in range(loops):
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
18 print(fd, "G0 %s%i F%i" % (
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
19 args.axis, pos[0], speed * 60))
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
20 print(fd, "G0 %s%i F%i" % (
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
21 args.axis, pos[1], speed * 60))
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
22
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
23 speed += args.inc
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
24
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
25 fd.close()
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
26
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
27
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
28 def main():
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
29 parser = argparse.ArgumentParser()
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
30 parser.add_argument("axis", help="Define X or Y axis")
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
31 parser.add_argument("file", help="Output gcode filename")
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
32 parser.add_argument("--min", type=int, default=100, help="Minimum speed mm/s (100)")
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
33 parser.add_argument("--max", type=int, default=200, help="Maximum speed mm/s (200)")
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
34 parser.add_argument("--dx", type=int, default=200, help="Maximum X dimension (200)")
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
35 parser.add_argument("--dy", type=int, default=200, help="Maximum Y dimension (200)")
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
36 parser.add_argument("--inc", type=int, default=10, help="Speed increment after each line")
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
37
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
38 args = parser.parse_args()
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
39
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
40 gen_speedtest(args)
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
41
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
42 if __name__ == '__main__':
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
43 main()

mercurial