CODESYS: Declaring and using "Structure" in the structured text (ST) programming

Поділитися
Вставка
  • Опубліковано 12 жов 2024
  • If you want to watch the videos in order, download the up-to-date version of the road map from the pinned comment of the corresponding video: • CODESYS: A road map fo...
    -------------------------------------------------------------------------------------------------------------------------------------

КОМЕНТАРІ • 22

  • @joshuajavier5158
    @joshuajavier5158 Рік тому +2

    Thank you for your videos but Im curious when should I use the DUT or Struct and when will I use the Global List..

    • @TohidAlizadeh
      @TohidAlizadeh  Рік тому

      Thanks for your comment. You normally create and use a global variable (which will be inside a global variable list) when you need to have access to the variable globally in the project, from any of the POUs. Global variables could be Boolean, Integer, or of any type.
      While DUT is declared and used to fit your needs for a specific variable, which could be used only within a single POU, or could be placed in a global variable list.
      I hope this helps.

  • @ahsankhalid6672
    @ahsankhalid6672 5 років тому +4

    Hello :)
    Your videos are really helpful. I would like to suggest that before explaining the actual program, it would be great if you first explain the topic on which you have written the program. In the case of this video, you should've explained what structures actually are and what are their uses.
    Otherwise, I really like your way of explaining.

    • @TohidAlizadeh
      @TohidAlizadeh  5 років тому +1

      Thanks a lot for your valuable feedback, Ahsan. I will consider it in my next videos (if I manage to make).

  • @admirhoxha9748
    @admirhoxha9748 8 років тому +1

    Hello Mr. Tohid, Thank you for allowing us to access this great work. I am interested in Structured Text(ST), i have a project in twincat(visual studio) which is the same as codesys, and i'm trying to figure it out. There is a Function block (FB) which contains most of the code logic, and other structs, one Global variable list, and the Main(PRG) program of course where there are only variable declarations and the inheritance of FB in PRG. I wanted to ask what is the reason of using FB and Global Variables when we could use just Main(PRG) and structs. I checked your tutorials of ST but there aren't many. I've been searching on internet about ST tutorials but i had no luck, do you know any website which could provide broader information about the language.

    • @TohidAlizadeh
      @TohidAlizadeh  8 років тому +1

      +Admir Hoxha Thanks a lot for your comment and interest in my videos. I would say that the main aim of using Function Blocks (FBs) is to make the programming easier and more organized. Specially, when you want to do a specific task (piece of code) more than once in the main program. Then it would be better to create a FB and refer to that. You may use your created FB later on in some other project as well, saving you the time and effort. the concept is somehow similar to the idea of creating Functions in Matlab and using them later as well (if you are familiar with Matlab). The aim of using Global variable list, is to create variables which are accessible all around the project (in the main program, FBs, ...).I hope this comment would be helpful for you. I may later leave another comment providing resources on ST.

    • @admirhoxha9748
      @admirhoxha9748 8 років тому +1

      +Tohid Alizadeh Thank you, I'm grateful

  • @abdullaheisajan2300
    @abdullaheisajan2300 5 років тому +1

    Hello Tohid,
    Thank you for the great tutorial videos you make. I was wondering why my counter doesn't get reset after reaching the PV value, or is it that the PV value is used for something else.
    Thanks in advance.

    • @TohidAlizadeh
      @TohidAlizadeh  5 років тому

      The counter continues to count even after reaching the PV value. It's output becomes True once it passes the PV value. To reset the counter, you should use the Reset input of the counter.

  • @azamafzaal769
    @azamafzaal769 7 років тому +1

    Hello Tohid, can you please upload a video creating functions/methods and calling them in the main program (ST)

    • @TohidAlizadeh
      @TohidAlizadeh  7 років тому

      Hi Azam,
      I will try to do so in the following days, however, for now, you can have a look at the following video, where TON and CTU function blocks are called within ST:ua-cam.com/video/-FYfyye6zNs/v-deo.html
      and this one, where you learn how to create Function blocks (in LLD, but you can do it with ST as well):
      ua-cam.com/video/SLQEtTvi3m8/v-deo.html
      Then, you can call the created function in a similar way to calling TON/CTU.
      I hope this will help you!

    • @azamafzaal769
      @azamafzaal769 7 років тому +1

      Thanks but i have seen this video already. I need to make a custom ST function/method and then calling it in the main program e.g. a derivative function (P.S. i know its already in the util library but i am not allowed to use it for my project)

    • @TohidAlizadeh
      @TohidAlizadeh  7 років тому

      I see. I will try to prepare the video till next week. I will update you here!

    • @TohidAlizadeh
      @TohidAlizadeh  7 років тому

      This video is for you:
      ua-cam.com/video/j9jl764005w/v-deo.html
      I hope you will find it useful.

  • @muhammaddanish4253
    @muhammaddanish4253 Рік тому +1

    So it seems struct variables are not global variables ,so you can not directly access using it you need to instantiate that structure first in program?

    • @TohidAlizadeh
      @TohidAlizadeh  Рік тому

      That's true. With Struct you create a new type of variable. You can instantiate a variable of the new type in the global variable list, if needed.

  • @tarrensmith9657
    @tarrensmith9657 8 років тому +1

    Hello Tohid, thank you for the great videos. Excuse my ignorance, but what is the purpose of a structure, why would you use it?

    • @TohidAlizadeh
      @TohidAlizadeh  8 років тому

      +tarren smith Dear Tarren, Structure type variables can contain more information within only one variable. When you want to group a set of variables which are related to each other in some sense, you can create a structure variable, and use each of those variable as the fields of the structure.
      Think about the Timers and Counters. Referring to them as a variable, you deal only with a single variable, Timer01 for example, however, you have some fields for the variable as Timer01.IN, Timero1.Q, Timer01.PT and Timer01.ET.
      In general, having Structure type variables makes the programming easier and the variables more compact.
      I hope this would help you. Let me know if you have any other concerns.
      You can also refer to the Google+ community, where I provide some more explanation in the written form, for the videos:
      plus.google.com/u/0/communities/114767566156039270858

    • @tarrensmith9657
      @tarrensmith9657 8 років тому +1

      +Tohid Alizadeh Thank you so much Tohid, this makes perfect sense. Thank you for your time and patience and great tutorials.

  • @V3loxX
    @V3loxX 3 роки тому +1

    How can I use structs on more level? I mean struct in a struckt.

    • @TohidAlizadeh
      @TohidAlizadeh  3 роки тому +1

      I think you only need to declare one structure first (call it struc01, for example), then in declaring the second structure, use struc01 as one element.

  • @jamiecoates9891
    @jamiecoates9891 4 роки тому

    Sorry, poorly explained.