Announcement

Collapse
No announcement yet.

Can't read register

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

    Can't read register

    Hi beerygaz,

    This is what I tried today:
    - installed the latest version on the downloader 3.1.5848.33860
    - changed the baud rate to 9600 (was using 115200)

    This is the result:
    - if I only have a Coil (register address 1) then the PI works fine
    - once I add a Holding Register (register address 40001) then nothing works anymore:
    - I can't control the Coil
    - the PI hangs as soon as it tries to read the Coil register
    - when I change to/from BigEndian, a read does seem to happen - see log file below

    I've restarted multiple times etc. I also tried to create ONLY the Holding Register device, but that also doesn't seem to work.

    Any suggestions what I can test or do next?

    Regards,
    Jan

    ===

    2016-01-06 11:05:59.1386| TRACE|HSPI_MODBUS.Utils.RegisterWebPage |Registering Web Page: Modbus_Config
    2016-01-06 11:06:01.1937| INFO|HSPI_MODBUS.plugin.InitailiseAllGateways|Initalising modbus master gateways
    2016-01-06 11:06:02.5178| INFO|HSPI_MODBUS.plugin.PopulateRegisters |Populating register database for gateway Modbus RTU Gateway
    2016-01-06 11:06:02.5458| DEBUG|HSPI_MODBUS.plugin.PopulateRegisters |Found 2 devices associated with this gateway.
    2016-01-06 11:06:02.5638| DEBUG|HSPI_MODBUS.plugin.PopulateRegisters |Adding 1:1:Coil:Bool to Modbus RTU Gateway
    2016-01-06 11:06:02.5988| DEBUG|HSPI_MODBUS.plugin.PopulateRegisters |Adding 1:40001:HoldingRegister:Int16 to Modbus RTU Gateway
    2016-01-06 11:06:02.6868| WARN|HSPI_MODBUS.plugin.UpdateGatewayDevice |Gateway status has changed to Connected
    2016-01-06 11:06:02.6958| INFO|HSPI_MODBUS.Gateway.InitTimer |Start poll timer for Modbus RTU Gateway every 60 seconds
    2016-01-06 11:07:02.7179| DEBUG|HSPI_MODBUS.Gateway.OnTimedEvent |Polling Modbus RTU Gateway. Reading 2 registers from slaves
    2016-01-06 11:07:02.7179| DEBUG|HSPI_MODBUS.Gateway.Read

    ==> First read from the Coil register works

    |Trying Slave: 1 Address: 1 Coil:Bool
    2016-01-06 11:07:02.7779| DEBUG|HSPI_MODBUS.Gateway.Read |Read Slave: 1 Address: 1 Coil:Bool as 0

    ==> Read from Input Register does not work

    2016-01-06 11:07:02.7879| DEBUG|HSPI_MODBUS.Gateway.Read |Trying Slave: 1 Address: 40001 HoldingRegister:Int16


    2016-01-06 11:08:02.7330| DEBUG|HSPI_MODBUS.Gateway.OnTimedEvent |Polling Modbus RTU Gateway. Reading 2 registers from slaves

    ==> Now read from Coil also does not work anymore, so the first read of the Input Register seems to have created a problem

    2016-01-06 11:08:02.7330| DEBUG|HSPI_MODBUS.Gateway.Read |Trying Slave: 1 Address: 1 Coil:Bool


    2016-01-06 11:09:02.7481| DEBUG|HSPI_MODBUS.Gateway.OnTimedEvent |Polling Modbus RTU Gateway. Reading 2 registers from slaves


    2016-01-06 11:09:02.7481| DEBUG|HSPI_MODBUS.Gateway.Read |Trying Slave: 1 Address: 1 Coil:Bool

    ==> At this stage I switch to BigEndian

    2016-01-06 11:09:41.9831| DEBUG|HSPI_MODBUS.Gateway.CloseSerial |Closing serial port
    2016-01-06 11:09:41.9831| WARN|HSPI_MODBUS.plugin.UpdateGatewayDevice |Gateway status has changed to Unavailable
    2016-01-06 11:09:41.9831| ERROR|HSPI_MODBUS.Gateway.ReadBoolean |Error in ReadBoolean: The port is closed.
    System.InvalidOperationException: The port is closed.
    at System.IO.Ports.SerialPort.DiscardInBuffer()
    at Modbus.IO.SerialPortAdapter.DiscardInBuffer()
    at Modbus.IO.ModbusSerialTransport.Write(IModbusMessage message)
    at Modbus.IO.ModbusTransport.UnicastMessage[T](IModbusMessage message)
    at Modbus.Device.ModbusMaster.PerformReadDiscretes(ReadCoilsInp utsRequest request)
    at Modbus.Device.ModbusMaster.ReadCoils(Byte slaveAddress, UInt16 startAddress, UInt16 numberOfPoints)
    at HSPI_MODBUS.Gateway.ReadBoolean(Int32 address, Int32 SlaveID, AddressTypes AddressType)
    2016-01-06 11:09:41.9831| ERROR|HSPI_MODBUS.Gateway.ReadInt16 |Error in ReadInt16: The port is closed.
    System.InvalidOperationException: The port is closed.
    at System.IO.Ports.SerialPort.DiscardInBuffer()
    at Modbus.IO.SerialPortAdapter.DiscardInBuffer()
    at Modbus.IO.ModbusSerialTransport.Write(IModbusMessage message)
    at Modbus.IO.ModbusTransport.UnicastMessage[T](IModbusMessage message)
    at Modbus.Device.ModbusMaster.PerformReadRegisters(ReadHoldingI nputRegistersRequest request)
    at Modbus.Device.ModbusMaster.ReadHoldingRegisters(Byte slaveAddress, UInt16 startAddress, UInt16 numberOfPoints)
    at HSPI_MODBUS.Gateway.ReadInt16(Int32 address, Int32 SlaveID, AddressTypes AddressType)
    2016-01-06 11:09:41.9831| ERROR|HSPI_MODBUS.Gateway.ReadBoolean |Error in ReadBoolean: The port is closed.
    System.InvalidOperationException: The port is closed.
    at System.IO.Ports.SerialPort.DiscardInBuffer()
    at Modbus.IO.SerialPortAdapter.DiscardInBuffer()
    at Modbus.IO.ModbusSerialTransport.Write(IModbusMessage message)
    at Modbus.IO.ModbusTransport.UnicastMessage[T](IModbusMessage message)
    at Modbus.Device.ModbusMaster.PerformReadDiscretes(ReadCoilsInp utsRequest request)
    at Modbus.Device.ModbusMaster.ReadCoils(Byte slaveAddress, UInt16 startAddress, UInt16 numberOfPoints)
    at HSPI_MODBUS.Gateway.ReadBoolean(Int32 address, Int32 SlaveID, AddressTypes AddressType)
    2016-01-06 11:09:42.0131| INFO|HSPI_MODBUS.plugin.PopulateRegisters |Populating register database for gateway Modbus RTU Gateway

    ==> Now the Read does seem to work, both for the Coil and the Input Register

    2016-01-06 11:09:42.0131| DEBUG|HSPI_MODBUS.Gateway.Read |Read Slave: 1 Address: 1 Coil:Bool as 0
    2016-01-06 11:09:42.0131| DEBUG|HSPI_MODBUS.Gateway.Read |Read Slave: 1 Address: 40001 HoldingRegister:Int16 as 0


    2016-01-06 11:09:42.0331| DEBUG|HSPI_MODBUS.Gateway.Read |Read Slave: 1 Address: 1 Coil:Bool as 0

    2016-01-06 11:09:42.0441| DEBUG|HSPI_MODBUS.plugin.PopulateRegisters
    |Found 2 devices associated with this gateway.


    2016-01-06 11:09:42.0601| DEBUG|HSPI_MODBUS.Gateway.Read
    |Trying Slave: 1 Address: 40001 HoldingRegister:Int16
    2016-01-06 11:09:42.0601| DEBUG|HSPI_MODBUS.plugin.UpdateDevice |Updating device Modbus Device : Address 1 as Coil:Bool to 0
    2016-01-06 11:09:42.0441| DEBUG|HSPI_MODBUS.Gateway.Read |Trying Slave: 1 Address: 40001 HoldingRegister:Int16
    2016-01-06 11:09:42.0731| DEBUG|HSPI_MODBUS.plugin.PopulateRegisters |Adding 1:1:Coil:Bool to Modbus RTU Gateway
    2016-01-06 11:09:42.0731| ERROR|HSPI_MODBUS.Gateway.ReadInt16 |Error in ReadInt16: Object reference not set to an instance of an object.
    System.NullReferenceException: Object reference not set to an instance of an object.
    at Modbus.Device.ModbusMaster.PerformReadRegisters(ReadHoldingI nputRegistersRequest request)
    at Modbus.Device.ModbusMaster.ReadHoldingRegisters(Byte slaveAddress, UInt16 startAddress, UInt16 numberOfPoints)
    at HSPI_MODBUS.Gateway.ReadInt16(Int32 address, Int32 SlaveID, AddressTypes AddressType)
    2016-01-06 11:09:42.0731| DEBUG|HSPI_MODBUS.plugin.UpdateDevice |Updating device Modbus Device : Address 40001 as HoldingRegister:Int16 to 0
    2016-01-06 11:09:42.0931| DEBUG|HSPI_MODBUS.plugin.PopulateRegisters |Adding 1:40001:HoldingRegister:Int16 to Modbus RTU Gateway
    2016-01-06 11:09:42.1061| DEBUG|HSPI_MODBUS.Gateway.Read |Read Slave: 1 Address: 40001 HoldingRegister:Int16 as 0
    2016-01-06 11:09:42.0931| ERROR|HSPI_MODBUS.Gateway.ReadInt16 |Error in ReadInt16: Object reference not set to an instance of an object.
    System.NullReferenceException: Object reference not set to an instance of an object.
    at Modbus.Device.ModbusMaster.PerformReadRegisters(ReadHoldingI nputRegistersRequest request)
    at Modbus.Device.ModbusMaster.ReadHoldingRegisters(Byte slaveAddress, UInt16 startAddress, UInt16 numberOfPoints)
    at HSPI_MODBUS.Gateway.ReadInt16(Int32 address, Int32 SlaveID, AddressTypes AddressType)
    2016-01-06 11:09:42.1301| DEBUG|HSPI_MODBUS.Gateway.Read |Read Slave: 1 Address: 40001 HoldingRegister:Int16 as 0
    2016-01-06 11:09:42.1301| DEBUG|HSPI_MODBUS.plugin.UpdateDevice |Updating device Modbus Device : Address 1 as Coil:Bool to 0
    2016-01-06 11:09:42.1351| DEBUG|HSPI_MODBUS.plugin.UpdateDevice |Updating device Modbus Device : Address 1 as Coil:Bool to 0
    2016-01-06 11:09:42.1351| DEBUG|HSPI_MODBUS.plugin.UpdateDevice |Updating device Modbus Device : Address 40001 as HoldingRegister:Int16 to 0
    2016-01-06 11:09:42.1351| DEBUG|HSPI_MODBUS.plugin.UpdateDevice |Updating device Modbus Device : Address 40001 as HoldingRegister:Int16 to 0
    2016-01-06 11:09:42.1751|

    WARN|HSPI_MODBUS.plugin.UpdateGatewayDevice |Gateway status has changed to Connected
    2016-01-06 11:09:42.1751| INFO|HSPI_MODBUS.Gateway.InitTimer |Start poll timer for Modbus RTU Gateway every 60 seconds

    ==> but then when it starts to poll again, things get stuck again when it read the Holding Register

    2016-01-06 11:10:42.1962| DEBUG|HSPI_MODBUS.Gateway.OnTimedEvent |Polling Modbus RTU Gateway. Reading 2 registers from slaves
    2016-01-06 11:10:42.1962| DEBUG|HSPI_MODBUS.Gateway.Read |Trying Slave: 1 Address: 1 Coil:Bool
    2016-01-06 11:10:42.2162| DEBUG|HSPI_MODBUS.Gateway.Read |Read Slave: 1 Address: 1 Coil:Bool as 0
    2016-01-06 11:10:42.2162| DEBUG|HSPI_MODBUS.Gateway.Read |Trying Slave: 1 Address: 40001 HoldingRegister:Int16

    ==> at this stage I try to change the status of the coil which does not work (get an error in the HS Log:
    Jan-06 11:11:37 Error Calling SetIOMulti in plugin Modbus:Object reference not set to an instance of an object.)

    2016-01-06 11:11:07.4812| DEBUG|HSPI_MODBUS.plugin.SetIOMulti |SetIOMulti set value: 1->ref:708

    ==> and then continues without results, also PI has become non-responsive: from HS Log:
    Jan-06 11:11:37 Warning Plugin Modbus is not responding but it is still running, not restarting yet.

    2016-01-06 11:11:42.2143| DEBUG|HSPI_MODBUS.Gateway.OnTimedEvent |Polling Modbus RTU Gateway. Reading 2 registers from slaves
    2016-01-06 11:11:42.2143| DEBUG|HSPI_MODBUS.Gateway.Read |Trying Slave: 1 Address: 1 Coil:Bool
    2016-01-06 11:12:42.2294| DEBUG|HSPI_MODBUS.Gateway.OnTimedEvent |Polling Modbus RTU Gateway. Reading 2 registers from slaves
    2016-01-06 11:12:42.2294| DEBUG|HSPI_MODBUS.Gateway.Read |Trying Slave: 1 Address: 1 Coil:Bool
    2016-01-06 11:13:42.2365| DEBUG|HSPI_MODBUS.Gateway.OnTimedEvent |Polling Modbus RTU Gateway. Reading 2 registers from slaves
    2016-01-06 11:13:42.2365| DEBUG|HSPI_MODBUS.Gateway.Read |Trying Slave: 1 Address: 1 Coil:Bool

    #2
    Jan, try the new version, I think there's an issue reading he holding registers, the new version will add more detail if that's the case and we can see which one is a problem.
    Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

    Comment


      #3
      Thx beerygaz, will test next week, camping with the family for a week. Cheers, Jan

      Comment


        #4
        Solved - used different addressing method

        Originally posted by beerygaz View Post
        Jan, try the new version, I think there's an issue reading he holding registers, the new version will add more detail if that's the case and we can see which one is a problem.
        Hi beerygaz,

        Success with the latest version ... but the problem reading Holding or Input registers was probably all along due to a misunderstanding in how the addressing works in the PI (which is different from how the yoyo HS2 modbus PI worked): to read Holding Register at address "40001", I previously entered "40001" as the address, but I realise now you already assume that Holding Registers start at "40000" and therefore to read Holding Register "40001", one needs to enter "1" as address. Once I used this addressing method, the PI works like a charm!

        Other feedback:
        - I'd like to poll faster than 1 second, so could your provide and option that polls as fast as possible, i.e. after all the devices have been polled, it starts a new round immediately; this is an important request from my perspective so I can read out potmeter values more or less in real time
        - the flag "Zero Based Addressing" seems to work the other way around, i.e. I have to enable the flag to use "1" to read from address "1"?

        Anyway, starts to look good.

        Cheers,
        Jan

        Comment


          #5
          Good feedback Jan. Thanks. I'll follow up on the zero-based addressing.

          Polling faster may be possible but it will put a lot of load on HS as I update the HS devices as soon as I read a value. Let me see what I can do and what it does to CPU and HS3 responsiveness.



          Sent from my iPhone using Tapatalk
          Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

          Comment


            #6
            Jan, anything below 1s and I start running into timeout issues on my modbus device connected at 19200 baud. The issue may be that I'm reading each register individually. There is a modbus command to read multiple registers at once which I'm sure will be a lot quicker, but then the issue is I need to do a lot of coding to sort the registers you want to us, bundle together the contiguous ones to read simultaneously and then red the others individually. See how that might be an issue?

            We you getting sub second, or even sub 500ms read times with YoYo's plugin?
            Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

            Comment


              #7
              Jan, if you grab the latest release and set the poll time to 0 then it will actually set the poll time to 300ms. Let me know how that performs.


              Sent from my iPhone using Tapatalk
              Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

              Comment


                #8
                Originally posted by beerygaz View Post
                Good feedback Jan. Thanks. I'll follow up on the zero-based addressing.

                Polling faster may be possible but it will put a lot of load on HS as I update the HS devices as soon as I read a value. Let me see what I can do and what it does to CPU and HS3 responsiveness.



                Sent from my iPhone using Tapatalk
                Beerygaz,

                FYI. In my case the zero-based addressing is working OK.

                The device is working according to the manual and your PI shows the same behavior as the Modbus Poll program with regards to addressing.

                ---
                John

                Comment


                  #9
                  Jan,

                  I believe you are using an Ocean controls KTA-225. Do you have a linkt to the Modbus information of this device?

                  ---

                  John

                  Comment


                    #10
                    Ocean Controls KTA-226

                    Hi John,

                    I am using KTA-226, here is the link to the manual:
                    https://oceancontrols.com.au/datashe...226_Manual.pdf

                    Regards,
                    Jan

                    Comment


                      #11
                      Originally posted by beerygaz View Post
                      Jan, if you grab the latest release and set the poll time to 0 then it will actually set the poll time to 300ms. Let me know how that performs.


                      Sent from my iPhone using Tapatalk
                      Hi beerygaz,

                      Thx, already much better, but you can still go faster. I am using 115200 as baudrate and when I look at the signal on my oscilloscope, I can see the polling happening each 300 ms (see attachment). To poll 8 input registers and 8 coils only takes about 30 ms, so you could go down to 50 ms or 100 ms poll time. It does seem to have a bigger impact on the CPU then the yoyo PI (which could go down to 50 ms I think): at 300 ms the CPU load is ~12 % for HS3 and ~8 % for HSPI_MODBUS, from memory even the fast polling with the yoyo PI did not use more than 2 or 3 % CPU time.

                      Anyway great progress again!

                      Cheers,
                      Jan
                      Attached Files

                      Comment


                        #12
                        Jan. Have you tried the latest version that gives you full control over the interval down to the ms.


                        Sent from my iPhone using Tapatalk
                        Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

                        Comment


                          #13
                          Hi beerygaz,

                          How can we test the latest version? I have still the expired trial issue




                          Sent from my iPhone using Tapatalk

                          Comment


                            #14
                            Originally posted by beerygaz View Post
                            Jan, if you grab the latest release and set the poll time to 0 then it will actually set the poll time to 300ms. Let me know how that performs.


                            Sent from my iPhone using Tapatalk
                            Hi beerygaz,

                            Just came back from a business trip, will try when I can install the latest version from the Homeseer store.

                            Jan

                            Comment


                              #15
                              The store now has the plugin available.


                              Sent from my iPhone using Tapatalk
                              Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

                              Comment

                              Working...
                              X