How to extract data for last three days in TIA V14

MarcusSkynet

Member
Join Date
May 2018
Location
Liberec
Posts
9
Hello guys,

I have made a data collector which counts how long was light on. I made it by counter which counts minutes when it is on, then converts it to hours, reset itself to start count another hour and so on. However I need to extract only time period of last three days, and I am totally lost. Can anybody help me how to do it in TIA V14 please?

Many thanks,

Marek
 
SCL source code tested in a 1516 under plcsim
Code:
FUNCTION_BLOCK "fbLampTime"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      bLamp : Bool;
   END_VAR

   VAR_OUTPUT 
      tOnInLast3Days : Time;
   END_VAR

   VAR 
      aiTimeStoresecs : Array[1..#TimeEntries] of Int;
      iTimePointer : Int := 1;
      bOnesec : Bool;
      bOneMinute : Bool;
      fbOneSec {InstructionName := 'TON_TIME'; LibVersion := '1.0'} : TON_TIME;
      fbOneMin {InstructionName := 'TON_TIME'; LibVersion := '1.0'} : TON_TIME;
   END_VAR

   VAR_TEMP 
      i : Int;
      diSum : DInt;
   END_VAR

   VAR CONSTANT 
      TimeEntries : Int := 2160;
   END_VAR


BEGIN
    //one sec one shot
    #fbOneSec(IN := NOT #bOnesec,
              PT := t#1s,Q=>#bOnesec);
    //one minute one shot
    #fbOneMin(IN := NOT #bOneMinute,
              PT := t#60s,Q=>#bOneMinute);
    //examine lamp every sec, if on increment time value for this array index
    IF #bOnesec THEN
        IF #bLamp THEN
            #aiTimeStoresecs[#iTimePointer] := #aiTimeStoresecs[#iTimePointer] + 1;
        END_IF;
    END_IF;
    
    //every minute increment pointer to array and reset when reaches the end. Clear the time
    //for the incremented array value
    IF #bOneMinute THEN
        #iTimePointer := #iTimePointer + 1;
        IF #iTimePointer > #TimeEntries THEN
            #iTimePointer := 1;
        END_IF;
        #aiTimeStoresecs[#iTimePointer] := 0;
    END_IF;
    #diSum := 0;;
    FOR #i := 1 TO #TimeEntries DO
        #diSum := #diSum + #aiTimeStoresecs[#i];
    END_FOR;
    
    #tOnInLast3Days := #diSum * 1000;
    
    
    
END_FUNCTION_BLOCK
 

Similar Topics

I would like to extract data from a Bizerba is50 using WebSockets or Profinet. I currently cannot find any information on the subject, any help...
Replies
1
Views
705
Hi all - got an S7 classic Step 7 program. I have a variable that's a TIME data type it contains a value such as T#1h30m5s - how can I extract...
Replies
2
Views
2,483
We are doing a proof of concept to try the following 1) get data from KepServer 2) The Data will be transformed eg: a Status code of 1 gets...
Replies
0
Views
1,207
Hi, I have a SLC 500 and connected to it via DH+ is a PanelView Plus. The PV+ has an ethernet port I'm looking for a way to get the status of...
Replies
10
Views
3,381
Hi I am planning to remotely extract data using the data extract utility. THE ML 1100 will have a static IP and I would like to know if I can...
Replies
2
Views
2,640
Back
Top Bottom