Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Serial communication

esse
2015-11-15
2015-11-16
  • esse - 2015-11-15

    Hello everyone !

    I am a new user in codesys and I want to communicate with a stepper motor i've got via serial port, can everyone guide me? The exact things I want to do is to send some commands for example rotate via my com port...I simply cannot find the way to connect with the com on my computer which is connectd to the motor

    THanks in advance

     
  • esse - 2015-11-16

    Thanks for your reply, well let me tell you what I've tried so far, I made a new project and I put a MODBUS COM and MODBUS Master COM port, then I thought that if I add a MODBUS slave COM port ,I could connect to my motor but I didn't though. Codesys see the MODBUS COM port but deny to communicate with the slave, what is the problem??

     
  • TimvH

    TimvH - 2015-11-16

    With Modbus communication, you have to add a Modbus COM port to your device. To this COM port you have to add your Modbus serial master and to this master you have to add your Modbus slave device.
    In the slave device you have to specify which variables you would like to read/write. You have to create "channels" for this.

    No programming is needed for this, just configuration.

     
  • esse - 2015-11-16

    I don't fully understand what are these channels, is there a similar example because i'm a little confused, my purpose is to send some basic commands i assume in binary mode or in bits...but when i try to run through codesys doesn't recognize the MODBUS slave COM port...

    IMG: error.png

     
  • esse - 2015-11-16

    Can somenone explain me how to use the read offset command in channel configuration of a slave COM port...I think this is my problem, that i don't send write values

     
  • TimvH

    TimvH - 2015-11-16

    Maybe the reason is that you don't use the variables in your application. In that case they are not updated by the Modbus I/O driver.

    What you could do, is go to the tab "ModbusGenericSerialSlave I/O mapping" and select: "Enabled 1 (use bus cycle task if not used in any task)". See the lower righthand corner for this setting.

    This causes the I/O driver to update also the variables which are not used in your application.

     
  • esse - 2015-11-16

    Tim thank you for your replies, I tried this option but nothing happened, I am searching how to send a command via a channel that establish to my motor...I think that I should send to it by the write register option but i don't know how

     
  • TimvH

    TimvH - 2015-11-16

    Ask the vendor of your Modbus slave device which Modbus register should be written to and which values are valid.
    Create a channel for this register (or registers) in the Modbus slave.
    Write the "value" to the I/O variable which is created in your IO mapping.

    Easiest is to create a cyclic write channel which updates the output variable cyclically.

     

Log in to post a comment.