How can I do??

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2665
    Joao
    Participant

    Hello all,

    When my communicator lose connection with a PLC, all my inputs become “—“, but I have problems with my boolean variables that I use the formula GetBit(), because at this moment, all of them become 0.
    How can I modificate the GetBit() formula, case I lose my connection, the boolean variables keep the old values?

    something like:

    double GetBit(double val, int n)
    {
    If (val == null)// or (val==”—“) <<<<< I dont know how can I do this
    {
    return (Cnl);
    }
    else{
    UInt64 uintVal = (UInt64)val;
    return (uintVal >> n) & 1;
    }
    }

    or something like:

    double GetBit(double val, int n, int ChannelNumber)
    {
    If (getCnlData(ChannelNumber)==null)
    {
    return (Cnl);
    .
    .
    .

    Thanks!!

    • This topic was modified 6 years, 5 months ago by Joao.
    #2667
    Mikhail
    Moderator

    Hi,

    In the formula of input channel use, for example: GetBit(Val(101),0); Stat(101)

    #2668
    Joao
    Participant

    It works, but the boolean value become “—” too.
    The Automatic Control Module read it as 0? I will have problems if I have a trigger with the condition val=0?
    Or I have to change the status condition too?

    • This reply was modified 6 years, 5 months ago by Joao.
    #2670
    Joao
    Participant

    For me its better the boolean input keep the old value…

    • This reply was modified 6 years, 5 months ago by Joao.
    #2672
    Mikhail
    Moderator

    In this case something like that:
    Stat(101) > 0 ? GetBit(Val(101),0) : Val()

    #2674
    Joao
    Participant

    Thanks Mikhail!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.