tools/axis_speedtest.py

Tue, 19 Jan 2021 20:44:16 +0100

author
mdd
date
Tue, 19 Jan 2021 20:44:16 +0100
changeset 44
310be640a303
parent 41
08d027d2a532
permissions
-rw-r--r--

Added tag WORKING_BEFORE_UPGRADE_TO_GITMASTER for changeset f7e9bd735ce1

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')
41
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
5 axis = args.axis.upper()
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
6 if axis == 'X':
40
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
7 pos = [0, args.dx]
41
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
8 fd.write("G0 Y%.2f F%i\n" % (
40
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]
41
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
12 fd.write("G0 X%.2f F%i\n" % (
40
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
13 args.dx / 2, args.min * 60))
9cb74db14c42 hardware axis speedtest
mdd
parents:
diff changeset
14
41
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
15 loops = (args.max - args.min) / args.inc
40
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):
41
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
18 fd.write("G0 %s%.2f F%i\n" % (
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
19 axis, pos[0], speed * 60))
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
20 fd.write("G0 %s%.2f F%i\n" % (
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
21 axis, pos[1], speed * 60))
40
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)")
41
08d027d2a532 dont know what i have done
mdd
parents: 40
diff changeset
36 parser.add_argument("--inc", type=int, default=20, help="Speed increment after each line")
40
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