DTE to get Monthly Readings

Hi,

I want to get monthly reading or a specific parameter using DTE, the classic code of DTE ( TE_Time_STR ) allows me only to give number of days and what I want to is to get values on the first day of each month regardless to the days of the month any advice how to control TE_Time_STR  and make the DTE active each first day of the month ?

Thanks

  • I use the DTE along with an INT block to get totalized values over the current month, and reset the totalizers at the beginning of each month.  However, since there are varying number of days in each month, I cannot INTERVAL_STR  parameter of the DTE; instead, I use the TE_TIME_STR specifying the date and time to reset the INT block.

    I use an input parameter (PARAM1) to capture the year and two CALC blocks - the first CALC block pulls the month and year from the local time and the second CALC block updates the DTE INTERVAL_STR and TE_TIME_STR based on the current month.  CALC1\OUT2 is input to CALC2\IN1.  I update the TE_TIME_STR so that I don't have to worry about this parameter changing when DST starts or ends.

    Here is the expressions for each:

    CALC1:

    'OUT1.CV' := time('$time_format:Local');
    'OUT2.CV' := time_to_str("%m", 'OUT1.CV');
    '^/PARAM1.CV' := time_to_str("%y",'OUT1.CV')

    CALC2:

    IF 'IN1.CV' = 1 THEN 
     '^/DTE3/INTERVAL_STR.CV' := "P00031T00:00:00";
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-02-01T00:00:00";
     ELSE IF 'IN1.CV' = 2 THEN 
     '^/DTE3/INTERVAL_STR.CV' := "P00028T00:00:00"; 
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-03-01T00:00:00";
     ELSE IF 'IN1.CV' = 3 THEN 
     '^/DTE3/INTERVAL_STR.CV' := "P00031T00:00:00"; 
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-04-01T00:00:00";
     ELSE IF 'IN1.CV' = 4 THEN 
     '^/DTE3/INTERVAL_STR.CV' := "P00030T00:00:00"; 
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-05-01T00:00:00";
     ELSE IF 'IN1.CV' = 5 THEN
     '^/DTE3/INTERVAL_STR.CV' := "P00031T00:00:00";
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-06-01T00:00:00";
     ELSE IF 'IN1.CV' = 6 THEN
     '^/DTE3/INTERVAL_STR.CV' := "P00030T00:00:00";
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-07-01T00:00:00";
     ELSE IF 'IN1.CV' = 7 THEN
     '^/DTE3/INTERVAL_STR.CV' := "P00031T00:00:00";
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-08-01T00:00:00";
     ELSE IF 'IN1.CV' = 8 THEN
     '^/DTE3/INTERVAL_STR.CV' := "P00031T00:00:00";
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-09-01T00:00:00";
     ELSE IF 'IN1.CV' = 9 THEN
     '^/DTE3/INTERVAL_STR.CV' := "P00030T00:00:00";
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-10-01T00:00:00";
     ELSE IF 'IN1.CV' = 10 THEN
     '^/DTE3/INTERVAL_STR.CV' := "P00031T00:00:00";
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-11-01T00:00:00";
     ELSE IF 'IN1.CV' = 11 THEN
     '^/DTE3/INTERVAL_STR.CV' := "P00030T00:00:00";
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-12-01T00:00:00";
     ELSE IF 'IN1.CV' = 12 THEN
     '^/DTE3/INTERVAL_STR.CV' := "P00031T00:00:00";
     '^/DTE3/TE_TIME_STR.CV' := '^/PARAM1.CV'+"-01-01T00:00:00";
    END_IF;END_IF;END_IF;END_IF;END_IF;END_IF;END_IF;END_IF;END_IF;END_IF;END_IF;END_IF;

    I am sure there are other ways to accomplish this, but this works for me.

    I hope it helps,

    Jeff

  • I had a similar situation arise here and I used a calc block to get the day of the month and store it with

    '^/DAY.CV' := time_to_str("%d",time('$time_format:Local'))

    I then used an condition block to evaluate

    '^/DAY.CV' = "01"

    Tie the condition block to a rising edge block and use that to get your one time value capture on the first day of every month.



    It is a pretty simple way to accomplish what you are looking for without hassling with the DTE or resets or anything else. Hope it helps!