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

RPI4 with CH341

Tiziano
2019-09-29
2019-10-04
  • Tiziano - 2019-09-29

    Hello to all,
    I have the Raspian PI4 and I have the problem of modbus communication with CH341 via USB.
    The port between Putty and the Hercules software you need to test modbus communication works because I can send a string so the problem is some CODESYS setting.
    Reading on the forums I found to add on

    CODESYSControl_User.cfg
    [SysCom]
    Linux.Devicefile = / dev / ttyUSB

    But as in the attached picture it doesn't start,
    Can anyone answer me?
    Edwin, do you have any information for me?
    Thanks

    IMG: ErroreRTU.png

     
  • eschwellinger

    eschwellinger - 2019-09-30

    Hi,

    without these spaces it might work ( and it should be 3.5SP15 at least ->version)
    [SysCom]Linux.Devicefile=/dev/ttyUSB

    BR
    Edwin

     
  • Tiziano - 2019-09-30

    Hello and thanks for the reply,
    I tried without spaces but still nothing, I tried to modify sudo nano /etc/CODESYSControl_User.cfg as in the attached file putting ttyUSB instead of ttyS and adding
    portname: = COM.SysCom.SYS_COMPORT1
    but still nothing, I have to maybe sudo nano /etc/CODESYSControl.cfg?
    I also set the speed to 115200 by default.
    I have to put ttyUSB in sudo nano /CODESYSControl_User.cfg
    so without etc?
    If someone kindly helps me or maybe Edwin can help me?
    Thanks

    IMG: sudo nano etcCODESYSControl_User_cfg .jpg

     
  • eschwellinger

    eschwellinger - 2019-10-01

    Hi,
    setting is ok,
    and from first screenshot I would say comports works.
    I would suggest to add the name of the serial modbus device to a watch window to have more information what happens...
    (add Modbus_Slave_Com_port to the watch window and undfold it to see more infommation/diag there)
    BR
    Edwin

    IMG: ModbusDiag.png

     
  • Tiziano - 2019-10-01

    Hi Edwin, I thank you for your kindness in answering me,
    I have attached to you what happens in the WATCH table, but I ask you, these lines:

    [SysCom]
    Linux.Devicefile = / dev / ttyUSB
    portnum: = COM.SysCom.SYS_COMPORT1;

    I have to add them up
    sudo nano /etc/CODESYSControl.cfg
    or
    sudo nano /etc/CODESYSControl_User.cfg
    I have to put it
    portnum: = COM.SysCom.SYS_COMPORT1;
    on CODESYSControl_User.cfg and not on CODESYSControl.cfg
    and the speed that I find on etc / CODESYSControl_User.cfg I have to leave to 115200 even if in the forum they speak of 9600?
    I ask you all these questions because I have now moved them but the communication does not start.
    I state that sending a string from Hercules with Putty the string is received so it must be a problem in the settings.
    Thanks for your kindness.

    IMG: WatchModbus.jpg

     
  • eschwellinger

    eschwellinger - 2019-10-01

    Hi,
    you just need:
    in /etc/CODESYSControl_User.cfg

    [SysCom]
    Linux.Devicefile=/dev/ttyUSB

    nothing else... if this section is in /etc/CODESYSControl.cfg this will be lost on every runtime update... so the correct place to have is /etc/CODESYSControl_User.cfg.

    According the watch window.
    "Undefined" means there is no real or proper response from the slave..!

    BR
    Edwin

     
  • Tiziano - 2019-10-01

    Hi Edwin and thanks for the help,
    in the attached file I see that the baudrate is set to 115200, on all the examples the tests are with 9600, do I have to change the speed on the file?
    Do you think the screen I have attached to you is correct and do I have to set the slaves to 115200?
    I ask because I made a thousand changes on the slave and also on the software to try communication from the PC but does not want to leave and honestly I do not know what else to try.

    IMG: sudo nano etcCODESYSControl_User_cfg .jpg

     
  • eschwellinger

    eschwellinger - 2019-10-02

    Hi,
    you need to change the baudrate here:

    remove the ';' infront of: Linux.Devicefile=/dev/ttyUSB
    BR
    Edwin

    IMG: Baudrate.png

     
  • Tiziano - 2019-10-03

    Hello,
    Without ; as you see in the attachment, it remains with the red triangle, it connects only if I put it and it becomes a green triangle

    IMG: SenzaPuntoEVirgola.jpg

     
  • Tiziano - 2019-10-03

    Hi and thanks Edwin for the kindness in answering me,
    now without the symbol; I managed to do what you see in the attached image, but values that are indecipherable appear, if I change a value, something happens in the registers but the indecipherable values change.
    Thank you for your kindness

    IMG: Immagine2.jpg

     
  • Tiziano - 2019-10-04

    Hi, I've changed the simulator and this works
    Thanks for the answers.

     

Log in to post a comment.