-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distributed clocks / SYNC message #126
Comments
DC sync is indeed not trivial, but it is not that complicated too. The main reason of why it is not implemented yet is the lack of setup to test it thoroughly which is a really important aspect for us as the stack is used in industrial and critical software. About your problem: SYNC is a CAN concept that may be mapped to DC sync when using CoE profile (CAN over EtherCAT) but as my understanding of this part is scarce, it may also be mapped to something else. Can you send me the manual of your drive? Also can you do a network trace (wireshark or tcpdump) with CODESYS and with KickCAT from start to functional state (or blocked state with KickCAT)? With this I'm pretty sure that we will be able to at least workaround this situation :) |
Thanks, you can find what you're after here: https://thetooth.name/tmp/ Ignore the FRMW commands in the kickcat dump, that's just wishful thinking on my part. |
It seems that your module documentation have an update: It says that EtherCAT mode can be either free run or DC so it should work without DC enabled (12.2.2.1 ) If yes: how is the state of the DS402 Can Open state machine? In CoE (CAN over EtherCAT), one have to go to OPERATIONAL (EtherCAT) then CANOpen ON_STATE to be able to move a motor. In our Ingenia or Elmo example, there is CANOpenStateMachine that is responsible to move set the motor FSM in the right state to control it. |
Yeah I've based my code on that example, here's the output, control word on the left and status on the right in those bin outputs. It looks to be correct to me. Also although the target position is being shown in the tuning software for the servo, the target position on the display of the drive itself is updated once when the EtherCAT link is established and never again.
|
Hi, in the EEPROM of the slave there are configurations about enabling or not the DC sync Can you use the tool, eeprom from the repo, to dump the eeprom so that we can check the configurations of the slave ? |
@Rdk-T I think you're on to something, dump is here: https://thetooth.name/tmp/eeprom.bin |
Alright, we'll look into this next week. |
@thetooth I can not download the eeprom.bin file: I got either a 0 bytes file or a 430 forbidden error (with wget)? |
@leducp it should work now, forgot I was running everything as root to avoid setting caps. I have asked Delta about this issue and yet to get a response. |
OK I dig a bit in the eeprom and it says that: This configuration should be mirrored iin the register 0x0150 (you can read it with a FPRD from the master if you want). My understanding is that the slave device requires a DC configuration on the network. We could either add it to the stack or update the eeprom to set the slave config to free run (writing 0 at eeprom word 1). Do you have an eeprom configuration tool to try? Forget about this, I mess up when reading the datasheet because there are multiples tabs depending on the slave structure |
I'm up for anything at this point. Btw I am able to move the motor in profile velocity mode just fine, profile position mode is also broken and neither of those are really useful for the application I had in mind. |
OK I may have something to try: Here is the perdioc frame config: You can try to add something like that in your loop: uint8_t sync_time[8];
memset(sync_time, 0, 8);
auto process = [](DatagramHeader const*, uint8_t const* state, uint16_t wkc)
{
if (wkc != bus.slave.count())
{
printf("Oops: %d\n", wkc);
}
return DatagramState::OK;
};
auto error = [](DatagramState const&){};
link->addDatagram(Command::ARMW, createAddress(0xfffd, reg::DC_SYSTEM_TIME), sync_time, 8, process, error); |
Thanks, there are presently 5 slaves, EK1100 with two cards, followed by two drives. Is the address returned by |
Axxx commands (like ARMW) do not work with fixed addresses but with network position: each salve on the network increment the address field by one and when it reached 0 the slave is addressed. I think you can just try the AMRW commands as codesys do it and if it unlock the situation you can mess up / play with the others commands and addressing scheme (especially because we are in the dark and I don't know if something is missing yet) :) |
Note that the addressed slave for DC may not be the motor you want to control but the slave that own the network clock (that is used to synchronize the whole system). DC reference clock shall be the first slave on the network (or at least before others slaves that need it). |
Doesn't seem to care, in packet capture I see the DC packet go out with zero time and the master replies with an offset, so it's working properly in one direction. I also found this in the manual: Seems like an easy fix right? Only I get the following when trying to set that to zero: |
An easy fix indeeed, but it seems that your device do not support it, maybe because this is a pure CANOpen feature and this one is a CAN over EtherCAT that use the EtherCAT feature for this feature. I'm digging into the documentation of the DC feature to check if something else is needed. P.I. the doc is freely available: Chapter 9 for DC. |
OK found something I missed on first analysis: Note that 0x981 is left to 0 (mode Cyclic Acknowledge). Without that the system is in single shot which seems to be useless in your case (only one SYNC0 will be generated). This configuration is done during the PREOP state (so after bus.init() in KickCAT). Extract of the doc: 9.2.3.3 Cyclic Acknowledge Mode |
Another info: 9.2.3.6 SyncSignal Initialization Example
It seems that as mention by @Rdk-T the eeprom contains a configuration that set the PDI in DC mode. |
@thetooth any update about this problem? Since I don't have access to your hardware I cannot do much more to help you |
@leducp I tried quite a few things but never got anything satisfactory. I was only able to get the drive to move a handful of times by effectively "hot swapping" from codesys runtime over to kickcat, in this mode the drive will vibrate due to the lack of perfect synchronisation. At least for these drives the timing requirements are extremely tight, the standard sleep function used in the ingenia example is non-functional and you must use timespec with drift compensation to align the control loop with the DC sync0 offset returned by the last device in the configuration(see here), this has an operating range of <50uS, that is if you write PDO data 25uS before or after sync0+toff then the drive discards the change (it's written to the drive register but not committed to the state machine) until the next time things happen to line up. Additionally there are some gotchas with the way FRMW datagrams for the DC clock are handled, they must be part of the same frame as the PDO payload and also needs to be the first datagram, not doing this gives the same behaviour as above. I think we would have to modify kickcat a fair bit to get this happening. Atm I am using the SOEM library which is working well enough. They're similar enough that if you give me a week or two I can likely setup my code to switch between kickcat and SOEM, that way if someone wants to have a stab at a DC implementation I'll be able to test, wouldn't mind implementing it myself but work would get in the way :( |
@thetooth |
I'm currently working on a robotics project and have been entertaining the idea of replacing CODESYS which I have been using for the RT aspects of the system with an open source stack. Found this library and it's very cool, took maybe all of an hour to adapt the example and get my drive booted and PDO mapped. The problem I now face is its a Delta B3 drive and apparently wont move unless it's receiving some form of sync message.
Delta servo drives only support synchronous operation which is the controller periodically sends the SYNC object (COB-ID = 0x80).
The drive is fully powered up (locked shaft), receiving control word, target position and mode of operation, it's sending back all the right status word bits as well as actual position + velocity. But it refuses to budge. The only configuration difference between this and CODESYS I can see is that its not receiving a distributed clock.
Now the problem is that I only know a little bit about CoE, and next to nothing about EtherCAT itself. Reading what's out there it seems as though SYNC messages and distributed clocks are two different things, if that's true is there a quick and dirty way to generate that payload and get this project moving forward? I assume the only reason we don't already have DC in this library is because it's a non trivial task and unfortunately I'm probably not in the position to contribute one even though I would like to.
Any help would be much appreciated.
The text was updated successfully, but these errors were encountered: