201 Commits
Video7 ... main

Author SHA1 Message Date
MetalMusings
9cc9a41ea2 Moved SetupTime and pulseLength to sdos. 2025-10-22 17:18:02 +02:00
Hakan Bastedt
a6b70bf6c6 Added syncToRefClock option 2025-10-21 21:54:32 +02:00
Hakan Bastedt
cf4bece469 Indentation 2025-10-21 21:53:51 +02:00
Hakan Bastedt
cd78577e4d Updated to read voltage from ground clamp
instead of ground in the plasma, which obviously
isn't the´real thing.
2025-10-21 21:51:53 +02:00
Hakan Bastedt
2a92e97aaa Apply voltage on work piece, not torch cable
Also read voltage on work piece
2025-10-19 09:54:27 +02:00
Hakan Bastedt
a19a3b5b4e Got hypersensing to work pretty reliably now.
Unfortunately indentation changes.
2025-10-18 21:36:26 +02:00
Hakan Bastedt
924ab972cb Removed states after probe started. Once probig, continue probe 2025-10-14 13:00:52 +02:00
Hakan Bastedt
08915ef4bb Cleaning of code. 2025-10-13 23:34:14 +02:00
Hakan Bastedt
f253ce8482 Only free run, no DC or SM2 sync 2025-10-13 22:07:05 +02:00
Hakan Bastedt
93c48940b8 Improved sensing algo, to only generate one 100 ms pulse every sense.
Also some more conditions to make probing more reliable.
2025-10-13 18:15:04 +02:00
Hakan Bastedt
b3bb88cf08 New option: voltagedrop for sensing ohmic sensing 2025-10-08 13:29:54 +02:00
Hakan Bastedt
b867d58b15 Added criteria voltage of 2 V means ohmic sense hit
Added criteria voltage drop of 2V over the 3 last cycles also means sense hit.
2025-10-07 22:46:47 +02:00
Hakan Bastedt
2770c70d90 Updated short-circuit resistor to 4k7 for more stable voltage. 2025-10-07 22:45:26 +02:00
Hakan Bastedt
719f1755fe Implemented setup time for sensing.
That is the time to wait from sensing signal received until measuring to allow
relay to activate, debounce and all that.

And changed to indentation style so the whole file looks edited buts it's only partially.
2025-10-07 11:18:56 +02:00
Hakan Bastedt
c31249b603 Larger MaxAcceleration values in eeprom. New axis_mm.ini file for testing 2025-08-20 11:09:33 +02:00
Hakan Bastedt
dcce7b5375 After testing, seems to work. Not tested: encoder,frequency,dac 2025-08-17 21:24:47 +02:00
Hakan Bastedt
430eedd77d Merged fix for too many PDOs\? and a new example 2025-08-17 20:41:59 +02:00
Hakan Bastedt
dac61fbba5 Moved PDOs to SDOs, made an example config 2025-08-17 20:01:12 +02:00
Hakan Bastedt
15d25ab06d Remove frequency counter on encoder pins (THCAD test) 2025-08-06 21:20:56 +02:00
Hakan Bastedt
44a15a21f8 Updated encoder 2025-08-06 21:02:22 +02:00
Hakan Bastedt
90a2d4dd32 Wip 2025-08-06 18:28:59 +02:00
Hakan Bastedt
4b3567aa45 Updated for THCLIP 2025-06-09 10:19:00 +02:00
Hakan Bastedt
28a3edc8b8 Updated for THCLIP 2025-06-09 10:14:12 +02:00
Hakan Bastedt
6dc4d9fa03 Updated for THCLIP 2025-06-09 10:12:49 +02:00
Hakan Bastedt
dfabecc28e updated process description more 2025-06-07 19:38:02 +02:00
Hakan Bastedt
f34c5ebe9b updated process description 2025-06-07 19:33:55 +02:00
MetalMusings
7ffe9158df Reference to a pointer also for MCP3221 2025-06-07 17:29:44 +02:00
MetalMusings
c6d88beb56 Ohmic sensing works 2025-06-07 17:04:30 +02:00
MetalMusings
d7a2110a67 Two voltage readers and ohmic sensing unitas 2025-06-07 14:43:35 +02:00
Hakan Bastedt
3c61897b8e Reshuffle and add second reader. 2025-06-07 09:53:48 +02:00
Hakan Bastedt
81b930b290 Cleaned schematics 2025-06-03 17:19:16 +02:00
Håkan Båstedt
6d7d20774d Update README.md 2025-06-02 14:49:23 +02:00
Håkan Båstedt
a0a4d5d9f3 Update README.md 2025-06-02 14:48:49 +02:00
Hakan Bastedt
bd5d77395f THCLIP released 2025-06-02 14:45:18 +02:00
Hakan Bastedt
e4c3f14809 THCLIP released 2025-06-02 14:45:01 +02:00
Hakan Bastedt
eb1d76ad3f Base period setting 2025-05-15 11:49:24 +02:00
Hakan Bastedt
f46140484b Added selection criteria for relay in Schematics 2025-04-28 10:21:38 +02:00
Hakan Bastedt
418aac0a35 Sent for fabrication. 2025-04-28 10:10:36 +02:00
Hakan Bastedt
73a34a2559 Renamed to THCLIP. Version 1. 2025-04-27 20:54:17 +02:00
Hakan Bastedt
20f1acdbeb THTIC3 - copy of THTIC 2025-04-26 11:22:28 +02:00
Hakan Bastedt
fe24b8f4a3 Lowpass filter of voltage now in client 2025-03-13 23:40:22 +01:00
Hakan Bastedt
ca4248ce2d New pictures 2025-03-10 15:47:47 +01:00
Hakan Bastedt
a73339d6ff Upload changes 2025-03-10 15:37:17 +01:00
Hakan Bastedt
9956a50722 Updated ethercat-conf.xml 2025-03-10 11:33:44 +01:00
Hakan Bastedt
5b61d87f68 ethercat-conf.xml for EaserCAT 7000 2025-03-10 11:14:10 +01:00
Hakan Bastedt
766985d11a ethercat-conf.xml for EaserCAT 7000 2025-03-10 11:13:22 +01:00
Hakan Bastedt
7f5e392a3e Added missing Viso connection to IS1540 2025-03-09 11:31:11 +01:00
Hakan Bastedt
97fefb19af Back to production mode from THTIC2 commisioning mode 2025-03-08 23:42:47 +01:00
Hakan Bastedt
a283091a3f Admin. nothing significant 2025-03-08 23:41:00 +01:00
Hakan Bastedt
3df3d63fff Shifted pin 0 and pin 1 for positive voltage value. 2025-03-08 23:22:42 +01:00
Hakan Bastedt
f79ad7035e Updated eeprom 2025-03-02 08:18:51 +01:00
Hakan Bastedt
8130f407b9 Gerbers done again. 2025-02-25 22:45:12 +01:00
Hakan Bastedt
a0ea80e368 Gerbers done. 2025-02-25 22:41:48 +01:00
Hakan Bastedt
47d05ff020 Gerbers generated. 2025-02-25 22:18:05 +01:00
Hakan Bastedt
bc08682f31 Now measuring 0 - -200 Volts. 2025-02-25 22:15:29 +01:00
Hakan Bastedt
b75cde78c1 now saved 2025-02-25 21:23:39 +01:00
Hakan Bastedt
9ba809d4cd Now measuring 0 - -200 Volts. 2025-02-25 21:21:56 +01:00
Hakan Bastedt
eced221b35 Added SDO for basePeriod, PDOs for scale, enable, maxAccel. All got default values in ESI 2025-02-23 20:40:11 +01:00
Hakan Bastedt
8726aff1f8 Updated 2025-02-21 19:06:36 +01:00
Hakan Bastedt
6de2a44814 Final version of THTIC2 2025-02-21 19:06:19 +01:00
Hakan Bastedt
27c644cd68 Pending upload for EaserCAT-7000 2025-02-20 22:29:40 +01:00
Hakan Bastedt
08f2544560 Pending upload for EaserCAT-7000 2025-02-20 22:23:12 +01:00
Hakan Bastedt
a0e74cf2dd Pending upload for EaserCAT-7000 2025-02-20 22:22:54 +01:00
Hakan Bastedt
9411889f54 Tested in cutter. Works just fine. Awesome. 2025-02-20 17:00:56 +01:00
Hakan Bastedt
206c033fc6 SDO config of I2C tested and works 2025-02-20 15:26:04 +01:00
Hakan Bastedt
47d8bdb89d SCL instead of SDL 2025-02-20 15:25:34 +01:00
Hakan Bastedt
fbc031a61e I2C setting (type and address) through SDO now 2025-02-20 14:45:18 +01:00
Hakan Bastedt
c160901131 Merge branch 'EaserCAT-7000' 2025-02-20 14:07:52 +01:00
Hakan Bastedt
e9d046bbb7 Access now working in ESI file. 2025-02-20 11:13:11 +01:00
Hakan Bastedt
71158e3e47 Now recognozing the chosen access method in the gui
Also RW in objectlist.c but not in esi file and unknown in eeprom
2025-02-20 11:12:47 +01:00
Hakan Bastedt
72ec3e38a0 Seems RW access now works in esi file (but not in eeprom, does not genrate that info) = tested 2025-02-20 11:09:42 +01:00
Hakan Bastedt
13463f269f Access now working in ESI file. 2025-02-20 10:33:38 +01:00
Hakan Bastedt
bec102b7f6 Now recognozing the chosen access method in the gui
Also RW in objectlist.c but not in esi file and unknown in eeprom
2025-02-20 09:57:54 +01:00
Hakan Bastedt
b136a93e28 ADS1014 working, in continuous mode. 0.15 ms to get value 2025-02-19 11:48:16 +01:00
Hakan Bastedt
72e861b174 Name change of E7000 2025-02-19 09:30:31 +01:00
Hakan Bastedt
7e0225711b Fixed status reporting 2025-02-17 09:22:07 +01:00
Hakan Bastedt
8e127929c4 Saved the pcb. 2025-02-16 17:25:57 +01:00
Hakan Bastedt
d357bfd43c Bummer, switched SDA and SCL position on THTIC vs E7000 I2C connector. Beware. 2025-02-16 16:40:06 +01:00
Hakan Bastedt
d52ec4672f Ordered the real version 2025-02-16 16:39:10 +01:00
Hakan Bastedt
aaebedc398 Commissioning tests added. E7000 tested all inputs, all outputs, I2C works. OK. 2025-02-16 08:58:08 +01:00
Hakan Bastedt
22531366af Fixed R17 C28 label position bug 2025-02-16 08:28:26 +01:00
Hakan Bastedt
0a66626fe4 I2C THTIC is working on a patched EaserCAT-4000., EaserCAT-7000 tested, STM32 and LAN9252 works. 2025-02-15 22:29:54 +01:00
Hakan Bastedt
f070ea592c R19 C27 Bug. Fixed. 2025-02-15 21:03:01 +01:00
Hakan Bastedt
e40d81e71c Works in TwinCAT. Prepare for test in machine. 2025-02-14 20:06:27 +01:00
Hakan Bastedt
310a08cc67 MCP3221 Found on I2C bus 2025-02-13 20:22:13 +01:00
Hakan Bastedt
d115eca125 ADS1115 wórking in prototype mode 2025-02-13 20:13:38 +01:00
Hakan Bastedt
e7872db6aa Branch mess fix 2025-02-13 14:25:46 +01:00
Hakan Bastedt
378a9eec89 Branch mess fix 2025-02-13 14:22:59 +01:00
Hakan Bastedt
2682eea508 Branch mess fix 2025-02-13 14:19:02 +01:00
Hakan Bastedt
191e652bb3 Branch mess fix 2025-02-13 14:07:40 +01:00
Hakan Bastedt
2fad0732f2 Branch mess fix 2025-02-13 14:06:57 +01:00
Hakan Bastedt
d2f17c5f7e EaserCAT-7000 project with two voltage sensor prototypes 2025-02-12 16:43:16 +01:00
Hakan Bastedt
3e8a4a7ec3 changes 2025-02-12 16:34:25 +01:00
Hakan Bastedt
8d31928d7a changes 2025-02-12 16:29:28 +01:00
Hakan Bastedt
a2787e04c2 update 2025-02-12 16:14:23 +01:00
Hakan Bastedt
edaf00681f Build.md initial 2025-02-12 15:31:59 +01:00
Hakan Bastedt
c62b865f03 Restored to cover also SM2/DC sync situation 2025-02-08 21:50:03 +01:00
Hakan Bastedt
ada1b8aa05 Works, sends Voltage during free-run to Twincat. 2025-02-08 21:48:26 +01:00
Hakan Bastedt
dda9d3bf20 EaserCAT-7000 initial 2025-02-08 11:41:29 +01:00
Hakan Bastedt
c410207d52 Merge branch 'main' of https://github.com/MetalMusings/MyOwnEtherCATDevice 2025-02-02 11:40:06 +01:00
Hakan Bastedt
1528d45ec6 EaserCAT 6000 release 2025-02-02 11:32:16 +01:00
Hakan Bastedt
0c5551663d Cleanup pending release 2025-02-02 09:43:58 +01:00
Hakan Bastedt
040ea4ab61 Closer to final version 2025-01-14 10:41:19 +01:00
Hakan Bastedt
3e76263177 Fixed placement of Out1-Out4 diodes' marking 2025-01-12 10:59:04 +01:00
Hakan Bastedt
28f05090f1 Added upload_port, to avoid program the wrong. 2025-01-11 20:07:19 +01:00
Hakan Bastedt
8568bf99b3 Modified, switch marker postions for C28 and R17 2025-01-11 20:05:59 +01:00
Hakan Bastedt
5f8c3ba5fc Firmware for EaserCAT-6000 brought in 2024-12-14 19:32:27 +01:00
Hakan Bastedt
909685cf0e Submitting design for fabrication 2024-12-14 11:47:00 +01:00
Håkan Båstedt
9cd264fa52 Update README.md 2024-12-13 11:06:58 +01:00
Hakan Bastedt
7ebc28a5ca Updated README after EaserCAT-5000 linuxcnc failure 2024-12-13 11:05:13 +01:00
Hakan Bastedt
77cc13f175 Updated EaserCAT 5000 description somewhat 2024-12-11 12:48:03 +01:00
Hakan Bastedt
2871fd7905 New place for eeprom programming program 2024-12-10 20:57:16 +01:00
Hakan Bastedt
44d2324a03 Updates to hw straps after startup of card. 2024-12-10 20:44:29 +01:00
Hakan Bastedt
1df85b5646 faulty .gitignore 2024-12-06 07:49:54 +01:00
Hakan Bastedt
a653a3d94a Removed Gerbers. Generate them as needed instead 2024-11-25 22:32:34 +01:00
Hakan Bastedt
e26d411d61 Updated reset circuit to PB12 2024-11-25 22:30:41 +01:00
Hakan Bastedt
e285923d2e Updated 24V field voltage routing. Files sent for fab 2024-11-25 20:15:11 +01:00
Hakan Bastedt
0aba15aaab make xml files available 2024-11-25 12:37:30 +01:00
Hakan Bastedt
29fb2bfe6c make xml files available 2024-11-25 12:36:07 +01:00
Hakan Bastedt
76335711e6 Conf, untested 2024-11-25 12:32:10 +01:00
Hakan Bastedt
4e32128a0f Fixes to e3000 2024-11-21 21:28:56 +01:00
Hakan Bastedt
cdce935560 Final update of README.md for this time 2024-11-21 11:49:29 +01:00
Hakan Bastedt
6e0496805a Updated README.md 2024-11-21 11:40:25 +01:00
Hakan Bastedt
3bd59f4c3e Updated README.md 2024-11-21 11:39:24 +01:00
Hakan Bastedt
92244e3c9c Updated README.md 2024-11-21 11:17:29 +01:00
Hakan Bastedt
b722cc6b25 Moving all to Kicad8. Housekeeping symbols,libraries,3d-models 2024-11-21 11:10:24 +01:00
Hakan Bastedt
0795eea21e Updated README.md 2024-11-20 16:48:25 +01:00
Hakan Bastedt
d38497ed85 Updated README.md 2024-11-20 16:45:50 +01:00
Hakan Bastedt
1918604586 Ny structure. Start of the "main" branch 2024-11-20 11:18:13 +01:00
Hakan Bastedt
31b896871d Actually fix the hex wrongful alignment 2024-11-18 12:36:50 +01:00
Hakan Bastedt
3a44cded1f Added study of OS version, NICs, computers to see what cycle times are reliable 2024-04-14 20:40:11 +02:00
Hakan Bastedt
c710f3e57e Added valid xml and bin esi for AX58100, from evaluation board, converted with siitool 2024-04-14 20:38:58 +02:00
Hakan Bastedt
855553bed7 Test version, test OS and nic. Added counters to detect work/no work 2024-04-14 13:07:43 +02:00
Hakan Bastedt
a4ca1f641a Tried to extrapolate when missing position data. Didn't work as expected but I'll keep it. 2024-04-12 17:56:26 +02:00
Hakan Bastedt
b1cc8f1717 Updated README 2024-04-11 12:19:39 +02:00
Hakan Bastedt
55f7e19e88 Updated readme 2024-04-11 11:22:21 +02:00
Hakan Bastedt
220daa4408 updated .gitignore 2024-04-10 10:36:24 +02:00
Hakan Bastedt
37c14850bf Replaced runningaverage (uses malloc) with CircularBuffer 2024-04-10 10:36:01 +02:00
Hakan Bastedt
ed9af2ec50 Reduce irq delay if it has gotten to large 2024-04-09 20:24:16 +02:00
Hakan Bastedt
939470a0c6 Mods to make encoder work again, and a possible 2nd iteration of encoder config 2024-04-09 08:25:59 +02:00
Hakan Bastedt
ec1c8fc70f Enable encoder again. Cleanup of unnecessary variables 2024-04-07 23:27:10 +02:00
Hakan Bastedt
5eda2b451e Use calibrated frequencty for the base timer. No big difference but more scientific, maybe 2024-04-07 22:55:46 +02:00
Hakan Bastedt
226cbc5035 Updated READM.md 2024-04-07 22:54:32 +02:00
Hakan Bastedt
39e2ab31f1 Adaptive (just max over time) maxIrqServeTime 2024-04-07 22:35:52 +02:00
Hakan Bastedt
b164040829 Removed debug-ish compiler directive NEEDED 2024-04-07 22:15:37 +02:00
Hakan Bastedt
084e6891b6 Updated readme 2024-04-07 21:54:21 +02:00
Hakan Bastedt
ed8e4d8d39 Working linuxcnc lathe config with 2 ms cycle time 2024-04-07 21:53:25 +02:00
Hakan Bastedt
a829b0c6e2 Standalone unix port of step generator, also stm32 arduino 2024-04-07 21:51:36 +02:00
Hakan Bastedt
ab1a306d86 Works really nice now. 20 usecs base period => 50 kHz, 25 kHz pulse freq. 2024-04-07 21:45:53 +02:00
Hakan Bastedt
544dd5ed85 I works.
Use 4.19-rt kernel
Ethernet Intel I210 controller
ethtool -C enp1s0 rx-usecs 0 tx-usecs 0
2 ms loop time in linuxcnc .ini and .xml and code
baseTimer period can be adjusted
startTime for baseTimer can also be adjusted.
2024-04-05 18:30:33 +02:00
Hakan Bastedt
511e6442e9 Removed all real work, now just echo 2024-04-05 10:53:12 +02:00
Hakan Bastedt
63fafb4936 FIx 1c13 index manually, nLoops is back 2024-04-05 09:54:56 +02:00
Hakan Bastedt
efa03e3095 Removed hex specifier 0x where it shouldn't be 2024-04-04 16:13:20 +02:00
Hakan Bastedt
dcf6c2d18a jitter flawed, removed 2024-04-04 10:38:27 +02:00
Hakan Bastedt
34e60e43d8 Adaptive max cycle time adjustment, use maxCycleTime 2024-04-03 21:21:51 +02:00
Hakan Bastedt
294831465b Added max irq time and jitter time measurement 2024-04-03 21:17:15 +02:00
Hakan Bastedt
5c128f49b5 syncTimer can be on flawed time units 2024-04-03 20:40:58 +02:00
Hakan Bastedt
9e00caf7c5 Added frequency-calibration to base-thread timer 2024-04-03 20:34:28 +02:00
Hakan Bastedt
1d14e1f295 At least it keeps nLoops at one, always 2024-03-28 10:09:12 +01:00
Hakan Bastedt
5d90765920 Didn't help using TICK_FORMAT in setOverflow() 2024-03-27 23:06:13 +01:00
Hakan Bastedt
e6ae2ad3c7 Test case for HardwareTime frequency discrepancy + doc 2024-03-27 22:03:10 +01:00
Hakan Bastedt
ea5a39d300 wip now the 50 kHz timer is only 40 kHz. How come? 2024-03-26 22:59:41 +01:00
Hakan Bastedt
88bd1ead78 pos_scale goes into make_pulses from lcnc 2024-03-23 21:49:13 +01:00
Hakan Bastedt
dccbd97a04 Tried to optimize BASE_PERIOD but 12000 ns (83 kHz) is the best it can do right now 2024-03-23 20:27:32 +01:00
Hakan Bastedt
1b8721930e Shortest BASE_PERIOD is 12000 as it is now. Plus some cleanup 2024-03-23 20:09:35 +01:00
Hakan Bastedt
8710a547fe Yesss software stepping works now. 2024-03-23 19:51:26 +01:00
Hakan Bastedt
369a795ce5 wip 2024-03-23 18:02:38 +01:00
Hakan Bastedt
2df0a0980c Stepgen3 is driven by HardwareTimer, in a way that resembles EtherCAT setup. Seems to actually work. 2024-03-22 22:38:16 +01:00
Hakan Bastedt
6383d6de89 Working test-program using user LEDs and delays 2024-03-22 21:20:31 +01:00
Hakan Bastedt
7bff3f3789 linuxcnc stepgen is now in StepGen3. Compiles 2024-03-22 17:31:21 +01:00
Hakan Bastedt
23fe81afbe Factored Stepgen2, StepGen3 is a copy of Stepgen2 2024-03-21 16:45:59 +01:00
Hakan Bastedt
fa34d81e41 Factored Stepgen2, StepGen3 is a copy of Stepgen2 2024-03-21 16:45:46 +01:00
Hakan Bastedt
30a9f10c7b Well it works, network-wise. But there are those extra peaks that have been since the start. Let's see if I can remove them. Welcome StepGen3 2024-03-21 16:28:55 +01:00
Hakan Bastedt
8f26a10224 It works. I hate RealTek. Even with the r8618_dkms driver it doesn't work. I bought a Intel network card, set irq coalesce rx-usecs and tx-usecs to 0. Now it works works WORKS. No lost packages, no delayed packages. I hate RealTek 2024-03-20 17:06:24 +01:00
Hakan Bastedt
d4fed6cfe8 Yes it works now. Made another implementation of the pulse IRQ and all that. We'll see if I keep this or go back to the older. It is IMPORTANT, REQUIRED to use a 4.9 linux kernel for it to work. There are obviously bugs in the RealTek network drivers R8168/R8169 in 5+ kernels. All this work could have been avoided with a 4.9 kernel. 2024-03-17 22:04:52 +01:00
Hakan Bastedt
27475eaecd Seems to actually work, but I have seen that before, so testing time 2024-03-14 10:15:23 +01:00
Hakan Bastedt
71ae242fc4 Fixed bug in extend32to64:extendTime() 2024-03-13 23:33:25 +01:00
Hakan Bastedt
f341eb5074 wip 2024-03-10 22:40:25 +01:00
Hakan Bastedt
fef934b103 wip 2024-03-10 01:03:50 +01:00
Hakan Bastedt
31be067dea After test in lathe. Basically ok, always use real Tstartf, not 1/n 2024-03-08 09:00:55 +01:00
Hakan Bastedt
94d68adbb1 Added Z stepgen. Both X and Z works on the scope 2024-03-03 19:01:02 +01:00
Hakan Bastedt
e8ef618fcc Test in lathe coming. 2024-03-03 17:02:04 +01:00
Håkan Båstedt
a99d0f0eda Update README.md 2024-02-19 22:16:27 +01:00
Hakan Bastedt
cbc45bc80b Merge branch 'Video8' into stepper2 2024-02-19 21:41:46 +01:00
Hakan Bastedt
30dc44d5e6 Direction output to dirPin. 2024-02-16 11:45:06 +01:00
Hakan Bastedt
2b2be4f63d Going for test in the lathe 2024-02-13 10:49:57 +01:00
Hakan Bastedt
cbae816bd9 More debug variables 2024-02-13 10:49:36 +01:00
Hakan Bastedt
c0d2bfcf62 doc update on stepgen problem and solution 2024-02-12 18:37:16 +01:00
Hakan Bastedt
f4a15afa8a a cycle's pwm train maight have been too long and run into the start of next cycle's pwm train. That's gone now and it seems to work.
A more brilliant solution is needed for this.
2024-02-11 19:56:16 +01:00
Hakan Bastedt
c04ac0e74b Consistently get SM2 event now. Must check directly in irq. DIG_PROCESS modified to check this ALevent copy 2024-02-09 22:58:28 +01:00
Hakan Bastedt
6d18c2cb3f Clear ALevents for DC_sync0 and SM3 might have solved the uneven pulse train. Looking better now. 2024-02-09 17:28:18 +01:00
Hakan Bastedt
d0433b29cf cleanup and removing StepGen from active code 2024-02-08 21:33:31 +01:00
Hakan Bastedt
fe3de876fa Class StepGen2 done after Stepgen.odb 2024-02-08 21:28:48 +01:00
Hakan Bastedt
2fb5252d37 CircularBuffer.h new file ending hpp due to version 1.4 od CB 2024-02-08 19:06:55 +01:00
Hakan Bastedt
43854ca4d0 wip 2024-02-05 21:22:23 +01:00
Hakan Bastedt
dbb4d0f34e Update 2024-02-05 20:32:49 +01:00
Hakan Bastedt
f9b37cfa6c Document stepgen 2024-02-05 01:04:20 +01:00
Hakan Bastedt
2b2704bb17 Added timer2 for proper start point 2024-02-02 21:43:58 +01:00
Hakan Bastedt
0384646972 wip 2024-02-02 15:26:01 +01:00
Hakan Bastedt
133df5662d wip, before timer stuff 2024-02-02 12:09:49 +01:00
Hakan Bastedt
d1eb1d9a40 logic might be there 2024-02-01 20:30:02 +01:00
562 changed files with 1321529 additions and 130014 deletions

10
.gitignore vendored
View File

@@ -4,3 +4,13 @@
.vscode/launch.json
.vscode/ipch
Octave
.pioenvs
.piolibdeps
.clang_complete
.gcc-flags.json
.pio
logs
*.bak
*~

70
Build.md Normal file
View File

@@ -0,0 +1,70 @@
# Building an EaserCAT board
## Parts
Most parts are generic and can be found in many places. SMD resistors and capacitors are standard, nothing special.
Crystals are standard type hc49/s.
In case of smd crystal then it's a "passive smd crystal 3225"
For ferrite beads marked BLM18EG221SN1D - you can use any generic "ferrite bead 220 Ohm 0603 1ln". Not sure if 1ln is important nor what it means. In the schematics some are called BLM18EG221SN1D, others are called BLM18EG221S. It is the same, just a mistake in the naming.
RJ45 connectors must include "magnetics" and be configured in this way\
![RJ45 Symbol](Utils/Pictures/RJ45-magnetics.png)\
I have used PulseJack JN0011D01BNL (and most likely a chinese knockoff) and it works fine, but any jack that meets the diagram above will work.
The EtherCAT ICs are from aliexpress. There are quite a few sellers that has the LAN9252i/PT and the Ax58100 (LAN9252/PT and LAN9252V/PT are also possible, temperature range differs). Afaik, there is only one variant of the Ax58100 - AX58100LT. The LAN9252 is generally available, the Ax58100 is more of a challenge but check aliexpress.
The pcb needs to be ordered. Consider using a solder stencil - but hey it's up to you. I have bought pcbs from some chinese factories and from Aisler, Germany. The Aisler pcb is the nicest and came with excellent solder stencil. At a bit higher cost, nothing dramatic though. If you are hunting pennies then go to one of the chinese ones, maybe check prices at https://pcbshopper.com.
## EEPROM
You need to fill the EEPROM with valid contents before putting it on the pcb. It is actually mandatory, the EtherCAT IC will not start with an empty EEPROM, or with a non-valid content. It doesn't have to be for a real EtherCAT slave, because the first thing you will do when the card works is to upload the correct contents using TwinCAT. Any valid EEPROM content.
There is a small Arduino program [Link here](Utils/EEPROM_store_valid/) that helps to fill the empty EEPROM. Follow the link.
## Populating the pcb
Enjoy!
## Soldering
I have put the pcb in the soldering oven. Hand soldering should work, although the pin spacing is only 0.4 m on the Ax58100 IC and can be a challenge. I usually get some solder bridges on the EtherCAT IC or the STM32 chip. A magnifyng device definitely helps.
## Powering up
Need:\
STLINK/V2\
Serial port - USB
Connect the STLINK/V2 unit and the serial port. The serial port will provide 5V, you don't need to see the serial output (there isn't any).
Ax58100\
Red led status - Blinking pattern means succesful read of eeprom
Gree led status - Blinking pattern indicates EtherCAT state (init, op, etc.)
LAN9252\
There is no indication.
## Hookup to TwinCAT
Install TwinCAT/XAE\
Ethernet cable\
Network interface assignment\
scan\
free-run\
download EEPROM contents
## Build and download firmware
vscode\
platformio\
open folder\
Build and upload\
## Twincat verification
## Linuxcnc
## Modifying the firmware

30
Cards/.gitignore vendored Normal file
View File

@@ -0,0 +1,30 @@
TEST*
Gerbers*
*.zip
For PCBs designed using KiCad: https://www.kicad.org/
# Format documentation: https://kicad.org/help/file-formats/
# Temporary files
*.000
*.bak
*.bck
*.kicad_pcb-bak
*.kicad_sch-bak
*-backups
*.kicad_prl
*.sch-bak
*~
_autosave-*
*.tmp
*-save.pro
*-save.kicad_pcb
fp-info-cache
~*.lck
\#auto_saved_files#
# Netlist files (exported from Eeschema)
*.net
# Autorouter files (exported from Pcbnew)
*.dsn
*.ses

6
Cards/EaserCAT-2000/Firmware/.gitignore vendored Executable file
View File

@@ -0,0 +1,6 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
.vscode/settings.json

View File

@@ -0,0 +1 @@
.~lock.*

Binary file not shown.

View File

@@ -1,8 +1,8 @@
#ifndef MYENCODER
#define MYENCODER
#include "Stm32F4_Encoder.h"
#include <CircularBuffer.h>
#define RINGBUFFERLEN 101
#include <CircularBuffer.hpp>
#define RINGBUFFERLEN 11
class MyEncoder
{
@@ -30,6 +30,7 @@ private:
CircularBuffer<double_t, RINGBUFFERLEN> Pos;
CircularBuffer<uint32_t, RINGBUFFERLEN> TDelta;
double curPos;
double oldFrequency;
TIM_TypeDef *tim_base;
};

View File

@@ -16,6 +16,7 @@ private:
volatile double_t requestedPosition;
volatile uint8_t enabled;
HardwareTimer *MyTim;
HardwareTimer *MyTim2;
uint16_t stepsPerMM;
uint8_t dirPin;
PinName stepPin;

View File

@@ -0,0 +1,53 @@
#ifndef STEPGEN
#define STEPGEN
#include <HardwareTimer.h>
class StepGen2
{
public:
volatile double_t actualPosition;
volatile int32_t nSteps;
volatile uint32_t timerFrequency;
volatile int32_t timerPosition = 0;
volatile int32_t timerEndPosition = 0;
public:
volatile float Tstartf; // Starting delay in secs
volatile uint32_t Tstartu; // Starting delay in usecs
volatile float Tpulses; // Time it takes to do pulses. Debug
HardwareTimer *pulseTimer;
uint32_t pulseTimerChan;
HardwareTimer *startTimer; // Use timers 10,11,13,14
uint8_t dirPin;
PinName dirPinName;
PinName stepPin;
uint32_t Tjitter = 400; // Longest time from IRQ to handling in handleStepper, unit is microseconds
uint64_t dbg;
const uint16_t t2 = 5; // DIR is ahead of PUL with at least 5 usecs
const uint16_t t3 = 5; // Pulse width at least 2.5 usecs
const uint16_t t4 = 5; // Low level width not less than 2.5 usecs
const float maxAllowedFrequency = 1000000 / float(t3 + t4) * 0.9; // 150 kHz for now
public:
volatile double_t commandedPosition; // End position when this cycle is completed
volatile int32_t commandedStepPosition; // End step position when this cycle is completed
volatile double_t initialPosition; // From previous cycle
volatile int32_t initialStepPosition; // From previous cycle
int16_t stepsPerMM; // This many steps per mm
volatile uint8_t enabled; // Enabled step generator
volatile float frequency;
static uint32_t sync0CycleTime; // Nominal EtherCAT cycle time nanoseconds
volatile float lcncCycleTime; // Linuxcnc nominal cycle time in sec (1 ms often)
StepGen2(TIM_TypeDef *Timer, uint32_t _timerChannel, PinName _stepPin, uint8_t _dirPin, void irq(void), TIM_TypeDef *Timer2, void irq2(void));
uint32_t handleStepper(uint64_t irqTime /* time when irq happened nanosecs */, uint16_t nLoops);
void startTimerCB();
void pulseTimerCB();
uint32_t updatePos(uint32_t i);
};
#endif

View File

@@ -0,0 +1,156 @@
#ifndef STEPGEN3
#define STEPGEN3
#include <HardwareTimer.h>
#define MAX_CHAN 16
#define MAX_CYCLE 18
#define USER_STEP_TYPE 13
typedef struct
{
/* stuff that is both read and written by makepulses */
volatile unsigned int timer1; /* times out when step pulse should end */
volatile unsigned int timer2; /* times out when safe to change dir */
volatile unsigned int timer3; /* times out when safe to step in new dir */
volatile int hold_dds; /* prevents accumulator from updating */
volatile long addval; /* actual frequency generator add value */
volatile long long accum; /* frequency generator accumulator */
volatile int rawcount; /* param: position feedback in counts */
volatile int curr_dir; /* current direction */
volatile int state; /* current position in state table */
/* stuff that is read but not written by makepulses */
volatile int enable; /* pin for enable stepgen */
volatile int target_addval; /* desired freq generator add value */
volatile long deltalim; /* max allowed change per period */
volatile int step_len; /* parameter: step pulse length */
volatile unsigned int dir_hold_dly; /* param: direction hold time or delay */
volatile unsigned int dir_setup; /* param: direction setup time */
volatile int step_type; /* stepping type - see list above */
volatile int cycle_max; /* cycle length for step types 2 and up */
volatile int num_phases; /* number of phases for types 2 and up */
volatile int phase[5]; /* pins for output signals */
volatile const unsigned char *lut; /* pointer to state lookup table */
/* stuff that is not accessed by makepulses */
int pos_mode; /* 1 = position mode, 0 = velocity mode */
unsigned int step_space; /* parameter: min step pulse spacing */
double old_pos_cmd; /* previous position command (counts) */
int count; /* pin: captured feedback in counts */
#define double float
double pos_scale; /* param: steps per position unit */
double old_scale; /* stored scale value */
double scale_recip; /* reciprocal value used for scaling */
double vel_cmd; /* pin: velocity command (pos units/sec) */
double pos_cmd; /* pin: position command (position units) */
double pos_fb; /* pin: position feedback (position units) */
double freq; /* param: frequency command */
double maxvel; /* param: max velocity, (pos units/sec) */
double maxaccel; /* param: max accel (pos units/sec^2) */
unsigned int old_step_len; /* used to detect parameter changes */
unsigned int old_step_space;
unsigned int old_dir_hold_dly;
unsigned int old_dir_setup;
int printed_error; /* flag to avoid repeated printing */
} stepgen_t;
#define MAX_STEP_TYPE 15
#define STEP_PIN 0 /* output phase used for STEP signal */
#define DIR_PIN 1 /* output phase used for DIR signal */
#define UP_PIN 0 /* output phase used for UP signal */
#define DOWN_PIN 1 /* output phase used for DOWN signal */
#define PICKOFF 28 /* bit location in DDS accum */
typedef enum CONTROL
{
POSITION,
VELOCITY,
INVALID
} CONTROL;
class StepGen3
{
public:
int step_type[MAX_CHAN] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; // stepping types for up to 16 channels
char *ctrl_type[MAX_CHAN] = {0}; // control type ("p"pos or "v"vel) for up to 16 channels
int user_step_type[MAX_CYCLE] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; // lookup table for user-defined step type
uint32_t stepPin[MAX_CHAN] = {0};
uint32_t dirPin[MAX_CHAN] = {0};
stepgen_t *stepgen_array = 0;
int num_chan = 0; // number of step generators configured */
long periodns; // makepulses function period in nanosec */
long old_periodns; // used to detect changes in periodns */
double periodfp; // makepulses function period in seconds */
double freqscale; // conv. factor from Hz to addval counts */
double accelscale; // conv. Hz/sec to addval cnts/period */
long old_dtns; // update_freq funct period in nsec */
double dt; // update_freq period in seconds */
double recip_dt; // recprocal of period, avoids divides */
volatile uint64_t cnt = 0; // Debug counter
#undef double
StepGen3(void);
void updateStepGen(double pos_cmd1, double pos_cmd2, uint32_t servoPeriod);
void makeAllPulses(void);
int rtapi_app_main();
int export_stepgen(int num, stepgen_t *addr, int step_type, int pos_mode);
void make_pulses(void *arg, long period);
void update_freq(void *arg, long period);
void update_pos(void *arg, long period);
int setup_user_step_type(void);
CONTROL parse_ctrl_type(const char *ctrl);
unsigned long ulceil(unsigned long value, unsigned long increment);
private:
/* lookup tables for stepping types 2 and higher - phase A is the LSB */
unsigned char master_lut[MAX_STEP_TYPE][MAX_CYCLE] = {
{1, 3, 2, 0, 0, 0, 0, 0, 0, 0}, /* type 2: Quadrature */
{1, 2, 4, 0, 0, 0, 0, 0, 0, 0}, /* type 3: Three Wire */
{1, 3, 2, 6, 4, 5, 0, 0, 0, 0}, /* type 4: Three Wire Half Step */
{1, 2, 4, 8, 0, 0, 0, 0, 0, 0}, /* 5: Unipolar Full Step 1 */
{3, 6, 12, 9, 0, 0, 0, 0, 0, 0}, /* 6: Unipoler Full Step 2 */
{1, 7, 14, 8, 0, 0, 0, 0, 0, 0}, /* 7: Bipolar Full Step 1 */
{5, 6, 10, 9, 0, 0, 0, 0, 0, 0}, /* 8: Bipoler Full Step 2 */
{1, 3, 2, 6, 4, 12, 8, 9, 0, 0}, /* 9: Unipolar Half Step */
{1, 5, 7, 6, 14, 10, 8, 9, 0, 0}, /* 10: Bipolar Half Step */
{1, 2, 4, 8, 16, 0, 0, 0, 0, 0}, /* 11: Five Wire Unipolar */
{3, 6, 12, 24, 17, 0, 0, 0, 0, 0}, /* 12: Five Wire Wave */
{1, 3, 2, 6, 4, 12, 8, 24, 16, 17}, /* 13: Five Wire Uni Half */
{3, 7, 6, 14, 12, 28, 24, 25, 17, 19}, /* 14: Five Wire Wave Half */
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* 15: User-defined */
};
unsigned char cycle_len_lut[14] =
{4, 3, 6, 4, 4, 4, 4, 8, 8, 5, 5, 10, 10, 0};
unsigned char num_phases_lut[14] =
{
2,
3,
3,
4,
4,
4,
4,
4,
4,
5,
5,
5,
5,
0,
};
};
// For the example
#define BASE_PERIOD 20000
//#define SERVO_PERIOD 2000000
#define JOINT_X_STEPGEN_MAXACCEL 0.0
#define JOINT_Z_STEPGEN_MAXACCEL 0.0
#define JOINT_X_SCALE -200
#define JOINT_Z_SCALE -80
#endif

View File

@@ -641,7 +641,8 @@ public:
uint16_t GetCount();
};
void rcc_config();
void encoder_config();
void encoder2_config(); // Experimental
void GpioConfigPortA(GPIO_TypeDef *GPIOx);
void GpioConfigPortC(GPIO_TypeDef *GPIOx);
void GpioConfigPortD(GPIO_TypeDef *GPIOx);

View File

@@ -0,0 +1,14 @@
#ifndef EXTEND32TO64
#define EXTEND32TO54
#include <Arduino.h>
class extend32to64
{
public:
int64_t previousTimeValue = 0;
const uint64_t ONE_PERIOD = 4294967296; // almost UINT32_MAX;
const uint64_t HALF_PERIOD = 2147483648; // Half of that
int64_t extendTime(uint32_t in);
};
#endif

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

@@ -0,0 +1,42 @@
#ifndef __ECAT_OPTIONS_H__
#define __ECAT_OPTIONS_H__
#define USE_FOE 0
#define USE_EOE 0
#define MBXSIZE 512
#define MBXSIZEBOOT 512
#define MBXBUFFERS 3
#define MBX0_sma 0x1000
#define MBX0_sml MBXSIZE
#define MBX0_sme MBX0_sma+MBX0_sml-1
#define MBX0_smc 0x26
#define MBX1_sma MBX0_sma+MBX0_sml
#define MBX1_sml MBXSIZE
#define MBX1_sme MBX1_sma+MBX1_sml-1
#define MBX1_smc 0x22
#define MBX0_sma_b 0x1000
#define MBX0_sml_b MBXSIZEBOOT
#define MBX0_sme_b MBX0_sma_b+MBX0_sml_b-1
#define MBX0_smc_b 0x26
#define MBX1_sma_b MBX0_sma_b+MBX0_sml_b
#define MBX1_sml_b MBXSIZEBOOT
#define MBX1_sme_b MBX1_sma_b+MBX1_sml_b-1
#define MBX1_smc_b 0x22
#define SM2_sma 0x1600
#define SM2_smc 0x24
#define SM2_act 1
#define SM3_sma 0x1A00
#define SM3_smc 0x20
#define SM3_act 1
#define MAX_MAPPINGS_SM2 5
#define MAX_MAPPINGS_SM3 11
#define MAX_RXPDO_SIZE 512
#define MAX_TXPDO_SIZE 512
#endif /* __ECAT_OPTIONS_H__ */

View File

@@ -0,0 +1,386 @@
/*
* Licensed under the GNU General Public License version 2 with exceptions. See
* LICENSE file in the project root for full license information
*/
#include <stddef.h>
#include "esc.h"
#include "esc_coe.h"
#include "esc_foe.h"
#include "esc_eoe.h"
#include "ecat_slv.h"
#define IS_RXPDO(index) ((index) >= 0x1600 && (index) < 0x1800)
#define IS_TXPDO(index) ((index) >= 0x1A00 && (index) < 0x1C00)
/* Global variables used by the stack */
uint8_t MBX[MBXBUFFERS * MAX(MBXSIZE, MBXSIZEBOOT)];
_MBXcontrol MBXcontrol[MBXBUFFERS];
_SMmap SMmap2[MAX_MAPPINGS_SM2];
_SMmap SMmap3[MAX_MAPPINGS_SM3];
_ESCvar ESCvar;
/* Private variables */
static volatile int watchdog;
#if MAX_MAPPINGS_SM2 > 0
static uint8_t rxpdo[MAX_RXPDO_SIZE] __attribute__((aligned(8)));
#else
extern uint8_t *rxpdo;
#endif
#if MAX_MAPPINGS_SM3 > 0
static uint8_t txpdo[MAX_TXPDO_SIZE] __attribute__((aligned(8)));
#else
extern uint8_t *txpdo;
#endif
/** Function to pre-qualify the incoming SDO download.
*
* @param[in] index = index of SDO download request to check
* @param[in] sub-index = sub-index of SDO download request to check
* @return SDO abort code, or 0 on success
*/
uint32_t ESC_download_pre_objecthandler(uint16_t index,
uint8_t subindex,
void *data,
size_t size,
uint16_t flags)
{
if (IS_RXPDO(index) ||
IS_TXPDO(index) ||
index == RX_PDO_OBJIDX ||
index == TX_PDO_OBJIDX)
{
uint8_t minSub = ((flags & COMPLETE_ACCESS_FLAG) == 0) ? 0 : 1;
if (subindex > minSub && COE_maxSub(index) != 0)
{
return ABORT_SUBINDEX0_NOT_ZERO;
}
}
if (ESCvar.pre_object_download_hook)
{
return (ESCvar.pre_object_download_hook)(index,
subindex,
data,
size,
flags);
}
return 0;
}
/** Hook called from the slave stack SDO Download handler to act on
* user specified Index and Sub-index.
*
* @param[in] index = index of SDO download request to handle
* @param[in] sub-index = sub-index of SDO download request to handle
* @return SDO abort code, or 0 on success
*/
uint32_t ESC_download_post_objecthandler(uint16_t index, uint8_t subindex, uint16_t flags)
{
if (ESCvar.post_object_download_hook != NULL)
{
return (ESCvar.post_object_download_hook)(index, subindex, flags);
}
return 0;
}
/** Function to pre-qualify the incoming SDO upload.
*
* @param[in] index = index of SDO upload request to handle
* @param[in] sub-index = sub-index of SDO upload request to handle
* @return SDO abort code, or 0 on success
*/
uint32_t ESC_upload_pre_objecthandler(uint16_t index,
uint8_t subindex,
void *data,
size_t size,
uint16_t flags)
{
if (ESCvar.pre_object_upload_hook != NULL)
{
return (ESCvar.pre_object_upload_hook)(index,
subindex,
data,
size,
flags);
}
return 0;
}
/** Hook called from the slave stack SDO Upload handler to act on
* user specified Index and Sub-index.
*
* @param[in] index = index of SDO upload request to handle
* @param[in] sub-index = sub-index of SDO upload request to handle
* @return SDO abort code, or 0 on success
*/
uint32_t ESC_upload_post_objecthandler(uint16_t index, uint8_t subindex, uint16_t flags)
{
if (ESCvar.post_object_upload_hook != NULL)
{
return (ESCvar.post_object_upload_hook)(index, subindex, flags);
}
return 0;
}
/** Hook called from the slave stack ESC_stopoutputs to act on state changes
* forcing us to stop outputs. Here we can set them to a safe state.
*/
void APP_safeoutput(void)
{
DPRINT("APP_safeoutput\n");
if (ESCvar.safeoutput_override != NULL)
{
(ESCvar.safeoutput_override)();
}
}
/** Write local process data to Sync Manager 3, Master Inputs.
*/
void TXPDO_update(void)
{
if (ESCvar.txpdo_override != NULL)
{
(ESCvar.txpdo_override)();
}
else
{
if (MAX_MAPPINGS_SM3 > 0)
{
COE_pdoPack(txpdo, ESCvar.sm3mappings, SMmap3);
}
ESC_write(ESC_SM3_sma, txpdo, ESCvar.ESC_SM3_sml);
}
}
/** Read Sync Manager 2 to local process data, Master Outputs.
*/
void RXPDO_update(void)
{
if (ESCvar.rxpdo_override != NULL)
{
(ESCvar.rxpdo_override)();
}
else
{
ESC_read(ESC_SM2_sma, rxpdo, ESCvar.ESC_SM2_sml);
if (MAX_MAPPINGS_SM2 > 0)
{
COE_pdoUnpack(rxpdo, ESCvar.sm2mappings, SMmap2);
}
}
}
/* Set the watchdog count value, don't have any affect when using
* HW watchdog 0x4xx
*
* @param[in] watchdogcnt = new watchdog count value
*/
void APP_setwatchdog(int watchdogcnt)
{
CC_ATOMIC_SET(ESCvar.watchdogcnt, watchdogcnt);
}
/* Function to update local I/O, call read ethercat outputs, call
* write ethercat inputs. Implement watch-dog counter to count-out if we have
* made state change affecting the App.state.
*/
void DIG_process(uint16_t ALEvent, uint8_t flags)
{
/* Handle watchdog */
if ((flags & DIG_PROCESS_WD_FLAG) > 0)
{
if (CC_ATOMIC_GET(watchdog) > 0)
{
CC_ATOMIC_SUB(watchdog, 1);
}
if ((CC_ATOMIC_GET(watchdog) <= 0) &&
((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0))
{
DPRINT("DIG_process watchdog expired\n");
ESC_ALstatusgotoerror((ESCsafeop | ESCerror), ALERR_WATCHDOG);
}
else if (((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) == 0))
{
CC_ATOMIC_SET(watchdog, ESCvar.watchdogcnt);
}
}
/* Handle Outputs */
if ((flags & DIG_PROCESS_OUTPUTS_FLAG) > 0)
{
if (((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0) &&
(ALEvent & ESCREG_ALEVENT_SM2))
{
RXPDO_update();
CC_ATOMIC_SET(watchdog, ESCvar.watchdogcnt);
/* Set outputs */
cb_set_outputs();
}
else if (ALEvent & ESCREG_ALEVENT_SM2)
{
RXPDO_update();
}
}
/* Call application */
if ((flags & DIG_PROCESS_APP_HOOK_FLAG) > 0)
{
/* Call application callback if set */
if (ESCvar.application_hook != NULL)
{
(ESCvar.application_hook)();
}
}
/* Handle Inputs */
if ((flags & DIG_PROCESS_INPUTS_FLAG) > 0)
{
if (CC_ATOMIC_GET(ESCvar.App.state) > 0)
{
/* Update inputs */
cb_get_inputs();
TXPDO_update();
}
}
}
/*
* Handler for SM change, SM0/1, AL CONTROL and EEPROM events, the application
* control what interrupts that should be served and re-activated with
* event mask argument
*/
void ecat_slv_worker(uint32_t event_mask)
{
do
{
/* Check the state machine */
ESC_state();
/* Check the SM activation event */
ESC_sm_act_event();
/* Check mailboxes */
while ((ESC_mbxprocess() > 0) || (ESCvar.txcue > 0))
{
ESC_coeprocess();
#if USE_FOE
ESC_foeprocess();
#endif
#if USE_EOE
ESC_eoeprocess();
#endif
ESC_xoeprocess();
}
#if USE_EOE
ESC_eoeprocess_tx();
#endif
/* Call emulated eeprom handler if set */
if (ESCvar.esc_hw_eep_handler != NULL)
{
(ESCvar.esc_hw_eep_handler)();
}
CC_ATOMIC_SET(ESCvar.ALevent, ESC_ALeventread());
} while (ESCvar.ALevent & event_mask);
ESC_ALeventmaskwrite(ESC_ALeventmaskread() | event_mask);
}
/*
* Polling function. It should be called periodically for an application
* when only SM2/DC interrupt is active.
* Read and handle events for the EtherCAT state, status, mailbox and eeprom.
*/
void ecat_slv_poll(void)
{
/* Read local time from ESC*/
ESC_read(ESCREG_LOCALTIME, (void *)&ESCvar.Time, sizeof(ESCvar.Time));
ESCvar.Time = etohl(ESCvar.Time);
/* Check the state machine */
ESC_state();
/* Check the SM activation event */
ESC_sm_act_event();
/* Check mailboxes */
if (ESC_mbxprocess())
{
ESC_coeprocess();
#if USE_FOE
ESC_foeprocess();
#endif
#if USE_EOE
ESC_eoeprocess();
#endif
ESC_xoeprocess();
}
#if USE_EOE
ESC_eoeprocess_tx();
#endif
/* Call emulated eeprom handler if set */
if (ESCvar.esc_hw_eep_handler != NULL)
{
(ESCvar.esc_hw_eep_handler)();
}
}
/*
* Poll all events in a free-run application
*/
void ecat_slv(void)
{
ecat_slv_poll();
DIG_process(ESC_ALeventread(), DIG_PROCESS_WD_FLAG | DIG_PROCESS_OUTPUTS_FLAG |
DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG);
}
/*
* Initialize the slave stack.
*/
void ecat_slv_init(esc_cfg_t *config)
{
/* Init watchdog */
watchdog = config->watchdog_cnt;
/* Call stack configuration */
ESC_config(config);
/* Call HW init */
ESC_init(config);
/* wait until ESC is started up */
while ((ESCvar.DLstatus & 0x0001) == 0)
{
ESC_read(ESCREG_DLSTATUS, (void *)&ESCvar.DLstatus,
sizeof(ESCvar.DLstatus));
ESCvar.DLstatus = etohs(ESCvar.DLstatus);
}
#if USE_FOE
/* Init FoE */
FOE_init();
#endif
#if USE_EOE
/* Init EoE */
EOE_init();
#endif
/* reset ESC to init state */
ESC_ALstatus(ESCinit);
ESC_ALerror(ALERR_NONE);
ESC_stopmbx();
ESC_stopinput();
ESC_stopoutput();
/* Init Object Dictionary default values */
COE_initDefaultValues();
}

View File

@@ -0,0 +1,69 @@
/*
* Licensed under the GNU General Public License version 2 with exceptions. See
* LICENSE file in the project root for full license information
*/
#ifndef __ECAT_SLV_H__
#define __ECAT_SLV_H__
#include "ecat_options.h"
#include "esc.h"
/**
* This function is called when to get input values
*/
void cb_get_inputs();
/**
* This function is called when to set outputs values
*/
void cb_set_outputs();
/** Set the watchdog count value
*
* @param[in] watchdogcnt = new watchdog count value
*/
void APP_setwatchdog(int watchdogcnt);
#define DIG_PROCESS_INPUTS_FLAG 0x01
#define DIG_PROCESS_OUTPUTS_FLAG 0x02
#define DIG_PROCESS_WD_FLAG 0x04
#define DIG_PROCESS_APP_HOOK_FLAG 0x08
/** Implements the watch-dog counter to count if we should make a state change
* due to missing incoming SM2 events. Updates local I/O and run the application
* in the following order, call read EtherCAT outputs, execute user provided
* application hook and call write EtherCAT inputs.
*
* @param[in] flags = User input what to execute
*/
void DIG_process(uint16_t ALEvent, uint8_t flags);
/**
* Handler for SM change, SM0/1, AL CONTROL and EEPROM events, the application
* control what interrupts that should be served and re-activated with
* event mask argument
*
* @param[in] event_mask = Event mask for interrupts to serve and re-activate
* after served
*/
void ecat_slv_worker(uint32_t event_mask);
/**
* Poll SM0/1, EEPROM and AL CONTROL events in a SM/DC synchronization
* application
*/
void ecat_slv_poll(void);
/**
* Poll all events in a free-run application
*/
void ecat_slv(void);
/**
* Initialize the slave stack
*
* @param[in] config = User input how to configure the stack
*/
void ecat_slv_init(esc_cfg_t *config);
#endif /* __ECAT_SLV_H__ */

View File

@@ -57,7 +57,7 @@
"pdo_mappings": [
"txpdo"
],
"dtype": "REAL64",
"dtype": "REAL32",
"value": "0",
"data": "&Obj.EncPos"
},
@@ -68,7 +68,7 @@
"pdo_mappings": [
"txpdo"
],
"dtype": "REAL64",
"dtype": "REAL32",
"value": "0",
"data": "&Obj.EncFrequency"
},
@@ -79,7 +79,7 @@
"pdo_mappings": [
"txpdo"
],
"dtype": "UNSIGNED32",
"dtype": "UNSIGNED16",
"value": "0",
"data": "&Obj.DiffT"
},
@@ -106,59 +106,74 @@
"data": "&Obj.IndexStatus"
},
"6005": {
"otype": "RECORD",
"name": "StepGenOut1",
"otype": "VAR",
"name": "ActualPosition1",
"access": "RO",
"items": [
{
"name": "Max SubIndex"
},
{
"name": "ActualPosition",
"dtype": "REAL64",
"data": "&Obj.StepGenOut1.ActualPosition",
"value": "0",
"access": "RO"
}
],
"pdo_mappings": [
"txpdo"
]
],
"dtype": "REAL32",
"value": "0",
"data": "&Obj.ActualPosition1"
},
"6006": {
"otype": "RECORD",
"name": "StepGenOut2",
"otype": "VAR",
"name": "ActualPosition2",
"access": "RO",
"items": [
{
"name": "Max SubIndex"
},
{
"name": "ActualPosition",
"dtype": "REAL64",
"data": "&Obj.StepGenOut2.ActualPosition",
"value": "0",
"access": "RO"
}
],
"pdo_mappings": [
"txpdo"
]
],
"dtype": "REAL32",
"value": "0",
"data": "&Obj.ActualPosition2"
},
"6007": {
"otype": "VAR",
"name": "D1",
"access": "RO",
"pdo_mappings": [
"txpdo"
],
"dtype": "INTEGER16",
"value": "0",
"data": "&Obj.D1"
},
"6008": {
"otype": "VAR",
"name": "D2",
"access": "RO",
"pdo_mappings": [
"txpdo"
],
"dtype": "INTEGER16",
"value": "0",
"data": "&Obj.D2"
},
"6009": {
"otype": "VAR",
"name": "D3",
"access": "RO",
"pdo_mappings": [
"txpdo"
],
"dtype": "INTEGER16",
"value": "0",
"data": "&Obj.D3"
},
"600A": {
"otype": "VAR",
"name": "D4",
"access": "RO",
"pdo_mappings": [
"txpdo"
],
"dtype": "INTEGER16",
"value": "0",
"data": "&Obj.D4"
}
},
"rxpdo": {
"7000": {
"otype": "VAR",
"name": "EncPosScale",
"access": "RO",
"pdo_mappings": [
"rxpdo"
],
"dtype": "INTEGER32",
"value": "0",
"data": "&Obj.EncPosScale"
},
"7001": {
"otype": "VAR",
"name": "IndexLatchEnable",
"access": "RO",
@@ -169,70 +184,49 @@
"value": "0",
"data": "&Obj.IndexLatchEnable"
},
"7002": {
"otype": "RECORD",
"name": "StepGenIn1",
"7001": {
"otype": "VAR",
"name": "CommandedPosition1",
"access": "RO",
"items": [
{
"name": "Max SubIndex"
},
{
"name": "CommandedPosition",
"dtype": "REAL64",
"data": "&Obj.StepGenIn1.CommandedPosition",
"value": "0",
"access": "RO"
},
{
"name": "StepsPerMM",
"dtype": "INTEGER16",
"value": "0",
"access": "RO",
"data": "&Obj.StepGenIn1.StepsPerMM"
}
],
"pdo_mappings": [
"rxpdo"
]
],
"dtype": "REAL32",
"value": "0",
"data": "&Obj.CommandedPosition1"
},
"7002": {
"otype": "VAR",
"name": "CommandedPosition2",
"access": "RO",
"pdo_mappings": [
"rxpdo"
],
"dtype": "REAL32",
"value": "0",
"data": "&Obj.CommandedPosition2"
},
"7003": {
"otype": "RECORD",
"name": "StepGenIn2",
"otype": "VAR",
"name": "StepsPerMM1",
"access": "RO",
"items": [
{
"name": "Max SubIndex"
},
{
"name": "CommandedPosition",
"dtype": "REAL64",
"data": "&Obj.StepGenIn2.CommandedPosition",
"value": "0",
"access": "RO"
},
{
"name": "StepsPerMM",
"dtype": "INTEGER16",
"value": "0",
"access": "RO",
"data": "&Obj.StepGenIn2.StepsPerMM"
}
],
"pdo_mappings": [
"rxpdo"
]
],
"dtype": "INTEGER16",
"value": "0",
"data": "&Obj.StepsPerMM1"
},
"7004": {
"otype": "VAR",
"name": "Enable1",
"name": "StepsPerMM2",
"access": "RO",
"pdo_mappings": [
"rxpdo"
],
"dtype": "BOOLEAN",
"dtype": "INTEGER16",
"value": "0",
"data": "&Obj.Enable1"
"data": "&Obj.StepsPerMM2"
},
"60664": {
"otype": "VAR",

View File

@@ -13,24 +13,21 @@ static const char acName1018_01[] = "Vendor ID";
static const char acName1018_02[] = "Product Code";
static const char acName1018_03[] = "Revision Number";
static const char acName1018_04[] = "Serial Number";
static const char acName1600[] = "EncPosScale";
static const char acName1600[] = "IndexLatchEnable";
static const char acName1600_00[] = "Max SubIndex";
static const char acName1600_01[] = "EncPosScale";
static const char acName1601[] = "IndexLatchEnable";
static const char acName1600_01[] = "IndexLatchEnable";
static const char acName1601[] = "CommandedPosition1";
static const char acName1601_00[] = "Max SubIndex";
static const char acName1601_01[] = "IndexLatchEnable";
static const char acName1602[] = "StepGenIn1";
static const char acName1601_01[] = "CommandedPosition1";
static const char acName1602[] = "CommandedPosition2";
static const char acName1602_00[] = "Max SubIndex";
static const char acName1602_01[] = "CommandedPosition";
static const char acName1602_02[] = "StepsPerMM";
static const char acName1603[] = "StepGenIn2";
static const char acName1602_01[] = "CommandedPosition2";
static const char acName1603[] = "StepsPerMM1";
static const char acName1603_00[] = "Max SubIndex";
static const char acName1603_01[] = "CommandedPosition";
static const char acName1603_02[] = "StepsPerMM";
static const char acName1604[] = "Enable1";
static const char acName1603_01[] = "StepsPerMM1";
static const char acName1604[] = "StepsPerMM2";
static const char acName1604_00[] = "Max SubIndex";
static const char acName1604_01[] = "Enable1";
static const char acName1604_02[] = "Padding 1";
static const char acName1604_01[] = "StepsPerMM2";
static const char acName1A00[] = "EncPos";
static const char acName1A00_00[] = "Max SubIndex";
static const char acName1A00_01[] = "EncPos";
@@ -46,12 +43,24 @@ static const char acName1A03_01[] = "IndexByte";
static const char acName1A04[] = "IndexStatus";
static const char acName1A04_00[] = "Max SubIndex";
static const char acName1A04_01[] = "IndexStatus";
static const char acName1A05[] = "StepGenOut1";
static const char acName1A05[] = "ActualPosition1";
static const char acName1A05_00[] = "Max SubIndex";
static const char acName1A05_01[] = "ActualPosition";
static const char acName1A06[] = "StepGenOut2";
static const char acName1A05_01[] = "ActualPosition1";
static const char acName1A06[] = "ActualPosition2";
static const char acName1A06_00[] = "Max SubIndex";
static const char acName1A06_01[] = "ActualPosition";
static const char acName1A06_01[] = "ActualPosition2";
static const char acName1A07[] = "D1";
static const char acName1A07_00[] = "Max SubIndex";
static const char acName1A07_01[] = "D1";
static const char acName1A08[] = "D2";
static const char acName1A08_00[] = "Max SubIndex";
static const char acName1A08_01[] = "D2";
static const char acName1A09[] = "D3";
static const char acName1A09_00[] = "Max SubIndex";
static const char acName1A09_01[] = "D3";
static const char acName1A0A[] = "D4";
static const char acName1A0A_00[] = "Max SubIndex";
static const char acName1A0A_01[] = "D4";
static const char acName1C00[] = "Sync Manager Communication Type";
static const char acName1C00_00[] = "Max SubIndex";
static const char acName1C00_01[] = "Communications Type SM0";
@@ -74,32 +83,30 @@ static const char acName1C13_04[] = "PDO Mapping";
static const char acName1C13_05[] = "PDO Mapping";
static const char acName1C13_06[] = "PDO Mapping";
static const char acName1C13_07[] = "PDO Mapping";
static const char acName1C13_08[] = "PDO Mapping";
static const char acName1C13_09[] = "PDO Mapping";
static const char acName1C13_10[] = "PDO Mapping";
static const char acName1C13_11[] = "PDO Mapping";
static const char acName6000[] = "EncPos";
static const char acName6001[] = "EncFrequency";
static const char acName6002[] = "DiffT";
static const char acName6003[] = "IndexByte";
static const char acName6004[] = "IndexStatus";
static const char acName6005[] = "StepGenOut1";
static const char acName6005_00[] = "Max SubIndex";
static const char acName6005_01[] = "ActualPosition";
static const char acName6006[] = "StepGenOut2";
static const char acName6006_00[] = "Max SubIndex";
static const char acName6006_01[] = "ActualPosition";
static const char acName7000[] = "EncPosScale";
static const char acName7001[] = "IndexLatchEnable";
static const char acName7002[] = "StepGenIn1";
static const char acName7002_00[] = "Max SubIndex";
static const char acName7002_01[] = "CommandedPosition";
static const char acName7002_02[] = "StepsPerMM";
static const char acName7003[] = "StepGenIn2";
static const char acName7003_00[] = "Max SubIndex";
static const char acName7003_01[] = "CommandedPosition";
static const char acName7003_02[] = "StepsPerMM";
static const char acName7004[] = "Enable1";
static const char acName6005[] = "ActualPosition1";
static const char acName6006[] = "ActualPosition2";
static const char acName6007[] = "D1";
static const char acName6008[] = "D2";
static const char acName6009[] = "D3";
static const char acName600A[] = "D4";
static const char acName7000[] = "IndexLatchEnable";
static const char acName7001[] = "CommandedPosition1";
static const char acName7002[] = "CommandedPosition2";
static const char acName7003[] = "StepsPerMM1";
static const char acName7004[] = "StepsPerMM2";
const _objd SDO1000[] =
{
{0x0, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1000, 5001, NULL},
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 5001, NULL},
};
const _objd SDO1008[] =
{
@@ -116,73 +123,90 @@ const _objd SDO100A[] =
const _objd SDO1018[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1018_00, 4, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1018_01, 2730, NULL},
{0x02, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1018_02, 12303564, NULL},
{0x03, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1018_03, 2, NULL},
{0x04, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1018_04, 1, &Obj.serial},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_01, 2730, NULL},
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_02, 12303564, NULL},
{0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_03, 2, NULL},
{0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_04, 1, &Obj.serial},
};
const _objd SDO1600[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1600_00, 1, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1600_01, 0x70000020, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_01, 0x70000020, NULL},
};
const _objd SDO1601[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 1, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1601_01, 0x70010020, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_01, 0x70010020, NULL},
};
const _objd SDO1602[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1602_00, 2, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1602_01, 0x70020140, NULL},
{0x02, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1602_02, 0x70020210, NULL},
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1602_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_01, 0x70020020, NULL},
};
const _objd SDO1603[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1603_00, 2, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1603_01, 0x70030140, NULL},
{0x02, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1603_02, 0x70030210, NULL},
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1603_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1603_01, 0x70030010, NULL},
};
const _objd SDO1604[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1604_00, 2, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1604_01, 0x70040001, NULL},
{0x02, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1604_02, 0x00000007, NULL},
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1604_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1604_01, 0x70040010, NULL},
};
const _objd SDO1A00[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A00_01, 0x60000040, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A00_01, 0x60000020, NULL},
};
const _objd SDO1A01[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A01_00, 1, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A01_01, 0x60010040, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_01, 0x60010020, NULL},
};
const _objd SDO1A02[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A02_00, 1, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A02_01, 0x60020020, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_01, 0x60020010, NULL},
};
const _objd SDO1A03[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A03_00, 1, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A03_01, 0x60030020, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A03_01, 0x60030020, NULL},
};
const _objd SDO1A04[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A04_00, 1, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A04_01, 0x60040020, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A04_01, 0x60040020, NULL},
};
const _objd SDO1A05[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A05_00, 1, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A05_01, 0x60050140, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A05_01, 0x60050020, NULL},
};
const _objd SDO1A06[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A06_00, 1, NULL},
{0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A06_01, 0x60060140, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A06_01, 0x60060020, NULL},
};
const _objd SDO1A07[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A07_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A07_01, 0x60070010, NULL},
};
const _objd SDO1A08[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A08_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A08_01, 0x60080010, NULL},
};
const _objd SDO1A09[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A09_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A09_01, 0x60090010, NULL},
};
const _objd SDO1A0A[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A0A_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A0A_01, 0x600A0010, NULL},
};
const _objd SDO1C00[] =
{
@@ -203,7 +227,7 @@ const _objd SDO1C12[] =
};
const _objd SDO1C13[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 7, NULL},
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 11, NULL},
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_01, 0x1A00, NULL},
{0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_02, 0x1A01, NULL},
{0x03, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_03, 0x1A02, NULL},
@@ -211,18 +235,22 @@ const _objd SDO1C13[] =
{0x05, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_05, 0x1A04, NULL},
{0x06, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_06, 0x1A05, NULL},
{0x07, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_07, 0x1A06, NULL},
{0x08, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_08, 0x1A07, NULL},
{0x09, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_09, 0x1A08, NULL},
{0x0a, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_10, 0x1A09, NULL},
{0x0b, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_11, 0x1A0A, NULL},
};
const _objd SDO6000[] =
{
{0x0, DTYPE_REAL64, 64, ATYPE_RO | ATYPE_TXPDO, acName6000, 0, &Obj.EncPos},
{0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6000, 0x00000000, &Obj.EncPos},
};
const _objd SDO6001[] =
{
{0x0, DTYPE_REAL64, 64, ATYPE_RO | ATYPE_TXPDO, acName6001, 0, &Obj.EncFrequency},
{0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6001, 0x00000000, &Obj.EncFrequency},
};
const _objd SDO6002[] =
{
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_TXPDO, acName6002, 0, &Obj.DiffT},
{0x0, DTYPE_UNSIGNED16, 16, ATYPE_RO | ATYPE_TXPDO, acName6002, 0, &Obj.DiffT},
};
const _objd SDO6003[] =
{
@@ -234,37 +262,47 @@ const _objd SDO6004[] =
};
const _objd SDO6005[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6005_00, 1, NULL},
{0x01, DTYPE_REAL64, 64, ATYPE_RO, acName6005_01, 0, &Obj.StepGenOut1.ActualPosition},
{0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6005, 0x00000000, &Obj.ActualPosition1},
};
const _objd SDO6006[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6006_00, 1, NULL},
{0x01, DTYPE_REAL64, 64, ATYPE_RO, acName6006_01, 0, &Obj.StepGenOut2.ActualPosition},
{0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6006, 0x00000000, &Obj.ActualPosition2},
};
const _objd SDO6007[] =
{
{0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_TXPDO, acName6007, 0, &Obj.D1},
};
const _objd SDO6008[] =
{
{0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_TXPDO, acName6008, 0, &Obj.D2},
};
const _objd SDO6009[] =
{
{0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_TXPDO, acName6009, 0, &Obj.D3},
};
const _objd SDO600A[] =
{
{0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_TXPDO, acName600A, 0, &Obj.D4},
};
const _objd SDO7000[] =
{
{0x0, DTYPE_INTEGER32, 32, ATYPE_RO | ATYPE_RXPDO, acName7000, 0, &Obj.EncPosScale},
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_RXPDO, acName7000, 0, &Obj.IndexLatchEnable},
};
const _objd SDO7001[] =
{
{0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_RXPDO, acName7001, 0, &Obj.IndexLatchEnable},
{0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7001, 0x00000000, &Obj.CommandedPosition1},
};
const _objd SDO7002[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7002_00, 2, NULL},
{0x01, DTYPE_REAL64, 64, ATYPE_RO, acName7002_01, 0, &Obj.StepGenIn1.CommandedPosition},
{0x02, DTYPE_INTEGER16, 16, ATYPE_RO, acName7002_02, 0, &Obj.StepGenIn1.StepsPerMM},
{0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7002, 0x00000000, &Obj.CommandedPosition2},
};
const _objd SDO7003[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7003_00, 2, NULL},
{0x01, DTYPE_REAL64, 64, ATYPE_RO, acName7003_01, 0, &Obj.StepGenIn2.CommandedPosition},
{0x02, DTYPE_INTEGER16, 16, ATYPE_RO, acName7003_02, 0, &Obj.StepGenIn2.StepsPerMM},
{0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_RXPDO, acName7003, 0, &Obj.StepsPerMM1},
};
const _objd SDO7004[] =
{
{0x0, DTYPE_BOOLEAN, 1, ATYPE_RO | ATYPE_RXPDO, acName7004, 0, &Obj.Enable1},
{0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_RXPDO, acName7004, 0, &Obj.StepsPerMM2},
};
const _objectlist SDOobjects[] =
@@ -276,9 +314,9 @@ const _objectlist SDOobjects[] =
{0x1018, OTYPE_RECORD, 4, 0, acName1018, SDO1018},
{0x1600, OTYPE_RECORD, 1, 0, acName1600, SDO1600},
{0x1601, OTYPE_RECORD, 1, 0, acName1601, SDO1601},
{0x1602, OTYPE_RECORD, 2, 0, acName1602, SDO1602},
{0x1603, OTYPE_RECORD, 2, 0, acName1603, SDO1603},
{0x1604, OTYPE_RECORD, 2, 0, acName1604, SDO1604},
{0x1602, OTYPE_RECORD, 1, 0, acName1602, SDO1602},
{0x1603, OTYPE_RECORD, 1, 0, acName1603, SDO1603},
{0x1604, OTYPE_RECORD, 1, 0, acName1604, SDO1604},
{0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00},
{0x1A01, OTYPE_RECORD, 1, 0, acName1A01, SDO1A01},
{0x1A02, OTYPE_RECORD, 1, 0, acName1A02, SDO1A02},
@@ -286,20 +324,28 @@ const _objectlist SDOobjects[] =
{0x1A04, OTYPE_RECORD, 1, 0, acName1A04, SDO1A04},
{0x1A05, OTYPE_RECORD, 1, 0, acName1A05, SDO1A05},
{0x1A06, OTYPE_RECORD, 1, 0, acName1A06, SDO1A06},
{0x1A07, OTYPE_RECORD, 1, 0, acName1A07, SDO1A07},
{0x1A08, OTYPE_RECORD, 1, 0, acName1A08, SDO1A08},
{0x1A09, OTYPE_RECORD, 1, 0, acName1A09, SDO1A09},
{0x1A0A, OTYPE_RECORD, 1, 0, acName1A0A, SDO1A0A},
{0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00},
{0x1C12, OTYPE_ARRAY, 5, 0, acName1C12, SDO1C12},
{0x1C13, OTYPE_ARRAY, 7, 0, acName1C13, SDO1C13},
{0x1C13, OTYPE_ARRAY, 11, 0, acName1C13, SDO1C13},
{0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000},
{0x6001, OTYPE_VAR, 0, 0, acName6001, SDO6001},
{0x6002, OTYPE_VAR, 0, 0, acName6002, SDO6002},
{0x6003, OTYPE_VAR, 0, 0, acName6003, SDO6003},
{0x6004, OTYPE_VAR, 0, 0, acName6004, SDO6004},
{0x6005, OTYPE_RECORD, 1, 0, acName6005, SDO6005},
{0x6006, OTYPE_RECORD, 1, 0, acName6006, SDO6006},
{0x6005, OTYPE_VAR, 0, 0, acName6005, SDO6005},
{0x6006, OTYPE_VAR, 0, 0, acName6006, SDO6006},
{0x6007, OTYPE_VAR, 0, 0, acName6007, SDO6007},
{0x6008, OTYPE_VAR, 0, 0, acName6008, SDO6008},
{0x6009, OTYPE_VAR, 0, 0, acName6009, SDO6009},
{0x600A, OTYPE_VAR, 0, 0, acName600A, SDO600A},
{0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000},
{0x7001, OTYPE_VAR, 0, 0, acName7001, SDO7001},
{0x7002, OTYPE_RECORD, 2, 0, acName7002, SDO7002},
{0x7003, OTYPE_RECORD, 2, 0, acName7003, SDO7003},
{0x7002, OTYPE_VAR, 0, 0, acName7002, SDO7002},
{0x7003, OTYPE_VAR, 0, 0, acName7003, SDO7003},
{0x7004, OTYPE_VAR, 0, 0, acName7004, SDO7004},
{0xffff, 0xff, 0xff, 0xff, NULL, NULL}
};

View File

@@ -0,0 +1,40 @@
#ifndef __UTYPES_H__
#define __UTYPES_H__
#include "cc.h"
/* Object dictionary storage */
typedef struct
{
/* Identity */
uint32_t serial;
/* Inputs */
float EncPos;
float EncFrequency;
uint16_t DiffT;
uint32_t IndexByte;
uint32_t IndexStatus;
float ActualPosition1;
float ActualPosition2;
int16_t D1;
int16_t D2;
int16_t D3;
int16_t D4;
/* Outputs */
uint32_t IndexLatchEnable;
float CommandedPosition1;
float CommandedPosition2;
int16_t StepsPerMM1;
int16_t StepsPerMM2;
} _Objects;
extern _Objects Obj;
#endif /* __UTYPES_H__ */

View File

@@ -0,0 +1,24 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:genericSTM32F407VGT6]
framework = arduino
platform = ststm32
board = genericSTM32F407VGT6
upload_protocol = stlink
debug_tool = stlink
debug_build_flags = -O0 -g -ggdb
monitor_port = COM10
monitor_filters = send_on_enter, time, colorize, log2file
monitor_speed = 115200
build_flags = -Wl,--no-warn-rwx-segment
lib_deps =
SPI
rlogiacco/CircularBuffer

View File

@@ -61,14 +61,19 @@ double MyEncoder::frequency(uint64_t time)
double diffT = 0;
double diffPos = 0;
double frequency;
TDelta.push(time); // Running average over the length of the circular buffer
Pos.push(curPos);
if (Pos.size() >= 2)
if (Pos.size() == RINGBUFFERLEN)
{
diffT = 1.0e-9 * (TDelta.last() - TDelta.first()); // Time is in nanoseconds
diffT = 1.0e-6 * (TDelta.last() - TDelta.first()); // Time is in microseconds
diffPos = fabs(Pos.last() - Pos.first());
frequency = diffPos / diffT;
oldFrequency = frequency;
return frequency; // Revolutions per second
}
return diffT != 0 ? diffPos / diffT : 0.0; // Revolutions per second
else
return oldFrequency;
}
uint8_t MyEncoder::getIndexState()
{

View File

@@ -0,0 +1,124 @@
#include <Arduino.h>
#include <stdio.h>
#include "StepGen2.h"
#include "extend32to64.h"
extern "C"
{
#include "esc.h"
}
extern extend32to64 longTime;
StepGen2::StepGen2(TIM_TypeDef *Timer, uint32_t _timerChannel, PinName _stepPin, uint8_t _dirPin, void irq(void), TIM_TypeDef *Timer2, void irq2(void))
{
actualPosition = 0;
commandedPosition = 0;
commandedStepPosition = 0;
initialPosition = 0;
initialStepPosition = 0;
stepsPerMM = 0;
enabled = 0;
dirPin = _dirPin;
dirPinName = digitalPinToPinName(dirPin);
stepPin = _stepPin;
pulseTimerChan = _timerChannel;
pulseTimer = new HardwareTimer(Timer);
pulseTimer->attachInterrupt(pulseTimerChan, irq); // Capture/compare innterrupt
pinMode(dirPin, OUTPUT);
startTimer = new HardwareTimer(Timer2);
startTimer->attachInterrupt(irq2);
}
uint32_t StepGen2::handleStepper(uint64_t irqTime, uint16_t nLoops)
{
frequency = 0;
nSteps = 0;
dbg = 0;
if (!enabled) // Just .... don't
return updatePos(0);
commandedStepPosition = floor(commandedPosition * stepsPerMM); // Scale position to steps
nSteps = commandedStepPosition - initialStepPosition;
if (nSteps == 0) // No movement
{
return updatePos(1);
}
lcncCycleTime = nLoops * StepGen2::sync0CycleTime * 1.0e-9; // nLoops is there in case we missed an ethercat cycle. secs
if (abs(nSteps) < 0) // Some small number
{ //
frequency = (abs(nSteps) + 1) / lcncCycleTime; // Distribute steps inside available time
Tpulses = abs(nSteps) / frequency; //
Tstartf = (lcncCycleTime - Tpulses) / 2.0; //
} //
else // Regular step train, up or down
{ //
float kTRAJ = (commandedPosition - initialPosition) / lcncCycleTime; // Straight line equation. position = kTRAJ x time + mTRAJ
float mTRAJ = initialPosition; // Operating on incoming positions (not steps)
if (kTRAJ > 0) //
Tstartf = (float(initialStepPosition + 1) / float(stepsPerMM) - mTRAJ) / kTRAJ; // Crossing upwards
else //
Tstartf = (float(initialStepPosition) / float(stepsPerMM) - mTRAJ) / kTRAJ; // Crossing downwards
frequency = fabs(kTRAJ * stepsPerMM); //
Tpulses = abs(nSteps) / frequency;
}
updatePos(5);
uint32_t timeSinceISR = (longTime.extendTime(micros()) - irqTime); // Diff time from ISR (usecs)
dbg = timeSinceISR; //
Tstartu = Tjitter + uint32_t(Tstartf * 1e6) - timeSinceISR; // Have already wasted some time since the irq.
if (nSteps == 0) // Can do this much earlier, but want some calculated data for debugging
return updatePos(1);
timerFrequency = uint32_t(ceil(frequency));
startTimer->setOverflow(Tstartu, MICROSEC_FORMAT); // All handled by irqs
startTimer->refresh();
startTimer->resume();
return 1;
}
void StepGen2::startTimerCB()
{
startTimer->pause(); // Once is enough.
digitalWriteFast(dirPinName, nSteps < 0 ? HIGH : LOW); // nSteps negative => decrease, HIGH
// There will be a short break here for t2 usecs, in the future.
timerEndPosition += nSteps;
pulseTimer->setMode(pulseTimerChan, TIMER_OUTPUT_COMPARE_PWM2, stepPin);
pulseTimer->setOverflow(timerFrequency, HERTZ_FORMAT);
// pulseTimer->setCaptureCompare(pulseTimerChan, 50, PERCENT_COMPARE_FORMAT);
pulseTimer->setCaptureCompare(pulseTimerChan, t3, MICROSEC_COMPARE_FORMAT);
pulseTimer->refresh();
pulseTimer->resume();
}
void StepGen2::pulseTimerCB()
{
int16_t dir = digitalReadFast(dirPinName); //
if (dir == HIGH) // The step just taken
timerPosition--;
else
timerPosition++;
int32_t diffPosition = timerEndPosition - timerPosition; // Same "polarity" as nSteps
if (diffPosition == 0)
pulseTimer->pause();
else
{
if (diffPosition < 0 && dir == LOW) // Change direction. Should not end up here, but alas
digitalWriteFast(dirPinName, HIGH); // Normal is to be HIGH when decreasing
if (diffPosition > 0 && dir == HIGH) // Change direction. Should not end up here, but alas
digitalWriteFast(dirPinName, LOW); // Normal is to be LOW when increasing
// Normally nothing is needed
}
}
uint32_t StepGen2::updatePos(uint32_t i)
{ //
initialPosition = commandedPosition; // Save the numeric position for next step
initialStepPosition = commandedStepPosition; // also the step we are at}
return i;
}
uint32_t StepGen2::sync0CycleTime = 0;

File diff suppressed because it is too large Load Diff

View File

@@ -263,7 +263,7 @@ void GPIO_PinAF(GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;
}
void rcc_config()
void encoder_config()
{
RCC->AHB1ENR |= 0x1; // GPIOA
RCC->AHB1ENR |= 0x4; // GPIOC
@@ -271,13 +271,13 @@ void rcc_config()
RCC->AHB1ENR |= 0x10; // GPIOE
RCC->APB1ENR |= 0x20000000; // ENABLE DAC
// RCC->APB2ENR |= 0x00000002; // APB2 TIM8
// RCC->APB2ENR |= 0x00000002; // APB2 TIM8
RCC->APB1ENR |= 0x00000004; // APB1 TIM4
RCC->APB1ENR |= 0x00000001; // APB1 TIM2
// RCC->APB1ENR |= 0x00000002; // APB1 TIM3
// RCC->APB1ENR |= 0x00000002; // APB1 TIM3
GpioConfigPortA(GPIOA);
// GpioConfigPortC(GPIOC);
// GpioConfigPortC(GPIOC);
GpioConfigPortD(GPIOD);
#if 0 // Skipping since TIM8 is step generator and TIM3, chan4 is smae as TIM8, chan4
GPIO_PinAF(GPIOA, GPIO_PinSource6, GPIO_AF_TIM3);
@@ -326,4 +326,66 @@ void rcc_config()
TIM3->CNT = 0;
#endif
}
void encoder2_config()
{
#if 0
#include "mbed.h"
#include "stm32f4xx.h"
#include "stm32f4xx_hal_tim_ex.h"
TIM_HandleTypeDef timer;
TIM_Encoder_InitTypeDef encoder;
// direction to PA_9 -- step pulse to PA_8
int main()
{
GPIO_InitTypeDef GPIO_InitStruct;
__TIM1_CLK_ENABLE();
__GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
timer.Instance = TIM1;
timer.Init.Period = 0xffff;
timer.Init.Prescaler = 0;
timer.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
timer.Init.CounterMode = TIM_COUNTERMODE_UP;
encoder.EncoderMode = TIM_ENCODERMODE_TI12;
encoder.IC1Filter = 0x0f;
encoder.IC1Polarity = TIM_INPUTCHANNELPOLARITY_RISING;
encoder.IC1Prescaler = TIM_ICPSC_DIV4;
encoder.IC1Selection = TIM_ICSELECTION_DIRECTTI;
encoder.IC2Filter = 0x0f;
encoder.IC2Polarity = TIM_INPUTCHANNELPOLARITY_FALLING;
encoder.IC2Prescaler = TIM_ICPSC_DIV4;
encoder.IC2Selection = TIM_ICSELECTION_DIRECTTI;
HAL_TIM_Encoder_Init(&timer, &encoder);
HAL_TIM_Encoder_Start(&timer,TIM_CHANNEL_1);
TIM1->EGR = 1; // Generate an update event
TIM1->CR1 = 1; // Enable the counter
while (1) {
int16_t count1;
count1=TIM1->CNT;
printf("%d\r\n", count1);
wait(1.0);
};
}
#endif
}

View File

@@ -0,0 +1,18 @@
#include "extend32to64.h"
// Extend from 32-bit to 64-bit precision
int64_t extend32to64::extendTime(uint32_t in)
{
int64_t c64 = (int64_t)in - HALF_PERIOD; // remove half period to determine (+/-) sign of the wrap
int64_t dif = (c64 - previousTimeValue); // core concept: prev + (current - prev) = current
// wrap difference from -HALF_PERIOD to HALF_PERIOD. modulo prevents differences after the wrap from having an incorrect result
int64_t mod_dif = ((dif + HALF_PERIOD) % ONE_PERIOD) - HALF_PERIOD;
if (dif < int64_t(-HALF_PERIOD))
mod_dif += ONE_PERIOD; // account for mod of negative number behavior in C
int64_t unwrapped = previousTimeValue + mod_dif;
previousTimeValue = unwrapped; // load previous value
return unwrapped + HALF_PERIOD; // remove the shift we applied at the beginning, and return
}

View File

@@ -0,0 +1,355 @@
#include <Arduino.h>
#include <stdio.h>
extern "C"
{
#include "ecat_slv.h"
#include "utypes.h"
};
_Objects Obj;
HardwareSerial Serial1(PA10, PA9);
volatile uint16_t ALEventIRQ; // ALEvent that caused the interrupt
HardwareTimer *baseTimer; // The base period timer
HardwareTimer *syncTimer; // The timer that syncs "with linuxcnc cycle"
uint32_t sync0CycleTime; // nanosecs, often 1000000 ( 1 ms )
#include "MyEncoder.h"
volatile uint16_t encCnt = 0;
void indexPulseEncoderCB1(void);
MyEncoder Encoder1(TIM2, PA2, indexPulseEncoderCB1);
void indexPulseEncoderCB1(void)
{
encCnt++;
Encoder1.indexPulse();
}
// #include <RunningAverage.h>
// RunningAverage irqServeDelays(1000); // To get the max delay of the irq serve time over the last second
CircularBuffer<uint16_t, 1000> irqServeDelays;
#include "StepGen3.h"
StepGen3 *Step = 0;
#include "extend32to64.h"
volatile uint64_t irqTime = 0, irqCnt = 0;
extend32to64 longTime;
void setFrequencyAdjustedMicrosSeconds(HardwareTimer *timer, uint32_t usecs);
void cb_set_outputs(void) // Master outputs gets here, slave inputs, first operation
{
Encoder1.setLatch(Obj.IndexLatchEnable);
Encoder1.setScale(2000);
}
volatile uint16_t basePeriodCnt;
volatile uint64_t makePulsesCnt = 0, prevMakePulsesCnt = 0;
volatile uint16_t deltaMakePulsesCnt;
volatile double posCmd1, posCmd2;
double oldPosCmd1, oldPosCmd2;
double deltaPosCmd1, deltaPosCmd2;
void syncWithLCNC()
{
syncTimer->pause();
baseTimer->pause();
deltaMakePulsesCnt = makePulsesCnt - prevMakePulsesCnt;
prevMakePulsesCnt = makePulsesCnt;
Step->updateStepGen(posCmd1, posCmd2, sync0CycleTime); // Update positions
Step->makeAllPulses(); // Make first step right here
basePeriodCnt = sync0CycleTime / BASE_PERIOD; //
baseTimer->refresh(); //
baseTimer->resume(); // Make the other steps in ISR
}
void basePeriodCB(void)
{
if (--basePeriodCnt > 0) // Stop
Step->makeAllPulses();
else
baseTimer->pause();
}
int32_t delayT;
uint16_t thisCycleTime; // In usecs
int16_t maxIrqServeTime = 0;
uint64_t oldIrqTime = 0;
uint16_t nLoops;
uint16_t failedSM2s = 0;
uint16_t totalFailedSM2s = 0;
uint16_t nLoopsAboveNorm = 0;
void handleStepper(void)
{
if (oldIrqTime != 0) // See if there is a delay in data, normally it *should* be nLoops=1, but sometimes it is more
{
thisCycleTime = irqTime - oldIrqTime;
nLoops = round(float(thisCycleTime) / float(sync0CycleTime / 1000));
nLoopsAboveNorm += nLoops - 1;
}
oldIrqTime = irqTime;
uint32_t diffT = longTime.extendTime(micros()) - irqTime; // Time from interrupt was received by isr
irqServeDelays.push(diffT);
if (irqServeDelays.isFull()) // Do max calcs, just waiting a second
{
uint16_t maxInBuffer = 0;
using index_t = decltype(irqServeDelays)::index_t;
for (index_t i = 0; i < irqServeDelays.size(); i++)
{
if (maxInBuffer < irqServeDelays[i])
maxInBuffer = irqServeDelays[i];
}
if (maxIrqServeTime > maxInBuffer) // Reduce by one, slowly eating up excess time
maxIrqServeTime--;
if (maxIrqServeTime < maxInBuffer)
maxIrqServeTime = maxInBuffer;
}
if (ALEventIRQ & ESCREG_ALEVENT_SM2)
{ // The normal case, position update every cycle
posCmd1 = Obj.CommandedPosition1; // The position update
posCmd2 = Obj.CommandedPosition2;
deltaPosCmd1 = posCmd1 - oldPosCmd1; // Needed for extrapolation in the other case
deltaPosCmd2 = posCmd2 - oldPosCmd2;
failedSM2s = 0;
}
else
{ // Not normal, we didn't get a position update. Extrapolate from previous updates
if (failedSM2s++ < 100) // Do max 10 such extrapolations, should be plenty
{ //
posCmd1 += deltaPosCmd1; // Continue with the same speed
posCmd2 += deltaPosCmd2;
}
totalFailedSM2s++;
}
oldPosCmd1 = posCmd1;
oldPosCmd2 = posCmd2;
// Obj.ActualPosition1 = Obj.CommandedPosition1;
// Obj.ActualPosition2 = Obj.CommandedPosition2;
Step->stepgen_array[0].pos_scale = -Obj.StepsPerMM1;
Step->stepgen_array[1].pos_scale = -Obj.StepsPerMM2;
Obj.ActualPosition1 = Step->stepgen_array[0].pos_fb;
Obj.ActualPosition2 = Step->stepgen_array[1].pos_fb;
delayT = maxIrqServeTime - diffT; // Add 10 as some safety margin
if (delayT > 0 && delayT < 900)
{
syncTimer->setOverflow(delayT, MICROSEC_FORMAT); // Work in flawed units, its ok
syncTimer->refresh();
syncTimer->resume();
}
else
{
syncWithLCNC();
}
}
float_t oldCommandedPosition = 0;
void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation
{
Obj.IndexStatus = Encoder1.indexHappened();
Obj.EncPos = Encoder1.currentPos();
Obj.EncFrequency = Encoder1.frequency(longTime.extendTime(micros()));
Obj.IndexByte = Encoder1.getIndexState();
Obj.DiffT = nLoops;
Obj.D1 = 1000 * deltaPosCmd2; // abs(1000 * (ap2 - Obj.CommandedPosition2)); // Step2.actPos();
Obj.D2 = totalFailedSM2s; // Step->stepgen_array[1].pos_fb; // Step->stepgen_array[1].rawcount % INT16_MAX; // Step->stepgen_array[1].freq;
Obj.D3 = 1000 * Obj.CommandedPosition2; // Step->stepgen_array[1].freq;
Obj.D4 = 1000 * posCmd2; // Step->stepgen_array[1].rawcount % UINT16_MAX;
oldCommandedPosition = Obj.CommandedPosition2;
}
void ESC_interrupt_enable(uint32_t mask);
void ESC_interrupt_disable(uint32_t mask);
uint16_t dc_checker(void);
void sync0Handler(void);
static esc_cfg_t config =
{
.user_arg = NULL,
.use_interrupt = 1,
.watchdog_cnt = 150,
.set_defaults_hook = NULL,
.pre_state_change_hook = NULL,
.post_state_change_hook = NULL,
.application_hook = handleStepper,
.safeoutput_override = NULL,
.pre_object_download_hook = NULL,
.post_object_download_hook = NULL,
.rxpdo_override = NULL,
.txpdo_override = NULL,
.esc_hw_interrupt_enable = ESC_interrupt_enable,
.esc_hw_interrupt_disable = ESC_interrupt_disable,
.esc_hw_eep_handler = NULL,
.esc_check_dc_handler = dc_checker,
};
void measureCrystalFrequency(void);
volatile byte serveIRQ = 0;
void setup(void)
{
Serial1.begin(115200);
#if 0
measureCrystalFrequency(); // Calibrate crystal frequency
#endif
Step = new StepGen3;
encoder_config(); // Needed by encoder, probably breaks some timers.
ecat_slv_init(&config);
pinMode(PA11, OUTPUT); // Step X
pinMode(PA12, OUTPUT); // Dir X
pinMode(PC9, OUTPUT); // Step Z
pinMode(PC10, OUTPUT); // Dir Z
baseTimer = new HardwareTimer(TIM11); // The base period timer
setFrequencyAdjustedMicrosSeconds(baseTimer, BASE_PERIOD / 1000);
// baseTimer->setOverflow(BASE_PERIOD / 1000, MICROSEC_FORMAT); // Or the line above, This one is uncalibrated
baseTimer->attachInterrupt(basePeriodCB);
syncTimer = new HardwareTimer(TIM3); // The Linuxcnc servo period sync timer
syncTimer->attachInterrupt(syncWithLCNC);
}
void loop(void)
{
uint64_t dTime;
if (serveIRQ)
{
DIG_process(ALEventIRQ, DIG_PROCESS_WD_FLAG | DIG_PROCESS_OUTPUTS_FLAG |
DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG);
serveIRQ = 0;
ESCvar.PrevTime = ESCvar.Time;
ecat_slv_poll();
}
dTime = longTime.extendTime(micros()) - irqTime;
if (dTime > 5000) // Don't run ecat_slv_poll when expecting to serve interrupt
ecat_slv_poll();
}
void sync0Handler(void)
{
ALEventIRQ = ESC_ALeventread();
// if (ALEventIRQ & ESCREG_ALEVENT_SM2)
{
irqTime = longTime.extendTime(micros());
serveIRQ = 1;
}
irqCnt++; // debug output
}
// Enable SM2 interrupts
void ESC_interrupt_enable(uint32_t mask)
{
// Enable interrupt for SYNC0 or SM2 or SM3
// uint32_t user_int_mask = ESCREG_ALEVENT_DC_SYNC0 | ESCREG_ALEVENT_SM2 | ESCREG_ALEVENT_SM3;
uint32_t user_int_mask = ESCREG_ALEVENT_SM2; // Only SM2
if (mask & user_int_mask)
{
ESC_ALeventmaskwrite(ESC_ALeventmaskread() | (mask & user_int_mask));
ESC_ALeventmaskwrite(ESC_ALeventmaskread() & ~(ESCREG_ALEVENT_DC_SYNC0 | ESCREG_ALEVENT_SM3));
attachInterrupt(digitalPinToInterrupt(PC3), sync0Handler, RISING);
// Set LAN9252 interrupt pin driver as push-pull active high
uint32_t bits = 0x00000111;
ESC_write(0x54, &bits, 4);
// Enable LAN9252 interrupt
bits = 0x00000001;
ESC_write(0x5c, &bits, 4);
}
}
// Disable SM2 interrupts
void ESC_interrupt_disable(uint32_t mask)
{
// Enable interrupt for SYNC0 or SM2 or SM3
// uint32_t user_int_mask = ESCREG_ALEVENT_DC_SYNC0 | ESCREG_ALEVENT_SM2 | ESCREG_ALEVENT_SM3;
uint32_t user_int_mask = ESCREG_ALEVENT_SM2;
if (mask & user_int_mask)
{
// Disable interrupt from SYNC0
ESC_ALeventmaskwrite(ESC_ALeventmaskread() & ~(mask & user_int_mask));
detachInterrupt(digitalPinToInterrupt(PC3));
// Disable LAN9252 interrupt
uint32_t bits = 0x00000000;
ESC_write(0x5c, &bits, 4);
}
}
extern "C" uint32_t ESC_SYNC0cycletime(void);
// Setup of DC
uint16_t dc_checker(void)
{
// Indicate we run DC
ESCvar.dcsync = 1;
sync0CycleTime = ESC_SYNC0cycletime(); // nanosecs
return 0;
}
//
// Code to calibrate the crystal.
//
#include <HardwareTimer.h>
HardwareTimer *timer;
volatile uint32_t cnt;
void CB(void)
{
if (cnt-- == 0)
{
timer->pause();
}
}
void setFrequencyAdjustedMicrosSeconds(HardwareTimer *timer, uint32_t usecs)
{
const uint16_t calibrated1000 = 1042; // <- This is the factor to adjust to make 1 sec = 1 sec
uint32_t period_cyc = (usecs * (timer->getTimerClkFreq() / 1000)) / calibrated1000; // Avoid overflow during math
uint32_t Prescalerfactor = (period_cyc / 0x10000) + 1;
uint32_t PeriodTicks = period_cyc / Prescalerfactor;
timer->setPrescaleFactor(Prescalerfactor);
timer->setOverflow(PeriodTicks, TICK_FORMAT);
// Serial1.printf("Period_cyc=%u Prescalefactor =%u ticks = %u\n", period_cyc, Prescalerfactor, PeriodTicks);
}
void measureCrystalFrequency(void)
{
timer = new HardwareTimer(TIM1);
Serial1.begin(115200);
delay(3000);
Serial1.printf("Clock freq = %u\n", timer->getTimerClkFreq());
setFrequencyAdjustedMicrosSeconds(timer, 1000);
timer->refresh();
timer->attachInterrupt(CB);
cnt = 10000;
Serial1.printf("\n");
uint32_t startT = micros();
timer->resume();
while (cnt != 0)
;
uint32_t endT = micros();
uint32_t diffT = endT - startT;
Serial1.printf("\n");
Serial1.printf("diff = %u\n", diffT);
Serial1.printf("\n");
delay(10000);
Serial1.printf("\n");
exit(0);
}

47
Cards/EaserCAT-2000/Kicad/.gitignore vendored Normal file
View File

@@ -0,0 +1,47 @@
fp-info-cache
Ethercat-stm32-backup*
*.lck
# For PCBs designed using KiCad: https://www.kicad.org/
# Format documentation: https://kicad.org/help/file-formats/
# Temporary files
*.000
*.bak
*.bck
*.kicad_pcb-bak
*.kicad_sch-bak
*-backups
*.kicad_prl
*.sch-bak
*~
_autosave-*
*.tmp
*-save.pro
*-save.kicad_pcb
fp-info-cache
~*.lck
\#auto_saved_files#
# Netlist files (exported from Eeschema)
*.net
# Autorouter files (exported from Pcbnew)
*.dsn
*.ses
# Exported BOM files
*.xml
*.csv
# Gerber outputs
Gerbers\*
*.zip
# Exported BOM files
*.xml
*.csv
*.step
*.stp
*.stl
.~lock.*

File diff suppressed because it is too large Load Diff

View File

@@ -169,6 +169,13 @@
"via_dimensions": [],
"zones_allow_external_fillets": false
},
"ipc2581": {
"dist": "",
"distpn": "",
"internal_id": "",
"mfg": "",
"mpn": ""
},
"layer_presets": [],
"viewports": []
},
@@ -427,14 +434,76 @@
"gencad": "",
"idf": "",
"netlist": "C:/Program Files/KiCad/7.0/",
"plot": "",
"pos_files": "",
"specctra_dsn": "Ethercat-stm32.dsn",
"step": "",
"svg": "",
"vrml": ""
},
"page_layout_descr_file": ""
},
"schematic": {
"annotate_start_num": 0,
"bom_export_filename": "",
"bom_fmt_presets": [],
"bom_fmt_settings": {
"field_delimiter": ",",
"keep_line_breaks": false,
"keep_tabs": false,
"name": "CSV",
"ref_delimiter": ",",
"ref_range_delimiter": "",
"string_delimiter": "\""
},
"bom_presets": [],
"bom_settings": {
"exclude_dnp": false,
"fields_ordered": [
{
"group_by": false,
"label": "Reference",
"name": "Reference",
"show": true
},
{
"group_by": true,
"label": "Value",
"name": "Value",
"show": true
},
{
"group_by": false,
"label": "Datasheet",
"name": "Datasheet",
"show": true
},
{
"group_by": false,
"label": "Footprint",
"name": "Footprint",
"show": true
},
{
"group_by": false,
"label": "Qty",
"name": "${QUANTITY}",
"show": true
},
{
"group_by": true,
"label": "DNP",
"name": "${DNP}",
"show": true
}
],
"filter_string": "",
"group_symbols": true,
"name": "Grouped By Value",
"sort_asc": true,
"sort_field": "Reference"
},
"connection_grid_size": 50.0,
"drawing": {
"dashed_lines_dash_length_ratio": 12.0,
"dashed_lines_gap_length_ratio": 3.0,
@@ -448,6 +517,11 @@
"intersheets_ref_suffix": "",
"junction_size_choice": 3,
"label_size_ratio": 0.375,
"operating_point_overlay_i_precision": 3,
"operating_point_overlay_i_range": "~A",
"operating_point_overlay_v_precision": 3,
"operating_point_overlay_v_range": "~V",
"overbar_offset_ratio": 1.23,
"pin_symbol_size": 25.0,
"text_offset_ratio": 0.15
},
@@ -463,6 +537,7 @@
"spice_external_command": "spice \"%I\"",
"spice_model_current_sheet_as_root": true,
"spice_save_all_currents": false,
"spice_save_all_dissipations": false,
"spice_save_all_voltages": false,
"subpart_first_id": 65,
"subpart_id_separator": 0
@@ -470,7 +545,7 @@
"sheets": [
[
"5597aedc-b607-407f-bbfd-31b3b298ecb1",
""
"Root"
],
[
"a120273a-c1ae-42b3-935d-01f789f654a3",

View File

@@ -0,0 +1,176 @@
(kicad_sch
(version 20231120)
(generator "eeschema")
(generator_version "8.0")
(uuid "5597aedc-b607-407f-bbfd-31b3b298ecb1")
(paper "A3")
(lib_symbols)
(text "Huvudsida"
(exclude_from_sim no)
(at 162.56 85.09 0)
(effects
(font
(size 1.27 1.27)
)
(justify left bottom)
)
(uuid "adf2be63-7ec7-44be-837f-901ddbc80717")
)
(sheet
(at 144.78 224.79)
(size 71.12 16.51)
(fields_autoplaced yes)
(stroke
(width 0.1524)
(type solid)
)
(fill
(color 0 0 0 0.0000)
)
(uuid "0a376a6c-0f15-42f8-81f6-3a55619be267")
(property "Sheetname" "Peripherals"
(at 144.78 224.0784 0)
(effects
(font
(size 1.27 1.27)
)
(justify left bottom)
)
)
(property "Sheetfile" "peripherals.kicad_sch"
(at 144.78 241.8846 0)
(effects
(font
(size 1.27 1.27)
)
(justify left top)
)
)
(instances
(project "Ethercat-stm32"
(path "/5597aedc-b607-407f-bbfd-31b3b298ecb1"
(page "5")
)
)
)
)
(sheet
(at 46.99 224.79)
(size 82.55 17.78)
(fields_autoplaced yes)
(stroke
(width 0.1524)
(type solid)
)
(fill
(color 0 0 0 0.0000)
)
(uuid "650f1ee4-2ce7-4e9d-a70d-f9d8defa5d03")
(property "Sheetname" "LAN9252_diverse"
(at 46.99 224.0784 0)
(effects
(font
(size 1.27 1.27)
)
(justify left bottom)
)
)
(property "Sheetfile" "LAN9252_diverse.kicad_sch"
(at 46.99 243.1546 0)
(effects
(font
(size 1.27 1.27)
)
(justify left top)
)
)
(instances
(project "Ethercat-stm32"
(path "/5597aedc-b607-407f-bbfd-31b3b298ecb1"
(page "3")
)
)
)
)
(sheet
(at 46.99 200.66)
(size 82.55 17.78)
(fields_autoplaced yes)
(stroke
(width 0.1524)
(type solid)
)
(fill
(color 0 0 0 0.0000)
)
(uuid "a120273a-c1ae-42b3-935d-01f789f654a3")
(property "Sheetname" "LAN9252"
(at 46.99 199.9484 0)
(effects
(font
(size 1.27 1.27)
)
(justify left bottom)
)
)
(property "Sheetfile" "LAN9252.kicad_sch"
(at 46.99 219.0246 0)
(effects
(font
(size 1.27 1.27)
)
(justify left top)
)
)
(instances
(project "Ethercat-stm32"
(path "/5597aedc-b607-407f-bbfd-31b3b298ecb1"
(page "2")
)
)
)
)
(sheet
(at 142.24 200.66)
(size 74.93 17.78)
(fields_autoplaced yes)
(stroke
(width 0.1524)
(type solid)
)
(fill
(color 0 0 0 0.0000)
)
(uuid "d564400f-40ba-4aca-9c2a-14ec52a8353b")
(property "Sheetname" "STM32F4"
(at 142.24 199.9484 0)
(effects
(font
(size 1.27 1.27)
)
(justify left bottom)
)
)
(property "Sheetfile" "STM32F4.kicad_sch"
(at 142.24 219.0246 0)
(effects
(font
(size 1.27 1.27)
)
(justify left top)
)
)
(instances
(project "Ethercat-stm32"
(path "/5597aedc-b607-407f-bbfd-31b3b298ecb1"
(page "4")
)
)
)
)
(sheet_instances
(path "/"
(page "1")
)
)
)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 4.8 MiB

After

Width:  |  Height:  |  Size: 4.8 MiB

View File

@@ -0,0 +1,159 @@
# Generated by PNCconf at Sat Sep 10 10:10:56 2016
# If you make changes to this file, they will be
# overwritten when you run PNCconf again
loadrt [KINS]KINEMATICS
#autoconverted trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadusr -W lcec_conf ethercat-conf.xml
loadrt lcec
loadrt metalmusings_encoder
addf lcec.read-all servo-thread
addf metalmusings-encoder.0 servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
#*******************
# AXIS X
#*******************
# --- joint signals for motion
net x-pos-cmd <= joint.0.motor-pos-cmd
net x-vel-cmd <= joint.0.vel-cmd
net x-pos-fb <= joint.0.motor-pos-fb
net x-enable <= joint.0.amp-enable-out
# --- connect stepper driver to joint
# 1/2 of stepper's p/rev 2000 => 1000
setp lcec.0.0.steps-per-mm-1 200
net x-pos-cmd => lcec.0.0.commanded-position-1
net x-pos-fb => lcec.0.0.actual-position-1
#net x-enable => lcec.0.0.enable
#*******************
# AXIS Z
#*******************
# --- joint signals for motion
net z-pos-cmd <= joint.1.motor-pos-cmd
net z-vel-cmd <= joint.1.vel-cmd
net z-pos-fb <= joint.1.motor-pos-fb
net z-enable <= joint.1.amp-enable-out
# --- connect stepper driver to the joint
setp lcec.0.0.steps-per-mm-2 80
# 1/5 of drive's step/rev
net z-pos-cmd => lcec.0.0.commanded-position-2
net z-pos-fb => lcec.0.0.actual-position-2
# net z-enable => lcec.0.0.enable
#*********************
# E-STOP
#*********************
setp iocontrol.0.emc-enable-in 1
#net estop iocontrol.0.emc-enable-in lcec.0.1.din-0
#setp lcec.0.3.enc-pos-scale [SPINDLE_9]ENCODER_SCALE
#setp lcec.0.0.enc-pos-scale [SPINDLE_9]ENCODER_SCALE
#net spindle-revs <= lcec.0.3.enc-pos
net spindle-revs <= lcec.0.0.enc-position
loadrt invert
loadrt mult2 names=mult2.rps,mult2.rpm
addf invert.0 servo-thread
addf mult2.rps servo-thread
addf mult2.rpm servo-thread
setp invert.0.in [SPINDLE_9]ENCODER_SCALE
setp mult2.rpm.in0 -60.0
setp mult2.rpm.in0 60.0
#net enc-invert-pos-scale mult2.rps.in0 <= invert.0.out
#net enc-get-freq-rps mult2.rps.in1 <= lcec.0.3.enc-frequency
#net spindle-vel-fb-rps mult2.rpm.in1 <= mult2.rps.out
#net spindle-vel-fb-rpm mult2.rpm.out
#net spindle-index-enable lcec.0.3.enc-index-c-enable
net spindle-vel-fb-rps mult2.rpm.in1 <= lcec.0.0.enc-frequency
net spindle-vel-fb-rpm mult2.rpm.out
net to_encoder metalmusings-encoder.0.index-latch-enable lcec.0.0.enc-index-latch-enable
net from_encoder metalmusings-encoder.0.index-status lcec.0.0.index-status
net spindle-index-enable metalmusings-encoder.0.index-c-enable
# ---setup spindle control signals---
net spindle-vel-cmd-rps <= spindle.0.speed-out-rps
net spindle-vel-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-vel-cmd-rpm <= spindle.0.speed-out
net spindle-vel-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-enable <= spindle.0.on
net spindle-cw <= spindle.0.forward
net spindle-ccw <= spindle.0.reverse
net spindle-brake <= spindle.0.brake
net spindle-revs => spindle.0.revs
net spindle-at-speed => spindle.0.at-speed
net spindle-vel-fb-rps => spindle.0.speed-in
net spindle-index-enable <=> spindle.0.index-enable
#******************************
# connect miscellaneous signals
#******************************
# ---HALUI signals---
net joint-select-a halui.axis.x.select
net x-is-homed halui.joint.0.is-homed
net jog-x-pos halui.axis.x.plus
net jog-x-neg halui.axis.x.minus
net jog-x-analog halui.axis.x.analog
net joint-select-b halui.axis.z.select
net z-is-homed halui.joint.1.is-homed
net jog-z-pos halui.axis.z.plus
net jog-z-neg halui.axis.z.minus
net jog-z-analog halui.axis.z.analog
net jog-selected-pos halui.axis.selected.plus
net jog-selected-neg halui.axis.selected.minus
net spindle-manual-cw halui.spindle.0.forward
net spindle-manual-ccw halui.spindle.0.reverse
net spindle-manual-stop halui.spindle.0.stop
net machine-is-on halui.machine.is-on
net jog-speed halui.axis.jog-speed
net MDI-mode halui.mode.is-mdi
# ---coolant signals---
net coolant-mist <= iocontrol.0.coolant-mist
net coolant-flood <= iocontrol.0.coolant-flood
# ---probe signal---
net probe-in => motion.probe-input
# ---motion control signals---
net in-position <= motion.in-position
net machine-is-enabled <= motion.motion-enabled
# ---digital in / out signals---
# ---estop signals---
net estop-out <= iocontrol.0.user-enable-out
net estop-ext => iocontrol.0.emc-enable-in
# ---manual tool change signals---
loadusr -W hal_manualtoolchange
#net tool-change-request iocontrol.0.tool-change => hal_manualtoolchange.change
#net tool-change-confirmed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
#net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
#net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
addf lcec.write-all servo-thread

View File

@@ -0,0 +1,164 @@
# This config file was created 2016-11-26 11:13:55.093594 by the update_ini script
# The original config files may be found in the /home/debian/linuxcnc/configs/Turner/Turner.old directory
# Generated by PNCconf at Fri Sep 9 22:31:33 2016
# If you make changes to this file, they will be
# overwritten when you run PNCconf again
[EMC]
# The version string for this INI file.
VERSION = 1.1
MACHINE = Turner
DEBUG = 0
[DISPLAY]
LATHE=1
DISPLAY = gmoccapy
BACK_TOOL_LATHE = 0
CYCLE_TIME = 150
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 2.000000
MAX_SPINDLE_OVERRIDE = 2.000000
MIN_SPINDLE_OVERRIDE = 0.500000
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 1
PROGRAM_PREFIX = /home/debian/linuxcnc/configs/Turner/nc_files
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm
LATHE = 1
POSITION_FEEDBACK = ACTUAL
DEFAULT_LINEAR_VELOCITY = 6.000000
MAX_LINEAR_VELOCITY = 25.000000
MIN_LINEAR_VELOCITY = 0.500000
DEFAULT_ANGULAR_VELOCITY = 12.000000
MAX_ANGULAR_VELOCITY = 1800.000000
MIN_ANGULAR_VELOCITY = 1.666667
EDITOR = gedit
#EMBED_TAB_NAME = Cycles
#EMBED_TAB_LOCATION = ntb_preview
#EMBED_TAB_LOCATION = ntb_user_tabs
#EMBED_TAB_COMMAND = halcmd loadusr -Wn gladevcp gladevcp -c gladevcp -U notouch=1 -U norun=0 -u lathehandler.py -x {XID} lathemacro.ui
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
SUBROUTINE_PATH = .:../../nc_files/subs:nc_files:../../../nc2
RS274NGC_STARTUP_CODE = G18 G21 G40 G49 G54 G80 G90 G94 G7 M9 M5 G64 P0.005
FEATURES=12
USER_M_PATH = nc_files:.
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
COMM_WAIT = 0.010
BASE_PERIOD = 100000
SERVO_PERIOD = 2000000
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[HAL]
TWOPASS = true
HALUI = halui
HALFILE = Turner.hal
#HALFILE = custom_vfd.hal
HALFILE = custom.hal
#HALFILE = xhc-hb04.tcl
#HALFILE = monitor_xhc-hb04.tcl
POSTGUI_HALFILE = postgui_call_list.hal
SHUTDOWN = shutdown.hal
[TRAJ]
COORDINATES = X Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
CYCLE_TIME = 0.010
DEFAULT_LINEAR_VELOCITY = 20.0
MAX_LINEAR_VELOCITY = 40.00
DEFAULT_ACCELERATION = 400.0
MAX_ACCELERATION = 400.0
NO_FORCE_HOMING = 1
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl
[KINS]
KINEMATICS = trivkins coordinates=XZ
#This is a best-guess at the number of joints, it should be checked
JOINTS = 2
#********************
# Axis X
#********************
[AXIS_X]
MIN_LIMIT = -106
MAX_LIMIT = 106
MAX_VELOCITY = 15.0
MAX_ACCELERATION = 400.0
[JOINT_0]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 1
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 400.0
MAX_OUTPUT = 0.0
MIN_LIMIT = -106
MAX_LIMIT = 106
HOME_SEARCH_VEL = 0
HOME_LATCH_VEL = 0
HOME_SEQUENCE = 0
#********************
# Axis Z
#********************
[AXIS_Z]
MIN_LIMIT = -560.0
MAX_LIMIT = 560.0
MAX_VELOCITY = 50.0
MAX_ACCELERATION = 400.0
[JOINT_1]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 1
MAX_VELOCITY = 75.0
MAX_ACCELERATION = 400.0
HOME_SEARCH_VEL = 0
HOME_LATCH_VEL = 0
HOME_SEQUENCE = 0
[SPINDLE_9]
P = 0.0
I = 0.0
D = 0.0
FF0 = 1.0
FF1 = 0.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 2400.0
OUTPUT_SCALE =5760
OUTPUT_MIN_LIMIT = 0
OUTPUT_MAX_LIMIT = 2400
#ENCODER_SCALE = -4000
ENCODER_SCALE = 2000

View File

@@ -0,0 +1,79 @@
[DEFAULT]
dro_digits = 3
dro_size = 28
abs_color = #0000FF
rel_color = #000000
dtg_color = #FFFF00
homed_color = #00FF00
unhomed_color = #FF0000
enable_dro = False
scale_jog_vel = 24.0
scale_spindle_override = 1
scale_feed_override = 1
scale_rapid_override = 1
spindle_bar_min = 0.0
spindle_bar_max = 6000.0
turtle_jog_factor = 20
hide_turtle_jog_button = False
unlock_code = 123
toggle_readout = True
spindle_start_rpm = 300.0
kbd_height = 250
view = y
blockheight = 0.0
reload_tool = False
open_file =
screen1 = window
hide_titlebar = False
x_pos = 40
y_pos = 30
width = 979
height = 750
use_toolmeasurement = False
gtk_theme = Follow System Theme
icon_theme = classic
audio_enabled = True
audio_alert = /usr/share/sounds/freedesktop/stereo/dialog-warning.oga
audio_error = /usr/share/sounds/freedesktop/stereo/dialog-error.oga
grid_size = 1.0
mouse_btn_mode = 4
hide_cursor = False
hide_tooltips = False
system_name_tool = Tool
system_name_g5x = G5x
system_name_rot = Rot
system_name_g92 = G92
system_name_g54 = G54
system_name_g55 = G55
system_name_g56 = G56
system_name_g57 = G57
system_name_g58 = G58
system_name_g59 = G59
system_name_g59.1 = G59.1
system_name_g59.2 = G59.2
system_name_g59.3 = G59.3
jump_to_dir = /home/debian
show_keyboard_on_offset = False
show_keyboard_on_tooledit = False
show_keyboard_on_edit = False
show_keyboard_on_mdi = False
show_keyboard_on_file_selection = False
x_pos_popup = 45.0
y_pos_popup = 55
width_popup = 250.0
max_messages = 10
message_font = sans 10
use_frames = True
blockdel = False
show_offsets = False
show_dtg = False
view_tool_path = False
view_dimension = True
run_from_line = no_run
unlock_way = no
show_preview_on_offset = False
use_keyboard_shortcuts = False
offset_axis_z = 150.0
diameter offset_axis_x = 0
offset_axis_x = 0.0

View File

@@ -0,0 +1,27 @@
THREAD servo-thread
MAXCHAN 4
HMULT 1
HZOOM 1
HPOS 4,132653e-01
CHAN 1
PIN lcec.0.0.D1
VSCALE 1
VPOS 0,781382
VOFF 0,000000e+00
CHAN 2
PIN lcec.0.0.DiffT
VSCALE 0
VPOS 0,678420
VOFF 0,000000e+00
CHAN 3
PIN lcec.0.0.D3
VSCALE 1
VPOS 0,743300
VOFF 2,000000e+02
CHAN 4
PIN lcec.0.0.D4
VSCALE 5
VPOS 0,364679
VOFF 0,000000e+00
TMODE 1
RMODE 2

View File

@@ -0,0 +1,31 @@
# core HAL config file for simulation
# first load all the RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb
net Zpos joint.1.motor-pos-cmd => joint.1.motor-pos-fb
# estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
net spindle-fwd spindle.0.forward
net spindle-rev spindle.0.reverse
#net spindle-speed spindle.0.speed-out
net lube iocontrol.0.lube
net flood iocontrol.0.coolant-flood
net mist iocontrol.0.coolant-mist

View File

@@ -0,0 +1,4 @@
# Gamepad
loadusr -W hal_input -KRAL F310
# Resten är i custom_postgui.hal

View File

@@ -0,0 +1,48 @@
# Include your custom HAL commands here
# Load the Huanyang VFD user component
loadusr -Wn spindle-vfd hy_vfd -n spindle-vfd -d /dev/hy_vfd -r 19200 -p none -s 1 -b 8
# motion.spindle-speed-in needs rev per second
loadrt scale names=scale.0,scale.1,scale.2
# scale.0 gearbox via M101-M106, M101 being lowest gear.
# scale.1 Inverted gear ratio
# scale.2 motion.spindle-speed.in in rev/sec
loadrt limit2 names=spindlemax
loadrt mult2 names=mult2.1
addf scale.0 servo-thread
addf scale.1 servo-thread
addf scale.2 servo-thread
addf mult2.1 servo-thread
addf spindlemax servo-thread
setp scale.0.gain 0.8846 # Start with fourth gear
setp scale.1.gain 1.13045
setp scale.2.gain 0.0166666667
setp mult2.1.in1 25.0
unlinkp spindle.0.forward
unlinkp spindle.0.reverse
unlinkp spindle.0.on
#unlinkp motion.spindle-at-speed
net spindle-fwd spindle.0.forward => spindle-vfd.spindle-forward
net spindle-reverse spindle.0.reverse => spindle-vfd.spindle-reverse
net spindle-on spindle.0.on => spindle-vfd.spindle-on
net spindle-at-speed <= spindle-vfd.spindle-at-speed
#net spindle-enable => spindle-vfd.enable
setp spindle-vfd.enable 1
# Prepare max limit rpm for spindle
net spindle-max-freq spindle-vfd.max-freq => mult2.1.in0
net spindle-max-rpm mult2.1.out => spindlemax.max # Max limit for motor rpm, like 67*25 = 1675
# Give speed to vfd, limited to max possible
unlinkp spindle.0.speed-out-abs
net spindle-speed-scale spindle.0.speed-out-abs => scale.1.in # Spindle rpm => Motor rpm
net spindle-speed-cmd-unlimited scale.1.out => spindlemax.in # Limit spindle rpm
net spindle-speed-cmd-limited spindlemax.out => spindle-vfd.speed-command # Feed to vfd
# Convert actual feed from rpm to rps, consider gear in use.
unlinkp spindle.0.speed-in
net spindle-speed-scale2 spindle-vfd.spindle-speed-fb => scale.2.in # Motor rpm => Motor rps
net spindle-speed-gears scale.2.out => scale.0.in # Motor rps => spindle rps
net spindle-speed-in scale.0.out => spindle.0.speed-in

View File

@@ -0,0 +1,59 @@
<masters>
<master idx="0" appTimePeriod="2000000" refClockSyncCycles="1">
<slave idx="0" type="generic" vid="00aaa" pid="000bbbccc" configPdos="true">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="500000"/>
<syncManager idx="2" dir="out">
<pdo idx="1600">
<pdoEntry idx="7000" subIdx="00" bitLen="32" halPin="enc-index-latch-enable" halType="u32"/>
</pdo>
<pdo idx="1601">
<pdoEntry idx="7001" subIdx="00" bitLen="32" halPin="commanded-position-1" halType="float-ieee"/>
</pdo>
<pdo idx="1602">
<pdoEntry idx="7002" subIdx="00" bitLen="32" halPin="commanded-position-2" halType="float-ieee"/>
</pdo>
<pdo idx="1603">
<pdoEntry idx="7003" subIdx="00" bitLen="16" halPin="steps-per-mm-1" halType="s32"/>
</pdo>
<pdo idx="1604">
<pdoEntry idx="7004" subIdx="00" bitLen="16" halPin="steps-per-mm-2" halType="s32"/>
</pdo>
</syncManager>
<syncManager idx="3" dir="in">
<pdo idx="1a00">
<pdoEntry idx="6000" subIdx="00" bitLen="32" halPin="enc-position" halType="float-ieee"/>
</pdo>
<pdo idx="1a01">
<pdoEntry idx="6001" subIdx="00" bitLen="32" halPin="enc-frequency" halType="float-ieee"/>
</pdo>
<pdo idx="1a02">
<pdoEntry idx="6002" subIdx="00" bitLen="16" halPin="DiffT" halType="u32"/>
</pdo>
<pdo idx="1a03">
<pdoEntry idx="6003" subIdx="00" bitLen="32" halPin="index-byte" halType="u32"/>
</pdo>
<pdo idx="1a04">
<pdoEntry idx="6004" subIdx="00" bitLen="32" halPin="index-status" halType="u32"/>
</pdo>
<pdo idx="1a05">
<pdoEntry idx="6005" subIdx="00" bitLen="32" halPin="actual-position-1" halType="float-ieee"/>
</pdo>
<pdo idx="1a06">
<pdoEntry idx="6006" subIdx="00" bitLen="32" halPin="actual-position-2" halType="float-ieee"/>
</pdo>
<pdo idx="1a07">
<pdoEntry idx="6007" subIdx="00" bitLen="16" halPin="D1" halType="s32"/>
</pdo>
<pdo idx="1a08">
<pdoEntry idx="6008" subIdx="00" bitLen="16" halPin="D2" halType="s32"/>
</pdo>
<pdo idx="1a09">
<pdoEntry idx="6009" subIdx="00" bitLen="16" halPin="D3" halType="s32"/>
</pdo>
<pdo idx="1a0a">
<pdoEntry idx="600a" subIdx="00" bitLen="16" halPin="D4" halType="s32"/>
</pdo>
</syncManager>
</slave>
</master>
</masters>

View File

@@ -0,0 +1,82 @@
<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="5">
<slave idx="0" type="EK1100"/>
<slave idx="1" type="EL1008"/>
<slave idx="2" type="EL2008"/>
<slave idx="3" type="EL5101"/>
<slave idx="4" type="generic" vid="00000a88" pid="0a880002" configPdos="true">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
<sdoConfig idx="2000" subIdx="0"><sdoDataRaw data ="b8 0b"/></sdoConfig> <!-- Max motor current (3.0A) -->
<sdoConfig idx="2003" subIdx="0"><sdoDataRaw data ="64 00"/></sdoConfig> <!-- Standby current percentage (100%) -->
<sdoConfig idx="2011" subIdx="0"><sdoDataRaw data ="00 00"/></sdoConfig> <!-- Open loop -->
<syncManager idx="2" dir="out">
<pdo idx="1600">
<pdoEntry idx="6040" subIdx="00" bitLen="16" halPin="cia-controlword" halType="u32"/>
<pdoEntry idx="6060" subIdx="00" bitLen="8" halPin="opmode" halType="s32"/>
<pdoEntry idx="607A" subIdx="00" bitLen="32" halPin="target-position" halType="s32"/>
<pdoEntry idx="60FF" subIdx="00" bitLen="32" halPin="target-velocity" halType="s32"/>
</pdo>
</syncManager>
<syncManager idx="3" dir="in">
<pdo idx="1a00">
<pdoEntry idx="6041" subIdx="00" bitLen="16" halPin="cia-statusword" halType="u32"/>
<pdoEntry idx="6061" subIdx="00" bitLen="8" halPin="opmode-display" halType="s32"/>
<pdoEntry idx="6064" subIdx="00" bitLen="32" halPin="actual-position" halType="s32"/>
<pdoEntry idx="606C" subIdx="00" bitLen="32" halPin="actual-velocity" halType="s32"/>
<pdoEntry idx="6077" subIdx="00" bitLen="32" halPin="actual-torque" halType="s32"/>
</pdo>
</syncManager>
</slave>
<slave idx="5" type="generic" vid="00000a88" pid="0a880002" configPdos="true">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
<sdoConfig idx="2000" subIdx="0"><sdoDataRaw data ="68 10"/></sdoConfig> <!-- Max motor current (4.2A) -->
<sdoConfig idx="2003" subIdx="0"><sdoDataRaw data ="64 00"/></sdoConfig> <!-- Standby current percentage (100%) -->
<sdoConfig idx="2011" subIdx="0"><sdoDataRaw data ="00 00"/></sdoConfig> <!-- Open loop -->
<syncManager idx="2" dir="out">
<pdo idx="1600">
<pdoEntry idx="6040" subIdx="00" bitLen="16" halPin="cia-controlword" halType="u32"/>
<pdoEntry idx="6060" subIdx="00" bitLen="8" halPin="opmode" halType="s32"/>
<pdoEntry idx="607A" subIdx="00" bitLen="32" halPin="target-position" halType="s32"/>
<pdoEntry idx="60FF" subIdx="00" bitLen="32" halPin="target-velocity" halType="s32"/>
</pdo>
</syncManager>
<syncManager idx="3" dir="in">
<pdo idx="1a00">
<pdoEntry idx="6041" subIdx="00" bitLen="16" halPin="cia-statusword" halType="u32"/>
<pdoEntry idx="6061" subIdx="00" bitLen="8" halPin="opmode-display" halType="s32"/>
<pdoEntry idx="6064" subIdx="00" bitLen="32" halPin="actual-position" halType="s32"/>
<pdoEntry idx="606C" subIdx="00" bitLen="32" halPin="actual-velocity" halType="s32"/>
<pdoEntry idx="6077" subIdx="00" bitLen="32" halPin="actual-torque" halType="s32"/>
</pdo>
</syncManager>
</slave>
<slave idx="6" type="generic" vid="00aaa" pid="000bbbccc" configPdos="true">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
<syncManager idx="2" dir="out">
<pdo idx="1600">
<pdoEntry idx="7000" subIdx="00" bitLen="32" halPin="enc-pos-scale" halType="s32"/>
</pdo>
<pdo idx="1601">
<pdoEntry idx="7001" subIdx="00" bitLen="32" halPin="enc-index-latch-enable" halType="u32"/>
</pdo>
</syncManager>
<syncManager idx="3" dir="in">
<pdo idx="1a00">
<pdoEntry idx="6000" subIdx="00" bitLen="32" halPin="enc-position" halType="float-ieee"/>
</pdo>
<pdo idx="1a01">
<pdoEntry idx="6001" subIdx="00" bitLen="32" halPin="enc-frequency" halType="float-ieee"/>
</pdo>
<pdo idx="1a02">
<pdoEntry idx="6002" subIdx="00" bitLen="32" halPin="DiffT" halType="u32"/>
</pdo>
<pdo idx="1a03">
<pdoEntry idx="6003" subIdx="00" bitLen="32" halPin="index-byte" halType="u32"/>
</pdo>
<pdo idx="1a04">
<pdoEntry idx="6004" subIdx="00" bitLen="32" halPin="index-status" halType="u32"/>
</pdo>
</syncManager>
</slave>
</master>
</masters>

View File

@@ -0,0 +1,83 @@
[DEFAULT]
dro_size = 28
abs_color = #0000FF
rel_color = #000000
dtg_color = #FFFF00
homed_color = #00FF00
unhomed_color = #FF0000
spindle_bar_min = 0.0
spindle_bar_max = 6000.0
unlock_code = 123
view = y
blockheight = 0.0
spindle_start_rpm = 300.0
scale_jog_vel = 140.4
scale_spindle_override = 1
scale_feed_override = 1
scale_rapid_override = 1
hide_turtle_jog_button = False
turtle_jog_factor = 20
open_file =
screen1 = window
x_pos = 40
y_pos = 30
width = 979
height = 750
gtk_theme = Follow System Theme
audio_alert = /usr/share/sounds/freedesktop/stereo/dialog-warning.oga
audio_error = /usr/share/sounds/freedesktop/stereo/dialog-error.oga
grid_size = 1.0
mouse_btn_mode = 4
hide_cursor = False
system_name_tool = Tool
system_name_g5x = G5x
system_name_rot = Rot
system_name_g92 = G92
system_name_g54 = G54
system_name_g55 = G55
system_name_g56 = G56
system_name_g57 = G57
system_name_g58 = G58
system_name_g59 = G59
system_name_g59.1 = G59.1
system_name_g59.2 = G59.2
system_name_g59.3 = G59.3
jump_to_dir = /home/emcmesa
show_keyboard_on_offset = False
show_keyboard_on_tooledit = False
show_keyboard_on_edit = False
show_keyboard_on_mdi = False
show_keyboard_on_file_selection = False
x_pos_popup = 45.0
y_pos_popup = 55
width_popup = 250.0
max_messages = 10
message_font = sans 10
use_frames = True
reload_tool = True
blockdel = False
opstop = False
enable_dro = False
show_offsets = False
show_dtg = False
view_tool_path = True
view_dimension = True
run_from_line = no_run
unlock_way = no
show_preview_on_offset = False
use_keyboard_shortcuts = True
dro_digits = 3
toggle_readout = True
tool_in_spindle = 3
diameter offset_axis_x = 0
offset_axis_x = 0.0
offset_axis_z = 0.0
offset_axis_r = 50.0
radius offset_axis_x = 0
use_toolmeasurement = False
kbd_height = 250
icon_theme = None
hide_tooltips = False
hide_titlebar = False
audio_enabled = True

View File

@@ -0,0 +1,22 @@
# Halshow settings
# This file is generated automatically.
wm geometry . 700x475+1121+46
placeFrames 0.3
set ::ratio 0.3
set ::old_w_leftf 160
set ::watchlist {
pin+lcec.0.0.DiffT
pin+lcec.0.0.D1
pin+lcec.0.0.D2
pin+lcec.0.0.D3
pin+lcec.0.0.D4
pin+lcec.0.0.commanded-position-2
pin+lcec.0.0.actual-position-2
}
set ::workmode watchhal
set ::watchInterval 100
set ::col1_width 100
set ::ffmts
set ::ifmts
set ::alwaysOnTop 0
set ::autoSaveWatchlist 1

View File

@@ -0,0 +1,159 @@
# EMC controller parameters for a simulated machine.
# General note: Comments can either be preceded with a # or ; - either is
# acceptable, although # is in keeping with most linux config files.
# General section -------------------------------------------------------------
[EMC]
VERSION = 1.1
MACHINE = gmoccapy_lathe
#DEBUG = 0x7FFFFFFF
DEBUG = 0
# for details see nc_files/subroutines/maco_instructions.txt
[DISPLAY]
DISPLAY = gmoccapy
LATHE = 1
BACK_TOOL_LATHE = 0
# Cycle time, in milliseconds, that display will sleep between polls
CYCLE_TIME = 100
# Highest value that will be allowed for feed override, 1.0 = 100%
MAX_FEED_OVERRIDE = 1.5
MAX_SPINDLE_OVERRIDE = 1.2
MIN_SPINDLE_OVERRIDE = .5
# Prefix to be used
PROGRAM_PREFIX = /home/debian/linuxcnc/nc_files
# Introductory graphic
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
# list of selectable jog increments
INCREMENTS = 1.000 mm, 0.100 mm, 0.010 mm, 0.001 mm
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Grayscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
# Task controller section -----------------------------------------------------
[RS274NGC]
RS274NGC_STARTUP_CODE = G18 G21 G40 G49 G54 G80 G90 G94 G8 M9 M5 G64 P0.005
PARAMETER_FILE = sim.var
SUBROUTINE_PATH = macros
# Motion control section ------------------------------------------------------
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
BASE_PERIOD = 100000
SERVO_PERIOD = 1000000
# Hardware Abstraction Layer section --------------------------------------------------
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
# Part program interpreter section --------------------------------------------
[HAL]
HALFILE = core_sim_lathe.hal
HALFILE = spindle_sim.hal
HALFILE = simulated_home_lathe.hal
# Single file that is executed after the GUI has started.
POSTGUI_HALFILE = gmoccapy_postgui.hal
HALUI = halui
# Trajectory planner section --------------------------------------------------
[HALUI]
#No Content
[TRAJ]
COORDINATES = X Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 50
MAX_LINEAR_VELOCITY = 234
POSITION_FILE = position.txt
#NO_FORCE_HOMING = 1
# First axis
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
# tool table file
TOOL_TABLE = lathe.tbl
[KINS]
KINEMATICS = trivkins coordinates=XZ
JOINTS = 2
[AXIS_X]
MIN_LIMIT = -50.0
MAX_LIMIT = 200.0
MAX_VELOCITY = 166
MAX_ACCELERATION = 1500.0
[JOINT_0]
TYPE = LINEAR
MAX_VELOCITY = 166
MAX_ACCELERATION = 1500.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -50.0
MAX_LIMIT = 200.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_OFFSET = 0.0
HOME = 100
HOME_SEARCH_VEL = 200.0
HOME_LATCH_VEL = 20.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
HOME_SEQUENCE = 1
HOME_IS_SHARED = 1
# Third axis
[AXIS_Z]
MIN_LIMIT = -75.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 166
MAX_ACCELERATION = 1500.0
[JOINT_1]
TYPE = LINEAR
MAX_VELOCITY = 166
MAX_ACCELERATION = 1500.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -75.0
MAX_LIMIT = 1000.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_OFFSET = 1.0
HOME = 250
HOME_SEARCH_VEL = 200.0
HOME_LATCH_VEL = 20.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
HOME_SEQUENCE = 0
HOME_IS_SHARED = 1
# section for main IO controller parameters -----------------------------------
[MACROS]
MACRO = i_am_lost
MACRO = halo_world
MACRO = jog_around
MACRO = increment xinc yinc
MACRO = go_to_position X-pos Y-pos Z-pos

Some files were not shown because too many files have changed in this diff Show More