Tia Portal Rs485 communication with plc

thewalkerist

Member
Join Date
May 2021
Location
Izmir
Posts
178
Hello

I have 1 loadcell, 1 loadcell transmitter(rs485(RX, TX) communication) a s7-1200 plc and a cb1241 rs485 module. Now i need to write a code that lets me communicate with my transmitter, Now there is a manual and there are modbus adresses that i presumeably call and activate through tia portal. I posted a pic of the adresses(sorry the manual is in Turkish, couldnt find the english one). I just want to read what my weight value is

I've tried using a P2P_RCV but nope. This is not cyclical. Since it is not cyclical i need to send a command through modbus to it and get an answer from it. But i dont know how to do that. Can you please help me with the code?

Which blocks and in how?

Screenshot (657).png Screenshot (656).png
 
Last edited:
Here is what i can do inside the loadcell transmitter. I can see the weight values and tare and everything is fine. But how can i do this in plc?

Screenshot (659).png
 
Now i've wrote some code to read the values.

Now i need to find a way to write those adresses on my plc. But i dont know how, tried writing to the DATA_ADRRES but didnt work. I need to somehow find a way to send those numbers to my transmitter so that i can read the weight values. But how?

Screenshot (662).png Screenshot (661).png Screenshot (660).png
 
Last edited:
The screenshots you posted is from a program that displays information from the transmitter via USB ?
Can you see data being received via Modbus ?
So you need to find out what Modbus addresses are used to send commands to the transmitter, and what command to send.
If this is not clear from the manual, then I think you need to contact the supplier.
 
so here is what i've gathered so far. If i change the mode on master to 4(so that it will give out an error) the transmitter just does nothing. But if i change the mode to 1 or 0 the transmitter will start blinking the Rx light. Tx does nothing still

The screenshots you posted is from a program that displays information from the transmitter via USB ?

Yeah, but i cant see or know if what i write is going to the transmitter or not. Only way i can prove the code i write is going to the transmitter is the light flickering when i change the mode from 4(which is none existent) to 1 or 0

Can you see data being received via Modbus ?
No there is nothing

1ed2ebd3-8e47-487b-9013-0540981eacde.jpg 1d2f8ce7-460f-4bf8-9a3a-10e3ec7d841c.jpg 452532a6-ad11-41ba-ae69-ce2f91849b51.jpg
 
xxx.png

The best way to do this is one small step at a time:

 
Last edited:
Actually, get 14 INTs, seven on each read: 7-13 or 8-14

The MB_MASTER parameters will probably be something like this:

  • REQ: mb_req (a BOOL); 1 to do the read, 0 after read is complete
  • MB_ADDR: probably 1; the IDx value from post #2
  • MODE: 0; read
  • DATA_ADDRESS, DATA_LEN: 40008, 7 (or 30008, 7)
    • So you get Modbus addresses 40008-40014, which will be either
      • TUNA "Adrs" 7-13,
      • or TUNA "Adrs" 8-14.
    • TUNA Adrs 8/9 are probably Modbus registers 40009 and 40010
    • TUNA ADr 13 is probably Modbus register 40014
  • DATA_PTR: Reading_val[0] for the first read, and Reading_val[7] for the second read; Reading_val needs to be 14 INTs long.
  • DONE, BUSY, ERROR: write these output BOOls to bits that should be part of the logic to control the REQ input
 
Last edited:
What do you mean by get 14INT's? you mean put a database and give it array(0 to 13) int and then call it from the master?

Sorry i didnt understand. I apologize
 
What do you mean by get 14INT's? you mean put a database and give it array(0 to 13) int and then call it from the master?

Sorry i didnt understand. I apologize

No need for you to apologize.

However, I should apologize, because I did not fully understand what you already did. It looks to me, from your post #3, that you have already done what is necessary, and there should be 10 16-bit Int values written to the array Registers.Reading_val[0..9].

It looks like you used a process similar to the one described by this youtube video. There were a few times during that video where the author set specific checkboxes to make the application work.

The MODE is 0, which is correct for reading.. If that request never succeeds, then there are a few possible problems I can think of, and there are probably more beyond that.

  • The DATA_ADDRESS of 40008 is good for Holding Registers,
    • but perhaps the weight data have been placed in what the Modbus protocol defines as Input Registers, in which case the DATA_ADDRESS of 30008 should be used.
  • The baud rate may be mismatched between the S7-1200 and the TUNA;
    • it is probably easiest to try different baud rates in the MB_COMM_LOAD instruction
    • it looks to me that the BUSY output bit is TRUE, which suggests the MB_MASTER in the S7-1200 sent a request, but the TUNA did not send a response; if there was an RS485 comm parameter setting mismatch, that would explain the symptom.
  • By the same token, the parity or stop bits may be mismatched between the S7-1200 and the TUNA
  • The wires could be reversed from how they should be
    • RS485 is pretty forgiving, so switching them should not cause a problem

One approach would be to disconnnect the TUNA, and use a modbus slave simulator on your laptop with a RS485 (USB?) device, as was done in the video, and connect the S7-1200 to that, because then you have better control of how the communication should work. Once you have that working correctly, you have isolated any problem to some sort of a mismatch between the TUNA and the S7-1200. Note also that, if you have a RS485 device on the laptop, then you can hook up the wires in a multidrop arrangement, and with an application like HyperTerminal, Putty, etc, you can monitor the communication between the S7-1200 and the TUNA.

Also note that, since the first register of the TUNA is 0, but the first DATA_ADRESS of the MB_MASTER is 40001 or 30001, that that TUNA register 8 might be at DATA_ADDRESS 40009 or 30009, but we can solve that problem later.
 
Also, in the interface you showed in post #2, what to you see when you enter the P (comm status) command?

Also, in the video, starting here, it talked about disabling optimized block access to the Register DB; I suspect you may need to do that.
 
Last edited:
Is your 1200 Siemens PLC transmitting serial data (is there TX led blinking)?


Do you see that TUNA is receiving data (RX led blinking)?


If yes to both, then it can be wrong register area or wrong speed if TUNE is not replying (NO TX led on TUNA)


Try reading only one register for test.
 

Similar Topics

Hi guys , I'm new with Allen Bradley, but I have experience with Tia portal (s7 1200 ,s7 1500) I want to convert my project from Tia portal to...
Replies
1
Views
67
Hi, I have had problem with upgrading some projects from v16 to v18. I tried it on 3 diffrent computers. I want to post this so that anyone that...
Replies
3
Views
101
Hello gentlemen, Im working on a small project on TIA Portal, about establishing a Modbus TCP connection between my ET200SP plc and a socomec...
Replies
11
Views
251
I am currently am in a PLC class and need urgent help on how the ladder logic would be laid out. I understand how to get the traffic lights to...
Replies
19
Views
405
Hello, If the date on the license manager of tia Portal has expired, can I still work with it? or is this just to keep the program up to date...
Replies
7
Views
192
Back
Top Bottom