-
Notifications
You must be signed in to change notification settings - Fork 8
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
EtherCAT connection with OpenPLC and Raspberry Pi #5
Comments
Looks nice so far, please do Then make sure the path to xml is correct in conf/ethercat.cfg and switch configonly to =0 and then if you have everything installed right OpenPLC log should be printing out the ethercat PDO registries you can access in your PLC program. 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. Unless you are willing to try your hand at that challenge, I hope your drive has some alternative means to configure it, through usb cable or something. Anyway, let me know how it goes, I would love to hear my code being used and working out for someone's application. |
Dear Friend, Thanks for your kind reply. I have done upto ".xml generation. It would be very helpful if you share the simple code. Based on this i can proceed further. Kindly share sample code |
Have you installed OpenPLC with ethercat option? If you start it up do you get EtherCAT PDOs printed out in log? Like:
If so, then you are good to go, just declare those in your PLC program as normal and use them. |
When you press Start PLC button on the web interface, you should get something like this So look at those Runtime Logs and maybe upload that file you sent to pi, should be program_some_name.st I think there must be something quite wrong there because it sounds like it's not compiling properly Or you are uploading it incorrectly, you can do it via web interface without needing a pendrive: |
Hi I think you don't have EtherCAT option installed for OpenPLC, please use install command as indicated in readme
Even if you have raspberry, still use the same command. As for hiring, I have a job I'm plenty busy with. I'll gladly answer questions I see popping up here when I notice them, but this is pretty experimental piece of FOSS code with near non-existent user base. It's not a commercial product you can expect to deploy from an install wizard and just plug and play. Takes time and effort to get such things working. If your end goal is a working servo rather than getting open source code to do something it never has before, then there are companies that sell solutions for that sort of thing, CODESYS Group and Beckhoff to bring examples. And even then, paying quite a bit for software and hardware it's not one hour type of task from zero to working result. |
Looks to me like everything is ok on the ethercat side, modbus is what explodes on trying to open port 502 See if you can disable it Also, could you post contents of your master_config.xml, as text or file not image |
Dear friend |
Alright, I went through that xml and I think I know what the issues are and all of them are solvable by slightly modifying the xml First issue, pdo entry Name properties are empty and it doesn't handle it properly, bug on my end Second issue, multiple entries per Pdo elements, I don't think I have built handling for that.
Third issue - UINT32 registers, I think on OpenPLC side there was some gap in implementing those way back when so they are not implemented in ethercat_src. Those registries need to be broken up to two UINT16 types each. I improvised a bit based on https://d.veichi.com/manual/sd700-ethercat-communication-manual-v1.0.pdf at least in config only mode it does it's thing now, no idea how it will perform with actual hardware, some creativity in further customizing the xml file might be needed if things don't work right |
Hi, Is everything ok? Shall i test with PLC code? Now i am getting logs in run time. upto this what we called? ethercat connection established with openPLC? can you share the blink code you have done with ek100? i am totally new to this one. i need one reference code. with that i can able to complete. Kindly send |
Here is where you would find indication that everything is working right with EtherCAT Recording.2023-11-16.214705.mp4 |
Dear friend, Full log: thanks for the reference code i will work on it |
Turn configonlyparam off, I need to use it because I dont have real sd700 slave device, but you have real hardware so on your end this param should be set to 0. |
Hi, How did you find the vendor Id, product code and revision number? i have referred manual unable to get it. Id = 8716548 ProductCode="#x01030507" RevisionNo="#x02040608" |
Dear friend, I have compared your xml with sd700 (modified by you). your xml fille working good. and while using sd700 xml file "Sync master 0 [error invalid direction]" error coming. how to solve this sync master error? and other errors are kindly tell what are the parameter need to configure correctly? i will modify and try |
Alright, I found a few issues that are likely affecting you This is not a case for BOOL type digital IO, but with byte, int, dint registers, if you have a it in EtherCAT IO conf, you need to have it in PLC program too. So if your IO conf says this: But if you are running a blank program with nothing declared at %IW0.0, it just segfaults the moment ethercat starts working. Id, Product code, revision etc those all came from your initial conf file, nowhere else. I don't quite understand the logic of all those modifications you did in your version of xml, lets try the other way, make it as minimal as possible, try the following, it has control register, status register and nothing else. This will print out IO conf like so:
So make sure you have those declared in your plc program
|
Well, the good news is the configuration passes successfully and EtherCAT has started communicating. The bad news is, the drive is stuck in SAFEOP, which means it's not going to do anything. That is likely because we removed those other pdo entries to simplify the problem, so one by one you need to add those back. Next RxPDO entry is 607a, target location, but it's a 32bit register, OpenPLC only supports up to 16 bit registers. So have to break it up and hope it can work. Same story for 6064 location actual. Let see, try the following:
Make sure to update on PLC program side and add necessary variables.
|
Hi, I am getting the following response after adding the Next PDOs Run time log:OpenPLC Runtime starting... Again servo drive is stuck in SAFEOP |
Try |
hi, the pdos response lraja@lraja-desktop:~/OpenPLCRpi/OpenPLC_v3$ sudo ethercat pdos |
Well, it wants those 0x60ff and 0x606c velocity registers, try adding them see if that improves things
Add PLC variables too of course
|
Hi, the web runtime response after adding the above one web runtime:OpenPLC Runtime starting... |
hmmmm... maybe it really wants those sync managers with zero PDOs on them for some reason SM0: PhysAddr 0x1000, DefaultSize 128, ControlRegister 0x26, Enable 1 As you remember, that threw an error previously, well, I did an update so it should at least pass configuration.
|
Dear friend, I have referred one forum related to SAFEOP . They shared the below solution "Ok so I have solved this problem. The dual channel AX5000 does take a very long time to transition from PREOP->SAFEOP->OP. I changed this in the ethercat master to 10 seconds. After that things have worked reliably." Is it acceptable solution? if so , tell where i have to change to increase the time. I tried but i could not get the right parameter Kindly help me |
I don't think this is the issue you are having. This is not the same drive and you know the master conf is less than perfect fit because of OpenPLC compadibilities. It's not surprising it stays stuck in safeop when it doesn't get exactly the configuration it's asking for. But if you wanted to change it, then here this parameter is https://gitlab.com/etherlab.org/ethercat/-/blob/master/master/fsm_change.c#L45 |
Yes. This solution not working. I will pull the latest one and try it as you suggested |
yes, 3rd PDO mapping is only velocity control |
Ok..friend i will modify it. |
What else wee need to check/verify before the PLC part? |
The xml file first, then the sdo config script https://github.com/LRAJA33/OpenPLC_EtherCAT/blob/main/servo_drive_sdo_config.sh Because that script has to match what PDO mapping you want to use right? There are still some errors there, for example: you say you want to download uint16, but then you give it a 32 bit value. |
No friend. The modified script file is in my college system. I will update it on Monday. Its 32 only and i have used 32 only not 16 |
Right, then lets check it on Monday, but everything 32 is also not good, for example at the end of the script you have 16 and 8 bit values, that's just wrong if you download 32 bit value to them. The datatype has to match the register size. 8 bit to 8 bit, 16 to 16 and 32 to 32 That's why I'm saying, don't jump ahead, go through every step carefully and double check that you have done everything right. A mistake in the beginning makes success at the end impossible. |
Yes friend. not all 32 bit. I shared previously have look. I will double check, Modify and test all the things and update you on Monday
|
are you entirely clear on variable sizes? 0x00 is 8 bits just mentioning so that there is no confusion. |
Ok.Friend...got it I will make the changes and update you |
Alright, the datatypes and variable sizes make sense now, but how did you generate values? if we look at following:
I think the interpretation of it here is: in twincat I can create this modified mapping as in your xml but the startup list that it produces is different, because of course it is. The xml configures the master, the SDO download list configures the drive, those two have to match. please make it match |
Dear Friend, Thanks for the detailed information. I will follow the SDO configuration as suggested by you. From the diagrammatic representation of mode of operation, My understanding is that its enough to transmit the target velocity 0x60FF from PLC code for run the servo drive (in csv mode). Is it right? PLC code (csv mode)
|
Yes, except that csv mode is no 9 not no 3. |
Ok...friend. I will try and update you. Thanks |
Dear Friend, Finally it is over. I have ran the servo successfully in velocity mode. Thanks lots for your kind support.:) :) :) 👍 |
Heh, now that took some time and effort, I'm glad you finally got it running. Do you mind maybe uploading a short clip on youtube to show off your running servo? I think you are likely the very first to run such a servo using OpenPLC. If anyone has run any servos using OpenPLC, they have been much simpler types, nothing as complex as an ethercat drive. |
Dear Friend, Thanks with all your support. Yes. I will prepare the video and share the video link. Thanks |
Dear Friend, Kindly check the video link for the running servo. |
Nice job, very well done. |
Dear friend, How are you? I need one small help. I am trying to configure the "Cyclic Synchronous Position" mode. It is rotating. But un able to continuously run the servo. these lines are included in the code " FOR i := 1 TO 10 DO Upto count value 10, the motor moves. How to configure the servo? when i am giving 360 as target position, it will rotate one rotation. My servo encoder is 17 bit resolution. Absolute type. kindly check the video https://drive.google.com/file/d/1Wnl1woR-tUmICFYhO9x4_T6B0I7P30Ej/view?usp=drive_link(Edited) |
Hi..friend , I can easily write the values to target_position and target_velocity. But how to read the actual_velocity and actual_position ? *ptr = EC_READ_U32(domain1_pd + pdo.offset); How to use this to read the actual position and velocity? |
That code is equivalent to doing: the Actual_Velocity variable in your program already reads the actual velocity, you have set it up previously and configured the drive to report it, so it already exists at %ID2.0 address, you just use it in your plc program as is. as for actual position you have it configured at %ID1.0 |
Ok..friend. I will check it |
Hi...How to adjust the cycle time in the source code.? how to calculate the cycle time? based on this , we will provide position control pulses. kindly check and help |
Dear Friend, Thanks. I will check it out. |
Check the init_done flag, right now it waits for either WC_COMPLETE state, or 500 incomplete cycles, which is half a second at 1ms cycle. And this is operative only at startup. Does it cause any problems? If not, then it's good enough. If it does, then it's necessary to investigate in more detail. This has been there all the way from 2022, I don't even remember what the issue was if it was not there. It would have to be tested and investigated. |
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.
The text was updated successfully, but these errors were encountered: