You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old November 23rd, 2020, 07:47 PM   #1
shantanuc
Member
Germany

shantanuc is offline
 
Join Date: Nov 2020
Location: Aachen
Posts: 1
Function Block Problem

I am using Codesys as my PLC Programmer. I use structured text as the language.
I tried using a timer inside a function block and then mentioning it in variables of main program but its not getting started. the (IN) of the timer is not getting a TRUE value.
If i write the same code in PLC_PRG then it works.

Do i need to do anything additional to make my timer run? Please Help
  Reply With Quote
Old November 23rd, 2020, 09:21 PM   #2
ndzied1
Lifetime Supporting Member
United States

ndzied1 is offline
 
ndzied1's Avatar
 
Join Date: Aug 2002
Location: Chicago, Illinois
Posts: 2,580
Normally you would never reference a timer that is inside of a function block from outside the function block itself. More normal would be to have an input to the function block turn on the timer.

Function blocks are meant to encapsulate a subset of code that you would re-use many times. In this way, you write the code once and then define multiple instances of the code and use it.

Here is a video I made that attempts to help you learn about function blocks and their use:
https://youtu.be/aYwH2O_QOQo
__________________
nOrM
======================
nOrM=Norman Dziedzic Jr.
I've never been to China but my phone has.
  Reply With Quote
Old November 24th, 2020, 02:26 AM   #3
kalabdel
Member
Canada

kalabdel is offline
 
Join Date: Feb 2015
Location: Ontario
Posts: 654
Quote:
Originally Posted by shantanuc View Post
I am using Codesys as my PLC Programmer. I use structured text as the language.
I tried using a timer inside a function block and then mentioning it in variables of main program but its not getting started. the (IN) of the timer is not getting a TRUE value.
If i write the same code in PLC_PRG then it works.

Do i need to do anything additional to make my timer run? Please Help



Can you provide more explanation and perhaps screen capture to show us what you mean.


Are using a global tag or are you addressing a tag declared inside the function block? Are you getting any errors or is compiling error free but the time doesn't start?


What I show in the attached screenshot is bad practice but it shows that it is possible, provided the tag is declared as VAR_STAT; a tag declared as VAR will is not accessible from outside the block and if you try you will get compile error.
Attached Images
File Type: png timer.PNG (49.1 KB, 35 views)
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Function Block/ AOI Demonstration ndzied1 LIVE PLC Questions And Answers 11 December 13th, 2018 09:06 AM
IEC61131-3 Function block within a function block kolyur LIVE PLC Questions And Answers 3 December 13th, 2017 03:47 PM
Unity function with block dynamic array input V0N_hydro LIVE PLC Questions And Answers 4 September 16th, 2010 12:39 PM
Siemens Function Block troubles... DanJack LIVE PLC Questions And Answers 24 May 13th, 2010 09:08 PM
FC vs FB, DB mico207 LIVE PLC Questions And Answers 69 January 26th, 2010 10:34 PM


All times are GMT -5. The time now is 09:34 AM.


.