Announcement

Collapse
No announcement yet.

4Discovery 35 & Productivity PLC

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

  • 4Discovery 35 & Productivity PLC

    Hi,

    Full disclosure, I do not know C or Pascal. What little I know about 4DGL is from reading 4D Systems manuals, their sample programs, and from alejoseb's code he posted to Github. If you are reading this alejoseb, thank you so much for that! Currently, I am looking at a host of things I could be doing wrong. Any help you can throw my way I would be much obliged.

    I am trying to make a 4Disovery 35 communicate with a Productivity P2-550 CPU. The CPU has an onboard RS485 Port with a RX+, TX-, and ground terminal screws. This port is configured to Modbus RTU. The panel and CPU are connected by an Ethernet cord I cut up. I have Pin 2 wired to RX+, Pin 3 Wired to TX-. and Pin 5 to ground which is jumped to my 5vDC power supply common. My screen has power. I am using alejoseb's code as a base. https://github.com/alejoseb/modbus4dsys


    I matched the PLC's com setup with the settings I used for PLC simulators on my PC. I have a Copy Data and a Modbus Write box in my ladder logic. Copy Data is to move a real number in HEX to the specific Modbus Address, 400001, 400002, 400003, and 400004. (Limitations of the PLC limit my starting point to 400,000).

    Click image for larger version

Name:	Small Screen Ladder Logic.JPG
Views:	118
Size:	104.4 KB
ID:	72622






    I think I changed the Modbus starting point in the code to 400000:
    CONST

    BASE_RHOLD:=400000;
    BASE_COILS:=0;
    #END

    I do not know how to define the node number for the screen. I have the PLC set as node 1 because it is the master, I think. Also, I do not know if SLAVE_ADDRESS is for the screen or the PLC. I assumed if SLAVE_ADDRESS = X; was the code for setting the slave address, then NODE_ADRESS =X; might be for setting the node address. I tried several combinations of node numbers and serial numbers.
    MOD_POOL is 500 in both devices.

    #CONST

    SERIAL:= 1; //serial port to USE 0 for defualt port , 1 for serial port 1
    SLAVE_ADDRESS := 2; // it could be set here or in each telegram
    MOD_TIMEOUT := 3000; // timeout read/write modbus in ms
    MOD_POOL_T := 500; // pooling time period modbus in ms
    MOD_BAUDRATE := 960; // 9600/10 this is the value required by diablo
    NODE_ADDRESS := 1;
    #END

    The Visigenie manual mentioned the signal termination resister might need to be soldered on the back. I tried most of these combinations with both it soldered and not soldered. I cannot get the screen to display the LEDdigits I want it too.

    This got long winded, I reckon knowing a few specific things would help me on my way.

    What pins need to be wired to what terminals screws on the CPU? ie Pin 2 to RX+

    What Port configuration do I need?

    Do I need to solder the termination resister?

    Thank you for any assistance


  • #2
    Hi,

    Sorry to hear your having a problem communicating. To me everything looks fine and I am sure you don't need to solder the termination resistor in your setup. The wiring seems correct also but I will double check this also.

    Everything here seems fine

    #CONST
    SERIAL:= 1; //serial port to USE 0 for defualt port , 1 for serial port 1
    SLAVE_ADDRESS := 2; // it could be set here or in each telegram
    MOD_TIMEOUT := 3000; // timeout read/write modbus in ms
    MOD_POOL_T := 500; // pooling time period modbus in ms
    MOD_BAUDRATE := 960; // 9600/10 this is the value required by diablo
    NODE_ADDRESS := 1;
    #END

    However SERIAL:=1, this should be SERIAL:=0 as it is Serial port 0 which is attached to the RS485

    Looking at the code on Github it's the display that is the Master and the PLC is the slave in his implementation. Did you make any changes to make this way around ?

    You may also want to take a look at this forum post


    https://forum.4dsystems.com.au/node/65017

    Best regards

    Paul

    Comment


    • #3
      The only changes I made was changing the starting Modbus Address, The Mod_ POOL, and added the NODE_ADDRESS.

      So if the screen is the master, it should request the data in the specified Modbus addresses from the PLC and then display it, right? Maybe I have the wrong definition for the addresses.

      Comment


      • #4
        Hi,

        Did making any of the changes above solve your issue ?

        Best regards

        Paul

        Comment


        • #5
          Hi,

          There is also our implementation of Modbus which you can find here which may help.

          https://forum.4dsystems.com.au/node/65017

          Best regards

          Paul

          Comment


          • #6
            I tried setting the Serial = 0 with and without the resistor soldered and played with all the com settings to no avail. I have gotten that coil program to run with the simulator and I will try and make that work with the PLC in the upcoming days.

            Thank you for all your help
            Matt

            Comment


            • #7
              Hi Matt,

              Just looking at the library from Github which you are using, and reading your first post, you are using your PLC as Master, correct? And so the Display is going to be a Modbus slave?
              On the github library, it states "This port implements the Master function codes 1, 2, 3, 4, 5, 6, 15 and 16 of Modbus RTU protocol. Slave functionality, which is part of the original library, is not implemented."
              So to me that would indicate what you are trying to do will not work. That library only supports the display being the Master. So your PLC would have to be the slave.
              You would then do what you are trying to do in reverse I guess, and have the Display read your PLC addresses. You then don't need to set a node number for the display, as it will be reading from the PLC, not the PLC writing to the node of the Display.

              Please let me know if I have interpreted what you said incorrectly.

              Regards
              James

              Comment


              • James_4DSystems
                James_4DSystems commented
                Editing a comment
                To add to this, its often better (Safer) to have devices read from each other, rather than writing to each other too. In a previous life I worked as an Automation Engineer and the company I worked for had a best practice stating writes should be only used as a last resort, and to implement reads where possible, for the risk of writing to something unintentionally and starting some part of the plant up which should not have been started. Just food for thought.

            • #8
              HI James,

              You are correct, I was trying to use the PLC as the Master. Making the screen the Master is ideal for the application so I will switch it around.

              Thank you for the type with the write vs read, I will remember that.

              Comment

            Working...
            X