Hello,
I'm wondering if anyone has setup serial communications to a Modicon M340 PLC in Unity software?
I want to be able to command subroutines as well as receive status's back from the smart motor.
Any help would be greatly appreciated!
We can do some simple Modbus communications that lets you call subroutines, read motor status, and read/write variables . It only works on the Class5 motors (firmware version 5.x.x.x.
That would be great! Do you have any sample code to get me started. It is on a class 5 motor.
Thanks!
I didn't think it would let me attach the file... but it did. Please let me know if you got it.
Got the word document! Thanks a bunch I will look it over and test this on Monday once I get back to the office. If I have any more questions I will be sure to ask. Thanks again.
csearcy, Do you know of anyone that has used the Modbus communication with a PLC? I think I understand the mapping but I'm not getting any responses back to the PLC. Was hoping someone else has done this to maybe step me in the right direction.
Thanks!
I don't know of anyone here who has done it. If might be helpful to set up a sniffer to make sure the response is actually occurring.
I was finally able to write to the user variables but what I'm unsure of is how to call subroutines. The document you posted just describes the "GOSUB(value)" command but it doesn't explain much more than that. Does this have to be a string command in my PLC that writes out the command?
I don't think you have to use any strings. I think you just have to write the value of the subroutine (ex. 123 would call C123 in your user program) into 0x8004 ...but I remember something about registers being indexed from 0 or 1... so that may need to be 0x8003 or ox8005 😉
Also... what firmware did you say you had on the motor? There was a bug in one of the earlier versions.
Ok I'll try that. So basically if I have a subroutine of C50, I should be able to write 50 to the 0x8004 address and it should call C50. The firmware I have is 5.0.4.8.
Again thanks for the help!
That sounds correct... and that firmware should be good. Please let me know if you get it working.
Oops... I just got an email from one of our firmware guys. There is still a bug in 5.0.4.8 that keeps the GOSUB from working... and that's the latest release. I "might" be able to get a beta release to send to you ...but you'll have to treat it as such... and not distribute it.
Send me an email at csearcy@moog.animatics.com ...and I'll send you the beta... then I'll delete this post with my email address. 😉
Just sent you an email csearcy.