Nanobrain (Customer) asked a question.

Click PLC address mismatch when programming Modbus communication

I am trying to communicate with a Click PLC (Basic) via a Node JS server. I've had success and can change the values in memory. The issue is that the addresses in the address picker in the Click Programming Software seem to be offset by 1 address location when changing the memory from a Node JS server.

 

I'm attempting to turn on the first output coil, which the software shows it at Modbus address 8193:forum - address picker

 

So in code I set this address (8193) in an attempt to turn on the 1st (Y001) output coil:

forum - code

 

However, this actually turn on the 2nd output coil:

forum - plc

 

Strange...

 

However, if I turn on address 8192 it will turn on the 1st coil. Wha? 😂

 

So, my question is, why does the address picker not show 8192?


Garry likes this.
  • Garry (Customer)

    +1 RBPLC

    You are dealing with Modbus base 1.

     

    Modbus “Standard” 4xxxx (base 1) 4xxxx (base 0)

    Function 3, Offset 0 40001 40000

    Function 3, Offset 1 40002 40001

    http://support.elkor.net/knowledgebase.php?article=14

     

    "To add more confusion to the scenario, some device manufacturers start their “4xxxx” references at 40001, and some start at 40000.  The starting register corresponds to offset “0” within the given function.  It is not always evident which reference a manufacturer uses, and it is best to clearly read the documentation to attempt to gain understanding."

     

    Regards,

    Garry

    https://accautomation.ca/series/click-plc/

     

     

    Expand Post
    Selected as Best
  • Todd Dice (Customer)

    Yes, as I recall from the past, the Modbus addresses are off by 1.

  • RBPLC (Customer)

    What you're showing is common with Modbus. Modbus devices can reference registers as 0 or 1 based and manufacturers implement this in different ways. Programming languages implement the 0 or 1 based addressing in different ways also. With Modbus devices/software you just have to make them match up. Offset your script by one and move on. The next device you try to communicate with might have to be offset by one or it might not. You'll also encounter this in regards to endianness and reading hi/low word orders. Try reading a 32 bit value out of the Click and see if you get garbage. If so you'll have to change the hi/low order of the two read registers.

    Expand Post
  • Garry (Customer)

    +1 RBPLC

    You are dealing with Modbus base 1.

     

    Modbus “Standard” 4xxxx (base 1) 4xxxx (base 0)

    Function 3, Offset 0 40001 40000

    Function 3, Offset 1 40002 40001

    http://support.elkor.net/knowledgebase.php?article=14

     

    "To add more confusion to the scenario, some device manufacturers start their “4xxxx” references at 40001, and some start at 40000.  The starting register corresponds to offset “0” within the given function.  It is not always evident which reference a manufacturer uses, and it is best to clearly read the documentation to attempt to gain understanding."

     

    Regards,

    Garry

    https://accautomation.ca/series/click-plc/

     

     

    Expand Post
    Selected as Best
  • Kuba-Sikora (Customer)

    Hi, could you please send me the full nodejs code? I’m having trouble with a similar problem and can’t find anything helpful. I would really appreciate it thank you so much.

    • Nanobrain (Customer)

      I was successful in getting a project going. I was able to create a simulator of an industrial machine...basically an arcade using industrial tech, web tech and Unity3D.

      I will definitely send you the full source ​code as soon as I get a chance.

      Never thought this question would see the light of day haha.

      Expand Post
      • Kuba-Sikora (Customer)

        Thank you so much! Honestly I'm still struggling to even connect to the plc. I'm using the modbus-serial library and I keep getting the Port Not Open error even tho I enabled everything I could on the PLC.

    • Nanobrain (Customer)

      Wow! This looks awesome. Thank you...if I ever each back into industrial tech. ​

  • kewakl (Customer)

    Not to beat the horse. Others have mentioned the base 0 -vs- base 1 issue.

     

    Your question 'Why does the address picker not show 8192?'

     

    Too many manufacturers/developers have too much hardware/firmware/software deployed to go mucking with their offsets and, thus, leave it to documentation, experience, forums, common knowledge etc. to help us to figure out how they have implemented their addressing.

     

    Expand Post