Functions

Morberis
2020-11-11
2020-11-12
  • Morberis

    Morberis - 2020-11-11

    It's pretty basic but I feel like I'm doing something wrong because I can't seem to get the TODConcat function from the CAA DTUtil library to work. I have used a few functions before and I had no problems then but...

    Β―\_(Β°_o)_/Β― 
    
    PROGRAM Testing
    VAR
    
        iInputHour:UINT;
        iInputMinute:UINT;
        todOutput:TOD;
    
        eError : DTU.ERROR;
    
    END_VAR
    
    todOutput := DTU.TODConcat(uiHour:=iInputHour, uiMinute:=iInputMinute, uiSecond:=0, uiMillisecond:=0, peError:=ADR(eError));
    

    The reason I think I'm doing something wrong is that todOutput always equals TOD#00:00 which is what the documentation says the output will be in case of invalid inputs. The error code is always No Error (0)

    I did try the example from the examples page on Codesys Help, same output. The example code is very similar to what I was thinking....

    VAR
    
    eError : DTU.ERROR;
    
    todTime : TIME_OF_DAY;
    
    END_VAR
    
    todTime := TODConcat
    
    (
    
    uiHour := 5,
    
    uiMinute := 4,
    
    uiSecond := 3,
    
    uiMillisecond := 2,
    
    peError := ADR(eError)
    
    );
    

    Thanks for any help.

     

    Last edit: Morberis 2020-11-11
  • kislov - 2020-11-11

    Hm, for same strange reason it's not work in simulation.
    But it will work with real PLC (for example, CODESYS Control WIN V3).

    But you can just do it by your code and of course it will work in simulation.

    todOutput := TO_TOD(T#1H *  iInputHour + T#1M * iInputMinute);
    
     
    πŸ‘
    1

    Last edit: kislov 2020-11-11
  • Morberis

    Morberis - 2020-11-12

    Thanks for the heads up. This was not something I would have thought would be effected by being in a simulation. Frankly I thought the problem was me.

     

Log in to post a comment.