COM18. ModbusTCP Client via Siemens S7-1200/S7-1500 PLC and TIA Portal
摘要
TLDREl vídeo detalla el procés per configurar un client Modbus TCP utilitzant el controlador Siemens S7 1200. L'usuari completa els passos necessaris per establir la comunicació entre el PLC i un servidor Modbus TCP, incloent la configuració de l'adreça IP del PLC, l'assignació de paràmetres de connexió i la implementació de la lògica de programació. S'expliquen altres aspectes importants, com la gestió de la memòria i la creació de búfers per a les dades llegides i escrites. Al final, s'experimenta amb la comunicació entre el client i el servidor per a comprovar que funciona correctament. El vídeo és una guia pràctica per a usuaris que vulguin integrar comunicacions Modbus TCP en les seves aplicacions amb el PLC S7 1200.
心得
- 🔧 Configuració de la IP del PLC a 192.168.1.201
- 💻 Implementació d'un client Modbus TCP amb el PLC
- 📦 Creació de blocs de dades per a la comunicació
- 📡 Enviament de dades cap i des del servidor
- 📝 Utilització de função FC03 per llegir dades
- 📈 Gestió de la memòria en el controlador 1211
- ⚙ Configurar la unitat ID per a la connexió correcta
- 📊 Visualització de les dades en una taula de vigilància
时间轴
- 00:00:00 - 00:05:00
En aquest vídeo, l'autor mostra com configurar un controlador Siemens PLC S7-1200 com a client Modbus TCP per connectar-se a un esclau Modbus TCP. El controlador que s'utilitzarà és el 1211, que té un limitat capacitat de memòria de treball de 50KB. Es necessiten configurar les adreces IP adequades per a la connexió, tant al controlador PLC com al servidor Modbus TCP que es troba al portàtil de l'autor.
- 00:05:00 - 00:10:00
El primer pas és configurar l'adreça IP del controlador PLC per assegurar-se que es pugui comunicar amb el servidor Modbus TCP. L'autor detalla com establir el port Ethernet i configurar l'adreça IP, així com el número d'identificació de l'hardware que s'ha de recordar per a la programació posterior. També introdueix l'ús de blocs de programació dins del TI Portal.
- 00:10:00 - 00:15:00
A continuació, l'autor crea un nou bloc de dades TCP per a la connexió i explica la importància de configurar correctament els tipus d'estat i els paràmetres de connexió, com l'adreça IP remota i el port. S'inclou la manera de convertir adreces IP a format hexadecimal i la importància de mantenir l'ID correcte per evitar errors de connexió.
- 00:15:00 - 00:20:00
L'autor comença a programar el client Modbus TCP en el bloc de programació OB1 i explica com afegir instruccions per a la comunicació. Es discuteixen les diferents funcions de client, com llegir i escriure dades, així com els diferents modes i adreces de registre que es poden utilitzar en la comunicació Modbus.
- 00:20:00 - 00:25:00
Després de programar la funcionalitat de lectura, l'autor explica com configurar també la funcionalitat d'escriptura, creant un segon bloc de dades per gestionar les diferents interaccions amb el servidor. Això inclou la configuració de buffer i variables per enregistrar la informació que es llegeix o escriu.
- 00:25:00 - 00:33:43
Finalment, es realitza una demostració pràctica de la comunicació entre el client i el servidor Modbus TCP amb l'ús de la software ModelSim com a servidor Modbus TCP. Es verifica la correcta lectura i escriptura de dades, així com la importància de les ID d'unitat en la comunicació correctament establerta. L'autor convida a veure més vídeos en el seu canal.
思维导图
视频问答
Quin model de PLC s'utilitza en el vídeo?
S'utilitza el model Siemens S7 1200, específicament el controlador 1211.
Quina versió de TIA Portal se mostra?
La versió de TIA Portal mostrada és la 16.
Quin és l'objectiu del vídeo?
L'objectiu és implementar un client Modbus TCP amb el PLC S7 1200.
Quina adreça IP s'assigna al PLC?
La adreça IP assignada al PLC és 192.168.1.201.
Quina és la capacitat de memòria de treball del controlador 1211?
El controlador 1211 té una capacitat de memòria de treball de 50 KB.
Quina aplicació es fa servir com a servidor Modbus?
Es fa servir l'aplicació Modsim per actuar com a servidor Modbus TCP.
Quins protocols s'utilitzen per a la comunicació?
S'utilitza el protocol Modbus TCP per a la comunicació.
Quin tipus de dades es pot llegir/escriure amb Modbus?
Es pot llegir/escriure valors de registre sencer.
查看更多视频摘要
- 00:00:02hello everyone
- 00:00:03in this video i would like to show how
- 00:00:05can we use the siemens plc
- 00:00:08i7 1200 controller run
- 00:00:11as a modbus tcp client the modbus tcp
- 00:00:14master function
- 00:00:16to connect with one modbus tcp slave
- 00:00:19to build up this modbus tcp connection
- 00:00:22and i will use one actual controller for
- 00:00:25this test
- 00:00:26so this is the ti portal version 16 and
- 00:00:29let's click this add a new device and in
- 00:00:32this test
- 00:00:32i will use one lowest controller that is
- 00:00:35a 12
- 00:00:3611 this is the lowest controller from
- 00:00:39this
- 00:00:391200 series controller and my controller
- 00:00:43that is the latest version version 4.4
- 00:00:46basically to implement the modbus tcp
- 00:00:49all those new version their function
- 00:00:51they are the same
- 00:00:53okay so this is my controller but keep
- 00:00:56in mind because this is a 1211
- 00:00:58that is the lowest controller here so it
- 00:01:01only has a 50kb work memory
- 00:01:03so after we implement this modbus tcp
- 00:01:05client function
- 00:01:07so we can see how large vocal memory it
- 00:01:09will take
- 00:01:10within this controller okay let's click
- 00:01:13okay
- 00:01:14okay this is the hardware wheel so
- 00:01:16firstly we can double click this
- 00:01:17ethernet port
- 00:01:20and we can set the ip address for this
- 00:01:22controller
- 00:01:24so we can active this stop night and we
- 00:01:27can set the ip address
- 00:01:29for this controller so in this test this
- 00:01:32s7 1200 controller is ip address is a
- 00:01:35192 168.1.201
- 00:01:40and the motorbox tcp server side i will
- 00:01:43use my laptop
- 00:01:44and i will use the software moto sim run
- 00:01:47as a modbus tcp
- 00:01:49server and my laptop the ip address is
- 00:01:521.10
- 00:01:54and this plc is a 201
- 00:01:58okay and after we set up this ip address
- 00:02:01so we need to switch to this system
- 00:02:03constant let's look at one value here
- 00:02:06so this is the hardware interface one id
- 00:02:09number
- 00:02:10shown here so it shows 64 the integer
- 00:02:13that is 100
- 00:02:15this represents this hardware address so
- 00:02:18when we use the modbus ttp programming
- 00:02:20so when you use this
- 00:02:22number 64. so let's record here
- 00:02:25okay now we can shift to the programming
- 00:02:27side so
- 00:02:28expand here program blocks
- 00:02:31from this ob1 we can double click okay
- 00:02:34from here we can click this add a new
- 00:02:36block
- 00:02:37let's create a function and within this
- 00:02:40function
- 00:02:41we can program the motorbike tcp client
- 00:02:44click this and we can name it and
- 00:02:47we can rename this number for example we
- 00:02:49can name it
- 00:02:5110 number we will use the letter logic
- 00:02:54okay click ok
- 00:02:59and then go back to the main and then go
- 00:03:04back to the main
- 00:03:05we can drag this fc into the
- 00:03:08well of the network within this ob1 our
- 00:03:11program will be within this
- 00:03:12fc10 okay and
- 00:03:16to implement the modbus tcp we can go to
- 00:03:19the right side
- 00:03:20find out the instruction
- 00:03:24so we can expand this communication from
- 00:03:27this communication
- 00:03:28let's open this others and this modbus
- 00:03:32tcp
- 00:03:33here and because we are using the
- 00:03:36built-in ethernet port from this
- 00:03:38controller
- 00:03:39to implement the modbus tsp so that's
- 00:03:42why we grab this uh
- 00:03:43function block from this folder if you
- 00:03:46expand here communication processor here
- 00:03:50you can still find the motorbox rtu or
- 00:03:52modbus here
- 00:03:54this is a little bit confused that's why
- 00:03:56it's called
- 00:03:57communication processor if your
- 00:03:59controller
- 00:04:00has other module that's specially
- 00:04:03communication module
- 00:04:04so that will use this function block but
- 00:04:07we are using the built-in
- 00:04:09ethernet port to implement the modbus
- 00:04:12tcp
- 00:04:12that's why we are using this keep in
- 00:04:15mind this
- 00:04:16so to run the modbus client or the
- 00:04:19master function
- 00:04:20so we need to use this function block
- 00:04:22drag to here
- 00:04:23okay so and here we can select this menu
- 00:04:27and we can name it this is the one zero
- 00:04:29one so this is the instant
- 00:04:31db number let's name modbus client db
- 00:04:35name it as underscore one
- 00:04:38or we can name it this is a read i will
- 00:04:41explain
- 00:04:42this after
- 00:04:45okay here we can write the comments here
- 00:04:49and this is the ifc03 read
- 00:04:52so okay okay
- 00:04:56if this is the first time for you to
- 00:04:57implement this function this will be a
- 00:04:59confused for you
- 00:05:00especially for the live side please
- 00:05:02follow me i will show how can we do this
- 00:05:05okay let's firstly set up one db that's
- 00:05:08for this connection so here we can
- 00:05:12come here add a new block
- 00:05:15and click this datadb tcp
- 00:05:20connect okay and this
- 00:05:23number could be 10 okay
- 00:05:26connect
- 00:05:30okay here we can name it
- 00:05:33i'm b tcp client the read
- 00:05:38okay and keep in mind this state type is
- 00:05:41very important
- 00:05:42so we need to type in tcom underscore ip
- 00:05:45underscore
- 00:05:46v4 so keep in mind we must type in this
- 00:05:50and once we type in this it will
- 00:05:51automatically create
- 00:05:53this data type okay and
- 00:05:56and here we need to type in for this
- 00:05:59function block
- 00:06:00so this interface if we record
- 00:06:03this interface represent which ethernet
- 00:06:06port
- 00:06:07we need to communicate i showed from the
- 00:06:10hardware that port number
- 00:06:12is 64.
- 00:06:15here it shows hweny that is
- 00:06:18the hex that they type so if by accident
- 00:06:22you type in 100 if you saw that is an
- 00:06:25integer you type in 100
- 00:06:27so after that so when we set up the
- 00:06:29connection you will see the tco
- 00:06:32set of the connection will show a09
- 00:06:35default
- 00:06:36so i will show this after so i would
- 00:06:38simply type in 100 i will show this
- 00:06:40fault
- 00:06:41and this id number we can set this is
- 00:06:44the first one we can set the number one
- 00:06:46and for this connection type here we
- 00:06:49will type in the 11 because we are using
- 00:06:51the motorbox tcp
- 00:06:53the background is still using the tcp
- 00:06:56here
- 00:06:5611 we need to type in here but also we
- 00:06:59can type in the hex number here that is
- 00:07:01a zero b
- 00:07:02so we can leave this as zero b as a
- 00:07:04default
- 00:07:05okay or we can type in again 16
- 00:07:09upon zero b okay
- 00:07:12that is 11 this data and this active
- 00:07:15established we can set to one because
- 00:07:18this is a client
- 00:07:19so this client need to active to set up
- 00:07:22the communication
- 00:07:24so here the remote address we can set
- 00:07:26the address
- 00:07:27so that is the server ipf device if
- 00:07:30my client ip address is 192 168.1.101
- 00:07:36so we need to type in here let's explain
- 00:07:43and in this test my laptop ip address is
- 00:07:46192
- 00:07:48168.1.101
- 00:07:50so here i will type in the hex number
- 00:07:53i will use this calculator transfer to
- 00:07:56hex number
- 00:07:57okay and type in here
- 00:08:06101 hacks that's a 65
- 00:08:10so this is a remote this is the server
- 00:08:13side ip address keep in mind this
- 00:08:15and the remote port so we will use five
- 00:08:18zero one
- 00:08:21this is anzac this is the enzyme this is
- 00:08:24enzyme integer so we will type in 502
- 00:08:28here
- 00:08:28the port will be used 502 okay the local
- 00:08:31port we can use as a default
- 00:08:33okay remote is very important okay keep
- 00:08:36in mind this
- 00:08:37okay this is a setup connection
- 00:08:39parameter
- 00:08:40okay and keep in mind all those
- 00:08:44parameters
- 00:08:45we are under this modbus tcp client read
- 00:08:49this line here and then we can float
- 00:08:53here
- 00:08:53click this button and go back to this
- 00:08:57function here and we can drag
- 00:09:01this variable to here release
- 00:09:04this basically transfer those parameters
- 00:09:07to this connection here
- 00:09:09okay and then
- 00:09:12the mode bus mode so let's check out the
- 00:09:14detail explanation for this
- 00:09:16let's click this function block and hit
- 00:09:19the iphone
- 00:09:21okay this is the motorbike client
- 00:09:23function explanation here
- 00:09:25so we can see req that's the trigger
- 00:09:28function
- 00:09:29every time we trigger so we will trigger
- 00:09:31the client
- 00:09:33to read or write the data to the server
- 00:09:35side
- 00:09:36disconnect that's just enable or disable
- 00:09:38if we set one we will disconnect the
- 00:09:41communication
- 00:09:42okay and this motorbox mode this is
- 00:09:45very important if that is a zero that is
- 00:09:48the read
- 00:09:49if this is 1 that is right keep in mind
- 00:09:52this is the enzyme
- 00:09:54integer value here okay and
- 00:09:57here that is the motorbus address if you
- 00:09:59require motorbikes address that is a
- 00:10:011400
- 00:10:03for example forty thousand one forty
- 00:10:05thousand two
- 00:10:06that is a motorbike address and this is
- 00:10:09motorbikes lens
- 00:10:10that means how long the data the data
- 00:10:12register we need to read or we need to
- 00:10:14write
- 00:10:15okay and this modbus data pointer
- 00:10:18that means after we read or write the
- 00:10:21data
- 00:10:21to the server modbus server side so
- 00:10:24where we need to locate the plc data
- 00:10:27this will assign the plc data here
- 00:10:30okay so let's go back and let me program
- 00:10:33so firstly this motorbox mode i will
- 00:10:36directly type into the zero
- 00:10:38zero means this function block will run
- 00:10:40the row to read the data from the server
- 00:10:43to this client side okay and modbus data
- 00:10:47address
- 00:10:47will start from the forty thousand one
- 00:10:49so we're typing here directly
- 00:10:51forty
- 00:10:56okay this is the motor bus address this
- 00:10:58is a start address and the lens
- 00:11:00for example we will communicate read
- 00:11:0420 register back okay
- 00:11:07and this is the data we need to store
- 00:11:09the data
- 00:11:10so we need to create another db so
- 00:11:13double click
- 00:11:15click this data block click this data
- 00:11:17block
- 00:11:18and let's change the name this is a
- 00:11:20modbus tcp
- 00:11:23read so this is the motorbox tcp data
- 00:11:26okay and this number we can follow this
- 00:11:30number for example next one will be 11.
- 00:11:32okay all right and here we can create a
- 00:11:37buffer
- 00:11:37so we can create read just the name as a
- 00:11:41read
- 00:11:42and this date type we can create array
- 00:11:45the array less that is the word because
- 00:11:48we are going to use the function 0 3 or
- 00:11:5116
- 00:11:52and the function 0 3 and 16 read or
- 00:11:55write
- 00:11:56will operate the word one register that
- 00:11:58is one word
- 00:11:59so we will create one array array
- 00:12:02so like this style click and the array
- 00:12:07we can start from the 1 and
- 00:12:11120 this less
- 00:12:14and because this is the data too easy to
- 00:12:17operate the data
- 00:12:18this buffer so personally i will
- 00:12:21recommend
- 00:12:22from here right click click this
- 00:12:24properties
- 00:12:26and go to the attributes and uncheck
- 00:12:29this
- 00:12:30optimize the block size so that's some
- 00:12:32special case
- 00:12:33we can use this transitional way and we
- 00:12:36can
- 00:12:37use this offside this absolute position
- 00:12:40once we got a compile for example if i
- 00:12:43compile here
- 00:12:44after we uncheck the optimization
- 00:12:48so this db will show the absolute
- 00:12:50address here
- 00:12:51it's very easy for us to operate
- 00:12:53especially if we want to set one bit in
- 00:12:56one word
- 00:12:57so to use this we can drag
- 00:13:00this db read to this modbus data
- 00:13:04pointer
- 00:13:07okay we can drag to here this is read
- 00:13:10because we are using this modbus mode 0
- 00:13:13means we are using the modbus tcp
- 00:13:15function 0
- 00:13:163 that is reading the data from the
- 00:13:19server
- 00:13:20side to the client side okay
- 00:13:23disconnect done busy arrow so we will
- 00:13:26type in some template data
- 00:13:28for example we can come here
- 00:13:31and we can create some tags here
- 00:13:36so we can add a row disconnect
- 00:13:40that is a bool
- 00:13:46so i will create the same name as the
- 00:13:48interface of this ifb
- 00:13:51while using those variables we can look
- 00:13:53at the actual status
- 00:13:54from this client connection busy
- 00:14:02done and disconnect
- 00:14:06okay by default this value is a zero
- 00:14:09so that we do not need to disconnect is
- 00:14:12a function
- 00:14:13and this trigger signal here every time
- 00:14:16we give a trigger signal it will send
- 00:14:18so we can use one function from our
- 00:14:21controller
- 00:14:22if we double click this device
- 00:14:24configuration
- 00:14:27double click this controller property
- 00:14:34and we scroll down here the system clock
- 00:14:37if we enable this to checkbox
- 00:14:44so for example if we are using this
- 00:14:47onehurst clock
- 00:14:49if we directly use this m05 one hertz
- 00:14:53so we can directly use that okay
- 00:14:56if we go back we will use onehurst
- 00:14:58trigger
- 00:14:59so at this req here we can directly type
- 00:15:02in this i'm
- 00:15:030.5
- 00:15:07okay it will show clockwise once we
- 00:15:10download this controller it will run one
- 00:15:12of us
- 00:15:12this m address will automatically
- 00:15:14controlled by the controller
- 00:15:16okay here we set up this connection but
- 00:15:20now
- 00:15:20actually we only build up one direction
- 00:15:23data
- 00:15:23this is read the data from the server
- 00:15:26side
- 00:15:27to the client side now if i save this
- 00:15:30project
- 00:15:31and the compile
- 00:15:35and now this is only one direction
- 00:15:37reading the data from the server
- 00:15:39to the modbus client this plc site and
- 00:15:42now let's look at this uh
- 00:15:44program info only use this one direction
- 00:15:48modbus tcp client
- 00:15:49let's see and now it takes 8k
- 00:15:53bytes keep in mind this vocabulary
- 00:15:56for this small controller it already
- 00:15:58took 17
- 00:16:00on this controller because totally it
- 00:16:02only has a 50k
- 00:16:04bytes here so this size is a reference
- 00:16:08okay so here let me explain a little bit
- 00:16:11more
- 00:16:11so as we know from this port motor box
- 00:16:14mode
- 00:16:15zero that means reading reading the data
- 00:16:18from the server to this client
- 00:16:19if i read one so we can write the data
- 00:16:22from this client
- 00:16:23to the server side some cases some
- 00:16:26people will assign
- 00:16:27one variable here so we can switch this
- 00:16:30to zero or one
- 00:16:32and also associated with this uh req
- 00:16:35this command so we can use one function
- 00:16:38block here
- 00:16:39and one instant db to implement the
- 00:16:41reading
- 00:16:42and the writing then no problem that can
- 00:16:45save the cpu work memory
- 00:16:47however there will be a little bit
- 00:16:49complex problem
- 00:16:50here as we know when we're reading or
- 00:16:53writing the data
- 00:16:54communicating with the server side this
- 00:16:56buffer we are sharing
- 00:16:58used for the reading of writing so we
- 00:17:01need to very carefully about the switch
- 00:17:03in the data buffer
- 00:17:04so we need to prepare the data for the
- 00:17:06sending and after we read
- 00:17:08we need to transfer this buffer to a
- 00:17:11read back buffer
- 00:17:13so this is really annoying so personally
- 00:17:16if we are using a higher end controller
- 00:17:19and if you have enough space i recommend
- 00:17:22you use two function block and use the
- 00:17:24different instant db
- 00:17:26i will show after so this function block
- 00:17:29especially served for the reading
- 00:17:31and this is the read buffer and next one
- 00:17:34we will set
- 00:17:35one and that buffer is specially used
- 00:17:37for writing
- 00:17:39okay so let's do that so next one
- 00:17:43communication let's drag the next one
- 00:17:45this client
- 00:17:46because i'm using the ti portal version
- 00:17:4816
- 00:17:49so the latest version now that is a
- 00:17:52version 5.2
- 00:17:54okay and i will drag this client again
- 00:17:59drag to here pop off this instant db
- 00:18:02so click this a single instant because
- 00:18:05we are using the fc to code them
- 00:18:06okay so i have to use this a single
- 00:18:08instant select this uh menu
- 00:18:11and this time this is a one zero two
- 00:18:14okay
- 00:18:15i will rename this instant db motorbox
- 00:18:18client db right okay and
- 00:18:21i will select this number one zero two
- 00:18:25so here i will write this comment modbus
- 00:18:27tcp client
- 00:18:28master fc16 here right
- 00:18:32so to implement this i've seen 16 right
- 00:18:35so
- 00:18:35the modbus mode here i will write one
- 00:18:38one means write the data and
- 00:18:42this req here so
- 00:18:45we can use here we can click this
- 00:18:49we can use this signal is on or when
- 00:18:51it's off
- 00:18:52to trigger the modbus client reading and
- 00:18:56writing and when this signal on we can
- 00:19:00read the data
- 00:19:01and once off we can write the data okay
- 00:19:05so we can use a similar way program like
- 00:19:07this way
- 00:19:08so when the signal on it will trigger
- 00:19:10reading
- 00:19:11and this off this will trigger this
- 00:19:14writing
- 00:19:14and then let's config this connect so
- 00:19:18let's open this db10 this motorbike ccp
- 00:19:20connect
- 00:19:22and let's create a second one that is a
- 00:19:24modbus tcpa client
- 00:19:26right okay actually we can copy this
- 00:19:30copy paste
- 00:19:34rename that as a write okay
- 00:19:38the date type keep in mind the date type
- 00:19:40still tcom ipv4
- 00:19:44and this id number we're still using the
- 00:19:47same
- 00:19:48hardware port that's the 100 integer
- 00:19:50number
- 00:19:51so 64. and this id we can change the
- 00:19:55second one
- 00:19:56okay keep in mind id number while using
- 00:19:59the different id number
- 00:20:01so connection type is still the tcp
- 00:20:05so connection type still the tcp 0b
- 00:20:09that is 11 okay and active
- 00:20:12established still the active side that's
- 00:20:15one and the remote address this is this
- 00:20:18so the ip address 192 168.1
- 00:20:23one zero one okay and this is remote
- 00:20:26port
- 00:20:27that's still five zero two okay
- 00:20:30and then fully in the similar way we
- 00:20:32will declare
- 00:20:33some port here
- 00:20:38okay we declare here then we can drag
- 00:20:41them
- 00:20:42to this function block
- 00:20:46okay and then this modbus address
- 00:20:49so when we read the data from the
- 00:20:51motorbox server side
- 00:20:53so that address we start from the forty
- 00:20:55thousand one
- 00:20:56and the less we set the temp here and
- 00:20:59the reading we can start from the 4020
- 00:21:03and this lens still can be the 10 okay
- 00:21:06so here
- 00:21:06we can type in 40 000 40 021
- 00:21:11okay and the less we can this is 10
- 00:21:15and then this connect so we can drag
- 00:21:17this uh
- 00:21:18modbus tcp client right based on this
- 00:21:21data type we can drag to here
- 00:21:25okay and this plc local buffer
- 00:21:29so we need to declare one new buffer
- 00:21:31that is the right buffer
- 00:21:33so we double click this db11
- 00:21:36we can create a new line here and we can
- 00:21:41name it right
- 00:21:45so that's the array 1 to 120
- 00:21:48word here okay
- 00:21:51flow it come here we can drag this
- 00:21:55right to this port
- 00:21:58okay and because this db that is a
- 00:22:02non optimization db so by default it
- 00:22:05shows question mark here
- 00:22:07and once we compile it it will show okay
- 00:22:10so let's compile and now we have a two
- 00:22:13function block here why especially for
- 00:22:16reading the data from server to the
- 00:22:18client one is
- 00:22:19writing the data from the client to the
- 00:22:22server
- 00:22:22okay and because we just programmed this
- 00:22:25a second
- 00:22:26function block and now let's check out
- 00:22:28this program info
- 00:22:30it basically take a 10.5 k bytes
- 00:22:33within this work memory so for this
- 00:22:36smallest controller
- 00:22:3712 11 it takes 20 on the work memory
- 00:22:41so this value can be a reference for you
- 00:22:44okay
- 00:22:44okay now we can download this controller
- 00:22:51okay so the software we found this so we
- 00:22:54can download
- 00:22:58okay let's start this controller
- 00:23:01so our plc will be started and to test
- 00:23:04the data we can use the watch table
- 00:23:07and let's create one watch table
- 00:23:11and and here we can open this db
- 00:23:14so our actual data is within this read
- 00:23:17and write
- 00:23:18right so we can drag part of those data
- 00:23:21for example the reading
- 00:23:22so so we can drag the 15 buffer
- 00:23:27to this watch list
- 00:23:30okay and here
- 00:23:35we can drag the right 15
- 00:23:39here the lens we set the 10 so we drag
- 00:23:4215 that will be
- 00:23:43enough okay next let's use the model sim
- 00:23:47software
- 00:23:47run as a motorbike tcp server so to
- 00:23:50download the software
- 00:23:52we can browse this website wintac.com
- 00:23:55and browse this model sim 64
- 00:23:58this software that run as a modbus tcp
- 00:24:02server software okay
- 00:24:06okay after we download the model sim 64
- 00:24:09this version so we can double click this
- 00:24:13and this is the demo software okay so
- 00:24:16click ok
- 00:24:20click ok
- 00:24:23click ok and we can set up this server
- 00:24:30okay
- 00:24:32and the address we can start from one
- 00:24:35and the connection we can select this
- 00:24:37motorbike tcp is server
- 00:24:40and the port that's the 502 and my
- 00:24:43laptop is 192 168.1.101
- 00:24:49so my my laptop will run as a motorbox
- 00:24:52tcp server
- 00:24:53okay so it ready here so this is the plc
- 00:24:57side
- 00:24:58and let's look at the current status
- 00:25:00from this function block
- 00:25:01so it shows arrow and the code shows a09
- 00:25:05b
- 00:25:06so we can search this code
- 00:25:09so we can find out i've one
- 00:25:12and after we search this code a09b
- 00:25:16and we can find out basically this code
- 00:25:18come from the local device id
- 00:25:20setting so if we go back
- 00:25:23our program and we double click
- 00:25:27this problem come from one second from
- 00:25:29this connect
- 00:25:30so that can now come from the db10
- 00:25:32double click
- 00:25:34and this sighting setup connection
- 00:25:37setting
- 00:25:38so if we expand here and we click this
- 00:25:41online
- 00:25:42click this online now the value shows
- 00:25:45100 here
- 00:25:47here we need to set 64 direct
- 00:25:50to this hw so that is a direct
- 00:25:54hex number here so and here we need to
- 00:25:57type in
- 00:25:58the direct 64.
- 00:26:01so we can also change here 64.
- 00:26:04we can change there 64. and we can
- 00:26:08change this
- 00:26:08also change for 64. so keep in mind
- 00:26:12this and this number come from the
- 00:26:15device configuration
- 00:26:17if we double click this uh port click
- 00:26:20this assistant
- 00:26:21constants and this is the interface
- 00:26:23number 64 is here
- 00:26:25we directly type this 64
- 00:26:28to here okay so let's download this new
- 00:26:32setting
- 00:26:35okay now we haven't set up this client
- 00:26:38yet so it shows seven zero zero two okay
- 00:26:41now click this new
- 00:26:46and let's select this motorbox tcp
- 00:26:50server
- 00:26:52now let's set this address we start one
- 00:26:55and here the device id for the siemens
- 00:26:58by default
- 00:26:59we need to set this device id to 255
- 00:27:02here okay we need to cite a 255 here
- 00:27:07i will explain this after and now let's
- 00:27:10click this uh watch table click this
- 00:27:14monitor and this is our read buffer and
- 00:27:17the right buffer
- 00:27:18and now from this forty thousand one so
- 00:27:21we can double click
- 00:27:23and this is the and this is the decimal
- 00:27:26so we can type in one two three four
- 00:27:29so we can see the hex number is
- 00:27:31receiving here
- 00:27:32so we can change this scale into the hex
- 00:27:35so
- 00:27:36we can switch to the hex now we can see
- 00:27:3942 we received there so next one
- 00:27:42we can type in aabb
- 00:27:46so we can see aabb received here and
- 00:27:49from this right area
- 00:27:51hex number here we can write three three
- 00:27:54four four
- 00:27:55for example right enter
- 00:27:58and transfer so we can see three three
- 00:28:02four four
- 00:28:02we start from the 21 it received here
- 00:28:06so three zero four so from the client i
- 00:28:08write this three three four four
- 00:28:10to this server so next value
- 00:28:13one one two two right
- 00:28:17so one one two two here so because we
- 00:28:20write
- 00:28:20ten values so we can test this ten
- 00:28:24so write c c d d and next one we can
- 00:28:27specially test this c eleven this 11
- 00:28:29shouldn't send to this
- 00:28:30server so
- 00:28:34we can transfer so this lens will send
- 00:28:37the 10
- 00:28:38register so we can see only cctd here
- 00:28:42we send to here and this eeff
- 00:28:45because that is the 11th so this e iff
- 00:28:49will now be sent so we can see the value
- 00:28:51can be read from this
- 00:28:53server to this client correctly and this
- 00:28:56value can write
- 00:28:57from this client to this server
- 00:28:59correctly
- 00:29:00and this device id is very important
- 00:29:04if now i use this default for example
- 00:29:07one if now i write the data here
- 00:29:10for example if i rewrite this data if i
- 00:29:13said this is 3 here
- 00:29:15let's say 1 1 2 2.
- 00:29:18so we can see this value we write here
- 00:29:21and here it doesn't show up if i write a
- 00:29:24new value
- 00:29:25to here one two three four
- 00:29:31so we can see the one two three four
- 00:29:33cannot send correctly here
- 00:29:35so let's explain this device id here and
- 00:29:38let's open one instant db okay
- 00:29:41for example this db101
- 00:29:45we open it and
- 00:29:48from this instant db if we click this
- 00:29:52monitor and there's one value
- 00:29:55here it shows motorbox unit id
- 00:29:59for the modbus tcp communication
- 00:30:02sometimes
- 00:30:03it will care about this some modbus tcp
- 00:30:06server devices
- 00:30:07they will not care about this uid number
- 00:30:10but some wonder or some manufacturer
- 00:30:12when they provide these devices inside
- 00:30:15the devices might be the one
- 00:30:17or the i5 in siemens this number default
- 00:30:21that is i5
- 00:30:22255. you can write this value to 0 or to
- 00:30:271
- 00:30:27to match with your server side and
- 00:30:30in this case for example if now i write
- 00:30:34this value to 1.
- 00:30:39that is a the hex one but the integer
- 00:30:41also
- 00:30:42equal to one right also
- 00:30:46we can minimize this and open this
- 00:30:49next instantdb
- 00:30:52open monitor
- 00:30:57and right here we can write to one
- 00:31:02okay and keep in mind this value will
- 00:31:05now be retained
- 00:31:07so we can use the move directly right
- 00:31:10this imb
- 00:31:11unit id so let's temporarily test that
- 00:31:14first
- 00:31:14so we write one now let's go back to the
- 00:31:17server side
- 00:31:19so once we shift here so we can see this
- 00:31:22one two three four
- 00:31:23wrote correctly now if we're using the
- 00:31:26device id
- 00:31:27one because we change that to instant db
- 00:31:30change to one okay so if i change the
- 00:31:33value to do a verification here
- 00:31:35let's do seven eight nine four
- 00:31:39so right so we can see now it's
- 00:31:42communicating correctly
- 00:31:44now if i give a new value from this
- 00:31:46server side let's say abcd here
- 00:31:50we can see abcd read correctly from this
- 00:31:53client side
- 00:31:54so we are using one because we change
- 00:31:56that unit id
- 00:31:57from this client side so that means we
- 00:32:00set up this
- 00:32:01motorbike ccp communication correctly
- 00:32:04all right
- 00:32:04as we discussed since the unit ide
- 00:32:07cannot be retained
- 00:32:09inside the instant db so we better
- 00:32:12use this move directed write the value
- 00:32:15into the unit id
- 00:32:17we will run this one to that unit id
- 00:32:20so we can open this instant db
- 00:32:23how to open it so we can go to the
- 00:32:25system block
- 00:32:28and this two eastern db one is one zero
- 00:32:32one
- 00:32:33y is one zero two right so here from
- 00:32:36this
- 00:32:36system block open this or db101
- 00:32:40and we can flow that here
- 00:32:44scroll down so find out this modbus unit
- 00:32:47id here
- 00:32:49we can see default start value that is
- 00:32:51the i5
- 00:32:52so we can drag it to here
- 00:32:56okay so using this way we can write this
- 00:32:58one to this unit id
- 00:33:00okay so using this way we can directly
- 00:33:03write this
- 00:33:04instant db okay and we can write the
- 00:33:07commas here
- 00:33:08so this is the unit id
- 00:33:11okay that is the motorbox tcp client
- 00:33:14function
- 00:33:14in the siemens i7 1200 plc
- 00:33:18the i7 1500 plc there will be the same
- 00:33:21and basically from this program the
- 00:33:24reading and the writing
- 00:33:25this tool function block we can use this
- 00:33:28project as a template
- 00:33:30all right that is for today thank you
- 00:33:31for watching thank you for watching
- 00:33:34if you like this video please give me a
- 00:33:35thumb up if you like to watch more
- 00:33:37videos in my channel
- 00:33:39please subscribe and hit the bell thank
- 00:33:41you for watching
- Siemens
- PLC
- S7 1200
- Modbus TCP
- TIA Portal
- programació
- connectivitat
- servidor Modbus
- comunicació
- automació