Skip to main content
  • Project Name:

    Python Connect to FX5U for "Read" and Write Functions

  • Support PLC:

    FX5U (CPU Ethernet)

  • How to use ?:

    • Step-1 : Configure PLC

          IP   : 192.168.1.100
          PORT : 1025 ( TCP )
          Communiaction Data Code : Binary
      

      Example Image

    • Step-2 : Install rkmcprotocol ( Windows )

      pip install dist/rk_mcprotocal-0.0.2-py3-none-any.whl
      

      Example : C:\Users\Downloads\rkmcprotocol-main>pip install dist/rk_mcprotocal-0.0.2-py3-none-any.whl

    • Step-2 : Install / Uninstall rkmcprotocol ( Raspberr PI OS 64-bit )

      pip install dist/rk_mcprotocal-0.0.2-py3-none-any.whl --break-system-packages
      
      pip uninstall rk_mcprotocal --break-system-packages
      

      Example : rk@raspberrypi:~/rkmcprotocol $ pip install dist/rk_mcprotocal-0.0.2-py3-none-any.whl --break-system-packages

      Example : rk@raspberrypi:~/rkmcprotocol $ pip uninstall rk_mcprotocal --break-system-packages

  • Function Overview:

                                                             FX5U : Default Memory Range
                                                ( User can change memory blocks , so only default settings are introduced )
      Function       Device Code     Length         Device Code     Points    CarrySystem  Max.Points
      -------------------------------------------| --------------------------------------------------
      read_sign_word     D0           960        |      X         X0 ~ X1777      OCT       1024    
                         W0           512        |      Y         Y0 ~ Y1777      OCT       1024    
                         R0           960        |      M         M0 ~ M7679      DEC       7680    
                                                 |      B         B0 ~ B0FF       HEX       256     
      read_sign_Dword    D0           480        |      L         L0 ~ L7679      DEC       7680    
                         W0           256        |      F         F0 ~ F127       DEC       128     
                         R0           480        |
                                                 |      D         D0 ~ D7999      DEC       8000    
      read_bit           X0           1024       |      W         W0 ~ W1FF       HEX       512     
                         Y0           1024       |      R         R0 ~ R32767     DEC       32768   
                         M0           3584       |----------------------------------------------------
                         B0           256        |
                         L0           3584       |
                         F0           128        |
                                                 |
      write_sign_word    D0           960        |
                         W0           512        |
                         R0           960        |
                                                 |
      write_sign_Dword   D0           480        |
                         W0           256        | 
                         R0           480        |
                                                 |
      write_bit          X0           1024       |
                         Y0           1024       |
                         M0           3584       |
                         B0           256        |
                         L0           3584       |
                         F0           128        |                
      -------------------------------------------|
    
  • Commands:

        # Read M0 ~ M3583 , Value : 0 or 1
        print(mc.read_bit(s,headdevice = 'm0' , length = 3584 ))
    
        # Read D0 ~ D959              
        # signed_type=True  Value : -32,768 ~ 32,767 
        # signed_type=False Value :       0 ~ 65,535 
        print(mc.read_sign_word(s,headdevice = 'd0' , length = 960, signed_type=True))
    
        # Read (R0,R1) ~ (R958,R959)  
        # signed_type=True  Value : -2,147,483,648 ~ 2,147,483,647 
        # signed_type=False Value :              0 ~ 4,294,967,295       
        print(mc.read_sign_Dword(s,headdevice = 'r0' , length =480 , signed_type=True))
     
    
        # Write M0 ~ M3583 , Value : 0 or 1
        print(mc.write_bit(s,headdevice = 'm0' , data_list = [1]*3584 )) 
    
        # Write D0 ~ D959              
        # signed_type=True  Value : -32,768 ~ 32,767
        # signed_type=False Value :       0 ~ 65,535 
        print(mc.write_sign_word(s,headdevice = 'd0' , data_list = [-999]*960 ,signed_type =True))
    
        # Write (R0,R1) ~ (R958,R959)  
        # signed_type=True  Value : -2,147,483,648 ~ 2,147,483,647 
        # signed_type=False Value :              0 ~ 4,294,967,295       
        print(mc.write_sign_Dword(s,headdevice = 'r0' , data_list = [9999999]*480 ,signed_type =True))
    
  • Example:

        import rk_mcprotocol as mc
        import time
        
        HOST = '192.168.1.100'
        PORT = 1025
        s = mc.open_socket(HOST,PORT) 
    
        while True :
            st = time.time()
            
            print(mc.read_bit(s,headdevice = 'm0' , length = 3584 ))   
            print(mc.read_sign_word(s,headdevice = 'd0' , length = 960, signed_type=False))
            print(mc.read_sign_Dword(s,headdevice = 'r0' , length =480 , signed_type=True))      
            print(mc.write_bit(s,headdevice = 'm0' , data_list = [1]*3584 )) 
            print(mc.write_sign_word(s,headdevice = 'd0' , data_list = [-999]*960 ,signed_type =True))
            print(mc.write_sign_Dword(s,headdevice = 'r0' , data_list = [9999999]*480 ,signed_type =True))
        
            et = time.time()
            elapsed = et -st
            time.sleep(1)  
            
            print (f' elapsed time = {elapsed}')
    
  • Q&A:

    • Why use Binary instead of ASCII for communication ?

      A : ASCII is slower
      Reference : MELSEC iQ-F FX5 User's Manual (SLMP) Page 12 :
      When using binary codes , the communcation time will decrease since the amount of communication dreduced by approximately half comparing to using ASCII codes 。

    • Does using Threading make it faster ?

      A : No
      Reference : MELSEC iQ-F FX5 User's Manual (SLMP) Page 13 :
      Data communication using SLMP communication is executed in half-duplex communication。
      To access the Ethernet-equipped module, send the next command message after receiving a response message for the preceding command message from the Ethernet-equipped module。
      (Until the receiving of the response message is completed, the next command message cannot be sent.)

Metadata

Release files for rk-mcprotocol 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rk-mcprotocol 0.0.2
File Size Uploaded Provenance
rk_mcprotocol-0.0.2.tar.gz 7.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for rk-mcprotocol 0.0.2
File Interpreter ABI Platform
rk_mcprotocol-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / rk_mcprotocol-0.0.2.tar.gz

Download URL rk_mcprotocol-0.0.2.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fb045f0cc26bfaa834dc4fe752242c5d1b75f0f4f3fdfde9f12bcd842af2611a
BLAKE2b-256 checksum
How to use checksums
af393f037ed425790c8ab55b923596e73b9e32bbbd48d42b5d7e6167e5aa1ae9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / rk_mcprotocol-0.0.2-py3-none-any.whl

Download URL rk_mcprotocol-0.0.2-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88d188296edb6970269a71b5b2be7d87ccc25b09931945ff92c99b5b36a5ac1b
BLAKE2b-256 checksum
How to use checksums
f99790fec077501c22e59fe7a3e2ff0a27fa1ab6d5f39c8bb944df91920f4540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Security for rk-mcprotocol 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page