CODESYS: Using TON and CTU function blocks in Structured text (ST) programming

Поділитися
Вставка
  • Опубліковано 27 гру 2024

КОМЕНТАРІ • 26

  • @meta1nigga
    @meta1nigga 6 років тому +2

    Hi there! I have a strange question: can I use timer with variable time (not fixed - 1s, for example with "t" seconds, where I can write any value on "t")?

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

      Hi. Sorry for the late response. Sure, you can, and it is not a strange question! You need to declare a variable of type Time. then write values to it within your program (or in the visualization) and use that variable as the preset time of the timer.

    • @meta1nigga
      @meta1nigga 6 років тому +1

      @@TohidAlizadeh OK, Thanks a lot!

  • @ikramantaki
    @ikramantaki 7 років тому +2

    is it possible to connect CODESYS with any PLC software???????? for example, Im using WECON PLC EDITOR

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

      I am not sure about this. In general, if the PLC supports CODESYS, CODESYS will be its main software, I believe.

  • @fcbfcbfcb11224455
    @fcbfcbfcb11224455 7 років тому +2

    Hi Tohid, I am trying to implement a delay of for example 5seconds. What I tried is make a TON and then an if loop so it looks like this:
    my_ton : TON;
    my_ton(IN:= TRUE, PT := T#5s)
    label1: counter1 := counter1+1;
    IF NOT(my_ton.Q) THEN (*As long as Q is low, go back untill Q is high (so after 5
    JMP label1; seconds) *)
    END_IF
    But for some reason it doesn't recognise the label. Do you know how to solve this. I also tried doing this with a while loop but that makes my PLC crash.
    Thanks in advance!
    Bart

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

      Hi Brat,
      I think you can do this in a much easier way, like this:
      my_CTU: CTU;
      my_Ton: TON:
      my_Ton(IN:= not my_Ton.Q, PT:= T#5s); // You will have pulses of 5 seconds width, because output of the timer is used as its input.
      my_CTU(CU:= my_Ton.Q, PRESET:= reset, PV:=5);
      Try this and let me know if it works!
      Regards,
      Tohid

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

      Hi Tohid,
      thanks for your fast answer. I tried this code and if I understand it correctly, this code increments the CU every 5 seconds?
      What I actually wanted is a delay like the function "Sleep(ms)" in C.
      So imagine this is the code
      1.
      2.Some code
      3. Wait(5 seconds) (*I want the code here to wait 5 seconds and do
      4. absolutely nothing *)
      5.
      6.Some Other Code
      7.Some Other Code
      8.Some Other Code
      9.
      10.
      So I want the code to do nothing at point 3 and wait for 5 seconds before executing the code at line 4.
      When I run your code the my_ton.Q value stas FALSE for the entire time.
      Thanks a lot!
      Kind regards,
      Bart

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

      I see. I guess you have tried this one?
      my_ton(IN:= TRUE, PT := T#5s);
      while (not my_ton.Q) DO
      tempVar:=true;
      end_while
      What is the error that you receive when you run the code with the IF statement? I see that you do not have a ";" at the end of the line calling the timer. Is that the reason?

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

      Yes I tried it with the while loop but then my PLC crashes. The ";" I wrote in my code but I just forgot it to write here on youtube. I mailed to the company and they told me the JMP instruction doesn't work with the software I'm working with so that is my error.
      Thanks for your help anyways!

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

      Nice to hear that you have managed to solve the problem. Please let us know the solution, if you do not mind. What did you use at the end?

  • @preetparmar
    @preetparmar 8 років тому +2

    Hi there i am new to codesys i am trying to run an output say a motor for a set time but i cannot find the right funtion block/timer for this can you help me out

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

      +preetparmar I think you can do this using a Pulse Timer (TP) easily.

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

      thanks i couldn't find it before but i found it now your video are just brilliant

  • @Flofet
    @Flofet 2 роки тому +1

    Hello,
    is there any way to stop the turn on delay?
    For example using a stop button means stop counting the time-> motor won't turn on

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

      If the input to the timer becomes False, it will stop automatically, unless it is a retentive one.

    • @Flofet
      @Flofet 2 роки тому +1

      @@TohidAlizadehthank you very much for your help! the problem is that my trigger signal (input) stays true, I would like to stop the timer with another Trigger

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

      @@Flofet You may have that second one in series with the original one. So whenever one of them becomes False, the timer stops.

  • @emircansaracoglu3864
    @emircansaracoglu3864 8 місяців тому +1

    why 'START:BOOL:=FALSE'

    • @TohidAlizadeh
      @TohidAlizadeh  8 місяців тому +2

      Thanks for your comment. I thiunk I wanted the Start to be False at the beginning, so the motor does not start before we take an action. Though, since we have the visualization here, the value of the start will be taken from the visualization element here, so the initial value provided will not be important.

    • @emircansaracoglu3864
      @emircansaracoglu3864 8 місяців тому +1

      @@TohidAlizadeh thank you so much

    • @TohidAlizadeh
      @TohidAlizadeh  8 місяців тому

      Rica ederim!

  • @ronniegems8099
    @ronniegems8099 4 роки тому +2

    Hi, can you make a video on "Encoder programing and simulation with Codesys Structure Text? " I searched a lot, but couldn't find it. It will be much helpful...

    • @TohidAlizadeh
      @TohidAlizadeh  8 місяців тому

      Hi, thanks for your comment and suggestion. I will work on this, even though I am replying after 3 years 😉

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

    Post a video using jump command program and also traffic signal program

    • @TohidAlizadeh
      @TohidAlizadeh  8 місяців тому

      I think I already have videos covering these topics!