Hello, I created a post before but clearly I made a mistake about CoDeSys version which is currently running v3.5(not v2.3). So, please accept my apologies about posting same issue twice.
While I am trying to get real time values, I used the function block RTCLK.GetDateAndTime. But my problem is I could not figured out a way to get a real time value at second time. I even tried to use add a second function block for solving that but it did not work either. So, what am I missing and what should I do?
I am adding the project and code below so you can check it.
FUNCTION_BLOCKFB_PIZZAVAR_INPUT    bLoadPizza:BOOL;  bRemovePizza:BOOL;    END_VARVAR_OUTPUT    bBuzzer:BOOL;  sStateDesc:STRING;  iTotalPizzasCooked:UDINT;  fbPizzaTimer:TON;END_VARVAR    iState:DINT;  iLastState:DINT;    arrStateDescHistory:ARRAY[1..100]OFSTRING;    stPizzaOnDeck:ST_PIZZA;  stPizzaInOven:ST_PIZZA;  stPizzaAtOut:ST_PIZZA;  fbLoad_RTRIG:R_TRIG;  fbRemove_RTRIG:R_TRIG;    arrPizzaHistory:ARRAY[0..100]OFST_PIZZA;  fbNT_GetTime:RTCLK.GetDateAndTime;  dtCurrentTime:DT;   END_VARVARCONSTANT  standard:RTCLK.SetDateAndTime;  stNULL_PIZZA:ST_PIZZA;END_VAR//StructureofST_PIZZATYPEST_PIZZA:STRUCT    bExist:BOOL;  dtTimeEnteredOven:DT;  dtTimeExitedOven:DT;  tTimeInOven:TIME;  eType:E_PIZZA_TYPES;END_STRUCTEND_TYPE//Wecanpressthebutton'LoadPizza'anytimewewantandthe//firstfunctionblock(fbNT_GetTime)countsandmeasurethevaluehowmuchtimeafterwedidhitthebutton..//Itgivesthetrueclockvalueeventhereexistatime-difference!fbNT_GetTime();dtCurrentTime:=fbNT_GetTime.dtDateAndTime;IFstPizzaOnDeck.bExistANDNOTstPizzaInOven.bExistTHEN  stPizzaInOven:=stPizzaOnDeck;  stPizzaOnDeck:=stNULL_PIZZA;END_IFfbLoad_RTRIG(CLK:=bLoadPizza);IFfbLoad_RTRIG.QTHEN  //bLoadPizza:=FALSE;  stPizzaOnDeck.bExist:=TRUE;  stPizzaOnDeck.eType:=0;END_IFfbRemove_RTRIG(CLK:=bRemovePizza);IFfbRemove_RTRIG.QTHEN  //bRemovePizza:=FALSE;  F_FIFO_WRITE(cbData:=SIZEOF(stPizzaAtOut),pData:=ADR(stPizzaAtOut),cbBuffer:=SIZEOF(arrPizzaHistory),   pBuffer:=ADR(arrPizzaHistory));  stPizzaAtOut:=stNULL_PIZZA;END_IFCASEiStateOF  0:   sStateDesc:='Waitingforpizza!';   IFstPizzaInOven.bExistTHEN     iState:=10;   END_IF  10:   sStateDesc:='Bakingpizzarightnow!';   fbPizzaTimer(IN:=TRUE,PT:=T#5S);   fbNT_GetTime.xExecute:=TRUE;   stPizzaInOven.dtTimeEnteredOven:=dtCurrentTime;      IFfbPizzaTimer.QTHEN     fbPizzaTimer(IN:=FALSE);          fbNT_GetTime.xExecute:=FALSE;          iState:=20;   END_IF  20:   sStateDesc:='PIZZABURNING!!';   IFNOTstPizzaAtOut.bExistTHEN     fbNT_GetTime.xExecute:=TRUE;     stPizzaAtOut.dtTimeExitedOven:=dtCurrentTime;          stPizzaAtOut:=stPizzaInOven;     stPizzaInOven:=stNULL_PIZZA;          bBuzzer:=FALSE;     iState:=30;   ELSE     bBuzzer:=TRUE;   END_IF  30:   iTotalPizzasCooked:=iTotalPizzasCooked+1;   fbNT_GetTime.xExecute:=FALSE;   iState:=0;ELSE  sStateDesc:='InvalidState!';  END_CASE//StartstatehistoryIFiLastState<>iStateAND(iState<>30)THEN  F_FIFO_WRITE(cbData:=SIZEOF(sStateDesc),pData:=ADR(sStateDesc),cbBuffer:=SIZEOF(arrStateDescHistory),pBuffer:=ADR(arrStateDescHistory));  //Resetfornexttime.  iLastState:=iState;  END_IF
Hello, I created a post before but clearly I made a mistake about CoDeSys version which is currently running v3.5(not v2.3). So, please accept my apologies about posting same issue twice.
I am not so familiar with PLC programs and I decided to start learning CoDeSys with an excellent youtube tutorial. But the very first problem is he is using Beckhoff, so I can not use some libraries and function blocks as he did.
https://www.youtube.com/watch?v=BMrVOQJJhkg&index=11&list=PLE1CU6EebvTCJCMIUOSWgMseMaW-2k5zH
While I am trying to get real time values, I used the function block RTCLK.GetDateAndTime. But my problem is I could not figured out a way to get a real time value at second time. I even tried to use add a second function block for solving that but it did not work either. So, what am I missing and what should I do?
I am adding the project and code below so you can check it.
PizzaOven RTC (2).project [190.93 KiB]