How can I do??

This topic contains 5 replies, has 2 voices, and was last updated by Avatar Joao 1 year, 9 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2665
    Avatar
    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 1 year, 9 months ago by Avatar Joao.
    #2667
    Mikhail
    Mikhail
    Moderator

    Hi,

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

    #2668
    Avatar
    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 1 year, 9 months ago by Avatar Joao.
    #2670
    Avatar
    Joao
    Participant

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

    • This reply was modified 1 year, 9 months ago by Avatar Joao.
    #2672
    Mikhail
    Mikhail
    Moderator

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

    #2674
    Avatar
    Joao
    Participant

    Thanks Mikhail!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.