Moved Grbl Sim to its own repo.
This commit is contained in:
parent
fc0c4f4332
commit
48faf81c40
2
sim/.gitignore
vendored
2
sim/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
grbl_sim.exe
|
|
||||||
*.dat
|
|
@ -1,323 +0,0 @@
|
|||||||
( Made using CamBam - http://www.cambam.co.uk )
|
|
||||||
( Untitled 2/13/2012 2:54:50 PM )
|
|
||||||
( T0 : 0.0394 )
|
|
||||||
G20 G90 G64 G40
|
|
||||||
G0 Z0.125
|
|
||||||
( T0 : 0.0394 )
|
|
||||||
T0 M6
|
|
||||||
( Engrave1 )
|
|
||||||
G17
|
|
||||||
M3 S1000
|
|
||||||
G0 X-3.0 Y-0.0451
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G1 F60.0 X-2.8845 Y-0.035
|
|
||||||
G3 X-2.8723 Y-0.0943 I0.3244 J0.0363
|
|
||||||
G3 X-2.8467 Y-0.1492 I0.2072 J0.0631
|
|
||||||
G3 X-2.805 Y-0.1917 I0.1471 J0.1027
|
|
||||||
G3 X-2.7533 Y-0.2212 I0.1578 J0.2169
|
|
||||||
G3 X-2.6114 Y-0.2483 I0.1366 J0.3297
|
|
||||||
G3 X-2.4877 Y-0.2275 I0.006 J0.3418
|
|
||||||
G3 X-2.4438 Y-0.2048 I-0.0766 J0.2022
|
|
||||||
G3 X-2.4082 Y-0.1707 I-0.0792 J0.1182
|
|
||||||
G3 X-2.3817 Y-0.0912 I-0.1063 J0.0796
|
|
||||||
G3 X-2.4069 Y-0.0155 I-0.1191 J0.0024
|
|
||||||
G3 X-2.4449 Y0.0175 I-0.1101 J-0.0883
|
|
||||||
G3 X-2.4902 Y0.0394 I-0.1379 J-0.2279
|
|
||||||
G3 X-2.572 Y0.0637 I-0.3019 J-0.8663
|
|
||||||
G3 X-2.6549 Y0.0842 I-1.0468 J-4.0562
|
|
||||||
G2 X-2.7457 Y0.1086 I0.3878 J1.6213
|
|
||||||
G2 X-2.8334 Y0.1422 I0.1472 J0.5158
|
|
||||||
G2 X-2.8886 Y0.1787 I0.1401 J0.2718
|
|
||||||
G2 X-2.9325 Y0.2281 I0.1404 J0.1692
|
|
||||||
G2 X-2.9647 Y0.3435 I0.1821 J0.1129
|
|
||||||
G2 X-2.9249 Y0.4741 I0.2336 J0.0003
|
|
||||||
G2 X-2.8088 Y0.5669 I0.2044 J-0.1368
|
|
||||||
G2 X-2.6391 Y0.5984 I0.1639 J-0.4097
|
|
||||||
G2 X-2.5469 Y0.5908 I0.0024 J-0.5372
|
|
||||||
G2 X-2.458 Y0.565 I-0.0669 J-0.395
|
|
||||||
G2 X-2.3369 Y0.4678 I-0.0947 J-0.2421
|
|
||||||
G2 X-2.2915 Y0.3221 I-0.2346 J-0.1531
|
|
||||||
G1 X-2.4088 Y0.3132
|
|
||||||
G3 X-2.4277 Y0.386 I-0.236 J-0.0223
|
|
||||||
G3 X-2.4732 Y0.4457 I-0.1488 J-0.0662
|
|
||||||
G3 X-2.5498 Y0.4817 I-0.1158 J-0.1469
|
|
||||||
G3 X-2.6341 Y0.4905 I-0.08 J-0.3586
|
|
||||||
G3 X-2.7184 Y0.4829 I-0.0045 J-0.4232
|
|
||||||
G3 X-2.7962 Y0.4495 I0.0315 J-0.1804
|
|
||||||
G3 X-2.8331 Y0.4066 I0.0864 J-0.1118
|
|
||||||
G3 X-2.8467 Y0.3517 I0.1005 J-0.0539
|
|
||||||
G3 X-2.8107 Y0.2697 I0.1052 J-0.0028
|
|
||||||
G3 X-2.7679 Y0.2452 I0.1001 J0.125
|
|
||||||
G3 X-2.698 Y0.2215 I0.2359 J0.583
|
|
||||||
G3 X-2.6265 Y0.2034 I0.3957 J1.414
|
|
||||||
G2 X-2.5228 Y0.1782 I-0.5539 J-2.5053
|
|
||||||
G2 X-2.4215 Y0.1448 I-0.1803 J-0.7161
|
|
||||||
G2 X-2.3553 Y0.1057 I-0.1442 J-0.3193
|
|
||||||
G2 X-2.3022 Y0.0501 I-0.1407 J-0.1878
|
|
||||||
G2 X-2.2637 Y-0.0811 I-0.19 J-0.127
|
|
||||||
G2 X-2.306 Y-0.2205 I-0.2532 J0.0006
|
|
||||||
G2 X-2.4278 Y-0.3221 I-0.2339 J0.1566
|
|
||||||
G2 X-2.6057 Y-0.3581 I-0.1712 J0.3891
|
|
||||||
G2 X-2.7129 Y-0.3503 I-0.0037 J0.6909
|
|
||||||
G2 X-2.8164 Y-0.3215 I0.0637 J0.4292
|
|
||||||
G2 X-2.9495 Y-0.2117 I0.1147 J0.2747
|
|
||||||
G2 X-3.0 Y-0.0451 I0.265 J0.1712
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X-2.111
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G1 F60.0 Y0.5826
|
|
||||||
G1 X-1.9975
|
|
||||||
G1 Y0.2508
|
|
||||||
G2 X-1.9077 Y0.3198 I0.2024 J-0.1703
|
|
||||||
G2 X-1.7969 Y0.3429 I0.1077 J-0.2394
|
|
||||||
G2 X-1.6675 Y0.3132 I0.0063 J-0.2692
|
|
||||||
G2 X-1.5893 Y0.2325 I-0.0755 J-0.1515
|
|
||||||
G2 X-1.5698 Y0.1586 I-0.2396 J-0.1028
|
|
||||||
G2 X-1.5653 Y0.0823 I-0.5851 J-0.0725
|
|
||||||
G1 Y-0.3423
|
|
||||||
G1 X-1.6789
|
|
||||||
G1 Y0.0823
|
|
||||||
G3 X-1.6859 Y0.1476 I-0.2729 J0.0036
|
|
||||||
G3 X-1.7161 Y0.206 I-0.1238 J-0.027
|
|
||||||
G3 X-1.764 Y0.2366 I-0.0845 J-0.0794
|
|
||||||
G3 X-1.8202 Y0.2451 I-0.0537 J-0.1649
|
|
||||||
G3 X-1.9155 Y0.2186 I-0.0001 J-0.1841
|
|
||||||
G3 X-1.9786 Y0.1479 I0.072 J-0.1278
|
|
||||||
G3 X-1.9938 Y0.087 I0.221 J-0.0878
|
|
||||||
G3 X-1.9975 Y0.0243 I0.4875 J-0.0599
|
|
||||||
G1 Y-0.3423
|
|
||||||
G1 X-2.111
|
|
||||||
G1 Y-0.0451
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X-1.4292 Y-0.1385
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G2 F60.0 X-1.4088 Y-0.076 I0.182 J-0.0249
|
|
||||||
G2 X-1.3502 Y-0.0104 I0.1662 J-0.0896
|
|
||||||
G2 X-1.2681 Y0.0268 I0.1554 J-0.2334
|
|
||||||
G2 X-1.1672 Y0.0438 I0.1926 J-0.8334
|
|
||||||
G3 X-1.065 Y0.0586 I-0.2128 J1.8303
|
|
||||||
G3 X-0.9647 Y0.0829 I-0.1109 J0.6767
|
|
||||||
G3 X-0.9641 Y0.1126 I-1.9501 J0.0563
|
|
||||||
G3 X-0.97 Y0.1648 I-0.2046 J0.003
|
|
||||||
G3 X-0.9962 Y0.2104 I-0.0883 J-0.0204
|
|
||||||
G3 X-1.0574 Y0.2412 I-0.0943 J-0.111
|
|
||||||
G3 X-1.1256 Y0.2489 I-0.0647 J-0.2692
|
|
||||||
G3 X-1.187 Y0.2436 I-0.0032 J-0.3217
|
|
||||||
G3 X-1.2442 Y0.2205 I0.0237 J-0.141
|
|
||||||
G3 X-1.2805 Y0.1756 I0.0774 J-0.0998
|
|
||||||
G3 X-1.3003 Y0.1214 I0.2336 J-0.1162
|
|
||||||
G1 X-1.4114 Y0.1366
|
|
||||||
G2 X-1.3931 Y0.1969 I0.337 J-0.0694
|
|
||||||
G2 X-1.3615 Y0.2514 I0.2096 J-0.0848
|
|
||||||
G2 X-1.3162 Y0.2923 I0.1453 J-0.1155
|
|
||||||
G2 X-1.2612 Y0.3189 I0.1409 J-0.221
|
|
||||||
G2 X-1.1092 Y0.3429 I0.1442 J-0.4206
|
|
||||||
G2 X-1.0386 Y0.3388 I0.0029 J-0.5642
|
|
||||||
G2 X-0.9697 Y0.3227 I-0.0351 J-0.3052
|
|
||||||
G2 X-0.927 Y0.3022 I-0.0865 J-0.2354
|
|
||||||
G2 X-0.8909 Y0.2716 I-0.0727 J-0.1224
|
|
||||||
G2 X-0.8555 Y0.1946 I-0.1386 J-0.1102
|
|
||||||
G2 X-0.8507 Y0.1424 I-0.3836 J-0.0615
|
|
||||||
G2 X-0.8499 Y0.0899 I-1.3758 J-0.0494
|
|
||||||
G1 Y-0.0615
|
|
||||||
G3 X-0.8489 Y-0.1619 I4.6791 J-0.0068
|
|
||||||
G3 X-0.8429 Y-0.2622 I0.9512 J0.0067
|
|
||||||
G3 X-0.8139 Y-0.3423 I0.2546 J0.0469
|
|
||||||
G1 X-0.9325
|
|
||||||
G2 X-0.9552 Y-0.2596 I0.2182 J0.1044
|
|
||||||
G2 X-1.077 Y-0.3354 I-0.2823 J0.3183
|
|
||||||
G2 X-1.2019 Y-0.3574 I-0.1221 J0.3266
|
|
||||||
G2 X-1.2917 Y-0.3463 I-0.0042 J0.3355
|
|
||||||
G2 X-1.3716 Y-0.3038 I0.0496 J0.1895
|
|
||||||
G2 X-1.4309 Y-0.1656 I0.1197 J0.1332
|
|
||||||
G2 X-1.4292 Y-0.1385 I0.1837 J0.0022
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X-1.3093 Y-0.1513
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G3 F60.0 X-1.3098 Y-0.1625 I0.0949 J-0.0101
|
|
||||||
G3 X-1.2757 Y-0.2382 I0.0971 J-0.0018
|
|
||||||
G3 X-1.228 Y-0.2624 I0.075 J0.0889
|
|
||||||
G3 X-1.1748 Y-0.2685 I0.0506 J0.2058
|
|
||||||
G3 X-1.0581 Y-0.2401 I0.0042 J0.2367
|
|
||||||
G3 X-0.983 Y-0.1612 I-0.0857 J0.1567
|
|
||||||
G3 X-0.9681 Y-0.1054 I-0.1756 J0.0768
|
|
||||||
G3 X-0.9647 Y-0.0477 I-0.4434 J0.0549
|
|
||||||
G1 Y-0.006
|
|
||||||
G2 X-1.0563 Y-0.0325 I-0.2032 J0.5301
|
|
||||||
G2 X-1.1502 Y-0.0489 I-0.2867 J1.3668
|
|
||||||
G3 X-1.2003 Y-0.0575 I0.1165 J-0.8276
|
|
||||||
G3 X-1.2492 Y-0.0716 I0.0505 J-0.2671
|
|
||||||
G3 X-1.294 Y-0.1089 I0.0375 J-0.0907
|
|
||||||
G3 X-1.3093 Y-0.1513 I0.0797 J-0.0526
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X-0.6738
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G1 F60.0 Y0.3277
|
|
||||||
G1 X-0.5704
|
|
||||||
G1 Y0.2407
|
|
||||||
G2 X-0.4877 Y0.317 I0.2085 J-0.1428
|
|
||||||
G2 X-0.376 Y0.3429 I0.1052 J-0.2003
|
|
||||||
G2 X-0.2246 Y0.2987 I0.0049 J-0.265
|
|
||||||
G2 X-0.1256 Y0.1738 I-0.1536 J-0.2235
|
|
||||||
G2 X-0.0921 Y-0.0022 I-0.4197 J-0.1709
|
|
||||||
G2 X-0.1294 Y-0.1877 I-0.4477 J-0.0066
|
|
||||||
G2 X-0.2366 Y-0.3139 I-0.2559 J0.1088
|
|
||||||
G2 X-0.3842 Y-0.3574 I-0.1486 J0.2319
|
|
||||||
G2 X-0.4865 Y-0.3335 I-0.0033 J0.2159
|
|
||||||
G2 X-0.5603 Y-0.2729 I0.1079 J0.2068
|
|
||||||
G1 Y-0.5991
|
|
||||||
G1 X-0.6738
|
|
||||||
G1 Y-0.1513
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X-0.5586 Y-0.1219
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G3 F60.0 X-0.5186 Y-0.2022 I0.2066 J0.0526
|
|
||||||
G3 X-0.4624 Y-0.2478 I0.1393 J0.1145
|
|
||||||
G3 X-0.3918 Y-0.2641 I0.0691 J0.1387
|
|
||||||
G3 X-0.3198 Y-0.2472 I0.0014 J0.1565
|
|
||||||
G3 X-0.2625 Y-0.2003 I-0.0865 J0.1642
|
|
||||||
G3 X-0.2186 Y-0.1056 I-0.1741 J0.1382
|
|
||||||
G3 X-0.2082 Y-0.0016 I-0.463 J0.0985
|
|
||||||
G3 X-0.2185 Y0.0988 I-0.445 J0.0051
|
|
||||||
G3 X-0.2612 Y0.1902 I-0.2152 J-0.0448
|
|
||||||
G3 X-0.3165 Y0.2368 I-0.1435 J-0.1141
|
|
||||||
G3 X-0.3868 Y0.2539 I-0.0691 J-0.1308
|
|
||||||
G3 X-0.459 Y0.2348 I-0.0004 J-0.1446
|
|
||||||
G3 X-0.5155 Y0.1858 I0.1042 J-0.1769
|
|
||||||
G3 X-0.5599 Y0.0921 I0.1824 J-0.1439
|
|
||||||
G3 X-0.571 Y-0.0111 I0.4286 J-0.0981
|
|
||||||
G3 X-0.561 Y-0.1111 I0.4541 J-0.0052
|
|
||||||
G3 X-0.5586 Y-0.1219 I0.209 J0.0418
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X0.0092 Y-0.0653
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G2 F60.0 X0.0069 Y-0.013 I0.4635 J0.0463
|
|
||||||
G2 X0.0253 Y0.1266 I0.49 J0.0063
|
|
||||||
G2 X0.094 Y0.2495 I0.2937 J-0.0834
|
|
||||||
G2 X0.1968 Y0.3207 I0.209 J-0.1921
|
|
||||||
G2 X0.3199 Y0.3429 I0.1188 J-0.3064
|
|
||||||
G2 X0.4396 Y0.321 I0.004 J-0.3162
|
|
||||||
G2 X0.5394 Y0.2514 I-0.1055 J-0.2578
|
|
||||||
G2 X0.6066 Y0.1308 I-0.2207 J-0.202
|
|
||||||
G2 X0.6246 Y-0.006 I-0.4641 J-0.1307
|
|
||||||
G2 X0.624 Y-0.0363 I-1.1335 J0.0085
|
|
||||||
G1 X0.1243
|
|
||||||
G3 X0.1404 Y-0.1264 I0.3467 J0.0157
|
|
||||||
G3 X0.1867 Y-0.2054 I0.1984 J0.0632
|
|
||||||
G3 X0.3268 Y-0.2641 I0.1356 J0.1272
|
|
||||||
G3 X0.4334 Y-0.2312 I0.0048 J0.1741
|
|
||||||
G3 X0.4761 Y-0.184 I-0.1056 J0.1381
|
|
||||||
G3 X0.5034 Y-0.1265 I-0.2498 J0.1544
|
|
||||||
G1 X0.6208 Y-0.141
|
|
||||||
G2 X0.583 Y-0.2296 I-0.3145 J0.082
|
|
||||||
G2 X0.518 Y-0.3007 I-0.2247 J0.1403
|
|
||||||
G2 X0.4267 Y-0.3449 I-0.1599 J0.2137
|
|
||||||
G2 X0.3262 Y-0.3574 I-0.0969 J0.3673
|
|
||||||
G2 X0.1999 Y-0.337 I-0.005 J0.3687
|
|
||||||
G2 X0.0927 Y-0.2672 I0.094 J0.2616
|
|
||||||
G2 X0.0252 Y-0.1484 I0.2166 J0.2017
|
|
||||||
G2 X0.0092 Y-0.0653 I0.4475 J0.1294
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X0.1306 Y0.0571
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G1 F60.0 X0.5047
|
|
||||||
G3 X0.4926 Y0.1236 I-0.3356 J-0.0268
|
|
||||||
G3 X0.4618 Y0.1839 I-0.1636 J-0.0456
|
|
||||||
G3 X0.3211 Y0.2495 I-0.1362 J-0.1084
|
|
||||||
G3 X0.1893 Y0.1971 I-0.0043 J-0.1815
|
|
||||||
G3 X0.1467 Y0.1326 I0.1313 J-0.1328
|
|
||||||
G3 X0.1306 Y0.0571 I0.2303 J-0.0887
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X0.7412 Y0.0837
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G2 F60.0 X0.7407 Y0.1082 I0.5215 J0.0227
|
|
||||||
G2 X0.7673 Y0.3004 I0.6459 J0.0084
|
|
||||||
G2 X0.8643 Y0.4684 I0.405 J-0.1218
|
|
||||||
G2 X1.0099 Y0.568 I0.2954 J-0.2758
|
|
||||||
G2 X1.1836 Y0.599 I0.1677 J-0.4369
|
|
||||||
G2 X1.4145 Y0.5378 I0.0061 J-0.4431
|
|
||||||
G2 X1.5709 Y0.3669 I-0.2021 J-0.3421
|
|
||||||
G2 X1.6126 Y0.246 I-0.4508 J-0.2228
|
|
||||||
G2 X1.6252 Y0.1189 I-0.6041 J-0.1243
|
|
||||||
G2 X1.6119 Y-0.0104 I-0.6073 J-0.0028
|
|
||||||
G2 X1.5684 Y-0.1328 I-0.4911 J0.1054
|
|
||||||
G2 X1.4075 Y-0.3013 I-0.3494 J0.1726
|
|
||||||
G2 X1.1829 Y-0.3581 I-0.2218 J0.4049
|
|
||||||
G2 X1.0618 Y-0.343 I-0.0025 J0.4735
|
|
||||||
G2 X0.9495 Y-0.295 I0.1059 J0.4032
|
|
||||||
G2 X0.7937 Y-0.1227 I0.2106 J0.3471
|
|
||||||
G2 X0.7412 Y0.0837 I0.469 J0.2292
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X0.867 Y0.0872
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G3 F60.0 X0.8863 Y-0.0342 I0.4738 J0.0131
|
|
||||||
G3 X0.9564 Y-0.1574 I0.3033 J0.091
|
|
||||||
G3 X1.1823 Y-0.2533 I0.2187 J0.2012
|
|
||||||
G3 X1.3066 Y-0.2297 I0.004 J0.318
|
|
||||||
G3 X1.4094 Y-0.1562 I-0.1146 J0.269
|
|
||||||
G3 X1.4803 Y-0.0268 I-0.2365 J0.2136
|
|
||||||
G3 X1.499 Y0.1195 I-0.5092 J0.1396
|
|
||||||
G3 X1.4904 Y0.22 I-0.5565 J0.0028
|
|
||||||
G3 X1.4605 Y0.3164 I-0.4006 J-0.0713
|
|
||||||
G3 X1.3489 Y0.447 I-0.2653 J-0.1138
|
|
||||||
G3 X1.1842 Y0.4937 I-0.1607 J-0.2531
|
|
||||||
G3 X0.9602 Y0.4041 I-0.0045 J-0.3134
|
|
||||||
G3 X0.9124 Y0.3396 I0.1696 J-0.1757
|
|
||||||
G3 X0.8761 Y0.2256 I0.3481 J-0.1739
|
|
||||||
G3 X0.8669 Y0.1063 I0.7033 J-0.1142
|
|
||||||
G3 X0.867 Y0.0872 I0.474 J-0.0059
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X1.7691
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G1 F60.0 Y0.5826
|
|
||||||
G1 X1.8826
|
|
||||||
G1 Y0.0552
|
|
||||||
G1 X2.1514 Y0.3277
|
|
||||||
G1 X2.2984
|
|
||||||
G1 X2.0422 Y0.0792
|
|
||||||
G1 X2.3243 Y-0.3423
|
|
||||||
G1 X2.1842
|
|
||||||
G1 X1.9627 Y0.0003
|
|
||||||
G1 X1.8826 Y-0.0767
|
|
||||||
G1 Y-0.3423
|
|
||||||
G1 X1.7691
|
|
||||||
G1 Y0.0872
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X2.3737 Y0.0387
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G2 F60.0 X2.3936 Y0.142 I0.4767 J-0.0383
|
|
||||||
G2 X2.4757 Y0.2684 I0.2668 J-0.0833
|
|
||||||
G2 X2.5741 Y0.3252 I0.1952 J-0.225
|
|
||||||
G2 X2.6864 Y0.3429 I0.109 J-0.3265
|
|
||||||
G2 X2.8089 Y0.3214 I0.0042 J-0.3359
|
|
||||||
G2 X2.9123 Y0.252 I-0.1045 J-0.2674
|
|
||||||
G2 X2.9809 Y0.1358 I-0.2103 J-0.2027
|
|
||||||
G2 X3.0 Y0.0022 I-0.4192 J-0.1278
|
|
||||||
G2 X2.9922 Y-0.102 I-0.6432 J-0.0046
|
|
||||||
G2 X2.9608 Y-0.2016 I-0.3284 J0.0487
|
|
||||||
G2 X2.8479 Y-0.3164 I-0.2422 J0.1253
|
|
||||||
G2 X2.6864 Y-0.3574 I-0.1586 J0.2861
|
|
||||||
G2 X2.563 Y-0.3364 I-0.0045 J0.3461
|
|
||||||
G2 X2.4586 Y-0.2672 I0.1004 J0.2648
|
|
||||||
G2 X2.3902 Y-0.1456 I0.2134 J0.2001
|
|
||||||
G2 X2.3722 Y-0.0073 I0.4726 J0.1318
|
|
||||||
G2 X2.3737 Y0.0387 I0.4782 J0.0077
|
|
||||||
G0 Z0.125
|
|
||||||
G0 X2.4901 Y0.0298
|
|
||||||
G1 F10.0 Z-0.001
|
|
||||||
G3 F60.0 X2.4889 Y-0.0073 I0.4225 J-0.032
|
|
||||||
G3 X2.5 Y-0.1088 I0.4249 J-0.0051
|
|
||||||
G3 X2.5451 Y-0.2003 I0.2117 J0.0474
|
|
||||||
G3 X2.6864 Y-0.2641 I0.1376 J0.1166
|
|
||||||
G3 X2.8271 Y-0.1997 I0.0032 J0.1789
|
|
||||||
G3 X2.8724 Y-0.1065 I-0.1677 J0.1391
|
|
||||||
G3 X2.8832 Y-0.0035 I-0.432 J0.0977
|
|
||||||
G3 X2.8719 Y0.0957 I-0.3951 J0.0049
|
|
||||||
G3 X2.8265 Y0.1845 I-0.2065 J-0.0494
|
|
||||||
G3 X2.6864 Y0.2489 I-0.1372 J-0.1139
|
|
||||||
G3 X2.5451 Y0.1852 I-0.0037 J-0.1803
|
|
||||||
G3 X2.4999 Y0.0939 I0.164 J-0.1379
|
|
||||||
G3 X2.4901 Y0.0298 I0.4127 J-0.0961
|
|
||||||
G0 Z0.125
|
|
||||||
M5
|
|
||||||
M30
|
|
50
sim/Makefile
50
sim/Makefile
@ -1,50 +0,0 @@
|
|||||||
# Part of Grbl Simulator
|
|
||||||
#
|
|
||||||
# Copyright (c) 2012 Jens Geisler
|
|
||||||
#
|
|
||||||
# Grbl is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Grbl is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
PLATFORM = WINDOWS
|
|
||||||
|
|
||||||
OBJECTS = main.o simulator.o serial.o ../main.o ../protocol.o ../planner.o ../settings.o ../print.o ../nuts_bolts.o eeprom.o ../serial.o avr/pgmspace.o avr/interrupt.o avr/io.o util/delay.o util/floatunsisf.o ../stepper.o ../gcode.o ../spindle_control.o ../motion_control.o ../limits.o ../report.o ../coolant_control.o ../probe.o ../system.o platform_$(PLATFORM).o
|
|
||||||
CLOCK = 16000000
|
|
||||||
EXE_NAME = grbl_sim.exe
|
|
||||||
COMPILE = $(CC) -Wall -g -DF_CPU=$(CLOCK) -include config.h -I. -DPLAT_$(PLATFORM)
|
|
||||||
LINUX_LIBRARIES = -lrt -pthread
|
|
||||||
WINDOWS_LIBRARIES =
|
|
||||||
# symbolic targets:
|
|
||||||
all: main
|
|
||||||
|
|
||||||
new: clean main
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(EXE_NAME) $(OBJECTS)
|
|
||||||
|
|
||||||
# file targets:
|
|
||||||
main: $(OBJECTS)
|
|
||||||
$(COMPILE) -o $(EXE_NAME) $(OBJECTS) -lm $($(PLATFORM)_LIBRARIES)
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(COMPILE) -c $< -o $@
|
|
||||||
|
|
||||||
../planner.o: ../planner.c
|
|
||||||
$(COMPILE) -include planner_inject_accessors.c -c $< -o $@
|
|
||||||
|
|
||||||
../serial.o: ../serial.c
|
|
||||||
$(COMPILE) -include serial_hooks.h -c $< -o $@
|
|
||||||
|
|
||||||
../main.o: ../main.c
|
|
||||||
$(COMPILE) -include rename_main.h -c $< -o $@
|
|
||||||
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
GRBL SIM : by Jens Geisler
|
|
||||||
|
|
||||||
This directory contains an experimental Grbl simulator that compiles the main Grbl source code into a wrapped executable for use on a computer. No Arduino required. When the executable is run, the user should be able to interact with the Grbl simulator as if connected to an Arduino with Grbl.
|
|
||||||
|
|
||||||
WARNING: Grbl Sim is under heavy development. So many things may not work, or respond in ways unexpected. At the moment, this code is a proof-of-concept.
|
|
||||||
|
|
||||||
What can you do with Grbl Sim?
|
|
||||||
- Simply checking out how Grbl works without needing an Arduino.
|
|
||||||
- Visualize a g-code program by having the simulator parse and execute to a GUI. Fluctuations in feed rates by the acceleration planner can be viewed as well.
|
|
||||||
- A powerful debugging tool for development.
|
|
||||||
- Each of the AVR functions are replaced with dummy functions, like the stepper ISR. These could be written to whatever you need. For example, output simulated step pulses over time and examine its performance.
|
|
||||||
|
|
||||||
Realtime modifications by Adam Shelly:
|
|
||||||
|
|
||||||
Simulates Atmel hardware in separate thread. Runs in aproximate realtime.
|
|
||||||
|
|
||||||
On Linux, use `socat PTY,raw,link=/dev/ttyFAKE,echo=0 "EXEC:'./grbl_sim.exe -n -s step.out -b block.out',pty,raw,echo=0"` to create a fake serial port connected to the simulator. This is useful for testing grbl interface software.
|
|
||||||
|
|
@ -1,154 +0,0 @@
|
|||||||
/*
|
|
||||||
interrupt.c - replacement for the avr library of the same name to provide
|
|
||||||
dummy register variables
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "interrupt.h"
|
|
||||||
#include "io.h"
|
|
||||||
#include "wdt.h"
|
|
||||||
|
|
||||||
//pseudo-Interrupt vector table
|
|
||||||
isr_fp compa_vect[6]={0};
|
|
||||||
isr_fp compb_vect[6]={0};
|
|
||||||
isr_fp ovf_vect[6]={0};
|
|
||||||
isr_fp wdt_vect = 0;
|
|
||||||
isr_fp pc_vect = 0;
|
|
||||||
|
|
||||||
void sei() {io.sreg|=SEI;}
|
|
||||||
void cli() {io.sreg&=~SEI;}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int16_t sim_scaling[8]={0,1,8,64,256,1024,1,1}; //clock scalars
|
|
||||||
//Timer/Counter modes: these are incomplete, but enough for this application
|
|
||||||
enum sim_wgm_mode {
|
|
||||||
wgm_NORMAL,
|
|
||||||
wgm_CTC,
|
|
||||||
wgm_FAST_PWM,
|
|
||||||
wgm_PHASE_PWM,
|
|
||||||
wgm_PH_F_PWM,
|
|
||||||
wgm_RESERVED
|
|
||||||
};
|
|
||||||
|
|
||||||
//3-bit wgm table for 8-bit timers
|
|
||||||
enum sim_wgm_mode sim_wgm_3[] = {wgm_NORMAL,wgm_PHASE_PWM,wgm_CTC,wgm_FAST_PWM,
|
|
||||||
wgm_RESERVED,wgm_PHASE_PWM, wgm_RESERVED, wgm_FAST_PWM};
|
|
||||||
|
|
||||||
//4-bit wgm modes for 16-bit timers
|
|
||||||
enum sim_wgm_mode sim_wgm_4[16] = {wgm_NORMAL,wgm_PHASE_PWM,wgm_PHASE_PWM,wgm_PHASE_PWM,
|
|
||||||
wgm_CTC, wgm_FAST_PWM, wgm_FAST_PWM, wgm_FAST_PWM,
|
|
||||||
wgm_PH_F_PWM, wgm_PH_F_PWM, wgm_PHASE_PWM, wgm_PHASE_PWM,
|
|
||||||
wgm_CTC, wgm_RESERVED, wgm_FAST_PWM, wgm_FAST_PWM};
|
|
||||||
|
|
||||||
static const uint16_t timer_bitdepth[SIM_N_TIMERS] = {
|
|
||||||
0xFF,0xFFFF,0xFF,
|
|
||||||
//0xFFFF,0xFFFF,0xFFFF 3 more for mega
|
|
||||||
};
|
|
||||||
|
|
||||||
void timer_interrupts() {
|
|
||||||
int i;
|
|
||||||
uint8_t ien = io.sreg&SEI; //interrupts enabled?
|
|
||||||
io.prescaler++;
|
|
||||||
|
|
||||||
//all clocks
|
|
||||||
for (i=0;i<SIM_N_TIMERS;i++){
|
|
||||||
uint8_t cs = io.tccrb[i]&7; //clock select bits
|
|
||||||
int16_t increment = sim_scaling[cs];
|
|
||||||
uint16_t bitmask = timer_bitdepth[i];
|
|
||||||
|
|
||||||
//check scaling to see if timer fires
|
|
||||||
if (increment && (io.prescaler&(increment-1))==0) {
|
|
||||||
|
|
||||||
//select waveform generation mode
|
|
||||||
enum sim_wgm_mode mode;
|
|
||||||
if (i==0 || i==2) { //(T0 and T2 use only 3 wgm bits)
|
|
||||||
uint8_t wgm = ((io.tccrb[i]&0x08)>>1) | (io.tccra[i]&3);
|
|
||||||
mode = sim_wgm_3[wgm];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
uint8_t wgm = ((io.tccrb[i]&0x18)>>1) | (io.tccra[i]&3); //4 wgm bits
|
|
||||||
mode = sim_wgm_4[wgm];
|
|
||||||
}
|
|
||||||
|
|
||||||
//tick
|
|
||||||
if (io.tifr[i]&(1<<SIM_ROLL)) { //handle CTC mode rollover
|
|
||||||
io.tcnt[i]=0;
|
|
||||||
io.tifr[i]&=~(1<<SIM_ROLL);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
io.tcnt[i]++;
|
|
||||||
}
|
|
||||||
io.tcnt[i]&=bitmask; //limit the 8 bit timers
|
|
||||||
|
|
||||||
switch (mode) {
|
|
||||||
case wgm_NORMAL: //Normal mode, ovf on rollover
|
|
||||||
if (io.tcnt[i]==0) io.tifr[i]|=(1<<SIM_TOV); //overflow
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wgm_CTC: //CTC mode, ovf at TOP, 0 next tick
|
|
||||||
if (io.tcnt[i]==(io.ocra[i]&bitmask)) {
|
|
||||||
io.tifr[i]|=(1<<SIM_TOV)|(1<<SIM_ROLL); //overflow
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: //unsupported
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//comparators
|
|
||||||
if ((io.timsk[i]&(1<<SIM_OCA)) && io.tcnt[i]==(io.ocra[i]&bitmask)) io.tifr[i]|=(1<<SIM_OCA);
|
|
||||||
if ((io.timsk[i]&(1<<SIM_OCB)) && io.tcnt[i]==(io.ocrb[i]&bitmask)) io.tifr[i]|=(1<<SIM_OCB);
|
|
||||||
if ((io.timsk[i]&(1<<SIM_OCC)) && io.tcnt[i]==(io.ocrc[i]&bitmask)) io.tifr[i]|=(1<<SIM_OCC);
|
|
||||||
|
|
||||||
//call any triggered interupts
|
|
||||||
if (ien && io.tifr[i]) {
|
|
||||||
if (compa_vect[i] && (io.tifr[i]&(1<<SIM_OCA))) {
|
|
||||||
compa_vect[i]();
|
|
||||||
io.tifr[i]&=~(1<<SIM_OCA);
|
|
||||||
//TODO: insert port_monitor call here
|
|
||||||
}
|
|
||||||
if (compb_vect[i] && (io.tifr[i]&(1<<SIM_OCB))) {
|
|
||||||
compb_vect[i]();
|
|
||||||
io.tifr[i]&=~(1<<SIM_OCB);
|
|
||||||
}
|
|
||||||
if (ovf_vect[i] && (io.tifr[i]&(1<<SIM_TOV))) {
|
|
||||||
ovf_vect[i]();
|
|
||||||
io.tifr[i]&=~(1<<SIM_TOV);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//// TODO for more complete timer sim.
|
|
||||||
// pwm modes. (only used for variable spindle, I think).
|
|
||||||
// -- would require fixing wgm mode for Timers1..5
|
|
||||||
// -- phase correct modes need updown counter.
|
|
||||||
// output pins (also only for variable spindle, I think).
|
|
||||||
|
|
||||||
//// Other chip features not needed yet for grbl:
|
|
||||||
// writes to TCNT0 prevent compare match (need write detector.)
|
|
||||||
// force output compare (unused)
|
|
||||||
// input capture (unused and how would we signal it?)
|
|
||||||
// define the other output compare registers.
|
|
||||||
// usercode can clear unhandled interrupt flags by writing 1.
|
|
||||||
// --(this may be impossible, since bit was 1 before the write.)
|
|
||||||
// prescaler reset.
|
|
||||||
// maybe need to cli on interrupt entry
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
interrupt.h - replacement for the avr include of the same name to provide
|
|
||||||
dummy register variables and macros
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef interrupt_h
|
|
||||||
#define interrupt_h
|
|
||||||
|
|
||||||
// macros to turn avr interrupts into regular functions
|
|
||||||
//#define TIMER1_COMPA_vect
|
|
||||||
#define ISR(a) void interrupt_ ## a ()
|
|
||||||
|
|
||||||
// Stubs of the hardware interrupt functions we are using
|
|
||||||
void interrupt_TIMER0_COMPA_vect();
|
|
||||||
void interrupt_TIMER1_COMPA_vect();
|
|
||||||
void interrupt_TIMER0_OVF_vect();
|
|
||||||
void interrupt_SERIAL_UDRE();
|
|
||||||
void interrupt_SERIAL_RX();
|
|
||||||
void interrupt_LIMIT_INT_vect();
|
|
||||||
void interrupt_WDT_vect();
|
|
||||||
|
|
||||||
|
|
||||||
//pseudo-Interrupt vector table
|
|
||||||
typedef void(*isr_fp)(void);
|
|
||||||
extern isr_fp compa_vect[6];
|
|
||||||
extern isr_fp compb_vect[6];
|
|
||||||
extern isr_fp ovf_vect[6];
|
|
||||||
extern isr_fp wdt_vect;
|
|
||||||
extern isr_fp pc_vect; //pin change
|
|
||||||
|
|
||||||
// enable interrupts now does something in the simulation environment
|
|
||||||
#define SEI 0x80
|
|
||||||
void sei();
|
|
||||||
void cli();
|
|
||||||
|
|
||||||
//simulate timer operation
|
|
||||||
void timer_interrupts();
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,4 +0,0 @@
|
|||||||
#include "io.h"
|
|
||||||
|
|
||||||
// dummy register variables
|
|
||||||
volatile io_sim_t io={{0}};
|
|
224
sim/avr/io.h
224
sim/avr/io.h
@ -1,224 +0,0 @@
|
|||||||
/*
|
|
||||||
interrupt.h - replacement for the avr include of the same name to provide
|
|
||||||
dummy register variables and macros
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012-2104 Jens Geisler, Adam Shelly
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef io_h
|
|
||||||
#define io_h
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
union hilo16 {
|
|
||||||
uint16_t w;
|
|
||||||
struct {
|
|
||||||
uint8_t l; //TODO: check that these are right order on x86. Doesn't matter for current usage, but might someday
|
|
||||||
uint8_t h;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
SIM_A, SIM_B, SIM_C, SIM_D, SIM_E,
|
|
||||||
SIM_F, SIM_G, SIM_H, SIM_J, SIM_K, SIM_L,
|
|
||||||
SIM_PORT_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SIM_N_TIMERS 3 //328p has 3, Mega has 6
|
|
||||||
|
|
||||||
|
|
||||||
// dummy register variables
|
|
||||||
typedef struct io_sim {
|
|
||||||
uint8_t ddr[SIM_PORT_COUNT];
|
|
||||||
uint8_t port[SIM_PORT_COUNT];
|
|
||||||
uint8_t pin[SIM_PORT_COUNT];
|
|
||||||
uint8_t timsk[SIM_N_TIMERS];
|
|
||||||
uint16_t ocra[SIM_N_TIMERS];
|
|
||||||
uint16_t ocrb[SIM_N_TIMERS];
|
|
||||||
uint16_t ocrc[SIM_N_TIMERS];
|
|
||||||
uint16_t tcnt[SIM_N_TIMERS]; //tcint0 is really only 8bit
|
|
||||||
uint8_t tccra[SIM_N_TIMERS];
|
|
||||||
uint8_t tccrb[SIM_N_TIMERS];
|
|
||||||
uint8_t tifr[SIM_N_TIMERS];
|
|
||||||
uint8_t pcicr;
|
|
||||||
uint8_t pcmsk[3];
|
|
||||||
uint8_t ucsr0[3];
|
|
||||||
uint8_t udr[3];
|
|
||||||
uint8_t gpior[3];
|
|
||||||
uint8_t mcusr;
|
|
||||||
uint8_t wdtcsr;
|
|
||||||
union hilo16 ubrr0;
|
|
||||||
|
|
||||||
uint16_t prescaler; //continuously running
|
|
||||||
uint8_t sreg;
|
|
||||||
|
|
||||||
} io_sim_t;
|
|
||||||
volatile extern io_sim_t io;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// dummy macros for interrupt related registers
|
|
||||||
#define PORTA io.port[SIM_A]
|
|
||||||
#define PORTB io.port[SIM_B]
|
|
||||||
#define PORTC io.port[SIM_C]
|
|
||||||
#define PORTD io.port[SIM_D]
|
|
||||||
#define PORTE io.port[SIM_E]
|
|
||||||
#define PORTF io.port[SIM_F]
|
|
||||||
#define PORTG io.port[SIM_G]
|
|
||||||
#define PORTH io.port[SIM_H]
|
|
||||||
#define PORTJ io.port[SIM_J]
|
|
||||||
#define PORTK io.port[SIM_K]
|
|
||||||
#define PORTL io.port[SIM_L]
|
|
||||||
|
|
||||||
#define DDRA io.ddr[SIM_A]
|
|
||||||
#define DDRB io.ddr[SIM_B]
|
|
||||||
#define DDRC io.ddr[SIM_C]
|
|
||||||
#define DDRD io.ddr[SIM_D]
|
|
||||||
#define DDRE io.ddr[SIM_E]
|
|
||||||
#define DDRF io.ddr[SIM_F]
|
|
||||||
#define DDRG io.ddr[SIM_G]
|
|
||||||
#define DDRH io.ddr[SIM_H]
|
|
||||||
#define DDRJ io.ddr[SIM_J]
|
|
||||||
#define DDRK io.ddr[SIM_K]
|
|
||||||
#define DDRL io.ddr[SIM_L]
|
|
||||||
|
|
||||||
#define PINA io.pin[SIM_A]
|
|
||||||
#define PINB io.pin[SIM_B]
|
|
||||||
#define PINC io.pin[SIM_C]
|
|
||||||
#define PIND io.pin[SIM_D]
|
|
||||||
#define PINE io.pin[SIM_E]
|
|
||||||
#define PINF io.pin[SIM_F]
|
|
||||||
#define PING io.pin[SIM_G]
|
|
||||||
#define PINH io.pin[SIM_H]
|
|
||||||
#define PINJ io.pin[SIM_J]
|
|
||||||
#define PINK io.pin[SIM_K]
|
|
||||||
#define PINL io.pin[SIM_L]
|
|
||||||
|
|
||||||
|
|
||||||
#define TIMSK0 io.timsk[0]
|
|
||||||
#define TIMSK1 io.timsk[1]
|
|
||||||
#define TIMSK2 io.timsk[2]
|
|
||||||
#define TIMSK3 io.timsk[3]
|
|
||||||
#define TIMSK4 io.timsk[4]
|
|
||||||
#define TIMSK5 io.timsk[5]
|
|
||||||
|
|
||||||
|
|
||||||
#define SIM_TOV 0
|
|
||||||
#define SIM_OCA 1
|
|
||||||
#define SIM_OCB 2
|
|
||||||
#define SIM_OCC 3
|
|
||||||
#define SIM_ICI 5
|
|
||||||
#define SIM_ROLL 7 //stealing reserved TIFR bit
|
|
||||||
|
|
||||||
#define OCIE0A SIM_OCA
|
|
||||||
#define OCIE0B SIM_OCB
|
|
||||||
#define TOIE0 SIM_TOV
|
|
||||||
|
|
||||||
#define ICIE1 SIM_ICI
|
|
||||||
#define OCIE1C SIM_OCC
|
|
||||||
#define OCIE1B SIM_OCB
|
|
||||||
#define OCIE1A SIM_OCA
|
|
||||||
#define TOIE1 SIM_ICI
|
|
||||||
|
|
||||||
#define ICIE2 SIM_ICI
|
|
||||||
#define OCIE2C SIM_OCC
|
|
||||||
#define OCIE2B SIM_OCB
|
|
||||||
#define OCIE2A SIM_OCA
|
|
||||||
#define TOIE2 SIM_TOV
|
|
||||||
|
|
||||||
#define OCR0A io.ocra[0]
|
|
||||||
#define OCR1A io.ocra[1]
|
|
||||||
#define OCR2A io.ocra[2]
|
|
||||||
//There are more..
|
|
||||||
|
|
||||||
|
|
||||||
#define TCNT0 io.tcnt[0]
|
|
||||||
#define TCNT1 io.tcnt[1]
|
|
||||||
#define TCNT2 io.tcnt[2]
|
|
||||||
|
|
||||||
#define TCCR0A io.tccra[0]
|
|
||||||
#define TCCR0B io.tccrb[0]
|
|
||||||
#define TCCR1A io.tccra[1]
|
|
||||||
#define TCCR1B io.tccrb[1]
|
|
||||||
#define TCCR2A io.tccra[2]
|
|
||||||
#define TCCR2B io.tccrb[2]
|
|
||||||
|
|
||||||
#define CS00 0
|
|
||||||
#define CS01 1
|
|
||||||
#define CS12 2
|
|
||||||
#define CS11 1
|
|
||||||
#define CS10 0
|
|
||||||
#define CS21 1
|
|
||||||
|
|
||||||
#define WGM13 4
|
|
||||||
#define WGM12 3
|
|
||||||
#define WGM11 1
|
|
||||||
#define WGM10 0
|
|
||||||
#define WGM21 1
|
|
||||||
|
|
||||||
#define COM1A1 7
|
|
||||||
#define COM1A0 6
|
|
||||||
#define COM1B1 5
|
|
||||||
#define COM1B0 4
|
|
||||||
#define COM1C1 3
|
|
||||||
#define COM1C0 2
|
|
||||||
|
|
||||||
|
|
||||||
#define PCICR io.pcicr
|
|
||||||
#define PCIE0 0
|
|
||||||
#define PCIE1 1
|
|
||||||
#define PCIE2 2
|
|
||||||
|
|
||||||
//serial channel
|
|
||||||
#define UCSR0A io.ucsr0[SIM_A]
|
|
||||||
#define UCSR0B io.ucsr0[SIM_B]
|
|
||||||
#define UDR0 io.udr[0]
|
|
||||||
#define UDRIE0 0
|
|
||||||
#define RXCIE0 1
|
|
||||||
#define RXEN0 2
|
|
||||||
#define TXEN0 3
|
|
||||||
#define U2X0 4
|
|
||||||
#define UBRR0H io.ubrr0.h
|
|
||||||
#define UBRR0L io.ubrr0.l
|
|
||||||
|
|
||||||
#define PCMSK0 io.pcmsk[0]
|
|
||||||
#define PCMSK1 io.pcmsk[1]
|
|
||||||
#define PCMSK2 io.pcmsk[2]
|
|
||||||
|
|
||||||
//GPIO
|
|
||||||
#define GPIOR0 io.gpior[0]
|
|
||||||
#define GPIOR1 io.gpior[1]
|
|
||||||
#define GPIOR2 io.gpior[2]
|
|
||||||
|
|
||||||
//MCU Status
|
|
||||||
#define MCUSR io.mcusr
|
|
||||||
|
|
||||||
#define PORF 0
|
|
||||||
#define EXTRF 1
|
|
||||||
#define BORF 2
|
|
||||||
#define WDRF 3
|
|
||||||
#define JTRF 4
|
|
||||||
|
|
||||||
//Interrupt Status
|
|
||||||
#define SREG io.sreg
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
pgmspace.c - replacement for the avr library of the same name to provide
|
|
||||||
dummy functions
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// this is not really ever called in the simulation
|
|
||||||
char pgm_read_byte_near(const char* s) {
|
|
||||||
return s[0];
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
pgmspace.h - replacement for the avr include of the same name to provide
|
|
||||||
dummy functions andd macros
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef pgmspace_h
|
|
||||||
#define pgmspace_h
|
|
||||||
|
|
||||||
#define PSTR(s) s
|
|
||||||
|
|
||||||
char pgm_read_byte_near(const char* s);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
sleep.h - dummy replacement for the avr include of the same name
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
|||||||
#define WDTCSR wdt
|
|
||||||
#define WDP0 0
|
|
||||||
#define WDP1 1
|
|
||||||
#define WDP2 2
|
|
||||||
#define WDE 3
|
|
||||||
#define WDCE 4
|
|
||||||
#define WDP3 5
|
|
||||||
#define WDIE 6
|
|
||||||
#define WDIF 7
|
|
||||||
|
|
||||||
uint16_t wdt;
|
|
28
sim/config.h
28
sim/config.h
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
config.h - replacement for the include of the same name in grbl
|
|
||||||
to define dummy registers
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef config_h
|
|
||||||
#include "../config.h"
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
#define AUTO_REPORT_MOVE_DONE
|
|
||||||
#endif
|
|
95
sim/eeprom.c
95
sim/eeprom.c
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
eeprom.c - replacement for the avr library of the same name to provide
|
|
||||||
dummy functions
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// These are never called in the simulator
|
|
||||||
#include <stdio.h>
|
|
||||||
#define MAX_EEPROM_SIZE 4096 //4KB EEPROM in Mega
|
|
||||||
|
|
||||||
|
|
||||||
FILE* eeprom_create_empty_file(){
|
|
||||||
FILE* fp = fopen("EEPROM.DAT","w+b");
|
|
||||||
int i;
|
|
||||||
if (fp){
|
|
||||||
for(i=0;i<MAX_EEPROM_SIZE;i++){
|
|
||||||
fputc(0,fp);
|
|
||||||
}
|
|
||||||
fseek(fp,0,SEEK_SET);
|
|
||||||
}
|
|
||||||
return fp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FILE* eeprom_fp(){
|
|
||||||
static FILE* EEPROM_FP = NULL;
|
|
||||||
static int tried= 0;
|
|
||||||
if (!EEPROM_FP && !tried){
|
|
||||||
tried = 1;
|
|
||||||
EEPROM_FP = fopen("EEPROM.DAT","r+b");
|
|
||||||
if (!EEPROM_FP) {
|
|
||||||
EEPROM_FP = eeprom_create_empty_file();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return EEPROM_FP;
|
|
||||||
}
|
|
||||||
|
|
||||||
void eeprom_close(){
|
|
||||||
FILE* fp = eeprom_fp();
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
unsigned char eeprom_get_char( unsigned int addr ) {
|
|
||||||
|
|
||||||
FILE* fp = eeprom_fp();
|
|
||||||
if (fseek(fp,addr,SEEK_SET)) { return 0; } //no such address
|
|
||||||
return fgetc(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void eeprom_put_char( unsigned int addr, unsigned char new_value ) {
|
|
||||||
FILE* fp = eeprom_fp();
|
|
||||||
if (fseek(fp,addr,SEEK_SET)) { return; } //no such address
|
|
||||||
fputc(new_value, fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extensions added as part of Grbl
|
|
||||||
// KEEP IN SYNC WITH ../eeprom.c
|
|
||||||
|
|
||||||
void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size) {
|
|
||||||
unsigned char checksum = 0;
|
|
||||||
for(; size > 0; size--) {
|
|
||||||
checksum = (checksum << 1) || (checksum >> 7);
|
|
||||||
checksum += *source;
|
|
||||||
eeprom_put_char(destination++, *(source++));
|
|
||||||
}
|
|
||||||
eeprom_put_char(destination, checksum);
|
|
||||||
}
|
|
||||||
|
|
||||||
int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size) {
|
|
||||||
unsigned char data, checksum = 0;
|
|
||||||
for(; size > 0; size--) {
|
|
||||||
data = eeprom_get_char(source++);
|
|
||||||
checksum = (checksum << 1) || (checksum >> 7);
|
|
||||||
checksum += data;
|
|
||||||
*(destination++) = data;
|
|
||||||
}
|
|
||||||
return(checksum == eeprom_get_char(source));
|
|
||||||
}
|
|
||||||
|
|
||||||
// end of file
|
|
@ -1,3 +0,0 @@
|
|||||||
|
|
||||||
#include "../eeprom.h"
|
|
||||||
void eeprom_close();
|
|
@ -1,6 +0,0 @@
|
|||||||
t_= NaN
|
|
||||||
x_= NaN
|
|
||||||
y_= NaN
|
|
||||||
z_= NaN
|
|
||||||
|
|
||||||
splot 'HelloWorldSteps.dat' u 2:3:4:(dx= $2-x_,x_=$2,dy=$3-y_,y_=$3,dz=$4-z_,z_=$4,dt=$1-t_,t_=$1,sqrt(dx*dx+dy*dy+dz*dz)/(dt<0.01?0.01:dt)) title "Simulated steps with speed dependent coloring" with lines palette
|
|
166
sim/main.c
166
sim/main.c
@ -1,166 +0,0 @@
|
|||||||
/*
|
|
||||||
main.c - main grbl simulator program
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "../planner.h"
|
|
||||||
#include "../stepper.h"
|
|
||||||
#include "../gcode.h"
|
|
||||||
#include "../protocol.h"
|
|
||||||
#include "../nuts_bolts.h"
|
|
||||||
#include "../settings.h"
|
|
||||||
#include "../spindle_control.h"
|
|
||||||
#include "../limits.h"
|
|
||||||
#include "../coolant_control.h"
|
|
||||||
#include "simulator.h"
|
|
||||||
|
|
||||||
|
|
||||||
arg_vars_t args;
|
|
||||||
const char* progname;
|
|
||||||
|
|
||||||
int usage(const char* badarg){
|
|
||||||
if (badarg){
|
|
||||||
printf("Unrecognized option %s\n",badarg);
|
|
||||||
}
|
|
||||||
printf("Usage: \n"
|
|
||||||
"%s [options] [time_step] [block_file]\n"
|
|
||||||
" Options:\n"
|
|
||||||
" -r <report time> : minimum time step for printing stepper values. Default=0=no print.\n"
|
|
||||||
" -t <time factor> : multiplier to realtime clock. Default=1. (needs work)\n"
|
|
||||||
" -g <response file> : file to report responses from grbl. default = stdout\n"
|
|
||||||
" -b <block file> : file to report each block executed. default = stdout\n"
|
|
||||||
" -s <step file> : file to report each step executed. default = stderr\n"
|
|
||||||
" -c<comment_char> : character to print before each line from grbl. default = '#'\n"
|
|
||||||
" -n : no comments before grbl response lines.\n"
|
|
||||||
" -h : this help.\n"
|
|
||||||
"\n <time_step> and <block_file> can be specifed with option flags or positional parameters\n"
|
|
||||||
"\n ^-F to shutdown cleanly\n\n",
|
|
||||||
progname);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//prototype for renamed original main function
|
|
||||||
int avr_main(void);
|
|
||||||
//wrapper for thread interface
|
|
||||||
PLAT_THREAD_FUNC(avr_main_thread,exit){
|
|
||||||
avr_main();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
uint32_t tick_rate=1;
|
|
||||||
int positional_args=0;
|
|
||||||
|
|
||||||
//defaults
|
|
||||||
args.step_out_file = stderr;
|
|
||||||
args.block_out_file = stdout;
|
|
||||||
args.grbl_out_file = stdout;
|
|
||||||
args.comment_char = '#';
|
|
||||||
|
|
||||||
args.step_time = 0.0;
|
|
||||||
// Get the minimum time step for printing stepper values.
|
|
||||||
// If not given or the command line cannot be parsed to a float than
|
|
||||||
// step_time= 0.0; This means to not print stepper values at all
|
|
||||||
|
|
||||||
progname = argv[0];
|
|
||||||
while (argc>1) {
|
|
||||||
argv++;argc--;
|
|
||||||
if (argv[0][0] == '-'){
|
|
||||||
switch(argv[0][1]){
|
|
||||||
case 'c': //set Comment char
|
|
||||||
args.comment_char = argv[0][2];
|
|
||||||
break;
|
|
||||||
case 'n': //No comment char on grbl responses
|
|
||||||
args.comment_char = 0;
|
|
||||||
break;
|
|
||||||
case 't': //Tick rate
|
|
||||||
argv++;argc--;
|
|
||||||
tick_rate = atof(*argv);
|
|
||||||
break;
|
|
||||||
case 'b': //Block file
|
|
||||||
argv++;argc--;
|
|
||||||
args.block_out_file = fopen(*argv,"w");
|
|
||||||
break;
|
|
||||||
case 's': //Step out file.
|
|
||||||
argv++;argc--;
|
|
||||||
args.step_out_file = fopen(*argv,"w");
|
|
||||||
break;
|
|
||||||
case 'g': //Grbl output
|
|
||||||
argv++;argc--;
|
|
||||||
args.grbl_out_file = fopen(*argv,"w");
|
|
||||||
break;
|
|
||||||
case 'r': //step_time for Reporting
|
|
||||||
argv++;argc--;
|
|
||||||
args.step_time= atof(*argv);
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
return usage(NULL);
|
|
||||||
default:
|
|
||||||
return usage(*argv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else { //handle old positional argument interface
|
|
||||||
positional_args++;
|
|
||||||
switch(positional_args){
|
|
||||||
case 1:
|
|
||||||
args.step_time= atof(*argv);
|
|
||||||
break;
|
|
||||||
case 2: //block out and grbl out to same file, like before.
|
|
||||||
args.block_out_file = fopen(*argv,"w");
|
|
||||||
args.grbl_out_file = args.block_out_file;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return usage(*argv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure the output streams are flushed immediately.
|
|
||||||
// This is important when using the simulator inside another application in parallel
|
|
||||||
// to the real grbl.
|
|
||||||
// Theoretically flushing could be limited to complete lines. Unfortunately Windows
|
|
||||||
// does not know line buffered streams. So for now we stick to flushing every character.
|
|
||||||
//setvbuf(stdout, NULL, _IONBF, 1);
|
|
||||||
//setvbuf(stderr, NULL, _IONBF, 1);
|
|
||||||
//( Files are now closed cleanly when sim gets EOF or CTRL-F.)
|
|
||||||
platform_init();
|
|
||||||
|
|
||||||
init_simulator(tick_rate);
|
|
||||||
|
|
||||||
//launch a thread with the original grbl code.
|
|
||||||
plat_thread_t*th = platform_start_thread(avr_main_thread);
|
|
||||||
if (!th){
|
|
||||||
printf("Fatal: Unable to start hardware thread.\n");
|
|
||||||
exit(-5);
|
|
||||||
}
|
|
||||||
|
|
||||||
//All the stream io and interrupt happen in this thread.
|
|
||||||
sim_loop();
|
|
||||||
|
|
||||||
platform_kill_thread(th); //need force kill since original main has no return.
|
|
||||||
|
|
||||||
// Graceful exit
|
|
||||||
shutdown_simulator(0);
|
|
||||||
platform_terminate();
|
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
#include "../planner.h"
|
|
||||||
|
|
||||||
static plan_block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions
|
|
||||||
plan_block_t *get_block_buffer() { return block_buffer; }
|
|
||||||
|
|
||||||
static uint8_t block_buffer_head; // Index of the next block to be pushed
|
|
||||||
uint8_t get_block_buffer_head() { return block_buffer_head; }
|
|
||||||
|
|
||||||
static uint8_t block_buffer_tail; // Index of the next block to be pushed
|
|
||||||
uint8_t get_block_buffer_tail() { return block_buffer_tail; }
|
|
@ -1,23 +0,0 @@
|
|||||||
#ifndef platform_h
|
|
||||||
|
|
||||||
#ifdef PLAT_LINUX
|
|
||||||
#include "platform_linux.h"
|
|
||||||
#else
|
|
||||||
#include "platform_windows.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define platform_h
|
|
||||||
|
|
||||||
void platform_init();
|
|
||||||
void platform_terminate();
|
|
||||||
|
|
||||||
plat_thread_t* platform_start_thread(plat_threadfunc_t func);
|
|
||||||
void platform_stop_thread(plat_thread_t* thread);
|
|
||||||
void platform_kill_thread(plat_thread_t* thread);
|
|
||||||
|
|
||||||
uint32_t platform_ns(); //monotonically increasing nanoseconds since program start.
|
|
||||||
void platform_sleep(long microsec); //sleep for suggested time in microsec.
|
|
||||||
|
|
||||||
uint8_t platform_poll_stdin(); //non-blocking stdin read - returns 0 if no char present, 0xFF for EOF
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,116 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#define MS_PER_SEC 1000000
|
|
||||||
|
|
||||||
|
|
||||||
//any platform-specific setup that must be done before sim starts here
|
|
||||||
void platform_init()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//cleanup int here;
|
|
||||||
void platform_terminate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//returns a free-running 32 bit nanosecond counter which rolls over
|
|
||||||
uint32_t platform_ns()
|
|
||||||
{
|
|
||||||
static uint32_t gTimeBase = 0;
|
|
||||||
struct timespec ts;
|
|
||||||
clock_gettime(CLOCK_MONOTONIC,&ts);
|
|
||||||
if (gTimeBase== 0){gTimeBase=ts.tv_nsec;}
|
|
||||||
return ts.tv_nsec-gTimeBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
//sleep in microseconds
|
|
||||||
void platform_sleep(long microsec)
|
|
||||||
{
|
|
||||||
struct timespec ts={0};
|
|
||||||
while (microsec >= MS_PER_SEC){
|
|
||||||
ts.tv_sec++;
|
|
||||||
microsec-=MS_PER_SEC;
|
|
||||||
}
|
|
||||||
ts.tv_nsec = microsec*1000;
|
|
||||||
nanosleep(&ts,NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SIM_ECHO_TERMINAL 1 //use this to make grbl_sim act like a serial terminal with local echo on.
|
|
||||||
|
|
||||||
//set terminal to allow kbhit detection
|
|
||||||
void enable_kbhit(int dir)
|
|
||||||
{
|
|
||||||
static struct termios oldt, newt;
|
|
||||||
|
|
||||||
if ( dir == 1 )
|
|
||||||
{
|
|
||||||
tcgetattr( STDIN_FILENO, &oldt);
|
|
||||||
newt = oldt;
|
|
||||||
newt.c_lflag &= ~( ICANON );
|
|
||||||
if (!SIM_ECHO_TERMINAL) {
|
|
||||||
newt.c_lflag &= ~( ECHO );
|
|
||||||
}
|
|
||||||
tcsetattr( STDIN_FILENO, TCSANOW, &newt);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
tcsetattr( STDIN_FILENO, TCSANOW, &oldt);
|
|
||||||
}
|
|
||||||
|
|
||||||
//detect key pressed
|
|
||||||
int kbhit (void)
|
|
||||||
{
|
|
||||||
struct timeval tv={0};
|
|
||||||
fd_set rdfs={{0}};
|
|
||||||
int retval;
|
|
||||||
|
|
||||||
/* tv.tv_sec = 0; */
|
|
||||||
/* tv.tv_usec = 0; */
|
|
||||||
|
|
||||||
/* FD_ZERO(&rdfs); */
|
|
||||||
FD_SET (STDIN_FILENO, &rdfs);
|
|
||||||
|
|
||||||
select(STDIN_FILENO+1, &rdfs, NULL, NULL, &tv);
|
|
||||||
retval = FD_ISSET(STDIN_FILENO, &rdfs);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
plat_thread_t* platform_start_thread(plat_threadfunc_t threadfunc) {
|
|
||||||
plat_thread_t* th = malloc(sizeof(plat_thread_t));
|
|
||||||
if (pthread_create(&th->tid, NULL, threadfunc, &th->exit)){
|
|
||||||
free(th);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return th;
|
|
||||||
}
|
|
||||||
|
|
||||||
//ask thread to exit nicely, wait
|
|
||||||
void platform_stop_thread(plat_thread_t* th){
|
|
||||||
th->exit = 1;
|
|
||||||
pthread_join(th->tid,NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
//force-kill thread
|
|
||||||
void platform_kill_thread(plat_thread_t* th){
|
|
||||||
th->exit = 1;
|
|
||||||
pthread_cancel(th->tid);
|
|
||||||
}
|
|
||||||
|
|
||||||
//return char if one available.
|
|
||||||
uint8_t platform_poll_stdin() {
|
|
||||||
uint8_t char_in=0;
|
|
||||||
enable_kbhit(1);
|
|
||||||
if ( kbhit()) {
|
|
||||||
char_in = getchar();
|
|
||||||
}
|
|
||||||
enable_kbhit(0);
|
|
||||||
return char_in;
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <conio.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#define NS_PER_SEC 1000000000
|
|
||||||
#define MICRO_PER_MILLI 1000
|
|
||||||
|
|
||||||
double ns_per_perfcount;
|
|
||||||
|
|
||||||
//any platform-specific setup that must be done before sim starts here
|
|
||||||
void platform_init()
|
|
||||||
{
|
|
||||||
__int64 counts_per_sec;
|
|
||||||
QueryPerformanceFrequency((LARGE_INTEGER*)&counts_per_sec);
|
|
||||||
ns_per_perfcount = (float)NS_PER_SEC / counts_per_sec;
|
|
||||||
}
|
|
||||||
|
|
||||||
//cleanup int here;
|
|
||||||
void platform_terminate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//returns a free-running 32 bit nanosecond counter which rolls over
|
|
||||||
uint32_t platform_ns()
|
|
||||||
{
|
|
||||||
static uint32_t gTimeBase = 0;
|
|
||||||
__int64 counts;
|
|
||||||
uint32_t ns;
|
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*)&counts);
|
|
||||||
ns = (counts*ns_per_perfcount);
|
|
||||||
|
|
||||||
if (gTimeBase== 0){gTimeBase=ns;}
|
|
||||||
return ns-gTimeBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
//sleep in microseconds
|
|
||||||
void platform_sleep(long microsec)
|
|
||||||
{
|
|
||||||
Sleep(microsec/MICRO_PER_MILLI);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//create a thread
|
|
||||||
plat_thread_t* platform_start_thread(plat_threadfunc_t threadfunc) {
|
|
||||||
plat_thread_t* th = malloc(sizeof(plat_thread_t));
|
|
||||||
th->tid = CreateThread(NULL,0,threadfunc,&th->exit,0,NULL);
|
|
||||||
if (!th->tid){
|
|
||||||
free(th);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return th;
|
|
||||||
}
|
|
||||||
|
|
||||||
//ask thread to exit nicely, wait
|
|
||||||
void platform_stop_thread(plat_thread_t* th){
|
|
||||||
th->exit = 1;
|
|
||||||
WaitForSingleObject(th->tid,INFINITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//force-kill thread
|
|
||||||
void platform_kill_thread(plat_thread_t* th){
|
|
||||||
th->exit = 1;
|
|
||||||
TerminateThread(th->tid, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//return char if one available.
|
|
||||||
uint8_t platform_poll_stdin() {
|
|
||||||
if (_kbhit()) {
|
|
||||||
return getch();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
#ifdef platform_h
|
|
||||||
#error "platform implementation already defined"
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
pthread_t tid;
|
|
||||||
int exit;
|
|
||||||
} plat_thread_t;
|
|
||||||
|
|
||||||
typedef void*(*plat_threadfunc_t)(void*);
|
|
||||||
#define PLAT_THREAD_FUNC(name,arg) void* name(void* arg)
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,16 +0,0 @@
|
|||||||
#ifdef platform_h
|
|
||||||
#error "platform implementation already defined"
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
HANDLE tid;
|
|
||||||
int exit;
|
|
||||||
} plat_thread_t;
|
|
||||||
|
|
||||||
typedef DWORD WINAPI(*plat_threadfunc_t)(LPVOID);
|
|
||||||
#define PLAT_THREAD_FUNC(name,arg) DWORD WINAPI name(LPVOID arg)
|
|
||||||
|
|
||||||
#endif
|
|
@ -1 +0,0 @@
|
|||||||
#define main avr_main
|
|
74
sim/serial.c
74
sim/serial.c
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
serial.c - replacement for the modul of the same name in grbl
|
|
||||||
Make sure the simulator reads from stdin and writes to stdout.
|
|
||||||
Also print info about the last buffered block.
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../serial.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "simulator.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
//prototypes for overridden functions
|
|
||||||
uint8_t orig_serial_read();
|
|
||||||
|
|
||||||
//used to inject a sleep in grbl main loop,
|
|
||||||
// ensures hardware simulator gets some cycles in "parallel"
|
|
||||||
uint8_t serial_read() {
|
|
||||||
platform_sleep(0);
|
|
||||||
return orig_serial_read();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void simulate_write_interrupt(){
|
|
||||||
while (UCSR0B & (1<<UDRIE0)){
|
|
||||||
interrupt_SERIAL_UDRE();
|
|
||||||
grbl_out(UDR0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void simulate_read_interrupt(){
|
|
||||||
uint8_t char_in = platform_poll_stdin();
|
|
||||||
if (char_in) {
|
|
||||||
UDR0 = char_in;
|
|
||||||
//EOF or CTRL-F to exit
|
|
||||||
if (UDR0 == EOF || UDR0 == 0xFF || UDR0 == 0x06 ) {
|
|
||||||
sim.exit = 1;
|
|
||||||
}
|
|
||||||
//debugging
|
|
||||||
if (UDR0 == '%') {
|
|
||||||
printf("%ld %f\n",sim.masterclock,(double)sim.sim_time);
|
|
||||||
}
|
|
||||||
interrupt_SERIAL_RX();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern volatile uint8_t rx_buffer_head;
|
|
||||||
extern volatile uint8_t rx_buffer_tail;
|
|
||||||
void simulate_serial(){
|
|
||||||
simulate_write_interrupt();
|
|
||||||
uint8_t head = rx_buffer_head+1;
|
|
||||||
if (head==RX_BUFFER_SIZE) { head = 0; }
|
|
||||||
if (head!=rx_buffer_tail) {
|
|
||||||
simulate_read_interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
#define serial_read orig_serial_read
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
grbl_sim.exe 0.01 <HelloWorld.nc >HelloWorld.dat 2> HelloWorldSteps.dat
|
|
@ -1,2 +0,0 @@
|
|||||||
./grbl_sim.exe 0.01 <HelloWorld.nc >HelloWorld.dat 2> HelloWorldSteps.dat
|
|
||||||
gnuplot -persist gnuplot.plt
|
|
228
sim/simulator.c
228
sim/simulator.c
@ -1,228 +0,0 @@
|
|||||||
/*
|
|
||||||
simulator.c - functions to simulate how the buffer is emptied and the
|
|
||||||
stepper interrupt is called
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012-2014 Jens Geisler, Adam Shelly
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "../stepper.h"
|
|
||||||
#include "../planner.h"
|
|
||||||
#include "../nuts_bolts.h"
|
|
||||||
#include "simulator.h"
|
|
||||||
#include "avr/interrupt.h" //for registers and isr declarations.
|
|
||||||
#include "eeprom.h"
|
|
||||||
|
|
||||||
|
|
||||||
int block_position[N_AXIS]= {0}; //step count after most recently planned block
|
|
||||||
uint32_t block_number= 0;
|
|
||||||
|
|
||||||
sim_vars_t sim={0};
|
|
||||||
|
|
||||||
//local prototypes
|
|
||||||
void print_steps(bool force);
|
|
||||||
|
|
||||||
|
|
||||||
//setup
|
|
||||||
void init_simulator(float time_multiplier) {
|
|
||||||
|
|
||||||
//register the interrupt handlers we actually use.
|
|
||||||
compa_vect[1] = interrupt_TIMER1_COMPA_vect;
|
|
||||||
ovf_vect[0] = interrupt_TIMER0_OVF_vect;
|
|
||||||
#ifdef STEP_PULSE_DELAY
|
|
||||||
compa_vect[0] = interrupt_TIMER0_COMPA_vect;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_SOFTWARE_DEBOUNCE
|
|
||||||
wdt_vect = interrupt_WDT_vect;
|
|
||||||
#endif
|
|
||||||
pc_vect = interrupt_LIMIT_INT_vect;
|
|
||||||
|
|
||||||
|
|
||||||
sim.next_print_time = args.step_time;
|
|
||||||
sim.speedup = time_multiplier;
|
|
||||||
sim.baud_ticks = (int)((double)F_CPU*8/BAUD_RATE); //ticks per byte
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//shutdown simulator - close open files
|
|
||||||
int shutdown_simulator(uint8_t exitflag) {
|
|
||||||
fclose(args.block_out_file);
|
|
||||||
print_steps(1);
|
|
||||||
fclose(args.step_out_file);
|
|
||||||
fclose(args.grbl_out_file);
|
|
||||||
eeprom_close();
|
|
||||||
return 1/(!exitflag); //force exception, since avr_main() has no returns.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void simulate_hardware(bool do_serial){
|
|
||||||
|
|
||||||
//do one tick
|
|
||||||
sim.masterclock++;
|
|
||||||
sim.sim_time = (float)sim.masterclock/F_CPU;
|
|
||||||
|
|
||||||
timer_interrupts();
|
|
||||||
|
|
||||||
if (do_serial) simulate_serial();
|
|
||||||
|
|
||||||
//TODO:
|
|
||||||
// check limit pins, call pinchange interrupt if enabled
|
|
||||||
// can ignore pinout int vect - hw start/hold not supported
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//runs the hardware simulator at the desired rate until sim.exit is set
|
|
||||||
void sim_loop(){
|
|
||||||
uint64_t simulated_ticks=0;
|
|
||||||
uint32_t ns_prev = platform_ns();
|
|
||||||
uint64_t next_byte_tick = F_CPU; //wait 1 sec before reading IO.
|
|
||||||
|
|
||||||
while (!sim.exit || sys.state>2 ) { //don't quit until idle
|
|
||||||
|
|
||||||
if (sim.speedup) {
|
|
||||||
//calculate how many ticks to do.
|
|
||||||
uint32_t ns_now = platform_ns();
|
|
||||||
uint32_t ns_elapsed = (ns_now-ns_prev)*sim.speedup; //todo: try multipling nsnow
|
|
||||||
simulated_ticks += F_CPU/1e9*ns_elapsed;
|
|
||||||
ns_prev = ns_now;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
simulated_ticks++; //as fast as possible
|
|
||||||
}
|
|
||||||
|
|
||||||
while (sim.masterclock < simulated_ticks){
|
|
||||||
|
|
||||||
//only read serial port as fast as the baud rate allows
|
|
||||||
bool read_serial = (sim.masterclock >= next_byte_tick);
|
|
||||||
|
|
||||||
//do low level hardware
|
|
||||||
simulate_hardware(read_serial);
|
|
||||||
|
|
||||||
//print the steps.
|
|
||||||
//For further decoupling, could maintain own counter of STEP_PORT pulses,
|
|
||||||
// print that instead of sys.position.
|
|
||||||
print_steps(0);
|
|
||||||
|
|
||||||
if (read_serial){
|
|
||||||
next_byte_tick+=sim.baud_ticks;
|
|
||||||
//recent block can only change after input, so check here.
|
|
||||||
printBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO:
|
|
||||||
// set limit pins based on position,
|
|
||||||
// set probe pin when probing.
|
|
||||||
// if VARIABLE_SPINDLE, measure pwm pin to report speed?
|
|
||||||
}
|
|
||||||
|
|
||||||
platform_sleep(0); //yield
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//show current position in steps
|
|
||||||
void print_steps(bool force)
|
|
||||||
{
|
|
||||||
static plan_block_t* printed_block = NULL;
|
|
||||||
plan_block_t* current_block = plan_get_current_block();
|
|
||||||
|
|
||||||
if (sim.next_print_time == 0.0) { return; } //no printing
|
|
||||||
if (current_block != printed_block ) {
|
|
||||||
//new block.
|
|
||||||
if (block_number) { //print values from the end of prev block
|
|
||||||
fprintf(args.step_out_file, "%20.15f %d, %d, %d\n", sim.sim_time, sys.position[X_AXIS], sys.position[Y_AXIS], sys.position[Z_AXIS]);
|
|
||||||
}
|
|
||||||
printed_block = current_block;
|
|
||||||
if (current_block == NULL) { return; }
|
|
||||||
// print header
|
|
||||||
fprintf(args.step_out_file, "# block number %d\n", block_number++);
|
|
||||||
}
|
|
||||||
//print at correct interval while executing block
|
|
||||||
else if ((current_block && sim.sim_time>=sim.next_print_time) || force ) {
|
|
||||||
fprintf(args.step_out_file, "%20.15f %d, %d, %d\n", sim.sim_time, sys.position[X_AXIS], sys.position[Y_AXIS], sys.position[Z_AXIS]);
|
|
||||||
fflush(args.step_out_file);
|
|
||||||
|
|
||||||
//make sure the simulation time doesn't get ahead of next_print_time
|
|
||||||
while (sim.next_print_time<=sim.sim_time) sim.next_print_time += args.step_time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Functions for peeking inside planner state:
|
|
||||||
plan_block_t *get_block_buffer();
|
|
||||||
uint8_t get_block_buffer_head();
|
|
||||||
uint8_t get_block_buffer_tail();
|
|
||||||
|
|
||||||
// Returns the index of the previous block in the ring buffer
|
|
||||||
uint8_t prev_block_index(uint8_t block_index)
|
|
||||||
{
|
|
||||||
if (block_index == 0) { block_index = BLOCK_BUFFER_SIZE; }
|
|
||||||
block_index--;
|
|
||||||
return(block_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
plan_block_t *plan_get_recent_block() {
|
|
||||||
if (get_block_buffer_head() == get_block_buffer_tail()) { return(NULL); }
|
|
||||||
return(get_block_buffer()+prev_block_index(get_block_buffer_head()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print information about the most recently inserted block
|
|
||||||
// but only once!
|
|
||||||
void printBlock() {
|
|
||||||
plan_block_t *b;
|
|
||||||
static plan_block_t *last_block;
|
|
||||||
|
|
||||||
b= plan_get_recent_block();
|
|
||||||
if(b!=last_block && b!=NULL) {
|
|
||||||
int i;
|
|
||||||
for (i=0;i<N_AXIS;i++){
|
|
||||||
if(b->direction_bits & get_direction_mask(i)) block_position[i]-= b->steps[i];
|
|
||||||
else block_position[i]+= b->steps[i];
|
|
||||||
fprintf(args.block_out_file,"%d, ", block_position[i]);
|
|
||||||
}
|
|
||||||
fprintf(args.block_out_file,"%f", b->entry_speed_sqr);
|
|
||||||
fprintf(args.block_out_file,"\n");
|
|
||||||
fflush(args.block_out_file); //TODO: needed?
|
|
||||||
|
|
||||||
last_block= b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//printer for grbl serial port output
|
|
||||||
void grbl_out(uint8_t data){
|
|
||||||
static uint8_t buf[128]={0};
|
|
||||||
static uint8_t len=0;
|
|
||||||
static bool continuation = 0;
|
|
||||||
|
|
||||||
buf[len++]=data;
|
|
||||||
if(data=='\n' || data=='\r' || len>=127) {
|
|
||||||
if (args.comment_char && !continuation){
|
|
||||||
fprintf(args.grbl_out_file,"%c ",args.comment_char);
|
|
||||||
}
|
|
||||||
buf[len]=0;
|
|
||||||
fprintf(args.grbl_out_file,"%s",buf);
|
|
||||||
continuation = (len>=128); //print comment on next line unless we are only printing to avoid buffer overflow)
|
|
||||||
len=0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
simulator.h - functions to simulate how the buffer is emptied and the
|
|
||||||
stepper interrupt is called
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef simulator_h
|
|
||||||
#define simulator_h
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "../nuts_bolts.h"
|
|
||||||
#include "../system.h"
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
//simulation globals
|
|
||||||
typedef struct sim_vars {
|
|
||||||
uint64_t masterclock;
|
|
||||||
double sim_time; //current time of the simulation
|
|
||||||
uint8_t started; //don't start timers until first char recieved.
|
|
||||||
uint8_t exit;
|
|
||||||
float speedup;
|
|
||||||
int32_t baud_ticks;
|
|
||||||
double next_print_time;
|
|
||||||
|
|
||||||
} sim_vars_t;
|
|
||||||
extern sim_vars_t sim;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct arg_vars {
|
|
||||||
// Output file handles
|
|
||||||
FILE *block_out_file;
|
|
||||||
FILE *step_out_file;
|
|
||||||
FILE *grbl_out_file;
|
|
||||||
// Minimum time step for printing stepper values. //Given by user via command line
|
|
||||||
double step_time;
|
|
||||||
//char to prefix comments; default '#'
|
|
||||||
uint8_t comment_char;
|
|
||||||
|
|
||||||
} arg_vars_t;
|
|
||||||
extern arg_vars_t args;
|
|
||||||
|
|
||||||
|
|
||||||
// global system variable structure for position etc.
|
|
||||||
extern system_t sys;
|
|
||||||
|
|
||||||
// setup avr simulation
|
|
||||||
void init_simulator(float time_multiplier);
|
|
||||||
|
|
||||||
//shutdown simulator - close open files
|
|
||||||
int shutdown_simulator(uint8_t exitflag);
|
|
||||||
|
|
||||||
//simulates the hardware until sim.exit is set.
|
|
||||||
void sim_loop();
|
|
||||||
|
|
||||||
// Call the stepper interrupt until one block is finished
|
|
||||||
void simulate_serial();
|
|
||||||
|
|
||||||
// Print information about the most recently inserted block
|
|
||||||
void printBlock();
|
|
||||||
|
|
||||||
//printer for grbl serial port output
|
|
||||||
void grbl_out(uint8_t char_out);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
delay.c - replacement for the avr library of the same name to provide
|
|
||||||
dummy functions
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: the simulation time should reflect when grbl dwells
|
|
||||||
// Maybe this becomes a no-issue when dwell is executed in a buffered block
|
|
||||||
void _delay_ms(int i) {}
|
|
||||||
|
|
||||||
void _delay_us(int i) {}
|
|
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
delay.h - replacement for the avr include of the same name to provide
|
|
||||||
dummy functions
|
|
||||||
|
|
||||||
Part of Grbl Simulator
|
|
||||||
|
|
||||||
Copyright (c) 2012 Jens Geisler
|
|
||||||
|
|
||||||
Grbl is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Grbl is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef delay_h
|
|
||||||
#define delay_h
|
|
||||||
|
|
||||||
void _delay_ms(int i);
|
|
||||||
void _delay_us(int i);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,3 +0,0 @@
|
|||||||
float __floatunsisf (unsigned long v) {
|
|
||||||
return v;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user