Sign in to follow this  
Followers 0
cfmt

Reading DM from CJ using Sysmac Studio

13 posts in this topic

Hi guys, I'm using NJ501-1320 for the first time, but i'm having a hard time trying to get the information read from another PLC connected to the switch. I have successfully established the connection to the database, and write some values to it. The main problem now is sending the values in memory, to that same database. So i'm reading the values using an array [0..9] of word, and then converting the same variable to string. The instruction receive doesn't have no reference in the manual, so i don't know if the problem is there. Any help would be aprecciated. Thanks

Share this post


Link to post
Share on other sites
Did you create a local network routing table in both controllers? They both will need to know that the Ethernet network is network #1. If you want to see if this is the problem, try the repeating with SrcNetAdr.NetNo:=USINT#0; If it works, then likely you have not configured both controllers to treat the Ethernet network as NET#1. Also, you receive the data into a variable called Dados[0] and then use DM_0_9[0] in the Word_to_String instruction. Perhaps I cannot see what is going on in between the instructions, but this looks odd to me.

Share this post


Link to post
Share on other sites
I think that I have the routing table configured but i have to confirm. The NodeNo correspond to the last octet of the IPv4 address (which is 154). I also have issues regarding the Fins_Receive instruction. I can´t find anything related to that instruction. I also have doubt with those variables, since it was explained to me by an employee of Omron, and he used those variables to exemplify it. The type of address (Array [?..?] of Word) is also causing me some difficulties, since i'm using it to get more than one word at each time, but I don't find any instruction to convert it all to a string for example. I thought of passing each value of the array to one variable ( DM_0_9[0]=a; DM_0_9[1]=b....something that look a like what i use to do when I'm programming in C). I'm going to do a new test, changing the variables and checking the routing table, and I'll reply to you soon.

Share this post


Link to post
Share on other sites
After testing one more time I still can't understand what's wrong. I change the variable in the Fins_Receive function to the used in the conversion to string, but it only returned me 0. I did the opposite, and that didn't work either. However, using both variables seems to work, when I get all the values in the array (DM_0_9[0], DM_0_9[1..]... DM_0_9[9]) which gave me 1, 2, 3 and 4, for the first values in the array and the rest with 0's. Clearly not what is memory. My knowledge of Fins protocol isn't very profound and I can't remove the hypothesis of bad configuration in the configuration parameters. Again, lack of documentation on the Fins_Receive instruction (and also Fins_Send, couldn't understand why) can also be an issue. Does the DstDat variable has always to be an array of word? What if I only want to get one word? Doesn't make any sense to me use an array in such case. Does the value stored in the AT parameter corresponds to the word where I want to get information from (%D0 -> DM0)? If there is any another information that you think it should be relevant to solve this, let me know so that I can post it. Thank you.

Share this post


Link to post
Share on other sites
Your variables in the instruction looked good to me. That is why I did not comment on them. What is the value of SrcCH? That points to the address in the SrcArea from where the data is read. If it is indeed returning values, then the command is working, but perhaps it is not getting the values from the memory location that you think. As far as converting from a Word Array to a String, it is a two step process (see below): First you must convert the Word Array to a Byte Array. Then you can use the Byte Array to create a string.

Share this post


Link to post
Share on other sites
The value in the SrcCH is 0 (by default). From what I understand that value corresponds to the word from where we want to get the data (in this case DM0)?

Share this post


Link to post
Share on other sites
That is correct. If you want to post your code, perhaps we can look at it. I cannot tell what is wrong. Did you ever try to use Net 0 in the command to see if perhaps the routing tables were not set properly?

Share this post


Link to post
Share on other sites
Yes I tried that and it only returned 0's. I'm attaching my program here, but now I believe that the problem is the communication setup. Probably the node, or network in the remote PLC. To troubleshoot it, i'm doing a new test with a clean PLC and see what conclusions I can reach.

Share this post


Link to post
Share on other sites
So, the array Dados, has all zeros in it? And you are 100% sure that the values in D0-D9 in the CJ are numbers other than zero? What is the IP Address of the NJ? What is the IP Address of the CJ?

Share this post


Link to post
Share on other sites
It as al zeros in it. Yes I'm sure. The IP address of the CJ is 172.29.20.154, from the database 172.29.20.197 and from NJ 172.29.20.198. The problem isn't on the IP address. It could be on the fins communication. But, as I'm testing it with PLC's that are running and can´t be stopped or changed the configuration, I can't troubleshoot it. The connection to the database is also good, because if declare a variable and give it a value, it updates it to the database. I'm doing a new test using a CJ1M and a switch, that allows me to do all the tests I want. If you really don't see any problem in the code I suppose that the problem can only relay in the communications setup.

Share this post


Link to post
Share on other sites

Hi,

I read through your post, and have question regarding the array, can you explaine to me how can we initialize array in sysmac studio?? 

thanks

Share this post


Link to post
Share on other sites

Use the Clear function.

Share this post


Link to post
Share on other sites

Hello all,

I am using NJ501-1300 CPU, connect to HMI Via Ethernet and would like to capture data from the PLC/HMI to excel spread sheet.

What is the best way to do that and can you give me some outline how to start? Is there any manual should I follow to help read data in an excel sheet?

Thanks for your support.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0