How to swap the HEX data from the device via the Modbus protocol in RapidSCADA?

Forum Home Forums Communicating with Devices How to swap the HEX data from the device via the Modbus protocol in RapidSCADA?

Tagged: 

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #310
    vkevinv
    Participant

    Hi everyone,

    I want to get the temperature from a temperature controller via RapidSCADA with Modbus protocol.
    I have gotten the data from the device.
    I send “01 03 00 00 00 02 C4 0B” to the device then it returns ” 01 03 04 00 25 00 00 EB F8”.
    The real temperature is 37 degree from HEX “00 00 00 25”, but the data in RapidSCADA is 2424832 degree from HEX “00 25 00 00”.
    How can I swap HEX string “00 25 00 00” to “00 00 00 25” in RapidSCADA?

    Thanks!

    Kevin

    #311
    Mikhail
    Moderator

    Hi Kevin,

    You can swap bytes using formulas which are edited by SCADA-Administrator application.
    Seeing that Modbus driver is currently improved it is possible to implement this function in Modbus Template Editor of Rapid SCADA Modbus driver. Probable within 2 weeks.

    #312
    vkevinv
    Participant

    Dear Mikhail,

    Thank you for your quick reply. It is really a very good news from you. I am really looking forward to this function.

    But now how can I swap bytes using formulas in SCADA-Administrator application. Could you illustrate the formula for me?

    Thanks!

    Kevin

    #313
    Mikhail
    Moderator
    public double SwapBytes()
    {
        UInt32 val = (UInt32)CnlVal;
        byte[] bytes = BitConverter.GetBytes(val);
        byte[] newBytes = new byte[] 
        {
            bytes[1],
            bytes[0],
            bytes[3],
            bytes[2],
        };
        return (double)BitConverter.ToUInt32(newBytes, 0);
    }

    How to use:
    1. Run SCADA-Administrator
    2. Open Formulas table and add this method.
    3. Open Input channels table and find the appropriate input channel.
    4. Tick Formula used field.
    5. Input SwapBytes() into the Formula field

    If it doesn’t work at once write here)
    Play with order of bytes.

    • This reply was modified 8 years, 8 months ago by Mikhail.
    #314
    Mikhail
    Moderator

    Then click “Pass to SCADA-Server” button and restart SCADA-Server service.

    #316
    Mikhail
    Moderator

    I edited the code of the formula, be attentive, please.

    #317
    vkevinv
    Participant

    I did something following your in strunctions. And I click the “pass to SCADA-Server” button and restart the two services. But the temperature values is as the same values as before.

    I don’t know why?

    #320
    Mikhail
    Moderator

    Could you post here the content of C:\SCADA\ScadaComm\Log\kpXXX.txt ?
    where XXX is your device number

    #321
    vkevinv
    Participant

    Here it is:

    Device 901 "WMD-20-1210339", DLL: KpModbus
    ------------------------------------------
    State         : normal
    Comm. session : 25/08/2015 15:06:15
    Command       : time is undefined
    
    Comm. sessions (total / errors) : 14 / 0
    Commands       (total / errors) : 0 / 0
    Requests       (total / errors) : 14 / 0
    
    Current data
    +--------+-------------+--------+---------+
    | Signal | Name        |  Value | Channel |
    +--------+-------------+--------+---------+
    | ******** Temperature ****************** |
    +--------+-------------+--------+---------+
    |      1 | PV          | 720896 |     901 |
    +--------+-------------+--------+---------+
    
    No archive data
    
    No events
    #322
    Mikhail
    Moderator

    Hi,

    Looks like OK:
    – input channel number is 901,
    – value 720896 is hex 00 0B 00 00.

    The result of conversion doesn’t shown in SCADA-Communicator. You can watch it in a web page or with help of SCADA-Server GUI.
    What is the value of the channel 901?

    #323
    vkevinv
    Participant

    Deal Mikhail,

    I have used the code you sent me few days ago, and I also click the “pass to SCADA-Server” button and restart the two services, but the value from channel 901 is still 72896 degree.

    Could you help me find out the reason?

    Thanks!

    #324
    Mikhail
    Moderator

    Hi Kevin,

    The default configuration uses formula, for instance, in the channel 101. Is there any difference with 901? You could try using the simplest formula Cnl – 1 for the test reason.

    How about trying the new SCADA-Communicator that contains the required function?
    1. Download the update from http://rapidscada.org/download/scada_4.5_update.zip
    2. Rewrite the existing files.
    3. Continue our discussion…

    #325
    Mikhail
    Moderator

    Kevin, if you would like, I can help you to set up the system using remote connection. Is is payable service http://rapidscada.org/services/remote-troubleshooting/

    #326
    vkevinv
    Participant

    Dear Mikhail,

    It is a good thing for the udate. I will try the updated function that fit my requirement first, and then if I have any further more problems in using the Rapid SCADA, I will apply the payable service from you. ^_^

    Thanks!

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