Efficient Programming in Simatic TIA Portal | TIA Portal V16

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
with the topic of efficient programming in ti portal um my basic my basic agenda for today is to give you an idea of different tools and options that are available in tia portal which will help you in different aspects one how it can be helping you in saving time in your overall project engineering overall project development how time saving can be there in most of the cases then how the programming can be made uh you know much more efficient in terms of the memory consumption as well so certain programming methodology what we might use if we slightly alter it if we you know prefer to have a different way we have options or we have possibilities for optimizing the memory consumption so that will be another uh you know i mean by product shall i say so after going through these tips and tricks eventually we will also be discussing certain advanced topics you know once you uh do the program in such a way that it can be reused it is standardized at your factory level or at or at your company level then reusability of the program becomes much much more which means that becomes i mean that standardization is always your stepping first step towards digitalization if you eventually at some point of time would like to digitalize your entire process standardization is a you know very very basic requirement for that so how standardized program which can be reused uh you know such programming how it can be done this is also one of the topics that we'll be looking at uh unlike our usual way i don't have much of presentations uh today so i have compiled some certain set of links which i'll be sharing it with you at the end of the presentation which will mostly we'll be discussing in this session as well sorry okay so to begin with once you start ti portal once you open ti portal you know most probably this this portal view is the first view that you will be getting and if you are like me or if you would belong to the most majority of the you know engineers automation engineers portal view is not always the first uh view that you would like to have you always either open a project and then go to a project view and this is where you do things right uh if it was a live session i could have asked for more live feedback but i hope you are like me you know uh liking to do the things in the project view if that is the case instead of every time coming to ti portal and switching it to switching it to you know a bit portal view and project view all the time if you like project view i can show you one step if you go to options and if you go to settings in ti portal so under general we have some settings that we okay so there are a lot of settings available here what i would like to show for this particular option is coming up here start view so by default the selection is going to be a portal view in in in most of the cases but if you wish to have the project view as your default start view this is a place where you can switch it and you know things will be okay so this is one of the first tip that i would like to give you since we are here let me also discuss some other uh configurations or some other setups what might be helpful for you for example if you come to hardware configuration and hardware configuration has got an option called as product support information which by default is deactivated if you keep it activated i'll show you what will be the effect so let me open a project in in my case i have prepared a sample project just to save time in explaining different uh topics that we'll be discussing today so in that okay so if you have this product support information via internet enabled when you have the possibility that you can come to your ti portal hardware catalog may be in in the depend in the network view or in the device view it doesn't matter you can come to the hardware catalog you can uh take any of the product that you want you can right click on them and you will be getting some options uh which will take you directly to the product support site so if you want to know all the manuals related to this particular product you select it it will directly take you to our open of course you need to have internet connectivity in the system but once you have it enabled you are directly reaching it here with necessary filters and viewing all the information related to that in the same way if i could show you something on the cpu for example any one cpu right click i want to see all the faq use related to that so this is also an easy way to get the manuals or get some information related to a particular product easily from ti portal itself so this is possible once you keep the product support information via internet enabled fine ti portal when you use it uh you know most of the time you will need a little more of the screen space so for example if i open an fcr and fb any any block when you open it will be better if you have a you know a screen with bigger resolution then fine but otherwise to get little more space available on your block interface or i mean on your view one of the step what we can do is all the comments that comes up in in along with all the blog title or the network you can temporarily disable this of course you can put it but if you don't want to view it every time you look at a block then you have the option to disable the network comments by going up here and i hope that is visible for you okay so if you look at this this is what i was discussing about so i can't zoom into that area but this icon what is available is nothing but a toggle button just to keep your network comments on or off but this network comments on or off once you do it on a particular block but that doesn't mean that every other block what you open will still be following that other blocks will still have the network commands and and everything open or even if you close and open the ti portal even then things will be remaining the same even for this if you come back to the settings if you come to plc programming ladder fpd let me find out okay so once you come to plc programming here you have the option ladder fbd uh stl so you have the option to either make it enabled or disabled so what i would like to do i don't want to see the network commands all the time whenever it is needed i will i'll look at it that's it i keep it disabled now if i open any block by default network commands and all will be disabled giving you a little more uh you know view space so to speak okay fine among the topics what i would like to discuss i one of the first uh topic that i had thought of is getting diagnostics of all these devices all the modules what you have in the system is almost always useful for any project so we have some instructions we have some ways in which people take the diagnostic data for example just to show you if i take uh one io station if i go in and add some so let's say i i'll add a digital output card for example so if i go with a standard digital output card it's a 16 channel digital output card so once we go to the properties once we look at the output io addresses so two bytes of address it is consuming which is expected we know what it is now in this case if you want to have the diagnostic status or the channel status or the model status of each of this couple of ways that you can do this is once you go to the program instructions if you come to extended instructions under diagnostics you have the option of module states and device states so these two instructions i hope most of you are already using it i'm not going into the explanation of these two instructions here but programmatically taking this diagnostic values you i hope you are already doing that what i would like to show you right now is uh another possibility if you have the modules which is at least basic at least standard or high feature i hope you know that for example 8200 sp and mps i o systems different interface module and io modules available are of different categories which can be classified either as basic standard high feature etc so if you have a standard or a high feature card then what i'm going to say will be available for you so now so far if you have a look output address two bytes of output addresses being consumed which we know what it is but now if i go to dq configuration there is an option called as value status this value status once i enable okay before explaining that now let me go to the i o address area just by enabling value at value status what you see right now is for a digital output card okay for a digital output card it is consuming now not only output memory area which what we usually expect but now it is also consuming some input memory area to be exact it is consuming two bytes of input memory as well so what these two bytes of input memory is actually doing for you is nothing but it is giving you the status of individual channels now it depends on the module of course if it is a standard type module then usually the diagnostics is available only at the module level so if even if any one module gets followed you know all your input of that corresponding uh module will be showing 40 but if you have a high feature module which is actually capable of giving you diagnostics even to channel level so for example for a high feature card right now this is again an output card consuming only one byte of output memory one byte because this is a eight channel card right now but the moment i go to dq configuration and enable the so-called value status now if i come here it is actually consuming one byte of input and one byte of output now in this case so if q 2.0 is your address that particular channel status you will be getting it in i 2.0 in this case same as applicable even for input modules as well i was just showing it for output module so for example if i take a high feature digital input card so have a look this is an eight channel digital input module what i am taking if i take it into my configuration by default an eight channel digital input module only need one byte of input memory which is what we see here byte 3 so 3.0 to 3.7 but even for this module if i come to di configuration and i enable value status now if i go back to the i o addresses you will see even for an eight channel module now it is consuming two bytes of memory which is nothing but one byte the i 3.0 to i 3.7 in this particular case will be directly your input status i 4.0 to 4.7 in this case will reflect the module i mean the channel status of individual modules so without writing even a single line of code you have the possibility of getting the module status and i mean in fact you'll have the possibility of getting even the diagnostics up to channel level if you have the corresponding card and just by enabling the so called value status option only one point i would request you to remember in this case that is for this option to be available you need to have the modules both your interface module and the i o modules what you take it should at least be standard or high feature basic cards will not be having this option okay so that was one first topic that i wanted to show which is by uh how to take diagnostics without writing if if it was via program then i hope this device states and module sales instruction is already known to you if not the help file is pretty self-explanatory please have a look these instructions are also really helpful in getting the status okay so that was one i'll i'm moving into another topic which quite frankly it is a bit surprising that even uh sometimes even experienced programmers who are very much used to you know ti portal or even even siemens automation system when experienced programs sometimes miss to get the idea behind fc and fb when we write program within the uh ti portal or or within the step 7 platform we have the concept of organization blocks obs then we have fcs functions and function blocks so when fc will be used when fb will be used you know this is uh i i saw sometimes you know i mean as a confusing topic for most of the people so let me try to give you an explanation on that and again what i've mostly seen is you know always using fb is kind of the safe way to do things you know except for some extra memory consumption there is nothing much no wrong that could be happening while using the fb so i see people tending more towards fb which is totally okay but as i said in the beginning if we reach to a point where we want to optimize the memory consumption if there is a possibility then why not let us make use of fc itself but when to make that decision or or what differences will fc and fb give let me give you an idea i'm not going into the very very basics i hope you all know that fc when you call it there is no dbs associated with that but when you call an fb a function block always you have to give an instance db for every block call okay keeping that in mind let us start one of the first fc so i have prepared one fc here all i am using this for is to you know calculate the average of two numbers so i am taking two integer number i mean two real numbers as input i have an output which is nothing but the average value and of course to calculate average uh i need to have the sum stored somewhere which is not my final result so i make use of the temporary variable in this case okay this program in fact is pretty is is always okay there is no uh problem there is nothing wrong with that the place where people tend to make uh misconceptions is mostly about the usage of temp memory area so before giving you a demo let me first say you some things sometimes tell you something you can think of using temporary memory area only when you if you are sure that you are writing some value into the temporary memory area and you are consuming it within that scan cycle within the end of that program execution itself within the end of execution of that block if you want to read the temporary memory area without writing anything into it or if you expect that you know you you store something now and in the next or the future scan cycle you would like to access that temporary is not the way to go ahead but in this example anyway when i'm calculating the most complex average here it is totally fine because all i'm doing is at first i am calculating the sum writing it into that temporary variable and within that same before the end of this uh this block execution itself i am consuming it and giving it as you know i mean some other result that's fine so let's have a look at it so if i call that uh fc here i also have prepared 1db with some random variables now this db variable if you want to connect it over here ok this is another point of course we can type the values and take the data so i know that the name of the db is demo db so demo data dot number a1 you can type it like this or you always have the possibility of drag and drop in ti portal so for dagging and dropping let me show you some methods if you use the split screen option and use one of the panes to open up your db yes this is one way that you can make use of the entire screen and you can easily drag and drop instead of doing the same uh you know typing the entire addresses other than this another possibility would be if you know about under the project tree there is a so-called details view this details view will give you a peek into the object what is selected in the project tree so right now if i am selecting my program blocks folder under the blocks folder what are there i can have a look here similarly if i open it up if i open it up and i if i select that db inside that db all the variables what are there i can see that here so this is even applicable for tag tables for example so this is another method which you can you know make use to ease your life in programming and just doing the drag and drop option okay done so uh a small program i'm using nfc doing some small average calculation with the help of utilizing internally a temporary variable let me try to download this i don't have a real controller here with me so i'll take plc sim advanced for the simulation okay i'll start a plc maybe we'll see a something start whenever you want to use plc sim advanced the only one step that you need to do for the project is go to the project properties and make sure simulation is actually enabled support simulation during block compilation is enabled which i have already done in this case okay so my things are done i'll try to download loading i can have a look here how the cpu is actually behaving you will get to see the led status as what it is available on the cpu itself yes consistent download load and once the loading is complete i can ask my cpu to start which will reflect here showing in the leds okay anyway i'll minimize that so my downloading is done i go to monitor mode i monitor everything i come to the db as well and even the db i can monitor i can modify the variables here or here let me do it it doesn't matter so if i go to modify operand i give up 11 and the second one modify 33 i get the average without no problem so this is the common use of fc and to be more specific i'm trying to concentrate on the use of temporary memory here keeping this basic understanding in mind let me go ahead and open the second uh block what i have go offline so the second block what i have here is actually used to calculate the uh you know the the run number of a motor a device something so all i have is actually a boolean input where i'm expecting some pulse per second i'm calculating that seconds and that second information i'm using it to finally calculate the total run over to do this my block actually has only one input and one output so which is if i open the block so i have my run pulse which i will be giving it here and the final run hour uh i've made it as an in out so that's why it's appearing here so i give the pulse every second when when the motor or when the device is running and i get the run over calculation here let us have a look at the calculation what is done internally so whenever the pulse input is coming up i am incrementing the second so this second is actually a variable what i have made in the temporary area so i am incrementing that second one by one and if the second value oh sorry i forgot to zoom in okay if the second goes above 60 i am incrementing the minute and also i move the value 0 to seconds and similarly if the minute goes beyond 60 i increment one in the run hour and i move zero to so i mean basic calculation is what is being done here but the most important point i want to show is here the seconds variable and the minutes variable i am keeping it as my internal temporary memory and i hope you already see the point here this first time when i am adding this seconds so when the first pulse come in okay by default the second variable will be having the value 0 of course so 0 plus 1 1 and in the second scan cycle that one what was stored in the previous one is actually expected here this will not happen let me show it to you so if i go to my uh this one i had made some variables for this as well okay so i have some so what i have done machine one run and i have enabled the clock memory in my cpu so i need a pulse to be given there so let me give the edge bit over there and i have the run hour of machine one which i'll calculate like this that's it i'm calling it only one time and the program is pretty simple i'm just doing this so let me download this load okay so here monitoring will be little bit tricky because since i'm taking a positive edge i might not be able to see that pulse going in but anyway let's give a try so if i come and split the screen up if i monitor this block as well so what you see here is i'm going to make the run uh feedback on so when i make it on i really i should have got the second variable incrementing here but what you see is nothing this pulse since it is actually just an edge which is on only for one scan cycle you are not able to monitor it exactly but eventually nothing no change is happening inside this particular block just because we have made it as a temporary variable and in a temporary variable what happens is at the beginning of the execution you get the temporary variable when this block fc2 the last network is completed that temporary variable is removed from the scope of this fc it goes back to zero we can consider this is the scenario where you need to have a local memory for the block what you actually are creating the first example of the average where you were writing something into that variable and then reading it was totally fine but now here you are writing and you expect that value to be retained or or value to be available there even after some uh certain machine cycles so in in such cases we do not recommend i mean we cannot use this so-called fc concept with temporary memory internally we have to go with fb so at least let me show you whether the fb in this case will with the same logic will work or not now to show that okay i can create a new block here like this i'll call it okay some name block but i'll make it fb uh copying this is a huge task for me if i open up that fc i split the screen i can almost copy everything and i can paste it here but then all the variables are so copy pasting fcfb is going to be a big task for me let me tell you if you feel uh you know oh why am i doing this if you feel like that while using ti portal remember there is definitely some easy option available for you to do that so this fb what i created i am just deleting it let me introduce you to the concept of tia portal add-ins with ti portal version 16 if you have noticed your ti portal on the right side you have a folder i mean you have a separate tab uh uh here as a task card called as add-ins this is the one where i'm speaking about so if i go into this add-ins uh this is using the concept of ti portal openness just by writing some code and i don't know maybe c sharp or v dot any dot net framework you can create an add-in and that add-in you can insert or or you can add it into your ti portal to leverage its functionality the three add-ins what you see here are actually available in siemens site it is already published so if you go to i'll be sharing this link as well so we have a entry with a lot of downloads available so this add-in functionality how the add-in is actually used where to install it how to install it or even if you want to create an add-in there is even some application example where you can you get a sample code and you can go ahead and create your own add-in so all i have done here is i have installed some add-ins and one of the add-in available in the support site is as you see the name here fcfb converter since i have added this add-in and i have enabled it in my ti portal now what i can do is so this was my fc right fc2 so i just make a copy of that fc for the time being i paste it so this fc5 let me name it demo fb i know it is still an fb but now all i'm doing is i right click on this i have my add in section here under that if i go to fcfb converter second i have so since i am right clicking on an fc i get an option to convert it to fb so all i do is that it compiles the block it converts the block into an fb and here you go you have that block with the same set of code what you saw before but right now the only change i want to do is all the variables which we had declared previously inside the fcs temporary now i want to have them under static now that is one difference between fc and fb i hope this is again a known track to you fb has got a memory area called as static and what static is doing or or how static is different from temporary memory is just that static will be assigned a specific memory inside the instance db so when you come to the main program and when you want to call that fp so when you call it like this every time you call an fb a db will also be assigned for it right so in that db if i open that demo db what is created our static variable has got some dedicated memory there so even if you want to access this in some later scan cycle this is totally fine now this let me do the same logic up here whatever we did before i'm just converting it into this fb logic and now let me delete this network so same logic even internally all the program everything is same only change i did was i've taken the variables from temporary and i've put it in the static only because i want to have access to those values even in later scan cycles done let me download if i go to monitor mode oh this was already on so open and monitor now you see here already see since the machine run feedback is given my seconds variable is in fact increasing so some changes happening which we did not saw in the last one and if i stop this no stop to zero and that's it so 30 seconds it is just remaining there so this is one of the case where an fc will not help you in doing things you will eventually end up with fb and especially the use of temporary so if there is a possibility for you to use temporary please try to go ahead with that because temporary will not consume much of your code work i mean data work memory but if you do it in static which is eventually coming up in in a db that will consume your data work memory okay so that was one of the demo what i wanted to give moving ahead let us go to a next example where fc might not be your right choice i have an fc here the third fc ah okay so this is in fact the same concept as as what you had before uh so this program is all it is doing is it is just having two inputs and one uh output i'm just latching that output with the help of this latch bit so i'm using an sr block i know some of you might be thinking no i need not do this program like this i have some easy way to do this i know this is just for a demo but if you end up doing something like this i just wanted to show you the bit what you give on top of the sr block is actually retained there so that you will get the output even in the next scan cycle let me show you uh what i mean by that so if i call that fb and if i open my db i'll take uh okay i'll take say machine one start machine one stop and uh machine one conveyor output i'll give us the contactor so simple and internally all that is happening is it is just latching but this latch bit what you see here is something that is saved in the temporary bit so the same topic that that we discussed just before but just to give you a demo that even because this is these are all some cases what i have seen in certain programs i would say put that monitor okay now here what will happen is if i go ahead and modify this to one yes my set bit is high so because of that it is latched so since it is a sr block what i expect when i take this input off the output should remain there but what you see is that the output is also gone because the latch bit is again inside a temporary and the same topic the same explanation okay i'm i'm not going to give you a demo of converting this into an fb anyway i hope you got the idea okay next one or the last one in this particular scenario so here this simple fc all i have done is i have just one input and one output if i get the run status i want to give an indication lamp on which is pretty simple nothing in between no lamps nothing has come up in between but here all i want to do is i want to introduce a little bit of delay when the run status come up i don't want the output to be turned on immediately i want the output maybe after two seconds so i have my awesome timers for this i take the timer when i call the timer since timers are also internally basically some fb so it will also ask for some db so i'll name it uh timer1 i've given the timer there and i can mention the time so t hash two seconds so after two seconds i expect the output to be on okay pretty simple pretty straightforward let's call it so i want to call this fc twice okay and internally what i want to do is if the machine one run is there then i want the machine one indicator to give a status similarly if the machine to run is there i want the machine to indicator to give me the status so what will happen in this case let's have a look download load done i go to monitor mode i modify this to one and if i count one two so two second over and even then i don't have my output here so something went wrong let me modify it to zero if i do the same thing here modify it one so one two two second done even then even here output is not coming up but if i do the uh thing for both of them yeah then after two second both the outputs are turning so what is happening here the only explanation for that is in this particular case internally the timer that we are using is actually common which you already saw that right so if i open up this guy for both the block calls a single timer is actually working there with a static reference to this particular db db3 so eventually in the main block what is happening is when the first network try to make it on the second network try to make it off and the same timer is pretty much confused until and unless both the inputs are on and that's what was behaving uh i mean that what was causing that behavior what we saw so how to overcome this of course fbs can come for rescue in this case but i also want to show you some other topic here instead of creating a timer in this way i hope you might have noticed this when i call the timer here whenever when i'm asked to give a db for that i also have got an option here called as parameter instance which means instead of calling a single or instead of giving a single db as an instance for multiple calls i now have the option of giving a timer i'll be able to pass on some timer along with my block just for the sake of you know keeping that timer different so let me give some name for it so delay timer some name okay see it is coming with a hash simple which means it is available in the block interface and no no dbs are assigned to this and by default it got reflected here in the in out area of my block interface okay fine i'll just give the time t hash two second done so is that it done let us go back to ob now you see that since our block interface has changed the ob i mean the block calls are showing red i can update the block call here by right click and do the update block call i hope this you all know but let me show you also one other method if you have multiple block calls in the same block and if you want to update all of them rather than right clicking and doing this one by one let us do it in centrally if i go to options a block call update all block calls so you have an option up here so now once i updated here now i get to see a new uh in out variable asking for a separate timer so now here i have already prepared i mean given one timer before that was timer 1 so i'll give timer 1 i'll make sure that the second time i don't give the same timer 1 i'll pass on a different timer in this case but how to create a db for timer it is pretty simple you can just click on add new block you go to data block and a data block global data block is mostly the one that we see but if we scroll down we also have the option of iec timer counter all those blocks are available here so i just make a new db of the type iec timer let me call it timer 2. done it got created under the system resources okay and now i'll give the timer to here done so two times i'm calling and each time instead of giving us a uh internally a single reference i am now giving i'm passing two separate uh variables here as the reference let me download done okay now things will be okay if i modify it one one two after two second the first output is on no problem and the same for the second modified to one one two and after two second the second one is also on so when you call uh any block that requires a db i mean i was showing this with the help of i was showing this with the help of a timer but this is equally applicable for timers counters or any other block that you call from the instruction list which requires a separate db or it is also applicable for any block that you have created that requires a db which means any of the fb what you create this fb for any reason if i'm calling it up here that will also need either a single instance or a parameter instance so if you plan to call this fc multiple times don't give single instance then it will not work but okay now this solution what i just came up with for this particular case of just giving a delay for a timer this is okay but it is you know i mean hell of a task for a programmer every time i want to call this i have to create a new db i have to make everything here this is not the efficient way of doing things and we are not here to discuss an inefficient way of programming right so this is where i would like to introduce another possibility inside an fb which you might have seen it called as multi-instance concept so let us go back to that demo fb what we had we'll do a simple i know i mean i'm not creating some new fbs i'll just add run feedback if i can type it right oh okay and in the output section i'll make a lamp which is a boolean so somewhere down below i'll be creating one block like this which i can now make it uh run feedback given to lamp done now if i want to introduce a timer within an fb when i call any other fp that requires a db have a look you will be getting one new option that you haven't seen inside fc you know what single instances you know what parameter instances but only for fb you have this option called as multi instance so if you make use of multi instance this variable will be created in the static area of this fb so that your fb becomes self-sufficient every time you call that block you need not go ahead and manually separate create another db for timer another db for counter nothing required your fb is already self-sufficient with the concept of multi-instance so let us have a look so timer okay delay timer i have given the name it came with the hash but since i chose the option multi instance it did not appear under inout instead it came under static if you had given the option single instance it would be just another db natively i mean right away created on your blocks folder if you have given the options parameter instance it would have appeared under in out just like how you have seen it in the fc example but since it is an fb and we have the possibility of multi instance it came inside static now because of this timer will my block interface change absolutely no so let me give some t hash two second time so i go to my main let me delete them i'll call my demo fb here for that fb i have to give a db i know which is okay i'll give one i am asked to give my run pulse which as we have done before let me give it so run demo data machine one run and i can m 0.5 see already typing is becoming a hell of a task even for me so let me go ahead and do that edge run feedback i would like to give from i don't know i'll give the same run for the time being and run our give something up here and for the lamp i'll choose the indicator and done so the block interface is not asking for any db i mean a any timer dbs or anything to be given i can just download my block and the internal timer what is available will take care of the rest so if the run is made to zero the output the indicator lamp is also off okay so as i said just the point to remember is is that this i was showing you with the help of the timer instructions but the same is applicable for uh you know i mean other blocks as well so let's say you have prepared i mean you have an fb for your motor control and uh valve control and you want to call that motor block five times so you can call it inside another fb and every time you call it then that db what is required you can make it as a multi instance db i hope we will see some examples for that even so with this i would like to conclude the discussion on fcfp so to summarize the points what we discussed differences between fcfp most of you know fc when you call it there is no need for any db to be given fb function block when you call it a db has to be given but the real uh you know purpose behind that db or the usage of the db comes with the usage of the temp memory area temp memory area is something which is available in both a function and a function block but you have to be careful while using it if you are using always keep this in mind write a value into a memory into a temporary memory and consume it within the same scan cycle you're good to go but if you write something in one scan cycle and if you wish to have it in in some future point of time then you need to consider fb because that provides the static db option that is one so temporary static that is one difference another point is with with the help of fb we have the option of multi-instance dbs so any other block maybe timers or maybe other fp which which requires a db to be given you can make it multi instance and the biggest advantage is your block is becoming more and more self-sufficient you need not you know i mean depend on other blocks you you need not manually create n number of blocks even if you in uh even if you wish to reuse the same block in future so that is the whole idea behind this okay i hope that discussion was any bit of helpful for you let us go to the next topic here i don't want these let me delete them i don't want these as well okay all up to date go offline fine second topic a totally different topic that i would like to discuss is regarding addressing now uh i hope you might have already noticed in this demo or if you have attended any of our previous demonstrations or for that matter if you have seen any application examples or libraries available from our support site most of the times you might have seen that we always use db's data blocks for storing data we are not using bit memory uh for storing data bit memory is still available i totally know i totally understand but the recommended way of storing data whenever you want to store data always use dbs why we are saying that with the uh you know i mean with the firmware or or with the hardware of 1500 and 1200 series plc the data blocks can be optimized by itself you need not do anything on so let me make a data block with the name data so when a data block is created inside the data block when you go ahead and create some variables you can make those variables by knowing you know how many bytes it will consume how to arrange it so that it won't you know waste the memory but now we have the optimized block access which by the way is the default option always available and we always recommend keeping this optimized block access don't remove this no problem in removing but if you keep it optimized you don't have to worry about addresses the ir portal if you follow the latest uh uh not just something what was released in version 16 from the beginning all these features are available if you follow that uh facilities available as a programmer you need not worry about address at all you only play with symbols symbolic names are easy to remember easy to access rather than remembering some random address like db14 dot dbw 32 instead of going ahead with that you can easily remember addresses and address sorry easily remember symbolic names and that is what we give it to you so keeping the optimized block access you just use the symbolic addressing and symbolic accessing of the variables you totally forget about all the individual address that plays behind that let the compiler take care of allocating memory and the compiler take care of allocating all the required resources for that okay now with that especially people who have used some uh people who are used to the s7 300 400 or the classic platform we get a lot of questions with that so this demo what i'm going to show you right now is mostly to address those points so i have a an fb created here i mean it could have been anything but i am just creating an fb not going to run any uh things in the plc advance just to show you something so let's say we have some individual bits you know array of bits or individual boolean bits data coming from different places i want to combine it into a single word one of the very common example i'm pretty sure all of you might have faced is when you want to create some alarm tag for hmi panels you know that our hmi panel does not take the bit a single boolean bit as the alarm trigger bit right we have to combine it into an integer which is actually you know 16 bit size and then take it so that's what i want to show here so let me make some bits so bit one boolean and this i hope you must be already aware that we can drag and drop just as how you would be doing it in excel even inside the dbs inside the block interface and all so i have some boolean bits coming as input and i have an output here which may be alarm tag okay this alarm tag is actually a word or an integer it doesn't matter so it's not a brilliant it is a word all i want to do is i want to save the data inside each of these bits into the corresponding bit in that particular alarm tag because if you remember the some past programming what you have done in terms of creating hmi alarms i hope this must be very familiar to you so for doing that you know people go around with different ways but i want to show you a simple addressing mode or addressing possibility available here so let me take this is bit one and if i just drag and drop this definitely this will cause an error because this coil instruction can only take a single bit an alarm tag is not a bit but in dia portal it allows i mean especially with 1200 and 1500 we have an addressing concept called as slicing so if you have a symbolic access that you are actually doing but from a word you want to access a single bit or from a word you want to access a single byte we have an option called as slicing access i'll share this you know i mean link in the presentation but let me show you to you what i mean by that once you give a word type tag or something like this up here it will show error yes but you just type dot b0 b for bit so once you do that okay what is [Music] happening let me have a look am i making a mistake okay dot e1 let me try to put it inside static oh sorry sorry b is for byte my mistake my mistake it should have been x dot x zero if you give it that is a single bit so this word once you have it my mistake sorry for confusing you if i did okay this word that you have individual bits of that word you can access it by slicing access uh with the help of these keywords now word completely that word if you want to access individual bits then you make use of uh you know the dot x option so bit 2 bit 3 whatever here you come to dot x 1 dot x 2 it can go up to how much our size is available here so this is a word which means i can give it up to 15 but now if i try to give it a 16 it will start complaining because you know that's a word and 0 to 15. so totally 16 bits is what it has so this is a possibility as i have already shown you by mistake this access is also possible via single byte uh access as well so let's say for some reason from this word what you have i need um b1 byte which is a white and i need the second byte that is maybe b two byte now if i call that guy here sorry so i call that guy here and if i put a byte here this will cause uh some data loss because this is a word but we are compressing it into a byte just by doing this and we are actually only moving the last eight bits of that particular 16-bit word but instead if you do b0 which is for byte zero and if you want the second byte you can just do b1 and you will get the second byte out of it so the tag what you define if you look at your block interface it will just appear as a single word type tag itself but that word you are slicing it into different bits bytes so if you have a double word you can slice it into booleans you can slice it into wipes you can slide this into words that is also possible so if you want to slice it into a word you will just use the identifier w for that so with the help of this you will be able to easily access individual bits and individual words bytes from the status all these options let me also show you another example or another use case for this right now what i have shown was certain bits i am receiving from the field i am converting it into an alarm tag but instead now what i want to show is uh maybe via modbus or something i'm giving i'm getting some value i'm getting a 16-bit holding register so maybe holding register it's a 16-bit uh value you you know that so holding register a word i am getting up here and the place from where i'm getting this holding register one that uh hold eraser each bit refers to some individual status so maybe you are combining the status of uh eight different valves so eight valves open and close status you are combining it into a single word and sending it as whole into your server so now you want to access the individual status so val one open which is a boolean and valve one close valve to open well too close let me just make four more okay not c2 v2 val 3 open well three close well four open and valve four close so this is 16 bit i'm just trying to show it to you for eight of these bits not much so here now when i uh take that option just like before we have the possibility right now to do this not only the output byte in the input byte i can drag and drop that and say dot x zero okay dot x zero is val one open if only it was you know just simple as this it would have been okay for you but most of the cases maybe you want this access acting as an interlock for starting off some pump so when the valve is open then you want the pump to be on so you will then be doing uh you know i mean some on command you will be giving some on command to some pump in this case but tomorrow when you come and look at this particular program when you look this holding register percentage x0 you don't understand what that is right so we with the slicing access we don't have the full efficiency of having the symbolic names so for that i want to introduce you to the next topic what we have this is the concept of at uh keyword or at uh overlaying the variables what we have in the block interface so the if i make it this has to be set in idb for this to work so the very next variable if i create so var or status you see this is actually acting as a separate variable with the same type word int bool whatever it is possible but once you keep this option now you have the possibility to just type 80 at there what the 80 will do 80 will actually overlay this status on top of that holding register one so let me make it simple so i'll call it hr one i'm sick of seeing that so this this status tag is right now overlaid on top of that okay so to keep things simple let me delete all the old ones and here i'll delete the alarm tag as well okay so this we can see it from here so if you uh look at it so here we have a dot but if you see for the status this place there is no you know i mean connector available showing that that is not a separate tag it is just a continuation of the previous tag available now what is advantage advantage is that once we have this now instead of making it a word i can now make it as a structure so i will make it as a struct and under struct i can now put it like this v1 open v2 open and to make it easy let me copy these names over there copy and if i paste them up here so this is actually a 16-bit uh sized variable i have already pasted around okay so i've already used eight of them and the last one maybe i'll i'll keep it uh for future future use which is just a bite so eight bits plus a byte which means totally 16 bits all overlaid on top of that particular uh word over here now if i come down to my program if you now want to use it as an interlock for something or if you want to use it in any of your program you can directly make use of this okay this can be given down to your output now this does not mean that your block interface is changed so up here when i call this block okay see here i am still giving a symbol a word sized holiness itself internally i am slicing it and on top of that if i want to overlay other structures so that i can still have the possibility of symbolic access i can make use of that that is the use of a t keyword at keyword all the details of this 80 keyword usage and all these things are available in another faq in our support site i will also be sharing this with you you can have a look so all the you know i mean prerequisites for this how to make use of this everything is explained up here and just to show you if you have a look at this this faq was posted in 2016 so this has been there for a very long time i'm not sure how many of you were really aware are you really using this anyway so that is the use of a t keyword at keyword and uh you know using things in that fashion right now what we did was we had the usage of some structure so we want to group some data for example in this particular case all valve status and a particular byte i wanted to group it together that's why i created a structure here right this is totally okay but for some reason if i want to reuse the same structure somewhere else for some other variable or for some other case then i have to go ahead copy paste one by one or i have to you know i mean retype and reuse this everywhere else so instead of doing that let me show you another concept that is possible here which is the concept of udp's user defined data types whenever you have the possibility whenever you think of grouping some variables into a single unit so that you use that whole unit as a as a single element always think of user different data types and udt especially if by any chance if you come across a requirement of a struct that simply points to the fact that you can make use of some udts in your case so what is udt how to create the udt let me show you to create a udt you just come to the plc data types not the plc tag come to plc data types area and here you have the option of creating user defined data types you can give it a name i don't know i'll call it a valve status and inside that you can define the variables as required so to keep things easy let me just copy paste this so that i don't have to type it and waste your time okay this user different data type udt now i have made something called as valve status this looks like a db right if you have seen the interface of a db this looks much similar but this is not a db this this does not appear as a db but because of the creation of this user different data types now we have the possibility of using it in our you know block interfaces or inside db so for example usually when you create a variable maybe some variable you have data types available there are system data types like integer or word or real or no date and time so these are all system different data types available but if we have our own data types like this now those guys will also be appearing here now so if i come down you can now see here that you have this option called as valve status so if i open it this is actually nothing but a struct kind of a struct created but now you don't have to type it individually one by one every time you can make use of this at a single stretch wherever you need it so i hope you are getting to know where i am heading to so previously using that 80 overlaying structure what i did was i overlaid another structure and i manually created the structure for all those things now i need not make it a struct i can make it valve status done so if you have under the holding register which would like to use the same concept you can make use of this again over there so udt is another topic that we are starting to discuss now and it has much more features and facilities available along with that the concept of udt can in fact be used not only inside your i don't know maybe not only inside your dbs fps and all it can even be used natively with your io memory as well so to show you that let me go to okay i have an io device okay do i have a module it's an 8 channel module okay let me take a i'll take a 16 channel digital input module up here okay this 16 channel digital input module is having the address 5 and 6. so i 5.0 to i 6.7 is consumed by this guy oh by the way did you see what i just did if i want to see this area rather than using the scroll bar up down left right we have this option if you uh concentrate your thing over here there is a small icon that you can use which will if you click and hold on it you will get a preview of your you know area and you can use it to easily position your screen so especially when your rack is pretty long and if you have so many things you know i've just zoomed in right now now if i click on this area now i can move around and position the view to a particular place whenever it is required okay fine so i have this input 16 input module taking five and six of the input byte what i am trying to show you is i am assuming that this 16 channel input module is going to be completely used for all my eight valve status what i have shown you before so if i go to my plc tax i go to my plc tag i will make a tag table and maybe it was i 5.0 and now instead of instead of making it bold now i can type valve status so i five point zero i five point one i five point two up to i five point seven is automatically available for you and you can just you know either use it or keep it for future use you know when you think of standardization you can think of it this way maybe you have a valve and or a motor for for one motor associated with one motor you have around you know six or seven tags then instead of using a 16 channel digital input module to combine one motor and some other things you can standardize it in a way that whenever a motor is there you will always be using an 8 channel module and along with that 8 channel module then you will be creating a structure like this if you have your fb that that we have already seen you know your fb input output static all this area can have you know i mean these area can also have that same udt reused even if you have some db's that you would like to so maybe if i have some db i want to create some temporary variable for mapping so map valves i can make use of that udt inside this as well so there are endless possibilities available but all these takes planning towards standardization but i'm just showing you the tools what are available to you so that you can take it into a much much higher level okay so that was the use of udt to just to recap or to summarize certain points what we discussed so far we saw the concept of slicing access and with the help of slicing access we use that dot byte 0 or yeah so bits were accessed with the tag dot x0 x1 x2 word can be accessed with w0 and byte can be accessed with dot b you know so with this multiple higher sized tags can be accessed individually with with some less sizes second what we saw i mean one of the limitations what we saw there was you know just if you remember that example of holding register giving us values of eight different valves we never knew holding register dot x0 is val 1 or val 2 for that if you want to have a symbolic addressing you can overlay another tag on top of a tag so for that we use the a t construct ap keyword so using the ap keyword we did that now using 80 keyword we saw that we had to use the struct to make you make the full use of it using struct was totally okay but if you want to reuse that same structure somewhere else just like how you can have it uh you know if that input module can itself be used in this cases so instead of keeping some struct i made it as a user data type of udt now if you have opened and seen any of the siemens libraries siemens application example sample projects available in our support site you will see a heavy usage of all these options and they are the recommended ways of doing things they have even some more uh you know i mean power that they'll be giving you which we will see in a moment right now okay so that was some bit of demo on different addressing concepts let us go to the next one handling data whenever we have a huge amount of data or or when we have certain data that we use in the program and we want to have it much more readable we have certain tips that you know that i want to share it with you to give you an example i have made here a small fc this is a you know a unit conversion fc this is converting pressure in one unit to pressure to other unit i mean it's a simple example just for the demo uh both input and output are taking some real numbers and output is also giving you some real numbers for this internally once you look at it what you see there is you have the pressure input multiplied by 14.5038 giving out as the pressure output so as a programmer you might be knowing what is the relevance of this particular value here but for any other person who without having the context when they open and look at it then for them to make things easy it is better if you could make use of the so-called constants inside a block interface made bfc made bfb down there you will have an area called as constant this constant is nothing but giving a name for a fixed constant value just like this advantage readability your code will become much readable so that anyone will understand what is actually happening there in my case what what i have is if i remember it right it is bar to psi factor and i'll copy that and that is a real number and as a start value i'll give that value there okay so now in my program wherever i want to use some constants like this i can make use of this no change you know still it is a constant still it was the same effect as that of before as far as the calculation and and as far as the memory constraint and everything goes but your code is much more readable for you or for some other programmer for anyone using the constant available inside a block will provide you access to that constant only within that block so if i want to use this particular you know bar to psi factor somewhere inside ob1 or somewhere until some other block i might not be able to use that but if you want some constants declared globally you also have provisions for that which is with the help of tag table if you come to plc tag table any tag table i'm just opening the default tag table you will most probably be using this area right i mean the the normal tags what you create but here in addition to the tags tab and the system constants we also have a option called as user constants this user constants provide you the same concept and the same option just like what we have seen right now but only difference that instead of giving it a you know locally to one block we have some local access right now so if i you know define pi and that is a real number with the value three point one four 1 5 something like this now in everywhere in my program maybe in ob1 um i can use that constants are inside another block if i want to use it i can still make use of that here as well so user constants user constants will provide you the possibility to make your code much more readable and much more legible for yourself and and also for other users shall i say okay now second topic under data handling what i want to say is when we deal with data so first of all constant data this is the first step you can make use of the so called constants use a constant but other than that when you have bulk amount of data that you want to use it for some some particular you know logic then start thinking about array ra is a very very powerful and useful tool which can make your life very much easy in lot many different cases so to show you that i have prepared another small fb here this fb is i'm just going to do some motor speed calculation all i'm doing is i have three uh uh you know motor so motor run feedback i'll be getting if i'm getting the run feedback then i'll use that motor speed as the actual speed output if not i'll move zero which means i mean to keep things in context let me show this so m1 run if m1 is running then m1 speed sensor value i'll move it to m1 what happened is it a different type okay these are also real okay i'll move it to m1 actual speed if not i'll move 0 as the knob so this is the logic simple logic so i have a motor if it is running the sensor value will be moved as the actual speed if it is not running i'll just move 0 as actual speed so very pretty simple logic but now here if i want to you do it for three it is pretty simple i just copy paste it three times that same network what i wrote here i copy pasted three times now everywhere i have to go and change that m1 to m2 even for that i mean even for that you have some options but if you see here the naming convention what i have used you know i'm always following a particular structure and there is and there was a reason behind that since i have followed this now i know between network one and network two the only naming change what is there is everywhere m1 that is there it should be changed to m2 then my second network is ready right that is possible since i followed a standard in creating the block interface and the naming okay but what is advantage for that now that i have it i have copy pasted the same network twice so i have for one and two and all now over here i select the network too on the right side on the task card if you come to the task card here we have the simple find and replace option so i can now just say find m1 and replace it with m2 everywhere you see it and look downwards so i say find yeah it found one here replace replace replace replace done my first network is ready now i'll just say m3 and replace replace replace replace you see having standards in different walks of your engineering development is always helpful but anyway this this is not the easiest way that i want to show you here right now but still this is something that no good to know now that you have it when you go ahead and call this block so forget that guy if i call this block okay fine i can connect some you know i mean parameters and it will work fine no problem tomorrow i am doing a different project right now and in my new project instead of three motors i have now seven motors or or or i have ten motors now what do i do i have my logic ready right what is the logic required that is already prepared and and it is readily available all i have to do is i have to scale it little bit so how to do that for that uh i'm not even going to show it manually but you got there you can copy paste things one by one you can copy paste here one by one and make things a mess instead of doing all those let me show you a different way that's where i'll be using array so i'll delete these two networks i'll delete these two guys i'll delete these guys except network one let me delete the network two and three i'll go here um so run i'll say run m and speed sensor i'll name it speed sensor of the motor m and uh actual speed also i'll make it actual speed of motor okay now instead of making it a boolean now i'll make a array of boolean array of gold array of real same here array of real okay now if i have uh you know i mean 10 motors all right or if i have five motors i can do 0 to 4 or 1 to 5 whatever it is it doesn't matter i just adjust it here i just adjust it here and my block is ready so run m0 speed sensor m 0 actual speed actual speed m 0 same concept now if you are going ahead with copy pasting yeah still fine i copy paste one two i'll show it for two times and here i'll just come to task i'll say i'll ask for find bracket zero and replace it with square bracket one replace replace replace replace and over here replace it with square bracket 2. okay so using arrays is is a little bit easy at least the the uh having this you know interface changing is actually a little bit easy in this case fine okay but now when i look at the block interface what do you see block interface is all is all blown up now i'll go to update block call okay now fine now if i keep my pointer on top of this it'll ask me for a array of 0 to 4 of boolean so i come here it is array of 0 to 4 of real which means now if i have a data block m data motor data some data block and i'll create um motor on okay sorry yeah on off motor and array of boolean of what bull and speed sensor of motor and this is real and actually ok instead of 0 to 1 i will make it 0 to 4. done all i can do right now is i can come to the place where this is being called i can open up this guy i can connect that array completely over here i need not even do connecting the variables one by one i can fully connect it as a single element and it internally takes care of all these options right fine so this is you know i mean so far okay not that great so far okay i would say but this is not the only reason why i wanted to introduce array to you with array i want you to know okay let me delete all these networks so when i write something like this so maybe uh speed sensor of three moving to speed sensor or actual speed of three you know this first network writing it this way and if i just for a moment create a new variable i call it idx or index whatever you want to call it i'll make it an integer for the time being now have a look what i am going to do if i use a move block i move the value 3 to that index variable or idx variable and then in the next network i will copy that same guy and instead of m of 3 i'll say m of idx and even here m of idx this first network and second and third network combined both are actually same effect or let me even put it here i mean this is even okay so this network one and network two are actually having same effect now what's the advantage if i now want to go to the zeroth motor i can make the index 0 i can make the index 4 i can make the index any number what i want and this logic what i have here will work automatically okay this knowledge i can really leverage if you could you know go a little bit into scl programming as well now i know when i say the term sel at least a part of you will be oh cls you know i mean not my cup of tea it is too difficult but let me at least give you some you know basic background i hope this is already known to you that even creating while creating a new block i can add a new block maybe it is an fb and here itself i can make it either go as a scl or stl fpd these languages i can select it for the whole block or i also have the possibility that within a block itself i can have one network i can have one network as ladder in between another network as scl you know this is totally possible the moment i select that scl network you see here your favorites region has changed a bit instruction folder if you start digging deep i mean there will be you know little bit newer instructions available here but you know things are little different in this case before i show you the full purpose of you know i mean converting this into an array and using the scl and all let me at least show you how to deal with scl uh at least for simple examples so let's say i have a switch which is a boolean and i have a lamp it's a boolean if you want to make that lamp on you will just be doing this so switch and lamp right in ladder the same thing if you want to do it in scl the only thing what you do is where you want to save the data that is lamp so lamp you just mentioned colon equal to and say switch you end every line with a semicolon that's it so this and this is now a again the same if you want to move some you know the other variables for example if i take a speed sensor okay speed sensor of m of 0 colon equal to actual speed of m of zero this is equal i'm sorry outside this is equivalent to moving that value uh uh into one another so all these kind of options are possible but the biggest advantage is once we have the scl uh code written like this we have the option of using if conditions we have the possibility of using loops we have the possibility of using you know switch case statements those things come into picture now i mean i i don't have the a whole lot of time to teach all the basics of sel but let me show what i'll be doing in this case so the same logic what we wrote before which was like this so let me take this out the logic what i had written before was like this so um run motor zero and uh speed sensor of motor zero move it to actual speed of motor zero if not if not maybe i'll copy and paste this if not i'll move the value 0.02 so this same network if i want to convert it into sel it will look like this so i need an if condition to check if this is true or not for that i have the if logic i can i have some of the tools available here in the favorites area or if i go to program control operations here i have so many templates once you know the syntax you can type it by yourself but at least until then if you want you can make use of this you know boilerplate uh templates or snippets shall i say so when i call a snippet like this from this there is a you know kind of yellowish highlighted area that is a place where you have to change something so i'll just mention run m 0 equal to true so if that run m 0 equal to true then what do i want to do then i want actual speed of m 0 colon equal to uh speed sensor of motor zero end it with a semicolon if not what i want to do is i want to make it 0.0 that's it this network and this network is right now exactly the same okay now where am i going with this let me show it to you just like we have if conditions we also have the possibility of loops so uh one of the common loop what what we have something called as a for loop i am just taking a for loop out here the structure of the loop is pretty simple i have a counter variable i give a low limit and a high limit the counter variable will go from the lower limit to the high limit so all i can do is i have that idx variable which i made before let it go from 0 to four now this loop once it executes it will be automatically changing the value of idx from zero to four now if that is possible i'll just cut that code from there let me paste it inside this guy okay and inside wherever i have that 0 i'll just make it idx now so idx and even here i'll make it idx so that's it now your entire code for controlling or or for calculating the speed of you know i mean zero to four up to five motors is really ready you don't have to worry of anything else you can call this and this same block will equally work fine so i just update instance and block all done now i'm not totally done i have a couple of more points to say now here i have another problem now let's say you saw the way i have built this right so i have made it now for zero to four and even that db variable what i made for the mapping i have made all those for zero to four yeah totally fine but now what is the use of this what i want to show you is tomorrow if i want to come and change this to you know to to make it for 10 motors now it is compared to before it is still easy but still i have to go and change that 10 at least uh six and seven places where all things i think so this i'll make it so this i'll make it 10 and this i'll make it 10 this i'll make it 10 this i'll make it 10 this i'll make it 10 this is 10 and inside the logic and here this is also have to be 10. yeah now it is ready for 10 variables but every time having to do this is really not the efficient way of course we are not here to discuss all those and this is where i would like to go back to the last topic what we discussed that is user constants if i go to the default tag table i have this user constant i can make use of this inside my code how have a look so motor count and it is an integer i say that is having the number 10 okay once i have that now i come to my code wherever i have kept that 10 instead of keeping the 10 there now i can keep motor constant so instead of writing 0 to 10 if i type motor count since the motor count value is 10 right now that gives me 10 elements up here i can do the same thing for all of this copy not only inside the fb even inside the db variable when we declare i can do that i messed it up and since it is constant i already told you we can access it anywhere motor count done now your block is you know i mean so much reusable than how it was before if your code changes for any reason and and if you i mean tomorrow you have a program you have a project where you are doing it for you know i mean instead of 10 motors you want to do it for 5 motors 20 motors 100 motors it is just a matter of coming here and changing this variable to whatever you want so i did that single change you come here all your variables are already 30 inside you go here all your variables are already 30. that so this is the real power of using array so i said whenever you want to deal with a large amount of data it is always better to use array this was the real reason behind that now of course i was showing it here by creating all these variables individually by creating that data now this i can again make it one step ahead by creating udts if required for example if i go here if i make a new udt and i call it motor udt and inside moto udt all i have is the run status which is a boolean and i have actual speed sensor which is a real number you can have more variables i'm just limiting it to two now once i have that udt then instead of creating different variables like this now i can say this is m tr say let's say a motor array of i can say motor udt and even the array of motor udt even here this is motor count here you have to make the i mean unnecessary changes so instead of calling it as just run it will be mdr dot and tr of idx dot run status and this will be mtr of itx dot speed sensor i mean you can go ahead and make the changes given here even this was not required right now i can have one of them deleted this is again just a motor and array of motor count of bull that bolt now i'll change it to motor unity if i come to ob1 update block call okay and to this guy i'll just connect that complete array same effect okay so uh so far so good now before we really conclude the sessions two more small topics i want to discuss here so far if you have seen the pattern that i have been showing you i am showing you different tools and options with which you can make your blocks reusable so that you can standardize your entire thing you can make your own library blocks whenever a new project comes up you have the option to you know straight away call it reuse it and no you're done with it now on that aspect if you think of giving out this particular block to someone so in one project as a programmer as a developer you developed this now tomorrow you want to give this block to someone what you know precaution measure you have to take care the only measure that you have to take care is that inside this block everywhere i am accessing that so called motor count constant so if the person who is copying this block i mean person who is using this block into his project he did not create a constant named motor count then yeah then the entire thing will start failing you won't be able to you know i mean properly do that so how to overcome this last point let me also have a discussion on that inside your this i believe it's a functionality which got introduced in ti portal version 15. i guess i may be wrong but anyway so any type of array what you create you can define the sizes oh by the way i hope you know this you can define the size zero dot dot you know five this is how people do i mean this is okay if you want to make it you can make it 1.5 that's also okay or if you want to keep any other number you know i mean 758.99 this is also totally fine but when you access it you have to access it in that same way in the same manner if you want to make it you know minus five dot dot plus five this is also a valid uh index for any array but anyway i'm not here to discuss that instead of defining a size constantly here because that was the whole reason why you know they have to rely on the so-called motor count so that they will take the variable properly or not instead of doing that i can say my array when i'm creating this fb my array is of unknown size okay okay something is messing up we'll have a look at it but nevertheless if i go here even i'll make this as unknown or rather than putting it under input maybe i'll put it under in out if that makes any difference oh yes yeah so i have to give it under in out my mistake paste okay so all i did was i just put it under in out but my array size is not defined at all so what is the catch here what is the problem here when i execute this code i know that i need to know the loop has to run from where to where because the index will be going from that low point to that high point by any chance if you mention a index which is not really available here it will cause problems so how to define the limits because i don't want to keep this motor count variable as a you know constant inside here because then i can't you know with all ease of my mind i can't redistribute this block because i have to tell them you know go ahead and create a constant with the same name with the same type all those things i have to tell them so this is where we have this possibility so if you come to instructions under yeah under move operations we have an instruction called as lower bound and upper bound this instruction is nothing but an option to help you to find the lower limit and upper limit so l bound let me make a integer variable for example and u bound another variable so this l bound and so what does it need okay it need a d okay fine i'll bound new bound now for the array this array i'll connect it here this array i'll connect it here and this dimension is nothing but because i mean uh while creating array it is possible for us to create even multi-dimensional array you know array of array can be created so we are finding the size of which dimension so i'll just make the dimension one now this gives me a possibility of really really really reusable block i don't have to worry anything externally here okay i have to change this though so l bound to u-bond done this block you need i mean as long as you are sure of the logic what is written here if you are sure if you have tested this logic it works fine you are 100 sure then that's it you close this block you never have to ever open that again whenever you call it it just takes the size internally depending on what array size you connect it here if you connect here array of you know 10 variables it will be 10 variables if you make it 30 variables internally it will find the 30 variables that's it so that was you know the the real real uses and advantages of having uh indexing and array concept and even going ahead with scl how much of you know i mean effort you can really reduce you can have a look with this okay fine next so even till now all the variables what we created we were showing uh you know variables that has a particular type so if i come to an option here this is a simple example what i'm just trying to show not so meaningful example but anyway i could only think of this uh what i need here is i have a an input value and the output is whenever the limit of that particular range is reached i want the output should be you know i mean uh high and what do i mean by the limit let me go to the help for a second of di portal if it is an integer that i am connecting programming a plc i hope you know data types if you come to just you know to keep simple let me take integer data type let's say integer if i am connecting an integer variable there i know integer variable can go from minus 3 to 768 to plus 32767 so when my value is reaching approximately around ninety percent of that so three two seven six seven into point nine so when i when my value is reaching around twenty nine thousand four ninety i want a warning to be uh raised this is my requirement pretty simple but the only problem is if i am making such a block i have to make the block different different block for different different data type if i am using integer integer i have to play with this limit if i am using signed integer i mean short integer this is the limit if i am playing with unsigned short integer this is the limit everywhere i have different limits to play with so how do i deal with that so all i want to do is just this so if i value okay sorry greater than if my value is greater than now to to define those limits you know i know these are the constant values i have calculated you know just for the example 90 of all those and i have saved it as constants so if my value is so in this case this is an integer so i should be giving here int warning limit so that's how my logic is into one limit then i want my limit reached this output to be turned on this is what i need but what is the problem tomorrow if i come and connect uh a you know unsigned integer or a real number or a double integer my entire limit and all the range will go heavier so how to overcome this now for that i want to introduce the last topic that we'll be discussing for today that is variant so far we have seen the system data types we have seen different data types that we have created in the same way we can make it you know variant which means there is no data type i'm giving for that when you are playing with variant you almost will have to do the code in sel because in scl you have some instructions which will be helpful for you in this case so what i want to find out here first is this value which is a variant let me show you this if i go to my ob delete all the previous ones if i call this guys in which i have made variant if i keep my mouse pointer here it says i am getting an output that is a boolean because i know internally that is a boolean but once it is variant what do i see if i keep my mouse pointer here it can be any of these this is almost the entire list of data types supported by the uh this will be aplc it can be boolean character integer signed unsigned anything it can be so i'm making my block you know independent of the data type even what i have but how will i manage this then for that i have to use some uh you know built-in instructions for example i have this instruction called as type of type of you give that element so type of value this instruction when you call it it will return what type of i mean what is the data type of the variable what you have given here this will return that what is advantage now i can put it inside an if condition for example if type of value equal to inch then then okay my uh okay then i'll say if value greater than in one limit then my limit reached equal to true i know this is not a real world example so please bear with me for being a little lame on this and if and here instead of ending i'll say else if so now i'll copy paste the same stuff else if copy paste okay i know this looks a bit weird but let me show you what is happening in here just to give some spaces i'm not going to run this anyway so if this is ind or if this is you int and if this is s print then instead of into one limit i'll take u into one limit and this is s in one limit these three uh limit variables not variable they are constant so different constants i wanted to use i have defined them here or you or you can give the constant value here it doesn't matter all i am doing right now is i can connect any type of input to my uh you know this particular pin depending on the data type my block will automatically consider what you know limit it has to take and correspondingly it will give the actual output over here so that is the concept of variant and with variant when you do the programming you know all these are the possibilities i'm just barely touching the you know i mean the surface on this we have uh you know more instructions even uh available here in scl if you are interested so uh ease array so if a element what is connected is there an array or not we can check it this will return true or false if the if the element is array or not or if the element type of element if it is an array then we don't want the type we want the type of an element within that so type of element what what it should be we have this and if you want to uh move the variant from one place to another we can't use a normal move block we have instructions called a set variant was it or put variant oh no variant okay variant set okay vary input and variant get instructions we will use to this is equivalent to move block but when we play with variant when we are dealing with an unknown uh entity type but moving it to a known entity type we can make use of so i'm just giving you some glimpse of other instructions what are available which you can make use of if you move ahead with the concept of variant again so i am almost reaching time not almost i have already reached the time so i'm stopping my demonstration here with ti portal just to quickly summarize whatever things we have seen we saw the differences between fc and fb what is fc what is fp what is static when to use static when to use multi instance what is the purpose of temporary how temporary behaves within the block call all those things we have seen now we said as per the recommendation it is always better to use symbolic addressing because the hardware platform itself is really optimized to handle that we still have that uh old type of addressing still available but know this that is just kept or that is still available for you know backward compatibility purpose so if you have a new project try your level best to stick with symbolic addressing and if you are doing symbolic addressing we discussed that slicing concept we discussed the 80 overlay structure we also mentioned if you are dealing with a structure you know then why not use udts much better so we saw unity udts could have been used in your input area your output area your dbs your block interfaces everywhere you can use udts handling data multiple constant values if you are using in your project to make it a little more readable and legible you can think of constants constants can be available within a block interface or constants can be defined in your tag table also and of course when dealing with bulk data which is you know i would say the kind of the highlight topic for today if you're dealing with bulk data think of array y array array gives you the possibility of indexing and with indexing if you could switch to scl then you can go to even have options like this where you can have a block which will calculate the array size in runtime when you connect it and you can you know make a library block for your company forget about it and everything will be standard finally just like playing with array of unknown size if you want to play with a data of unknown type we have the possibility of variant i was just showing a small example on variant as well all these topics whatever we discussed today so far we have been saying that you know standardizing things will be helping you in digitalization because of course i mean having standards is much necessary so what do i mean by that i'm not going into a detailed explanation of those things but at least assuming that you have followed uh i mean you had some plan you you you did some standards you have developed some block following the standards for your company and you have this you can really reuse it easily if you have reached that level then what is possible have a look i hope you might be knowing that we have the concept of openness if you have installed yourself ti a portal any time then you you would have seen that there is a checkbox available asking you if you want to install openness or not so let me close everything else okay so using that openness openness basically provides you an api it's a dll file that is available for you with which you can write your own program which will interact with tia portal in a way you know things are done now how you leverage that dll how you write the program is up to us in our support site oh i should i closed it okay i think i have it here okay this link also i have included in my presentation this is a landing page where uh a topic page where almost all the information related to openness is actually made available you have previous i mean during the demo i have shown you the add-ins the ir portal add-ins even the add-ins are developed utilizing that so-called openness functionality so openness gives you much much possibilities for digitalizing your entire you know i mean project development workflow what i have done here let me say so i have an excel sheet so you know assuming that this is your case i want to generate a project for some machines but i am assuming that you know if i have a machine what type of modules i'll be using and what kind of program will be using and reusable type program and all i have already prepared i have made it ready if that is the case then have a look i uh on my desktop okay there is a projects folder which is empty let me copy that project location so i am telling this excel sheet to create a project i want to give the name project one that's fine and i want to save it under this location within that i'll be adding a plc and the plc name i want maybe main plc i want to have this block created for maybe two machines and machine one name is m1 machine 2 name is m2 and for every machine i'll be creating a separate you know remote io panel or not i'll just keep it yes for the time being so i just you know made some sample configuration like this have a look my tio portal is not open right now utilizing that uh that dll you utilizing that openness functionality we have we can develop some things like this you know this is just a you know excel add-in what is just created i gave some details here and this add-in is programmed to look into these details and the moment i click this okay now my hands are off the my mouse i'm not clicking or i'm not touching anything it is accessing that dll that dll is opening ti portal it will be creating projects well and by the way i'm i'm not the the best computer programmer so my program is actually working very very slow bear with that please anyway so if you see it has already created a project you can see on the title bar it is saved in the desktop projects proj1 folder it has made it right now the project tree is empty no devices are added not doing anything okay so now i have a plc with the name the same name main plc what i gave there it created two rios it added one rio it added some modules saved done my project is i have uh made this demo just with uh uh with the with with adding the hardware but mind you if you had made the libraries of the blocks then it is just a matter of accessing libraries and adding those blocks also into your program but now anyway just by giving a configuration like this your project is ready i don't want to save this but your project is already ready if i come to my oh sorry not this if i come to that desktop you have that project folder here not only this just to show you maybe a slightly different option i can even give some additional trigger so maybe i'll may give the name project two same i'll call it uh you know plc one and this time i have two machines i want it to be i don't know maybe mac1 or i want it to be packing and i want this to be loading is the names of the machines i don't want separate uh raos for each machine some configuration just some sample i go here but now i'll also do this okay i'll just say you know run in the background and eventually just give me a archive file not just the ti portal project just give me an archive file if i click on the create the status message you can see on the column f it is doing all those things but only difference is right now you don't see a project i mean the ti portal window opening up and doing all those things right now give it a moment okay so internally it had created the project by now controller is added are you rex added device network done done okay done so it says you know project is saved and archived let's have a look don't say this if i refresh my folder okay it was under the webinar folder so i think i made i kept the default name so under webinar folder there is a project too and there is an archive file that is automatically created now this archive file you can use it just as how you would do the normal archive but i also kept that project so if i just open the project what i just created okay so if i go to device and networks view first of all what you see right now i only have one rio i don't have two raos because the configuration was done that way i have kept the default name plc1 and all so it is appearing like that only one remote of your panel and if i open this inside i have more number of modules so i have the modules di1 di2 and dq1 for the packing and for the loading so this is just to show you the you know the in the hindsight uh with the help of standardization with the help of uh all this you know reusable code and all this concepts what we discussed once you make your things ready there are even much much more tools available along with the i portal in the background that you can utilize by your own and so many application examples and library functions available in the support side which can help you in taking your project and the project development life cycle much faster
Info
Channel: TONY TECH NSK
Views: 2,459
Rating: undefined out of 5
Keywords: tonytechnsk, tia portal software download, siemens tia portal tutorial, siemens tia portal v16 download, tia portal v16 system requirements
Id: s3OWjQpK4us
Channel Id: undefined
Length: 129min 18sec (7758 seconds)
Published: Thu Mar 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.