Retain Variable

Forum Home Forums Understanding the Software Retain Variable

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #5480
    scadarapid
    Participant

    Hi,
    I use modbus protocol.
    I have noticed when the communication of device and Rapid Scada have loss, the value of devices become zero and it will show on the graphic on the web that the device is off but I need to hold the old value until the communication come back and check it again to show the true status.

    if the communication have loss, How can we hold the old value until the communication come back.

    Thank you so much.

    #5482
    Mikhail
    Moderator

    Hi,

    When communication lost, you should get — in a screen. Why you get zero?

    How can we hold the old value until the communication come back.

    Try the formula: Cnl > 0 ? Cnl : Val()
    But this is a bad approach because an operator will be deceived in this situation.

    #5484
    scadarapid
    Participant

    Thank you so much.

    #6187
    SGG
    Participant

    Hello Mikhail,

    i use modbus protocol to communication over GPRS to my remote devices which include a master and a slave device.

    i want to retain values (of the slave devices) after a temporary loss of communication on the rapid scada interface. This retained values should only change after communication is established and the actual value is polled.

    you suggested the use of a formula ” Cnl > 0 ? Cnl : Val() ” in post #5482 BUT i already have formulas in most of the channels.

    How do i combine my formula with your suggested formula to resolve my issue or is there any other solution?

    #6188
    SGG
    Participant

    Hello Mikhail,

    sequel to my previous post #6187

    I was able to come up with a solution to retain the last polled value when there’s a temporary loss in communication. i created another input channel to retain the value using formula
    (Val(810) > 0 ? SetData(840, Val(810),114) : SetData(840,Val(840),103))

    Now I have a new question. how do i create a timestamp for that retained value so that an operator will be able to know how current the display values are?

    Thanks.

    #6189
    Mikhail
    Moderator

    Hi,
    For the both questions:
    You could create a new formula in the Formulas table. Something like that:

    double UpdateTime(double val, int timeCnlNum)
    {
      SetVal(timeCnlNum, EncodeDate(DateTime.Now));
      return val;
    }

    and use it for example
    Stat > 0 ? UpdateTime(Cnl * 100 + 1, 1001) : Val()
    The formulas are not tested.

    #6190
    SGG
    Participant

    Hello,
    Thanks for your formula in post #6189, it gave me direction on the actual formula to use.

    Now another issue arose. when i open a table on the web, i see an error that says
    “Error updating hourly data”.This error occurs only in this table, other tables are okay.

    I searched the forum for possible solutions but nothing. The link below is a screenshot of the error page, i also clicked F12 to open the console for error log.

    https://drive.google.com/open?id=1qZPN28KPX8ExPyxQXJ_Iyi45tF-pV8Ux

    Please, how do i solve this?

    #6191
    Mikhail
    Moderator

    Hello,

    For the question that is not related to the current topic, please create a new topic.

    #11207
    gabeirinhas
    Participant

    Hi, I need help with the following,

    I am connecting to a modbus tcp ip device,

    At certain times the connection stops and after a while it is re-established,

    This connection sends me MW memory zones, where some bit by bit alarms are located,

    I use the automatic module so that when these alarms are triggered, it sends me an email.

    In the connection it is usual to have a couple of alarms that are constant, when the connection is interrupted and returns to its normal state, it sends the alarms every day.

    I want this state to be stored and persist until the connection reconnects.

    I also want it to log if the alarm is cleared after successful communication.

    I have tried the following formula without success,

    Cnl > 0 ? Cnl: GetBit (Val (188), 0)

    Thanks in advance, best regards

    • This reply was modified 1 year, 6 months ago by gabeirinhas.
    #11210
    gabeirinhas
    Participant

    Hi, I need help with another formula,

    I would really appreciate your help,

    when a signal from a modbus device = 0,

    Cnl == 0,

    I copy the received value from another channel,

    something like this,

    Cnl == 0 ? Cnl: Val(743)

    For some reason it copies the value continuously, instead of only when this value = 0.

    Thanks in advance, best regards

    #11217
    Mikhail
    Moderator

    Hi,
    Please provide screenshots that illustrate the question.

    #11219
    gabeirinhas
    Participant

    Hello,

    Attached is a formula 1 case, where I need to hold the value of an offline alarm.

    https://drive.google.com/drive/folders/1eq1SSBFbwBZMmfHLElJGJAZVyXbyMaLO?usp=sharing

    Attached case formula 2, where I need to copy a value from another channel at a certain time.

    https://drive.google.com/drive/folders/1uxeylVigSNyvPkfSNe98R9woeF-XDsOp?usp=sharing

    Thank u, BR

    #11233
    Mikhail
    Moderator

    Hi,
    Using Cnl is incorrect for channel of the Calculated type. You should change channel type or change formula.
    Signal field must be unique within channels of a device.

    #11239
    gabeirinhas
    Participant

    Ok, by listening to you, I have made the following formula for a discrete channel (890)

    Cnl > 0 ? Cnl: Val(890)

    When communication is lost, the value is saved and when restored, it continues to have the same value,

    The problem I have is that when I change again having communication, it persists the value it had before the disconnection and does not update the value,

    Can you help me,

    Thanks

    #11240
    gabeirinhas
    Participant

    The other formula I need is that when a discrete channel = 0

    The value of a real channel is copied,

    into another real channel,

    That is if when the discrete channel (742) == 0

    Copy, the value of the real channel (743)

    In the real channel (1033), when this happens, an event is generated with the value of the copied channel,

    What formula should I use in the real channel (1033) to perform this operation,

    Thank you very much in advance

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