Skip to main content

Python connect to PLC LS

Project description

Python connect to PLC LS by TCP XGT Server

LS protocol(LS electric Communication Protocol) implementation by Python. LS protocol enables you to operate PLC from computer.

import library

from PyXGT.LS import plc_ls

connect to PLC

conn = plc_ls("192.168.1.10",2004) #PLC LS IP and port: 2004 (TCP XGT server)

write device

val = conn.command("XGB", "write", "bit", "M70","1")# Write ON to Bit M70

val = conn.command("XGB", "write", "bit", "M70") or conn.command("XGB", "write", "bit", "M70","0") # Write OFF to Bit M70

val = conn.command("XGB", "write", "byte", "D100","20") # Write 20 to 100th Byte(int8) D50( beacause 1 D= int16)

val = conn.command("XGB", "write", "word", "D100","1") # write 1 to Word(int16) D100

val = conn.command("XGB", "write", "dword", "D50","1") # Write 1 to 50th doubleWord(int32)( D100-D101)

val = conn.command("XGB", "write", "lword", "D25","1") # Write 1 to 25th long(int64) ( D100-D101-d102-d103)

read device

val = conn.command("XGB", "read", "bit", "M70") # read Bit M70 return [1] or [0]

val = conn.command("XGB", "read", "byte", "D100") # read 100th Byte(int8) D50( beacause 1 D= int16)

val = conn.command("XGB", "read", "word", "D100) # read Word(int16) D100

val = conn.command("XGB", "read", "dword", "D50) # read 50th doubleWord(int32)( D100-D101)

val = conn.command("XGB", "read", "lword", "D25) # read 25th long(int64) ( D100-D101-d102-d103)

write multi device

val = conn.command("XGB", "write", "bit", "M70,M71,M72","1,0,1")# Write ON to Bit M70, OFF M71 and ON M72

val = conn.command("XGB", "write", "bit", "M70,M71,M72") # write off all 3 bits M70,M71,M72

.......................

read multi device

val = conn.command("XGB", "read", "bit", "M70,M71,M72") # read 3 Bits M70,M71,M72 return [1,0,1]

.............................................

Project details


Release history Release notifications | RSS feed

This version

1.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyXGT-1.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyXGT-1.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file PyXGT-1.1.tar.gz.

File metadata

  • Download URL: PyXGT-1.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for PyXGT-1.1.tar.gz
Algorithm Hash digest
SHA256 d606a00dd52c2e27252d7975f9f94497f7ca3497784ff05dae9ea79f77cc5940
MD5 8858523758703fc06d0a160f8e4d68ea
BLAKE2b-256 dc53a000257f44c9f7becceefe5e36acfe32b5b77e9da52e89c4fe332b6bd08b

See more details on using hashes here.

File details

Details for the file PyXGT-1.1-py3-none-any.whl.

File metadata

  • Download URL: PyXGT-1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for PyXGT-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eca215f9285703989318578ec31219cca7d9241d6ec866ed42c8ae782be95583
MD5 4cb937b6b38f9943c3a31ea0bed254f8
BLAKE2b-256 39d02f69e3ab69caac13bb5f4d8ed234ccbf9e513c47b720d134bc5fd6fc933b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page