×

Subscribe to newsletter

subscribe to our weekly newsletter to get notified with latest story and article Subscribe now!




PLC BLOG | B&R Automation | C Programming Timer | < C Programming: B&R automation studio Timer Function Blocks In C Programming | TON | TOF | TP | TP_10ms | TON_10ms | TOF_10ms
Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


C Programming: B&R automation studio Timer Function Blocks In C Programming | TON | TOF | TP | TP_10ms | TON_10ms | TOF_10ms

C is text based programming language and ladder is graphical based programming language. so in a C programming you can use timer as function statement. so first declare timer function in a programming than you can use their parameter in programming for example if we want to use on delay timer, first declare timer instance and then declare same instance inside the program. for example TON(&ton_inst), TON() is function of on delay timer in c programming and ton_inst is a instance name. working of all timer is same as ladder program.

Instance Of timer Function Blocks

declare a variable with respective Instance name. instance name may be local or global. instance name for on delay timer is TON, off delay timer instance name is TOF, pulse timer instance name is TP. instance name for on delay timer with 10ms base is TON_10ms,off delay timer with 10ms base instance name is TOF_10ms, pulse timer with 10ms base instance name is TP_10ms. in a below image all timer function block declare with variable. first variable is timer_ton and instance of this variable is TON so we decalre timer_ton as variable for instance of on dela timer function block.

Instance Of timer Function Blocks

input and output parameter of timer functions block B&R automation studio

before making a program of functional block first declare instance name than declare basic parameter for starting a timer function. you can use these variable from other part program . if variable is global than these variable accessed anywhere of program if the variable is local so they can used only particular program. following the basic input and output parameter of timer function blocks with data types
    input parameter of timer
  • .INBOOl data type, if it's true than timer operation start. and output of timer set to
  • .PT PT is preset time of timer. output of timer is depend on preset time. Data type of preset time is TIME for TON_10ms, TOF_10ms and TP_10ms timer data type is UDINT.
  • output parameter of timer
  • .ET elapsed time of timer when timer start than elapsed time increment from 0 to preset value. data type of elapsed time is TIME for TON_10ms, TOF_10ms and TP_10ms timer data type is UDINT.
  • .Qoutput of timer set to true for specified preset time output is depend on timer type. data type of timer output is BOOL

input and output parameter of timer functions block B&R automation studio

B&R automation studio On delay timer (TON) in C programming

on delay timer delay the output to turn on. if the timer start input (IN) is set to true than timer operation start and increment elapsed time once the elapsed time(ET) equal to preset time(PT) than output of timer(Q) is turn on and timer operation stop.

B&R automation studio On delay timer (TON) in C programming

above is the example of on delay timer in B&R automation studio using C programming, TON(&timer_ton) call on delay timer (TON) with address of instance variable (timer_ton). start_timer is bool data type to start timer operation. timer_pt is time data type and value of this timer_pt is T#10s. so timer operation time is set to 10 second. when start_timer is set to true than timer operation start and increment elapsed time to preset time once preset time and elapsed time is equal than output is turn on.


B&R automation studio OFF delay timer (TOF) in C programming

off delay timer delay the output to turn off if the timer input change from true to false. if the timer input change from true to false than timer operation start increment elapsed time. timer output is turn off when elapsed time reached to preset value.

B&R automation studio OFF delay timer (TOF) programming

above is the example of OFF delay timer (TOF) in C programming timer_tof is variable of instance name TOF if the start_timer input is set to true than timer_output is set to true. when start_timer change from true to false than timer operation start and increment elapsed time to reach preset time once preset time and elapsed time are equal than time_output is turn off.


B&R automation studio Pulse timer (TP) in C programming

Pulse timer turn on output only particular time interval if the timer start Input(IN) is set to true. time for turn on timer out is depend on preset value of time (PT). once the timer Input(IN) is set to true than timer output turn on for preset time, elapsed time start increment if the timer start input is set to true if the elapsed time(ET) is equal to preset time than timer output turn off. below is the example of

B&R automation studio Pulse timer (TP) programming

B&R automation studio On delay timer with 10 ms base (TON_10ms) in C programming

TON_10ms is same as on delay timer but preset value and elapsed time have unsigned double integer data type (UDINT). these type of timer preset input value is numerical type not time.

B&R automation studio On delay timer with 10 ms base (TON_10ms) programming

above is the example of B&R automation studio On delay timer with 10 ms base (TON_10ms) timer preset value is 1000 so actual operation time of this timer is (1000/1000)1 second. if the preset value is 1200 than timer operation time is 1 second 200 millisecond.


B&R automation studio OFF delay timer with 10 ms base (TOF_10ms) in C programming

OFF delay timer with 10 ms base (TOF_10ms) working same as off delay timer if the preset value if timer is 15000 than timer operation time is equal to 15 second if the timer preset value is 2500 than timer operation time is equal to 2 second 500 Millisecond. Below is the example of B&R automation studio OFF delay timer with 10 ms base (TOF_10ms). in this example timer instance is TOF_10ms.

B&R automation studio OFF delay timer with 10 ms base (TOF_10ms) programming

B&R automation studio Pulse timer with 10 ms base (TP_10ms) in C programming

B&R automation studio Pulse timer with 10 ms base (TP_10ms) programming

TP_10ms is same as pulse timer with user defined timer value, operation time of this timer is equal to preset time/100. if the preset time if these timer 1540 than time operation is (1540/1000) than 1 second and 540 millisecond(T#01s_540ms).


variable of timer function block parameter

variable of timer function block parameter

in this example if we give gate close command and if gate not close at specified time interval than spare gate command set to true for closing gate. in this program we use a if else statement with and operator for comparing timer output with gate status if both are true than if condition is true and if condition executed otherwise else condition executed this is a simple demonstration of timer program.


Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


Suggested Post


 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

comment