Showing results 1 to 7 of 7

Thread: Variable in String Format

  1. #1
    Join Date
    16.07.2020
    Posts
    3

    Default Variable in String Format

    Hi,
     
    Iím trying to read Date and Time in copa-data from Modbus Driver in ďSTRINGĒ format with length of 8.
     
    From 1st address (TIME) Iím getting the correct value (05:00:00) as shown in below pic.
    From 2nd address (DATE) I should get (15/07/20) but Iím getting as :00:0015 as shown in below pic.
    In second address the value Iím getting is from address 1 but length of 2 shift is there.
    Same is continuing for address 3, 4 5Ö..
     
    If Iím reading from another driver then also only one value of string is coming correct.
     
    Can anyone help me out in this.


  2. #2
    Join Date
    17.03.2016
    Posts
    62

    Default Re: Variable in String Format

    How is the date formatted in the source device? There is no such thing as a 'standard' date format in modbus. Usually the value is sent encoded in some way... maybe you need bitwise operation, or it is a number of days after a certain given date? A modbus holding register is only sending a number.

    You will need to understand this before you can display it as a date or string in Zenon, I don't think it is just a case of reading the register and storing it as a string.

    Do you have a manual for the PLC?

    Here's an example of such an encoding.
    https://stackoverflow.com/questions/31746015/extract-date-and-time-from-two-16-bit-modbus-registers.

    Hope that helps.

  3. #3
    Join Date
    16.07.2020
    Posts
    3

    Default Re: Variable in String Format

    Hi,

    Thanks for your reply. I'm reading the data in string format (ASCII -8). Same I'm trying to show in HMI.
    1st address data is coming same, but from 2nd address only I'm getting wrong data.

    Please check the below pic FYR which I'm reading form Modbus Date and Time.





  4. #4
    Join Date
    17.03.2016
    Posts
    62

    Default Re: Variable in String Format

    Ok, still seem to be missing part of the puzzle here.

    Encoding is Ascii 8 bit. Each holding register is 16 bit. Therefore in each register you can only send 2 characters.
    The full date must be sent across as a minimum of 3 registers (19 07 20) or 4 (19 07 20 20). You would then need to combine them in to a single string.

    The example you gave of time may also be suspect... what happens when the time is 05:01? That would require at least 2 registers to send across.

    How are the colons being added in your example? If they are in the modbus transfer then that requires another bit for each colon (or you just add them in after decoding time /date).

    Are you able to view the output from all regsiters around your date /time eg by polling with modbusview type tool?

    It could be that the registers your PLC uses to send the date are using a different ordering than expected eg word swap / byte swap. So even if you have set up zenon to read mutltiple registers you may be reading the wrong ones.
    Last edited by HMIdeveloper123 : 19th July 2020 at 14:19

  5. #5
    Join Date
    18.08.2015
    Posts
    14

    Default Re: Variable in String Format

    Hello

    Quote Originally Posted by junedfazal486 View Post
    Please check the below pic FYR which I'm reading form Modbus Date and Time.




    Where does this screenshot come from?

    If you use a third-party tool to successfully read this data from the Modbus Slave, you can record the traffic (e.g. using WireShark). This may help to reverse engineer the required addressing, when no manual of the PLC is available.

    How to interpret the telegrams can be found online, e.g. at
    http://www.simplymodbus.ca/TCP.htm
    http://www.simplymodbus.ca/FC03.htm

    Holding Register STRING variables in zenon use registers according to the configured variable string length: n*Byte.

    As HMIdeveloper123 said, unless you know how the date and time data is stored (coded) in the Holding Registers, you also may have to reverse engineer interpretation of the polled information.

    BR, Leo
    Last edited by leos : 20th July 2020 at 12:42

  6. #6
    Join Date
    16.07.2020
    Posts
    3

    Default Re: Variable in String Format

    Thanks for your response.

    I'm reading the date and time from OMNI  Flow Computer and driver installed in zenon to read the variables. I'm directly reading all the data from driver in zenon. Only data with String format is creating issue for me. 
    If I'm reading only 1 data with String format 8 length (only 1 address), then i can read it correctly in zenon.
    If I'm reading 2 data (i.e., 2 address) then data from first address i'm getting correctly but data for second address is coming from 1st address (6 letters out of 8) and  remaining 2 letters from address 2.
    If I'm reading 3 data (i.e., 3 address) then data from first address i'm getting correctly but data for second address is coming from 1st address (6 letters out of 8, starting 2 letters it is leaving) and  remaining 2 letters from address 2, data from 3rd address is coming from (4 letters of address 1 starting 4 letters it is leaving) and remaining 4 letters from address 2.

    Thanks & Regards

    Juned Fazal

  7. #7
    Join Date
    10.12.2007
    Posts
    231

    Default AW: Variable in String Format

    Looks like you have the wrong Offsets for variable 2..3....
    I think in this example the offsets should be: Variable 2 Offset = Variable 1 Offset + 5 (Length/2 +1 StringHeader)...

Similar Threads

  1. IEC 850 variable-time format
    By hamid in forum zenon Energy Edition
    Replies: 5
    Last Post: 29th January 2018, 07:11
  2. String entry format enforcement?
    By EdgyUsername in forum zenon Supervisor
    Replies: 1
    Last Post: 29th August 2016, 09:55
  3. Custom text string format
    By sdolnyy in forum zenon Operator
    Replies: 1
    Last Post: 25th September 2015, 07:42
  4. IEC 850 variable-time format
    By hamid in forum Drivers
    Replies: 2
    Last Post: 30th October 2011, 06:43
  5. Replies: 1
    Last Post: 23rd July 2011, 08:51

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •