Open LRAJA33 opened 10 months ago
I have pull out the git. it says it was upto date., but related /modified files for 32 bit not updated. So i have copy and paste the files (ethercat_src.c, ethercat_src.h,main.c and files in the ethercat handler)
Hey
This description does not fill me with confidence that you are indeed running the correct source. If you copy files manually you must be doing something wrong already. Socket error sounds like your plc runtime is segfaulting or something which is likely if you have source versions mixed up.
Meanwhile thiagoralves has merged my changes back to OpenPLC main repo and I just went ahead and merged the Wideregistersupport to main in my repo so 32bit/64bit support is now canon.
So maybe clone fresh https://github.com/thiagoralves/OpenPLC_v3.git and go from there. Also, https://github.com/r2k-in-the-vortex/ethercat_src/blob/main/README.md has been updated based on some of your feedback, so might be worth having a second look at that.
Dear Friend, I have cloned the fresh one and tried with different 'xml" file. Now servo was in PREOP state only. Not goes to SAFEOP. I dont know the reason. kindly tell me, why it was responding like this? i will try to check and solve it.
*Terminal Logs***** OpenPLC Runtime starting... 16:49:24 reading file '../utils/ethercat_src/build/ethercat.cfg' Interactive Server: Listening on port 43628 Interactive Server: waiting for new client... 16:49:24 xmlfilenameparam: /home/lraja/lr_r2k/OpenPLC_v3/utils/ethercat_src/build/master_config.xml 16:49:24 ethercat_device_indexparam: 0 16:49:24 verboseparam: 0 16:49:24 configonlyparam: 0 Configuring EtherCAT PLC IO Printout, copy this to VAR..END_VAR of main program or something Variable names may be modified at will as long as the adresses and variable sizes remain the same Slave0_2nd_Send_PDO_Maping AT %IW0.0 : UINT; ( SD700_ECAT_V1.2_G ) Slave0_2nd_Recive_PDO_Maping AT %QW0.0 : UINT; ( SD700_ECAT_V1.2_G ) Persistent Storage: Reading persistent.file into local buffers Setting main thread priority to RT Locking main thread memory Getting current time enabled 1 slave(s). AL states: PREOP. Link is up. Interactive Server: Client accepted! Creating thread for the new client ID: 5... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 5 Issued runtime_logs() command 10.10.169.3 - - [08/Dec/2023 16:49:25] "GET /runtime_logs HTTP/1.1" 200 - Interactive Server: client ID: 5 has closed the connection Terminating interactive server connections Openning database Enabling Modbus on port 502 Interactive Server: Client accepted! Creating thread for the new client ID: 5... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 5 Issued start_modbus() command to start on port: 502 Server: Listening on port 502 Server: waiting for new client... Enabling DNP3 on port 20000 Interactive Server: client ID: 5 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 5... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 5 Issued start_dnp3() command to start on port: 20000 Enabling EtherNet/IP on port 44818 Interactive Server: client ID: 5 has closed the connection Terminating interactive server connections DNP3 ID manager: Starting thread (0) channel state change: OPENING DNP3 ID DNP3_Server: Listening on: 0.0.0.0:20000 DNP3 Enabled Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Issued start_enip() command to start on port: 44818 Enabling Persistent Storage with polling rate of 10 seconds Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections Server: Listening on port 44818 Server: waiting for new client... Interactive Server: Client accepted! Creating thread for the new client ID: 11... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 11 Issued start_pstorage() command with polling rate of 10 seconds Interactive Server: client ID: 11 has closed the connection Terminating interactive server connections 10.10.169.3 - - [08/Dec/2023 16:49:25] "GET /start_plc HTTP/1.1" 302 - Interactive Server: Client accepted! Creating thread for the new client ID: 11... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 11 Interactive Server: client ID: 11 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 11... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 11 Interactive Server: client ID: 11 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 11... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 11 Interactive Server: client ID: 11 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 11... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 11 Interactive Server: client ID: 11 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 11... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 11 Interactive Server: Client accepted! Creating thread for the new client ID: 12... 10.10.169.3 - - [08/Dec/2023 16:49:26] "GET /dashboard HTTP/1.1" 200 - Interactive Server: client ID: 11 has closed the connection Terminating interactive server connections Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 12 Issued runtime_logs() command 10.10.169.3 - - [08/Dec/2023 16:49:26] "GET /runtime_logs HTTP/1.1" 200 - Interactive Server: client ID: 12 has closed the connection Terminating interactive server connections 10.10.169.3 - - [08/Dec/2023 16:49:26] "GET /static/openplc_logo.gif HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/default-user.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/home-icon-64x64.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/programs-icon-64x64.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/modbus-icon-512x512.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/arrow.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/monitoring-icon-64x64.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/hardware-icon-980x974.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/users-icon-64x64.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/settings-icon-64x64.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:27] "GET /static/logout-icon-64x64.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:49:28] "GET /favicon.ico HTTP/1.1" 404 - Interactive Server: Client accepted! Creating thread for the new client ID: 11... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 11 Issued runtime_logs() command Interactive Server: client ID: 11 has closed the connection Terminating interactive server connections 10.10.169.3 - - [08/Dec/2023 16:49:28] "GET /runtime_logs HTTP/1.1" 200 - Interactive Server: Client accepted! Creating thread for the new client ID: 11... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 11 Issued runtime_logs() command Interactive Server: client ID: 11 has closed the connection Terminating interactive server connections 10.10.169.3 - - [08/Dec/2023 16:49:29] "GET /runtime_logs HTTP/1.1" 200 - Domain1: WC 2. Domain1: State 1. Interactive Server: Client accepted! Creating thread for the new client ID: 11... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 11 Issued runtime_logs() command
*Terminal Logs***** OpenPLC Runtime starting... 16:37:01 reading file '../utils/ethercat_src/build/ethercat.cfg' Interactive Server: Listening on port 43628 Interactive Server: waiting for new client... 16:37:01 xmlfilenameparam: /home/lraja/lr_r2k/OpenPLC_v3/utils/ethercat_src/build/master_config.xml 16:37:01 ethercat_device_indexparam: 0 16:37:01 verboseparam: 0 16:37:01 configonlyparam: 0 Configuring EtherCAT PLC IO Printout, copy this to VAR..END_VAR of main program or something Variable names may be modified at will as long as the adresses and variable sizes remain the same Slave0_2nd_Send_PDO_Maping AT %IW0.0 : UINT; ( SD700_ECAT_V1.2_G ) Slave0_ActualLocationA AT %IW1.0 : UINT; ( SD700_ECAT_V1.2_G ) Slave0_ActualLocationB AT %IW2.0 : UINT; ( SD700_ECAT_V1.2_G ) Slave0_2nd_Recive_PDO_Maping AT %QW0.0 : UINT; ( SD700_ECAT_V1.2_G ) Slave0_TargetPosA AT %QW1.0 : UINT; ( SD700_ECAT_V1.2_G ) Slave0_TargetPosB AT %QW2.0 : UINT; ( SD700_ECAT_V1.2_G ) Persistent Storage: Reading persistent.file into local buffers Setting main thread priority to RT Locking main thread memory Getting current time enabled 1 slave(s). AL states: PREOP. Link is up. Interactive Server: Client accepted! Creating thread for the new client ID: 5... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 5 Issued runtime_logs() command Interactive Server: client ID: 5 has closed the connection Terminating interactive server connections 10.10.169.3 - - [08/Dec/2023 16:37:02] "GET /runtime_logs HTTP/1.1" 200 - Openning database Enabling Modbus on port 502 Interactive Server: Client accepted! Creating thread for the new client ID: 5... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 5 Issued start_modbus() command to start on port: 502 Server: Listening on port 502 Server: waiting for new client... Enabling DNP3 on port 20000 Interactive Server: client ID: 5 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 5... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 5 Issued start_dnp3() command to start on port: 20000 Enabling EtherNet/IP on port 44818 Interactive Server: client ID: 5 has closed the connection Terminating interactive server connections DNP3 ID manager: Starting thread (0) channel state change: OPENING DNP3 ID DNP3_Server: Listening on: 0.0.0.0:20000 DNP3 Enabled Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Issued start_enip() command to start on port: 44818 Server: Listening on port 44818 Server: waiting for new client... Enabling Persistent Storage with polling rate of 10 seconds Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Issued start_pstorage() command with polling rate of 10 seconds 10.10.169.3 - - [08/Dec/2023 16:37:03] "GET /start_plc HTTP/1.1" 302 - Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Interactive Server: Client accepted! Creating thread for the new client ID: 12... 10.10.169.3 - - [08/Dec/2023 16:37:03] "GET /dashboard HTTP/1.1" 200 - Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections Interactive Server: Thread created for client ID: 12 Issued runtime_logs() command Interactive Server: waiting for new client... 10.10.169.3 - - [08/Dec/2023 16:37:03] "GET /runtime_logs HTTP/1.1" 200 - Interactive Server: client ID: 12 has closed the connection Terminating interactive server connections 10.10.169.3 - - [08/Dec/2023 16:37:04] "GET /static/openplc_logo.gif HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:37:04] "GET /static/modbus-icon-512x512.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:37:04] "GET /static/monitoring-icon-64x64.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:37:04] "GET /static/hardware-icon-980x974.png HTTP/1.1" 304 - 10.10.169.3 - - [08/Dec/2023 16:37:04] "GET /static/default-user.png HTTP/1.1" 200 - 10.10.169.3 - - [08/Dec/2023 16:37:04] "GET /static/home-icon-64x64.png HTTP/1.1" 200 - 10.10.169.3 - - [08/Dec/2023 16:37:05] "GET /static/arrow.png HTTP/1.1" 200 - 10.10.169.3 - - [08/Dec/2023 16:37:05] "GET /static/programs-icon-64x64.png HTTP/1.1" 200 - 10.10.169.3 - - [08/Dec/2023 16:37:05] "GET /static/users-icon-64x64.png HTTP/1.1" 200 - 10.10.169.3 - - [08/Dec/2023 16:37:05] "GET /static/settings-icon-64x64.png HTTP/1.1" 200 - 10.10.169.3 - - [08/Dec/2023 16:37:05] "GET /static/logout-icon-64x64.png HTTP/1.1" 200 - 10.10.169.3 - - [08/Dec/2023 16:37:06] "GET /favicon.ico HTTP/1.1" 404 - Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Issued runtime_logs() command Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections 10.10.169.3 - - [08/Dec/2023 16:37:06] "GET /runtime_logs HTTP/1.1" 200 - Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Issued runtime_logs() command 10.10.169.3 - - [08/Dec/2023 16:37:07] "GET /runtime_logs HTTP/1.1" 200 - Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections Domain1: WC 2. Domain1: State 1. Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Issued runtime_logs() command Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections 10.10.169.3 - - [08/Dec/2023 16:37:09] "GET /runtime_logs HTTP/1.1" 200 - Interactive Server: Client accepted! Creating thread for the new client ID: 10... Interactive Server: waiting for new client... Interactive Server: Thread created for client ID: 10 Issued runtime_logs() command Interactive Server: client ID: 10 has closed the connection Terminating interactive server connections
kindly help
How about if you manually try and take it to OP state? You can do that with ethercat states command
Dear Friend, I am new to this environment. I have followed your instruction and read me file and done everything. previously with these implementation steps only I got my servo in OP state. I did not add anything other than your steps.
So only , I asked that why it was in PREOP state.? But my question makes you angry. sorry for that. Really i dont know the procedure. Kindly share the steps you have other than the read me, tutorial or book. I will study and try to implement. Can you come 15 min online help?
My servo not move to SAFE and OP.
Dear Friend , I have displayed the log message related to ethercat, it would be helpful to find any solution for the issue. kindly check and tell
Hmmmzz... hard to say why it did go to OP previously, but isn't now. A servo drive is a lot more complicated device than various digital IO-s I have tried before.
Could be there is some configuration that isn't done and that is why it refuses to go beyond PREOP.
Maybe if you could try to get it to OP state with some other master, TwinCAT or CodeSYS, then unplug while keeping drive under power and plug in IgH Ethercat master. Maybe then the correct internal state is retained and it can go to OP state.
If all else fails, try to revert back to the configuration that did go to OP state, even if you only have 16 bit registers there and try to make that work.
The code I have is what I have, it hasn't ever run such a servo drive.
Also, try and debug what is going on at the drive side. They usually have usb cable and their own configuration software etc, maybe there you find out what the issue is.
Dear Friend, Kindly confirm, whether i have downloaded the packages in a right way? i have shared image
git checkout main
is the command
Dear friend, Finally the servo transition was done to OP state. But it is for 16bit register only. when we configure 32 bit register , i am getting socket error. Kindly check and help me
===============16bit register ========================
<EtherCATInfoList>
<EtherCATInfo>
<!-- Slave 0 -->
<Vendor>
<Id>8716548</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x01030507" RevisionNo="#x02040608">SD700_ECAT Drive</Type>
<Name><![CDATA[SD700_ECAT_V1.2_G]]></Name>
<Sm Enable="1" StartAddress="#x1100" ControlByte="#x64" DefaultSize="2"/>
<Sm Enable="1" StartAddress="#x1400" ControlByte="#x20" DefaultSize="6"/>
<RxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT</DataType>
</Entry>
</RxPdo>
<TxPdo Sm="1" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x6041</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>StatusRegister</Name>
<DataType>UINT</DataType>
</Entry>
</TxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
</EtherCATInfoList>
===============32 bit added xml=============================
<EtherCATInfoList>
<EtherCATInfo>
<!-- Slave 0 -->
<Vendor>
<Id>8716548</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x01030507" RevisionNo="#x02040608">SD700_ECAT Drive</Type>
<Name><![CDATA[SD700_ECAT_V1.2_G]]></Name>
<Sm Enable="1" StartAddress="#x1100" ControlByte="#x64" DefaultSize="2"/>
<Sm Enable="1" StartAddress="#x1400" ControlByte="#x20" DefaultSize="6"/>
<RxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT</DataType>
</Entry>
<Entry>
<Index>#x60FF</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>TargetVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</RxPdo>
<TxPdo Sm="1" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x6041</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>StatusRegister</Name>
<DataType>UINT</DataType>
</Entry>
</TxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
</EtherCATInfoList>
Hmmmzz... well, you can always combine these 16 bit registers in PLC code and use it that way.
As for these xmls you have here... I think we previously found that all 4 sync managers need to be defined even though first two are not used by pdos. Not sure what it does exactly, but it seemed to be necessary.
To modify your last xml, maybe try something like following
<EtherCATInfoList>
<EtherCATInfo>
<!-- Slave 0 -->
<Vendor>
<Id>8716548</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x01030507" RevisionNo="#x02040608">SD700_ECAT Drive</Type>
<Name><![CDATA[SD700_ECAT_V1.2_G]]></Name>
<Sm Enable="1" StartAddress="#x1000" ControlByte="#x26" DefaultSize="128" />
<Sm Enable="1" StartAddress="#x1080" ControlByte="#x22" DefaultSize="128" />
<Sm Enable="1" StartAddress="#x1100" ControlByte="#x64" DefaultSize="2"/>
<Sm Enable="1" StartAddress="#x1400" ControlByte="#x20" DefaultSize="6"/>
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT</DataType>
</Entry>
<Entry>
<Index>#x60FF</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>TargetVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</RxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x6041</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>StatusRegister</Name>
<DataType>UINT</DataType>
</Entry>
</TxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
</EtherCATInfoList>
Or it could be that you need to configure the drive so that it does expose the velocity register. It has different control modes, position control, torque control etc and depending on which one you have configured the appropriate registers will work, or not work. They are not all always active I think. So if there is a mismatch between drive configuration and EtherCAT configuration, then it might refuse to enter OP mode.
Alright, I think I know why your drive is not starting. It's the very first thing I said at the start of the thread
Servo drive might honestly be a bit of a tall order, you'll be able to access the PDOs just fine, but if you need to configure the drive through SDOs then sorry, that is not implemented. Etherlabs master is capable of it, but my ethercat_src doesn't expose any mechanism for it, that would have to be created from scratch.
If you take these SD700 esi files and load them into TwinCAT, it creates this sort of list of SDO items it writes during PREOP before trying to go to OP
Quite a few items there and this 0x6060 index 0 write 8 - Op mode seems particularly interesting. But the rest of them might be necessary too.
You can't do this via OpenPLC, but you should be able to do it using the IgH master, you just probably have to write a shell script to do it all for you.
What you can try is to first stop OpenPLC, then in terminal do this SDO manipulation, or at least the most important seeming command:
sudo ethercat states preop
sudo ethercat download -p 4 -t uint8 0x6060 0 8
sudo ethercat states op
(wait a minute)
sudo ethercat slaves
And then start OpenPLC again and cross fingers.
If that doesn't work, then you have to write a script to configure all of those SDO values, according to the XML configuration you are giving to openplc. These need to be configured before you start openplc.
When the correct values are written to drive, and open plc tries to connect, then it should be able to start up.
Dear friend, Thanks for kind support. I will try it now. Kindly tell me the ways to solve the socket error?
Dear friend, I am trying to install ethercat connection newly. I am getting this messages while passing "git checkout main". How to proceed further.
Previously i have used wideregistersupport as new branch name. is that ok? if i did anything wrong, kindly correct me
Socket error is just because plc runtime is crashing due to invalid conf. You can cd OpenPLC_v3/webserver
and sudo ./core/openplc
to start openplc without web interface and see where it crashes.
git checkout main
is doing the right thing, wideregistersupport was a development branch, its no more because these changes have been merged back to main
Dear friend, I have solved the Socket error, by modifying the XML structure based on parsepdo function. But now unable to start the ethercat service.
"$ systemctl start ethercat
Job for ethercat.service failed because the control process exited with error code.
See "systemctl status ethercat.service" and "journalctl -xeu ethercat.service" for details.
I have tried this command , i am getting "modprobe: ERROR: could not insert 'ec_master'". screen shot shared here. kindly check and help.
Systemctl restart ethercat ? Or just reboot pi.
Dear friend, I have tried restart and reboot. not worked. so I reinstalled the package. I am getting "pdo entry registration failed" error. i have tried myself unable find the reason. Kindly tell the reason , i will try to solve it
Dear friend, Kindly help to work with twin cat. I have loaded my xml file. TwinCAT--->IO---->ethercat I have added ethercat device I have created new item by right click ethercat device
When i see the startup, no information getting as like you. kindly mention if any steps missed
Interesting, maybe you have slightly different esi file? I got mine from here: https://d.veichi.org/software/SD700-ethercat-xml-v1.0.zip
you can check if your product/revision and esi filename match
Anyway, if you have issues getting same TC setup as mine just do add existing
and use the .xti file in here: Drive 3 (SD700_ECAT Drive).zip
Dear friend, Kindly clarify this one. This my xml file (SD700) : xml1
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT</DataType>
</Entry>
<Entry>
<Index>#x60FF</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>TargetVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</RxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x6041</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>StatusRegister</Name>
<DataType>UINT</DataType>
</Entry>
<Entry>
<Index>#x6064</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualPosition</Name>
<DataType>UINT32</DataType>
</Entry>
<Entry>
<Index>#x606c</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualVelocity</Name>
<DataType>UINT32</DataType>
</Entry>
</TxPdo>
I have changed this as per your xml format, : xml2
```
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT</DataType>
</Entry>
</RxPdo>
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x60FF</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>TargetVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</RxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x6041</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>StatusRegister</Name>
<DataType>UINT</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x6064</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualPosition</Name>
<DataType>UINT32</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x606c</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualVelocity</Name>
<DataType>UINT32</DataType>
</Entry>
</TxPdo>
Will this changes affect the function of servo motor?. I have tested , and **xml2** only working, **xml1** is stucked with pdo registration failed error.
I have tried to modify the parsepdo function in xml_conf_parser.c code. , but not working. kindly give some idea
int ParsePdo(xmlNode *node, EcatPdo *pdo) {
char *ptr;
xmlNode *entry;
pdo->pdotype = strdup((char *)node->name);
pdo->sm = (uint16_t)strtol(getAttributeValueNamed(node, "Sm"), &ptr, 10);
pdo->fixed = strdup(getAttributeValueNamed(node, "Fixed"));
pdo->mandatory = strdup(getAttributeValueNamed(node, "Mandatory"));
pdo->index = (uint16_t)hexstrtoint32(getNodeTextContent(getSingularnodeNamed(node->children, "Index")));
pdo->name = strdup(getNodeTextContent(getSingularnodeNamed(node->children, "Name")));
entry = getSingularnodeNamed(node->children, "Entry");
int entryCount = 1;
while (entry != NULL) {
char entryIndexStr[20];
sprintf(entryIndexStr, "Entry%d", entryCount);
char *entryindex = getNodeTextContent(getSingularnodeNamed(entry->children, "Index"));
pdo->entryindex = (uint16_t)hexstrtoint32(entryindex);
pdo->subindex = strdup(getNodeTextContent(getSingularnodeNamed(entry->children, "SubIndex")));
pdo->bitlen = (uint8_t)strtol(getNodeTextContent(getSingularnodeNamed(entry->children, "BitLen")), &ptr, 10);
pdo->entryname = strdup(getNodeTextContent(getSingularnodeNamed(entry->children, "Name")));
pdo->datatype = strdup(getNodeTextContent(getSingularnodeNamed(entry->children, "DataType")));
log_trace("%s %i %s %s 0x%X %s 0x%X %s %i %s %s",
pdo->pdotype, pdo->sm, pdo->fixed, pdo->mandatory,
pdo->index, pdo->name, pdo->entryindex, pdo->subindex,
pdo->bitlen, pdo->entryname, pdo->datatype);
entry = getSingularnodeNamed(entry->next, "Entry");
entryCount++;
}
return 0;
}
Seems to me it does not affect function to do this xml modification, registering two PDOs with one entry each adds up to same thing as registering one PDO with two entries.
I have actually been working on a fix for this issue, but it's more complex than your attempt at modifying it and it's not ready yet. So use the modified xml method.
Your modification does not work because you only have one pdo datastructure that you are overwriting in a loop. It has space for one entry, so all you are really doing is writing configuring to use the last entry in the xmls PDO configuration. Which doesn't help you at all. Also I think getSingularnodeNamed() doesn't work if you have more than one node of the same name, it expects to find a singular node.
Dear friend,
I have found the reason for PDO entry registration error. I have passed this stage after modifying my xml structure as like your xml file.
``` <RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT16</DataType>
</Entry>
</RxPdo>
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x60FF</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>TargetVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</RxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x6041</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>StatusRegister</Name>
<DataType>UINT16</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x6064</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualPosition</Name>
<DataType>DINT32</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping</Name>
<Entry>
<Index>#x606c</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</TxPdo>```
For this , the PDO index print on the terminal as like below "13:41:53 PDO index 1/2 0x1602 entryindex 0x6040 subindex 1 bitlen 16 13:41:53 PDO index 2/2 0x1602 entryindex 0x60FF subindex 2 bitlen 32 13:41:53 Sync master 3 EC_DIR_INPUT 13:41:53 PDO index 1/3 0x1A02 entryindex 0x6041 subindex 1 bitlen 16 13:41:53 PDO index 2/3 0x1A02 entryindex 0x6064 subindex 2 bitlen 32 13:41:53 PDO index 3/3 0x1A02 entryindex 0x606C subindex 3 bitlen 32" Slave is configured. when pdo entry starts, I am getting pdo entry registration error
when i have changed the index as like 13:41:53 PDO index 1/2 0x1602 entryindex 0x6040 subindex 1 bitlen 16 13:41:53 PDO index 2/2 0x1603 entryindex 0x60FF subindex 2 bitlen 32 13:41:53 Sync master 3 EC_DIR_INPUT 13:41:53 PDO index 1/3 0x1A02 entryindex 0x6041 subindex 1 bitlen 16 13:41:53 PDO index 2/3 0x1A03 entryindex 0x6064 subindex 2 bitlen 32 13:41:53 PDO index 3/3 0x1A04 entryindex 0x606C subindex 3 bitlen 32 , the error is resolved.
the RxPDO index are "13:41:53 PDO index 1/2 0x1602 entryindex 0x6040 subindex 1 bitlen 16 13:41:53 PDO index 2/2 0x1602 entryindex 0x60FF subindex 2 bitlen 32" . I have changed to 0x1602 and 0x1603
similarly, 13:41:53 PDO index 1/3 0x1A02 entryindex 0x6041 subindex 1 bitlen 16 13:41:53 PDO index 2/3 0x1A03 entryindex 0x6064 subindex 2 bitlen 32 13:41:53 PDO index 3/3 0x1A04 entryindex 0x606C subindex 3 bitlen 32. I have changed to 0x1A02, 0x1A03, and 0x1A04
SO the PDO indexes are same, PDO entry registration occurs. and PDO indexes are not same , i am not getting any error. Kindly tell me how to solve this issue.
Well, maybe you do need to register several entries in one go then. You can try branch https://github.com/r2k-in-the-vortex/ethercat_src/tree/multientrydev
It should be able to handle PDO registrations like below, no guarantees tho as I haven't really finished all the work on that.
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT</DataType>
</Entry>
<Entry>
<Index>#x60FF</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>TargetVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</RxPdo>
Dear Friend, I will try thanks. I need one help. Kindly spend few minutes, to explain the process of the ethercat_src connection for better understanding. I have read some information from the terminal. I will share and explain briefly about each stages.
`OpenPLC starting
Read==> ethercat.cfg
Parsing the file ==> master_config.xml
Parsing slave EtherCAT info
Sm count
RxPDOs | TxPDOs
Configuring EtherCAT ( where it is happening? are we sent all those information from Rpi to Servo?
1. initialiing Ethercat ecrt_version_magic 67072
2. /dev/EtherCAT open
3. domain crearted
4. Rx registry count
5. Tx registry count
6. PDO index in sm-2 =output
7. PDO index in sm-3 =input
Slave Configured (what does means?)
Activating the Master
Process the data memory
/dev/EtherCAT0 set up, ready to start cyclic
PREOP => OP` Then we can start to program to control the servo.
kindly explain very short how the communication take place during the configuration and during the servo control. It will give basic understanding. kindly help friend.
Right, really you can follow through the code here https://github.com/r2k-in-the-vortex/ethercat_src/blob/main/src/ecat_handler/ecat_handler.c
It boils down to parsing the xml and preparing configuration to call this function https://github.com/ningfei/ethercat/blob/d7b000b5447624ab27bbe7f5df32230ffc2c8594/include/ecrt.h#L1638
As far as I know, there is no communication with slaves happening during this configuration, this is all just setup of the ethercat master, specifying the format of the ethercat frame to be sent out and received. All the cyclic process data object(PDO) read writes happen according to the ethercat headers as they are configured in the frame. Same frame passes through the entire chain of slaves, each one receiving(RxPDO) or transmitting(TxPDO) their data directly to that one frame. Sort of like so https://www.youtube.com/watch?v=z2OagcHG-UU
If you wish to know in detail how it all works you will have to dig thorough documentation, there is a lot to it. https://www.ethercat.org/en/technology.html
PLC IO printout is just necessary for user to write the PLC program correctly so variables map to IOs they are meant to.
Dear friend, I was unable to write the information to slave. Fore this command "sudo ethercat download -p 4 -t uint8 0x6060 0 8" I am getting this information "The slave selection matches 0 slaves. 'download' requires a single slave". kindly check and help
I have tried OP state via terminal , and it shows error code `"E". kindly check
Hi
check the parameters of the ethercat download command, i have a slave at position 4, so -p 4, but you only have one slave with index 0, so it says it cant find a slave at position 4. you have to adjust according to the setup and slave that you have.
Dear Friend, Thanks for your kind support. I have make it work by modifying the xml file.
working xml file
`
`
Output images:
observations: it works only when we add sm=0 and sm=1. if we add 2 and 3 in xml file , the servo stuck with safe op. Q1: is it right approach ?
images:
I have selected the pdos and entry index as marked below
Q1: Will it work? Shall I follow this xml format?
Input:
Slave0_1st_Send_PDO_Mapping: UINT := %IW0.0; => status register
Slave0_2nd_Send_PDO_Mapping: DINT := %ID1.0; => Actual position
Slave0_3rd_Send_PDO_Mapping: DINT := %ID2.0; => Actual velocity
output: Slave0_1st_Receive_PDO_Mapping: UINT := %QW0.0; => control register Slave0_2nd_Receive_PDO_Mapping: DINT := %QD1.0; => target position Slave0_3rd_Receive_PDO_Mapping: DINT := %QD2.0; => target velocity
=======================================================
Kindly suggest me to run the servo drive with openplc
I think you can't mix those like so
You have to pick one of those RxPDO configurations, 1600, 1601, 1602 or 1603, they are exclusive. Similarly for TxPDO
And depending on which one you picked you have the corresponding entries you need to map. And of course you need to configure the drive to use your selected registers by downloading correct SDO values before you attempt to take the drive to OP mode.
Thanks. But If I choose any one of the PDO configuration, i am getting the issue. I have chooses the 2nd PDO mapping. configurations [ 0x1602 and 0x1A02]
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1602</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT16</DataType>
</Entry>
<Entry>
<Index>#x60FF</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>TargetVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</RxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping2</Name>
<Entry>
<Index>#x6041</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>StatusRegister</Name>
<DataType>UINT16</DataType>
</Entry>
<Entry>
<Index>#x6064</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualPosition</Name>
<DataType>DINT32</DataType>
</Entry>
<Entry>
<Index>#x606C</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>Velocityactualvalue</Name>
<DataType>DINT32</DataType>
</Entry>
</TxPdo>
Terminal Output:
we are passing the below pdo information from xml file 06:43:56 RxPdos 1 | TxPdos 1 06:43:56 RxPdo 2 1 1 0x1602 2nd Recive PDO Maping 0x6040 0 16 ControlRegister UINT16 06:43:56 RxPdo 2 1 1 0x1602 2nd Recive PDO Maping 0x60FF 0 32 TargetVelocity DINT32 06:43:56 TxPdo 3 1 1 0x1A02 2nd Send PDO Maping2 0x6041 0 16 StatusRegister UINT16 06:43:56 TxPdo 3 1 1 0x1A02 2nd Send PDO Maping2 0x6064 0 32 ActualPosition DINT32 06:43:56 TxPdo 3 1 1 0x1A02 2nd Send PDO Maping2 0x606C 0 32 Velocityactualvalue DINT32
but during the slave configuration, only last pdo , entry indexes are accepted.
06:43:56 Sync master 2 EC_DIR_OUTPUT 06:43:56 PDO index 1/1 0x1602 entryindex 0x60FF subindex 1 bitlen 32 06:43:56 Sync master 3 EC_DIR_INPUT 06:43:56 PDO index 1/1 0x1A02 entryindex 0x606C subindex 1 bitlen 32 06:43:56 Slave configured
It accepts the only last entry index of each pdos. so only i have chooses required entry index from different pdos.
Now suggest me how to get all the pdo information for slave configuration.
hey, I tried, on my pi with this xml and it parsed it just fine
19:41:29 Slave SD700_ECAT Drive 0|0 8716548 0x01030507
19:41:29 Sync master 0 EC_DIR_INPUT
19:41:29 Sync master 1 EC_DIR_INPUT
19:41:29 Sync master 2 EC_DIR_OUTPUT
19:41:29 PDO index 1/1 0x1602 entryindex 0x6040 subindex 0 bitlen 16
19:41:29 PDO index 1/1 0x1602 entryindex 0x60FF subindex 0 bitlen 32
19:41:29 Sync master 3 EC_DIR_INPUT
19:41:29 PDO index 1/1 0x1A02 entryindex 0x6041 subindex 0 bitlen 16
19:41:29 PDO index 1/1 0x1A02 entryindex 0x6064 subindex 0 bitlen 32
19:41:29 PDO index 1/1 0x1A02 entryindex 0x606C subindex 0 bitlen 32
19:41:29 Slave configured
19:41:29 Slaves configured
19:41:29 PDO registry complete
19:41:29 RxPDO registries for linking with PLC
19:41:29 0 slave 0 SD700_ECAT_V1.2_G | 2nd Recive PDO Maping_ControlRegister | 16 bits
19:41:29 1 slave 0 SD700_ECAT_V1.2_G | 2nd Recive PDO Maping_TargetVelocity | 32 bits
19:41:29 TxPDO registries for linking with PLC
19:41:29 0 slave 0 SD700_ECAT_V1.2_G | 2nd Send PDO Maping2_StatusRegister | 16 bits
19:41:29 1 slave 0 SD700_ECAT_V1.2_G | 2nd Send PDO Maping2_ActualPosition | 32 bits
19:41:29 2 slave 0 SD700_ECAT_V1.2_G | 2nd Send PDO Maping2_Velocityactualvalue | 32 bits
PLC IO Printout, copy this to VAR..END_VAR of main program or something
Variable names may be modified at will as long as the adresses and variable sizes remain the same
Slave0_2nd_Send_PDO_Maping2_StatusRegister AT %IW0.0 : UINT; (* SD700_ECAT_V1.2_G *)
Slave0_2nd_Send_PDO_Maping2_ActualPosition AT %ID1.0 : DINT; (* SD700_ECAT_V1.2_G *)
Slave0_2nd_Send_PDO_Maping2_Velocityactualvalue AT %ID2.0 : DINT; (* SD700_ECAT_V1.2_G *)
Slave0_2nd_Recive_PDO_Maping_ControlRegister AT %QW0.0 : UINT; (* SD700_ECAT_V1.2_G *)
Slave0_2nd_Recive_PDO_Maping_TargetVelocity AT %QD1.0 : DINT; (* SD700_ECAT_V1.2_G *)
19:41:29 Activating master...
So I think you did not take the correct branch into use.
Go to ethercat_src
do git pull and status to check you are on latest clean branch of multientrydev
pi@raspberrypi:\~/OpenPLC_v3/utils/ethercat_src $ git pull
Already up to date.
pi@raspberrypi:\~/OpenPLC_v3/utils/ethercat_src $ git status
On branch multientrydev
Your branch is up to date with 'origin/multientrydev'.
nothing to commit, working tree clean
then do ./install.sh
then update your program from web interface, doing so recompiles, now with new installed ethercat_src library.
Dear Friend, Hearty thanks. Now it is reading all the entries. But when runs, it stuked with safeop state. So i have added the SDO part code in ethercat_handler.c code. I am getting socket error.
I have tried my best. Kindly suggest how to handle the sdo code ?
I have also tried other way as suggested by you, but not working and getting error
kindly help
Dear friend,
I have modified the xml file by adding only two sync manager. The drive now switching to op state. but i am not adding any sdo code. i have modified only syn manager.
i have used only these two,Sm Enable="1" StartAddress="#x1100" ControlByte="#x64" DefaultSize="2" and Sm Enable="1" StartAddress="#x1400" ControlByte="#x20" DefaultSize="6"
<EtherCATInfoList>
<EtherCATInfo>
<!-- Slave 0 -->
<Vendor>
<Id>8716548</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x01030507" RevisionNo="#x02040608">SD700_ECAT Drive</Type>
<Name><![CDATA[SD700_ECAT_V1.2_G]]></Name>
<!--<Sm Enable="1" StartAddress="#x1000" ControlByte="#x26" DefaultSize="128" /> -->
<!--<Sm Enable="1" StartAddress="#x1080" ControlByte="#x22" DefaultSize="128" /> -->
<Sm Enable="1" StartAddress="#x1100" ControlByte="#x64" DefaultSize="2"/>
<Sm Enable="1" StartAddress="#x1400" ControlByte="#x20" DefaultSize="6"/>
<RxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1602</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT16</DataType>
</Entry>
<Entry>
<Index>#x60FF</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>TargetVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</RxPdo>
<TxPdo Sm="1" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping2</Name>
<Entry>
<Index>#x6041</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>StatusRegister</Name>
<DataType>UINT16</DataType>
</Entry>
<Entry>
<Index>#x6064</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualPosition</Name>
<DataType>DINT32</DataType>
</Entry>
<Entry>
<Index>#x606C</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</TxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
</EtherCATInfoList>
Your suggestions are needed here. is the xml configuration right? Shall i proceed to next?
Hi
The way I would solve the SDOs is with a shell script, you only need to call it and set up SDOs once before starting openplc so make a file servo_drive_sdo_configuration.sh, make it executable, put all the correct download commands in there and there you have it. You have something like 50ish different registry writes you need to make if you simply copy working configuration form twincat or codesys. That's just to get the drive reliably to opmode. But then you need to start configuring the drive to actually run a servo, there are thousand parameters for that too. You want to rebuild and reinstall ethercat_src every step of the way there? Hard coding it in C seems like a poor idea to me and there is no need for it to be written in C, you have a mechanism to do it without.
As for the xml, for what reason did you remove the sync managers 0 and 1? These are mailbox sync managers, while I'm not sure how they are used exactly, but twincat does configure them and every ESI file out there shows them configured by default, so I wouldn't mess with them.
Also, this copying code and files in comments is getting kind of ridiculous, make a github repo and push your conf files etc, that way you yourself can also keep track of what changes you are making and why.
Dear friend, I have prepared the servo_drive_sdo_configuration.sh file.
#!/bin/bash
# Start EtherCAT
sudo systemctl start ethercat
# Set EtherCAT state to PREOP
sudo ethercat states preop
# Wait for 3 seconds
sleep 3
# EtherCAT SDO Configuration
sudo ethercat download -p 0 -t uint16 0x1C12 0 0
sudo ethercat download -p 0 -t uint16 0x1600 0 0
sudo ethercat download -p 0 -t uint16 0x1601 0 0
sudo ethercat download -p 0 -t uint16 0x1602 0 0
sudo ethercat download -p 0 -t uint16 0x1602 1 0x6040
sudo ethercat download -p 0 -t uint16 0x1602 1 0x6071
sudo ethercat download -p 0 -t uint16 0x1602 0 2
sudo ethercat download -p 0 -t uint16 0x1C12 1 0x1602
sudo ethercat download -p 0 -t uint16 0x1C12 0 1
sudo ethercat download -p 0 -t uint16 0x1C13 0 0
sudo ethercat download -p 0 -t uint16 0x1A00 0 0
sudo ethercat download -p 0 -t uint16 0x1A01 0 0
sudo ethercat download -p 0 -t uint16 0x1A02 0 0
sudo ethercat download -p 0 -t uint16 0x1A02 1 0x6041
sudo ethercat download -p 0 -t uint16 0x1A02 1 0x606C
sudo ethercat download -p 0 -t uint16 0x1A02 0 2
sudo ethercat download -p 0 -t uint16 0x1C13 1 0x1A02
sudo ethercat download -p 0 -t uint16 0x1C13 0 1
sudo ethercat download -p 0 -t uint16 0x6060 0 8
# Set EtherCAT state to OP
sudo ethercat states op
# Wait for 3 seconds
sleep 3
And followed the steps.
chmod +x servo_drive_sdo_configuration.sh
./servo_drive_sdo_configuration.sh
sudo ./start_openplc.sh
But still my servo stucked with safeop. i have passed dmesg command and get the detailed information. shared for your reference. kindly check and help me.
Kindly verify my 'servo_drive_sdo_configuration.sh" file
Kindly give me suggestion/ solution to solve the time out while setting state op.
Dear Friend,
I have observed one thing now.
I have used sm=0 for RxPDO and sm=1 for TxPDO. The servo goes to op state smoothly.
But if used sm=2 for RxPDO and sm=3 for TxPDO. The servo stuck with SAFEOP
What is your command about this? Kindly suggest the right way
Sm 2 and sm 3 are the correct ones.
If you wish to map 1602 and 1a02 like so:
then the startup list from TwinCAT looks like this:
You need to duplicate this entire list of commands in your script
Read the sudo ethercat download help
message and pay attention to size of variables.
For example opmode 0x6060 is not uint16, it's only 8bits, some other variables are 32 bits.
Dear Friend, Thanks. I will try by adding all the list. I have few clarification needed, With sdo configuration the servo works properly or it need dc configuration(distributed clock) and xenomai porting? Kindly explain
Dear Friend,
kindly help me to find the reason in this issue.
#!/bin/bash
# Start EtherCAT
sudo systemctl start ethercat
# Set EtherCAT state to PREOP
sudo ethercat states preop
# Wait for 3 seconds
sleep 3
# EtherCAT SDO Configuration
sudo ethercat download -p 0 -t uint8 0x1C12 0 0
sudo ethercat download -p 0 -t uint8 0x1C13 0 0
sudo ethercat download -p 0 -t uint8 0x1A00 0 0
sudo ethercat download -p 0 -t uint16 0x1A00 1 0x6041
sudo ethercat download -p 0 -t uint32 0x1A00 2 0x6064
sudo ethercat download -p 0 -t uint16 0x1A00 3 0x60B9
sudo ethercat download -p 0 -t uint32 0x1A00 4 0x60BA
sudo ethercat download -p 0 -t uint32 0x1A00 5 0x60FD
sudo ethercat download -p 0 -t uint8 0x1A00 0 0x05
sudo ethercat download -p 0 -t uint8 0x1A01 0 0
sudo ethercat download -p 0 -t uint16 0x1A01 1 0x6041
sudo ethercat download -p 0 -t uint16 0x1A01 2 0x6040
sudo ethercat download -p 0 -t uint32 0x1A01 3 0x606C
sudo ethercat download -p 0 -t uint8 0x1A01 0 0x03
sudo ethercat download -p 0 -t uint8 0x1A02 0 0
sudo ethercat download -p 0 -t uint16 0x1A02 1 0x6041
sudo ethercat download -p 0 -t uint16 0x1A02 2 0x6040
sudo ethercat download -p 0 -t uint32 0x1A02 3 0x606C
sudo ethercat download -p 0 -t uint8 0x1A02 0 0x03
sudo ethercat download -p 0 -t uint8 0x1A03 0 0
sudo ethercat download -p 0 -t uint16 0x1A03 1 0x6041
sudo ethercat download -p 0 -t uint32 0x1A03 2 0x6064
sudo ethercat download -p 0 -t uint32 0x1A03 3 0x6077
sudo ethercat download -p 0 -t uint8 0x1A03 0 0x03
sudo ethercat download -p 0 -t uint8 0x1600 0 0
sudo ethercat download -p 0 -t uint16 0x1600 1 0x6040
sudo ethercat download -p 0 -t uint32 0x1600 2 0x607A
sudo ethercat download -p 0 -t uint32 0x1600 3 0x6060
sudo ethercat download -p 0 -t uint16 0x1600 4 0x60B8
sudo ethercat download -p 0 -t uint8 0x1600 0 0x04
sudo ethercat download -p 0 -t uint8 0x1601 0 0
sudo ethercat download -p 0 -t uint16 0x1601 1 0x6040
sudo ethercat download -p 0 -t uint32 0x1601 2 0x607A
sudo ethercat download -p 0 -t uint32 0x1601 3 0x60FF
sudo ethercat download -p 0 -t uint8 0x1601 0 0x03
sudo ethercat download -p 0 -t uint8 0x1602 0 0
sudo ethercat download -p 0 -t uint16 0x1602 1 0x6040
sudo ethercat download -p 0 -t uint32 0x1602 2 0x60FF
sudo ethercat download -p 0 -t uint8 0x1602 0 0x02
sudo ethercat download -p 0 -t uint8 0x1603 0 0
sudo ethercat download -p 0 -t uint16 0x1603 1 0x6040
sudo ethercat download -p 0 -t uint32 0x1603 2 0x6071
sudo ethercat download -p 0 -t uint8 0x1603 0 0x02
sudo ethercat download -p 0 -t uint16 0x1C12 1 0x1601
sudo ethercat download -p 0 -t uint8 0x1C12 0 0x01
sudo ethercat download -p 0 -t uint16 0x1C13 1 0x1A01
sudo ethercat download -p 0 -t uint8 0x1C13 0 0x01
sudo ethercat download -p 0 -t uint8 0x6060 0 8
sudo ethercat download -p 0 -t uint16 0x60C2 1 0x04
sudo ethercat download -p 0 -t uint16 0x60C2 2 0xFD
# Set EtherCAT state to OP
sudo ethercat states op
# Wait for 3 seconds
sleep 3
I have prepared script as per your suggestions. Still I am getting safeop error. What may be the issue. dc config and xenomai porting is necessary? kindly give your suggestion
try without sudo systemctl start ethercat
in the beginning, ethercat should already be running, so it's not obvious restarting it is all that beneficial at the very beginning. And could you post the exact xml conf you are currently using.
Dear Friend,
Thanks. I will try without "sudo systemctl start ethercat". Here is the exact xml file currently using
<EtherCATInfoList>
<EtherCATInfo>
<!-- Slave 0 -->
<Vendor>
<Id>8716548</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x01030507" RevisionNo="#x02040608">SD700_ECAT Drive</Type>
<Name><![CDATA[SD700_ECAT_V1.2_G]]></Name>
<Sm Enable="1" StartAddress="#x1000" ControlByte="#x26" DefaultSize="128"/>
<Sm Enable="1" StartAddress="#x1080" ControlByte="#x22" DefaultSize="128"/>
<Sm Enable="1" StartAddress="#x1100" ControlByte="#x64" DefaultSize="2"/>
<Sm Enable="1" StartAddress="#x1400" ControlByte="#x20" DefaultSize="6"/>
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1602</Index>
<Name>2nd Recive PDO Maping</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>ControlRegister</Name>
<DataType>UINT16</DataType>
</Entry>
<Entry>
<Index>#x60FF</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>TargetVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</RxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>2nd Send PDO Maping2</Name>
<Entry>
<Index>#x6041</Index>
<SubIndex>0</SubIndex>
<BitLen>16</BitLen>
<Name>StatusRegister</Name>
<DataType>UINT16</DataType>
</Entry>
<Entry>
<Index>#x6064</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualPosition</Name>
<DataType>DINT32</DataType>
</Entry>
<Entry>
<Index>#x606C</Index>
<SubIndex>0</SubIndex>
<BitLen>32</BitLen>
<Name>ActualVelocity</Name>
<DataType>DINT32</DataType>
</Entry>
</TxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
</EtherCATInfoList>
Dear Friend, I have tried without sudo systemctl start ethercat. No change in the output. Can you come online 5 to 10 min to check the things when you are free? kindly help
Hi
Why are you not replicating the list from twincat exactly?
item nr 4 clearly states to download 0x60410010 to 0x1A00:01, but you do:
sudo ethercat download -p 0 -t uint16 0x1A00 1 0x6041
Why?
Just do the exact same thing that twincat does, it's probably correct.
sudo ethercat download -p 0 -t uint32 0x1A00 1 0x60410010
This is just the first difference from template that we got from TC, there are bunch more, please go through all of them carefully.
Dear friend,
Finally the drive comes to OP state. Next trying to communicate with plc code. I need your terminal logs to understand how you managed the blinky-blink state. Kindly send.
Dear friend ,
How to consider theses rxpdo and txpdo parameters?
It would be very help to give flow of execution for better understanding.
step 1: we have started the open plc on the raspberry pi terminal and it moves to op state and server related information are displaying
step 2: we will write the plc code on openplc editor and update the code via runtime control.
Now how the these values are mapped wih txpdo and rxpdo?
control register UINT16 %QW0.0
operating_mode UNIT8 %QB1.0
target_velocity DINT32 %QD2.0
Status register UINT16 %IW0.0
Actual Velocity DINT32 %ID1.0
Actual Position DINT32 %IID2.0
Then how the raspberry pi get these values and run the servo?
This is the part of the code in Ethercat cyclic function in Ethercat handler.
if(pdo.bitlength == 1){
uint8_t *ptrout = bool_output(i, 0);
if (*ptrout){
if(config->config_only_flag && i == 0) log_trace("OUT=1");
if(!config->config_only_flag) EC_WRITE_BIT(domain1_pd + pdo.offset, pdo.bit_position, 1);
}else{
if(config->config_only_flag && i == 0) log_trace("OUT=0");
if(!config->config_only_flag) EC_WRITE_BIT(domain1_pd + pdo.offset, pdo.bit_position, 0);
}
} else if(pdo.bitlength == 8){
uint8_t *ptrout = byte_output(i);
if(!config->config_only_flag && ptrout){
EC_WRITE_U8(domain1_pd + pdo.offset, *ptrout);
}
} else if(pdo.bitlength == 16){
uint16_t *ptrout = word_output(i);
if(!config->config_only_flag && ptrout){
EC_WRITE_U16(domain1_pd + pdo.offset, *ptrout);
}
How the parameters values in the openplc code comes here (pdo.offset and *ptrout)?
For operating_mode UNIT8 %QB1.0
If I send the operating_mode =3 // for velocity
ptrout =3 and how the "0x6060" move to pdo.offset
Kindly explain friend.
Will I write additional lines along with it or not?
Kindly help and give some ideas.
Hi
ethercat_src specifically prints out the configured IO addresses to be used in the PLC program, for example
Slave0_2nd_Send_PDO_Maping2_StatusRegister AT %IW0.0 : UINT; ( SD700_ECAT_V1.2_G ) Slave0_2nd_Send_PDO_Maping2_ActualPosition AT %ID1.0 : DINT; ( SD700_ECAT_V1.2_G ) Slave0_2nd_Send_PDO_Maping2_ActualVelocity AT %ID2.0 : DINT; ( SD700_ECAT_V1.2_G ) Slave0_2nd_Recive_PDO_Maping_ControlRegister AT %QW0.0 : UINT; ( SD700_ECAT_V1.2_G ) Slave0_2nd_Recive_PDO_Maping_TargetVelocity AT %QD1.0 : DINT; ( SD700_ECAT_V1.2_G )
You are free to change the names, just keep the variable sizes and binding addresses same.
Where are you taking target position from? There is no target position configured in 0x1602 PDO, you have only control word and target velocity there.
What is this "operating_mode UNIT8 %QB1.0" there is no such PDO.
You should create your own github repo with your configuration files, the xml and the .sh you are using and the plc code you are trying to get to work. You seem to be changing a lot of things all the time and I have no idea what configuration you are really running. Difficult to give constructive help that way.
I don't think the following is relevant to getting the drive to run, but here's the summary answers to your questions:
The way that the linking of PLC variables to IO registers happens is using webserver/core/glueVars.cpp Don't bother looking for that file in git, it's only generated during buildtime when you upload your PLC program using this utility https://github.com/thiagoralves/OpenPLC_v3/tree/master/utils/glue_generator_src
The piece of code you are looking at is fetching the registers of those addresses by the index, for example for %QD2.0 it fetches address with word_output(2); which calls this https://github.com/thiagoralves/OpenPLC_v3/blob/6621e30830e256dd271a5cf60e430164e080e7b0/webserver/core/main.cpp#L220
and fetches pointer to dint_output[2];
pdo.offset is location in the frame, that is stored when the frame is configured https://github.com/r2k-in-the-vortex/ethercat_src/blob/ae67684b101f1dddc6402a2e4a4fa6d701ea64be/src/ecat_handler/ecat_handler.c#L95
Dear friend,
Sorry for the inconvenience. I will upload all the files in github soon. Finally I have used these index registers
RxPDO:
control register UINT16 %QW0.0 = OUTPUT
operating_mode UNIT8 %QB1.0 = OUTPUT
target_velocity DINT32 %QD2.0 = OUTPUT
TxPDO Status register UINT16 %IW0.0 = INPUT Actual Velocity DINT32 %ID1.0 = INPUT Actual Position DINT32 %IID2.0 = INPUT
I have written a PLC code by referring the web sources.
PLC Program1:
Control_Register := 16#0006;
Operating_Mode := 3;
Control_Register := 16#0007;
Control_Register := 16#000F;
Target_Velocity := 1000;
Control_Register := 16#001F;
The communication cycle between the PLC code (OpenPLC) and the Raspberry pi EtherCAT device.
Its working. Operating_Mode := 3; is updated and get response. Slave is changed to velocity mode
But other registers are not properly responding. motor is not rotating. I have tried this by referring the c code. i will share the portion of code here, sample program:
if( (status & command) == 0x0040 )
{
EC_WRITE_U16(domain1_pd + offset.ctrl_word, 0x0006 );
EC_WRITE_S8(domain1_pd + offset.operation_mode, PROFILE_VELOCITY);
command = 0x006F;
}
else if( (status & command) == 0x0021)
{
EC_WRITE_U16(domain1_pd + offset.ctrl_word, 0x0007 );
command = 0x006F;
}
else if( (status & command) == 0x0023)
{
EC_WRITE_U16(domain1_pd + offset.ctrl_word, 0x000f );
command = 0x006F;
}
/*Read state*/
status = EC_READ_U16(domain1_pd + offset.status_word);
//operation enabled
if( (status & command) == 0x0027)
{
EC_WRITE_S32(domain1_pd + offset.target_velocity, TARGET_VELOCITY);
EC_WRITE_U16(domain1_pd + offset.ctrl_word, 0x001f );
}
}
I have converted this as a structural PLC code PLC Program2:
Command := 16#0040;
IF Status_Register AND Command = 16#0040 THEN
Operating_Mode := 3;
Control_Register := 16#0006;
Command := 16#006F;
ELSIF Status_Register AND Command = 16#0021 THEN
Control_Register := 16#0007;
Command := 16#006F;
ELSIF Status_Register AND Command = 16#0023 THEN
Control_Register := 16#000F;
Command := 16#006F;
ELSIF Status_Register AND Command = 16#0027 THEN
Target_Velocity := 1000;
Control_Register := 16#001F;
ELSE
Command := 16#0040;
END_IF;
Unbale to compile. Errors coming.
so I used the first code(PLC Program1:) without if loop. There I got a operation mode response only.
Kindly suggest,
operating_mode UNIT8 %QB1.0 = OUTPUT
Where are you getting that from?
Your ST code does not compile because you are trying to use Status_Register as if it was a boolean
if( (status & command) == 0x0040 )
does not translate to IF Status_Register AND Command = 16#0040 THEN
With matiec compiler it would translate to
IF AND(uint_to_word(Status_Register), uint_to_word(Command)) = 16#0040 THEN
But just because you get it compiling does not mean the code will work, if this sample code of yours uses this operating mode register, I don't think it matches the PDO configuration you were previously working on. RxPDO 1602 has control word and target velocity, that's it, if you have 1602 active the drive only does velocity control and no other mode so you don't need to select any operating mode.
Operating mode exists on RxPDO 1600, which is a completely different configuration.
Put your code up on github and we'll go from there
Hi...I have changed Operating mode to RxPDO 1600, and TxPDO 1A00. Yes I will upload on gituhub
Dear friend, I have upload all the files in the github. kindly check.
Hi,
I have tried to connect Etherlab igh Ethercat master with OpenPLC using ethercat_src. It is working. I can able to read the slave information by running "Ethercat master command".
upto this ok? or need to do some more steps for ethercat.
I need to write the code to control the velocity and position of the ethercat servo drive. I dont know how to start. Kindly tell me the procedure. How to write a code to control the servo motor using OpenPLC IDE ? and How to configure ".*xml " file in OpenPLC It would be very helpful , if you share the example code for the same.