Skip to content

Getting started

Start here

Use this page for your first TOYOPUC Computerlink read and write from Python.

Step What you do
1 Install plc-comm-toyopuc.
2 Choose one exact canonical profile string.
3 Connect to 192.168.250.100:1025 over TCP.
4 Read P1-D0000.
5 Write only to a known-safe test word or bit.

Prerequisites

Item Requirement
Python Python 3.10 or later.
PLC network Your PLC is reachable at 192.168.250.100.
TCP port Computerlink TCP examples use 1025.
UDP port Computerlink UDP examples use 1035.
Canonical profile A profile such as toyopuc:plus:extended.

Install

pip install plc-comm-toyopuc

Choose profile

Start with toyopuc:plus:extended only when your PLC is a TOYOPUC-Plus target. Use profiles for the exact list.

from toyopuc import ToyopucPlcProfiles


def main() -> None:
    profile = ToyopucPlcProfiles.from_name("toyopuc:plus:extended")
    print(profile.name)


if __name__ == "__main__":
    main()

First read

import asyncio

from toyopuc import ToyopucConnectionOptions, open_and_connect, read_typed


async def main() -> None:
    options = ToyopucConnectionOptions(
        host="192.168.250.100",
        port=1025,
        transport="tcp",
        plc_profile="toyopuc:plus:extended",
    )

    async with await open_and_connect(options) as client:
        value = await read_typed(client, "P1-D0000", "U")
        print(f"P1-D0000 = {value}")


asyncio.run(main())

First write

Use a known-safe test word. Do not write to production outputs or motion-related registers while testing.

import asyncio

from toyopuc import ToyopucConnectionOptions, open_and_connect, read_typed, write_typed


async def main() -> None:
    options = ToyopucConnectionOptions(
        host="192.168.250.100",
        port=1025,
        transport="tcp",
        plc_profile="toyopuc:plus:extended",
    )

    async with await open_and_connect(options) as client:
        original = await read_typed(client, "P1-D0001", "U")
        try:
            await write_typed(client, "P1-D0001", "U", 1234)
            value = await read_typed(client, "P1-D0001", "U")
            print(f"P1-D0001 = {value}")
        finally:
            await write_typed(client, "P1-D0001", "U", original)


asyncio.run(main())

Confirm success

Check Expected result
Connection No timeout from open_and_connect.
Read P1-D0000 returns one integer value.
Write The readback from P1-D0001 matches your test value.
Address text Basic families use P1-, P2-, or P3- prefixes.

If it does not work

Use the shared Computerlink Troubleshooting & Codes page for connection, addressing, write, relay, and PLC error-code checks.

Symptom Check
Timeout Confirm host 192.168.250.100, TCP port 1025, and PLC network settings.
Profile error Use only exact canonical strings from profiles.
Address error Use P1-D0000, not D0000, for basic area families.
Dword reads look wrong Use P1-D0100:D or dtype "D"; P1-D0100.D means bit 13.
FR work-area write does not persist Call commit_fr() separately with the first address of the intended FR block.