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

CODESYS V3 RPi DATABASE .txt file on SD if RPI shut down

alecudr
2015-12-20
2015-12-31
  • alecudr - 2015-12-20

    Hello,
    here I can show example of saving INT values int txt file on Raspberry Pi SD

    I have used pymodbus TCP to create modbusMaster(client) on port 503, with 10 holdt_register and 10 input_registers
    in Cosesys v3 create ModBusSlave TCP also with 10 holdt_register and 10 input_registers,

    if raspberry pi shut down , at start you can get 10 int values from file vars.txt on SD

    IMG: CodeSys_v3Sceen.png

    steps DB master.txt [4.24 KiB]

    WebvisuMBtcpSlave.project [478.19 KiB]

     
  • alecudr - 2015-12-21

    How to make start at boot pymodbus master(client)

    using PuTTY:
    #sudo nano /etc/init.d/autorun

    and paste text from autorun.txt
    Ctrl + x
    y
    Enter

    #sudo chmod 777 /etc/init.d/autorun
    #sudo update-rc.d /etc/init.d/autorun defaults

    #cd /home/pi/Documents/pymodbus/examples/common

    root@raspberrypi:/home/pi/Documents/pymodbus/examples/common# sudo nano test.py

    and paste text from test.py.txt
    Ctrl + x
    y
    Enter

    before ShutDown RaspberryPi Download CodesysProject and try:

    #sudo /etc/init.d/autorun start

    output:

    Starting autorun
    done
    wait to start ethernet , wait for Codesys Slave to start 20sec
    cycle: 1
    Input0: 57648
    Input1: 57649
    Input2: 57650
    Input3: 57651
    Input4: 57652
    Input5: 57653
    Input6: 57654
    Input7: 57655
    Input8: 57656
    Input9: 57657
    line0: 57648
    line1: 57649
    line2: 57650
    line3: 57651
    line4: 57652
    line5: 57653
    line6: 57654
    line7: 57655
    line8: 57656
    line9: 57657
    cycle: 2

    test.py.txt [3.47 KiB]

    autorun.txt [910 Bytes]

     

Log in to post a comment.