Hello again.
I've been trying hard to follow up all your tips, and I am here to tell you that trying didn't used to be this hard.
I have, you'll recall, a problem getting my ProNET servo online, and I've come to you for help.
Before I tick off some of the things I've tried, let me ask 2 simple questions:
Is it normal that, while lcec is running, the ethercat commands for up- and download 'hang' until lcec is terminated, while "ethercat master, slave, cstruct, and pdos" run immediately? I was a little surprised.
Also, it would appear that, as long as the slave is powered up -- both while lcec is running, and while it's not -- the frame count from "ethercat masters" is increasing at about 1000/sec. I thought cyclic frames were only produced while a master is active. Is this normal?
With that out of the way, let me guide you through some of the things that didn't solve my problem:
Dead end #1: do it the way they tell you to do it.
I adapted the pronet xml from chimeno and used it to load the generic driver with a freshly-powered-up slave. See the attachment pronet_2.xml.
I started up lcec with this hal fragment:
Code:
loadusr -W lcec_conf /home/reid/linuxcnc-ethercat/examples/c3pr/pronet_2.xml
loadrt lcec
# apply 6-7-F control sequence to activate the motor.
net shouldercontrol lcec.0.shoulder.control
sets shouldercontrol 0x00000006
sets shouldercontrol 0x00000007
sets shouldercontrol 0x0000000f
The slave stayed in PREOP.
Plenty of hal pins were created. All the pins sourced from the slave are false or zero.
I did 'ethercat -p0 states OP' and it ran silently, but the slave stayed in PREOP.
I did 'ethercat -p0 pdos' and it listed an empty configuration:
Code:
~/linuxcnc-ethercat> ethercat -p0 pdos
SM0: PhysAddr 0x1000, DefaultSize 128, ControlRegister 0x36, Enable 1
SM1: PhysAddr 0x1080, DefaultSize 128, ControlRegister 0x32, Enable 1
SM2: PhysAddr 0x1100, DefaultSize 6, ControlRegister 0x74, Enable 1
SM3: PhysAddr 0x1d00, DefaultSize 6, ControlRegister 0x30, Enable 1
dmesg reports:
Code:
[450869.654923] EtherCAT WARNING 0: 65 datagrams TIMED OUT!
[450869.654929] EtherCAT WARNING 0: 1 datagram UNMATCHED!
[450871.028537] e1000: eth1 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX
[450871.030143] EtherCAT 0: Link state of ecm0 changed to UP.
[450871.034230] EtherCAT 0: 1 slave(s) responding on main device.
[450871.034237] EtherCAT 0: Slave states on main device: INIT.
[450871.034549] EtherCAT 0: Scanning bus.
[450871.089776] EtherCAT ERROR 0-0: SDO upload 0x0000:00 aborted.
[450871.089782] EtherCAT ERROR 0-0: SDO abort message 0x06020000: "This object does not exist in the object directory".
[450871.089784] EtherCAT ERROR 0-0: Failed to read number of mapped PDO entries.
[450871.089786] EtherCAT ERROR 0-0: Failed to read mapped PDO entries for PDO 0x0000.
[450871.108530] EtherCAT ERROR 0-0: SDO upload 0x0000:00 aborted.
[450871.108535] EtherCAT ERROR 0-0: SDO abort message 0x06020000: "This object does not exist in the object directory".
[450871.108537] EtherCAT ERROR 0-0: Failed to read number of mapped PDO entries.
[450871.108539] EtherCAT ERROR 0-0: Failed to read mapped PDO entries for PDO 0x0000.
[450871.108543] EtherCAT 0: Bus scanning completed in 76 ms.
[450871.108545] EtherCAT 0: Using slave 0 as DC reference clock.
[450871.112636] EtherCAT 0: Slave states on main device: PREOP.
[450893.559361] EtherCAT: Requesting master 0...
[450893.559367] EtherCAT: Successfully requested master 0.
[450893.559623] EtherCAT 0: Domain0: Logical address 0x00000000, 12 byte, expected working counter 3.
[450893.559626] EtherCAT 0: Datagram domain0-0-main: Logical offset 0x00000000, 12 byte, type LRW.
[450893.562153] EtherCAT 0: Master thread exited.
[450893.562158] EtherCAT 0: Starting EtherCAT-OP thread.
[450893.562197] EtherCAT WARNING 0: 189 datagrams UNMATCHED!
The first group of messages happens only when the slave is powered on and is probably normal ?
The next group happens when lcec starts up.
I'd done most of this before my first post, so not much of this is new.
Dead end #2: bash it into submission.
Using a freshly-powered-up slave and a bash script (see attachment pronet_2.txt), I did ethercat downloads to configure my slave before starting up lcec. This includes setting the MODE and providing the 6-7-F startup sequence.
Before starting lcec, the pdo configuration set up by the bash commands "looked good to me" and seemed to match the values used in the hal xml in dead end #1.
Code:
~/linuxcnc-ethercat> ethercat pdos
SM0: PhysAddr 0x1000, DefaultSize 128, ControlRegister 0x36, Enable 1
SM1: PhysAddr 0x1080, DefaultSize 128, ControlRegister 0x32, Enable 1
SM2: PhysAddr 0x1100, DefaultSize 6, ControlRegister 0x74, Enable 1
RxPDO 0x1602 ""
PDO entry 0x6040:00, 16 bit, ""
PDO entry 0x607a:00, 32 bit, ""
SM3: PhysAddr 0x1d00, DefaultSize 6, ControlRegister 0x30, Enable 1
TxPDO 0x1a02 ""
PDO entry 0x6041:00, 16 bit, ""
PDO entry 0x6064:00, 32 bit, ""
The motor actually turned on after the bash script, and I could control it with SDO downloads. (My wife was not impressed.)
ethercat -p0 states OP worked, but the drive reverted from 'run' to 'standby' when it went to OP.
I started up lcec while the slave was already in OP state, using the same generic xml as in dead end #1 (never mind that the xml and the ethercat commands are mostly redundant)
The slave stayed in OP mode.
The LINK light went to 'continuously on,' meaning "There is connection in link layer but there is no data exchange."
It was basically 'hung,' and 'ethercat -p0 states PREOP' failed to bring it out of OP state.
I repeated:
I powered up the slave afresh and ran the bash script to configure the PDOs, but this time I left it in PREOP when I started up lcec.
The slave stayed in PREOP mode.
The LINK light went to 'continuously on' again. It was basically 'hung' again and 'ethercat -p0 states OP'
I repeated with a twist:
I powered up the slave afresh and ran the bash script to configure the PDOs and again left it in PREOP before starting lcec.
This time, though, I changed configPdos="true" in the xml's 'slave' line to "false". I did this because, hey, the PDO's already got configured by the bash script, so why let the xml mess it up? (I also took out the sdoConfig stanza.)
Same thing: stayed in PREOP, LINK light stuck on.
No love!
Dead end #3:
"No error" from 'ethercat states' command, hmm? Perhaps, I thought, it's getting to OP just fine, but then getting chased out by ... a watchdog, maybe? I fiddled with my xml watchdog line, but nothing seemed to make a difference.
Dead end #4: do it the hard way
I built a custom lcec_pn4.c driver, but did not get better results. I found out the hard way that calls like ecrt_slave_config_sdo16() don't work in RT code. (Just like it says. Duh.)
I can believe that I screwed this up, so I won't drag you through it.
It seemed to me, though, that pretty much nothing in the xml was getting written to the slave, so I hacked the code with some rtpi_print_msg()'s so that I could watch as rtapi_app_main() and the generic driver processed the correct indices into the correct ecrt_whatever() calls, with good return codes. Everything looked good.
And yet, when the xml does something like:
Code:
<sdoConfig idx="6098" subIdx="0">
<sdoDataRaw data="23"/>
</sdoConfig>
and then I terminate lcec and go back to the command line, shouldn't
ethercat -p0 -t uint8 upload 0x6098 0
return 23? It returns whatever was in it before lcec ran, as though the sdoConfig never happened.
It's almost as though there were some kind of write-protect against sdo updates while lcec is running.
In all these cases, all the right hal pins are created, but all the inputs from the slave were false or zero.
It wasn't long ago that this was all greek to me, but by now, most of the code, docs, xml, concepts and samples make perfect sense, and this really ought to be straightforward.
Clearly, I'm doing something stupid, but what?
Thanks,
Reid