Cycle through DB using S7-300/TIA

DLMUK

Member
Join Date
Jun 2013
Location
Southampton
Posts
311
Hi,

I have a Modbus TCP/IP connection on my S7-314 PLC, this connects to a Siemens RMC30 (TCP/IP>Serial convertor) and then to 46 serial RTUs.

The PLC can only handle 8 simultaneous connections so I cannot simply establish 46 connections. I need to cycle through.

The MODBUS_PN block I am using for comms has a "DB_PARAM" parameter - this parameter is set as the DB which contains all of your connection settings. What I would like to do is cycle though this DB one at a time.

So...
establish connection using settings in DB1
disconnect
establish connection using settings in DB2
disconnect
establish connection using settings in DB3
so on and so on...

But i am not sure how to do this, can anyone offer and suggestions?

Thanks
 
It sounds like your idea should work, although I'm not familiar with the Modbus blocks used in the 300. Which part are you stuck on?
 
You could have one modbus block that always calls a generic DB with connection parameters. Copy the first DB of parameters into the Generic DB, and then connect. When you are done talking to one device, you disconnect. Copy the 2nd DB into the generic DB, and continue. When you finish with the 46th, start back at the beginning.

You could also set it up with 46 modbus blocks, each calling their own parameter DB, but that would probabyl take a lot more memory.

If you want, you could have 8 modbus blocks to use all 8 connections, or you could keep it simple and just go slow and steady with 1.

You will need a state machine to track which connection settings need to be used next, and what to do with the data you are currently recieving. My favorite state machine method is to have an integer as the current step. When you want to move to the next step, Move the new step number into "Next Step", and then at the end of your code copy "next step" into "Current Step". You then compare "current step" with whatever number at the beginning of each rung, to see which section of the code executes.

This if you are familiar with SCL, you can use a Select Case for the whole thing to make it simpler. If not, stick with LAD and lots of compare statements.
 
Last edited:
What is the data type of the "DB_PARAM" parameter?

What type of block is the MODBUS_PN block and is it know how protected ?
 
What is the data type of the "DB_PARAM" parameter?

What type of block is the MODBUS_PN block and is it know how protected ?

The DB_PARAM has varying data types - but you cannot add rows to it.

The Modbus PN block is know how protected.

So I need to create multiple instances of the DB_PARAM DB, and then cycle through these DBs. Show in the screenshot...

https://www.dropbox.com/s/vn3vgpaoyoctmc1/Untitled.png?dl=0
 
@mk42 - thanks - do you have an example of this?

I don't, sorry. Like I said, I've never worked with the S7300 modbus blocks. I know the forum has at least a few threads discussing state machines that might get you pointed in the right direction.
 
Hi,

I have a Modbus TCP/IP connection on my S7-314 PLC, this connects to a Siemens RMC30 (TCP/IP>Serial convertor) and then to 46 serial RTUs.

The PLC can only handle 8 simultaneous connections so I cannot simply establish 46 connections. I need to cycle through.

The MODBUS_PN block I am using for comms has a "DB_PARAM" parameter - this parameter is set as the DB which contains all of your connection settings. What I would like to do is cycle though this DB one at a time.

So...
establish connection using settings in DB1
disconnect
establish connection using settings in DB2
disconnect
establish connection using settings in DB3
so on and so on...

But i am not sure how to do this, can anyone offer and suggestions?

Thanks



use DB1 for all connections and copy new parameters for new query to DB1.

Siemens have example for this, select tia v12 or v13 for download
https://support.industry.siemens.com/cs/document/75312612/how-do-you-use-the-blocks-for-modbustcp-communication-via-an-industrial-ethernet-cp-of-s7-300-and-s7-400-in-step-7-professional-%28tia-portal%29?dti=0&lc=en-WW


On eample you need to add code for changing DB1 parameters for new slave. ("CONTROL_DAT".DONE_NDR , error or no error -> next)


For serial modbus there is examle for TIA:

https://support.industry.siemens.co...-using-the-modbus-rtu-protocol?dti=0&lc=en-WW
 
Last edited:
Here'a an example Step7 V5 project that calls a small FB and is passed DB1,2,3 using a simple ladder sequencer. It has been run and tested in PLCSIM after being migrated into TIA portal.

Choose your own tag in OB1 for starting the sequencer, I used M0.0
 
Last edited:
Hi

Thanks for your replies, I will take a look.

@L D[AR2,P#0.0] - thanks for the example unfortunately I do not have a way of opening it.
 
Ok - So I have thought about it a bit more and I only need to change the node address and the memory area.

I have written a bit of code which is not functioning correctly - I have set it to count up to 8, and then when it reaches 8 reset to 0.

What is happening is that the reset is latching on and stopping the count from running. If I remove the reset the count runs continously.

Can anyone point out my error?

https://www.dropbox.com/s/ymlgmnwxxv4fy10/count.png?dl=0

Thanks.
 

Similar Topics

Hi I am currently still a PLC newbie, so all help would be appreciated. I have an array on my studio 5000 with a set of random numbers of length...
Replies
18
Views
5,933
Hello there, I'm pretty new to all this... so forgive me if this sounds too stupid of a question. Right now I have 4 display pages, and I want...
Replies
5
Views
2,868
If I were to download a program that had a tag called "Count" that had an initial value of zero, and I MOVed the value of a counter accumulator...
Replies
5
Views
2,057
sorry about this very basic question. I did a thread search but was unsuccessful. So, my question. If I toggle a bit during a Run, and power...
Replies
9
Views
3,532
What's the best way to cycle through multiple messages in a SLC? They're going out to different PLCs on diffrent networks. I'm thinking I only...
Replies
12
Views
4,929
Back
Top Bottom