Announcement

Collapse
No announcement yet.

CLICK/PAC read from BRX MHR0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts


  • CLICK/PAC read from BRX MHR0

    My CLICK/PAC reads MHR from BRX. I want to read NETTIME/RTC timestamping from MHR0-MHR8.
    I cannot access MHR0.
    The value in MHR0 is 999
    I do get MHR1-MHR8

    Click (Modbus 984) does not allow a ZERO offset.
    Click (Modbus HEX) does allow 0h. ---Neither mode returns MHR0 value 999

    PAC (Modbus Decimal) does allow ZERO offset.
    PAC (Zero Based ) does allow a ZERO offset. ---Neither mode returns MHR0 value 999

    Wireshark (as far as I understand) indicates that we are ASKING for _and_ receiving register ZERO.


    Code:
    .  'BRX CODE
    .
    .  'V0 indicates a successful NetTime timeserver response.
    .  'If V0 = 1 then we can know that we are syncing time to TimeServer/NetTime
    .  'If V0 = 0 then we can know that we are syncing to ONLY the BRX RTC
    .  'Not shown:
    .  '    Accessory code for triggering NetTime
    .  '    Code to do the TimeSync using NetTime
    .  '    Code to remember last good timesync
    .          ST1
    .----------] [-----------+ COPY
    .                        | V999            MHR0             ' MHR0 TEST VALUE =999
    .                        | $Now.Year       MHR1             '
    .                        | $Now.Month      MHR2             '
    .                        | $Now.Day        MHR3             '
    .                        | $Now.Hour       MHR4             '
    .                        | $Now.Minute     MHR5             '
    .                        | $Now.Second     MHR6             '
    .                        | $Now.DayOfWeek  MHR7             '
    .                        | V0              MHR8             ' Is NetTime result 1=Success 0=Error
    .                        +-------------------------------
    Code:
    .  'CLICK (984) CODE
    .
    .           C1
    .----------]^[------------+ Receive
    .                         | Port 1 MODBUS
    .                         | IP 192.168.8.10
    .                         | Port 502
    .                         | FC 3       Modbus 984
    .                         | Slave Addr 400001
    .                         | Number of M Addr   8
    .                         | No Swap
    .                         +-------------------------
    .
    Code:
    .  'CLICK (HEX) CODE
    .
    .           C1
    .----------]^[------------+ Receive
    .                         | Port 1 MODBUS
    .                         | IP 192.168.8.10
    .                         | Port 502
    .                         | FC 3       Modbus HEX
    .                         | Slave Addr 0h
    .                         | Number of M Addr   8
    .                         | No Swap
    .                         +-------------------------
    .
    Code:
    .  'PAC (DECIMAL BASED) CODE
    .
    .           C1
    .----------]^[------------+ Receive
    .                         | Port 1 MODBUS
    .                         | IP 192.168.8.10
    .                         | Port 502
    .                         | Word Swap Slave Addr 1  + 400000
    .                         | Modbus Decimal
    .                         | FC 3      Read Holding Registers
    .                         | Number of M Addr   8
    .                         | (0) Array TIME_FROM_SERVER    1   8 
    .                         +-------------------------
    .
    Code:
    .  'PAC (ZERO BASED) CODE
    .
    .           C1
    .----------]^[------------+ Receive
    .                         | Port 1 MODBUS
    .                         | IP 192.168.8.10
    .                         | Port 502
    .                         | Word Swap Slave Addr 0  + 400000
    .                         | Zero Based Modbus 
    .                         | FC 3      Read Holding Registers
    .                         | Number of M Addr   8
    .                         | (0) Array TIME_FROM_SERVER    1   8 
    .                         +-------------------------
    .
    Attached Files


  • #2
    There is no such thing as Modbus Holding Register 0 at the protocol level, since Modbus is 1 based. The design intent for MHR memory is that it mirror Modbus addressing.

    We actually had all of the Modbus sandbox memories start at 1, but that interfered with certain cast operations (like MI0:B) so we changed it back. It's really moot though...having an extra item in the range you can't access from comm changes nothing. Just don't use it.

    Comment



    • #3
      That answers that!

      Thanks for the official wording.

      Comment



      • #4
        Originally posted by kewakl View Post
        That answers that!

        Thanks for the official wording.
        You're about the 100th guy to hit this. I don't like it, but I like even less the odd issues of array indexing (zero based) and cast operations (byte/word/dword aligned) that get screwed up with it being 1 based. We chose to keep zero, feeling like it was the lesser evil.

        Comment



        • #5
          Engineering is all about decisions.

          Comment



          • #6
            Originally posted by kewakl View Post
            Engineering is all about decisions.
            And compromise... unfortunately.
            If you've done the very best you can, worrying won't make it any better - Walt Disney

            Comment

            Working...
            X