# How to connect a Cognex camera to a Doosan robot over TCP

**URL:** <https://www.robotexchange.io/t/how-to-connect-a-cognex-camera-to-a-doosan-robot-over-tcp/4687>\
**Category:** 💡 How-to\
**Tags:** Cognex-camera, Doosan-robot\
**Created:** [September 2, 2026, 12:16am UTC](https://www.robotexchange.io/t/how-to-connect-a-cognex-camera-to-a-doosan-robot-over-tcp/4687 "2026-09-02T00:16:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thijs](https://www.robotexchange.io/user_avatar/www.robotexchange.io/thijs/32/4_2.png) [@thijs](https://www.robotexchange.io/u/thijs)\
**Post date:** [September 2, 2026, 12:16am UTC](https://www.robotexchange.io/t/how-to-connect-a-cognex-camera-to-a-doosan-robot-over-tcp/4687/1 "2026-09-02T00:16:33Z")

</div>

_Based on contributions by How-to, salvacmp._

Doosan robots can read results from a Cognex vision system directly over a TCP socket, without any extra hardware — the robot connects to the camera’s native command interface, logs in, triggers a capture, and reads back the values from a cell in the camera’s job.

## What you need

- A Doosan robot
- A Cognex camera, configured with a job that writes results to a table cell
- The camera set to **Online Mode** (triggering only works in this mode)
- The Doosan and the Cognex camera on the same IP subnet

## Steps

### 1. Configure the connection parameters

```python
port = 10000
ip = "192.168.137.10"

```

> Set `ip` to your camera’s actual IP address, and make sure the Doosan controller is on the same subnet.

### 2. Open a TCP connection to the camera

```python
socket = client_socket_open(ip, port)

```

### 3. Log in

After connecting, the camera sends a welcome message and then asks for a username and password:

```python
receive = client_socket_read(socket, -1, -1)[1].decode()
client_socket_write(socket, "admin\r\n".encode()) # username + carriage return, newline

### asked for a password ###
receive = client_socket_read(socket, -1, -1)[1].decode()
client_socket_write(socket, "\r\n".encode()) # empty password + carriage return, newline

```

A successful login returns a logged-in message:

```python
receive = client_socket_read(socket, -1, -1)[1].decode()

```

### 4. Trigger the camera

This only works if the camera is in **Online Mode**.

```python
client_socket_write(socket, "SE8\r\n".encode())
wait(3)

triggerstatus = client_socket_read(socket, -1, -1)[1].decode()[:-2]

if triggerstatus != "1":
    tp_log("Trigger failed: " + str(triggerstatus))
    return 0

```

### 5. Read a cell value

Cell names follow the pattern `GVxyyy`: `x` is the column letter, `yyy` is the row number. For example `GVC019` reads cell **C19**.

```python
cel_data = "GVC019"
client_socket_write(socket, (cel_data + "\r\n").encode())
getvaluestatus, rec, _empty = str(client_socket_read(socket, -1, -1)[1].decode()).split("\r\n")

if getvaluestatus == "1":
    rec = str(rec).split(",")
else:
    tp_log("GetValue failed: " + str(getvaluestatus))

```

### 6. Close the connection

```python
client_socket_close(socket)

```

## Full code

Combining the steps above into one reusable function:

```python
def get_data_from_cognex(cel_data):
    ### configuration, adjust as needed ###
    port = 10000
    ip = "192.168.137.10"

    ### connect to the camera ###
    socket = client_socket_open(ip, port)

    ### camera sends a welcome message and asks for username and password ###
    receive = client_socket_read(socket, -1, -1)[1].decode()
    client_socket_write(socket, "admin\r\n".encode()) # username + carriage return, newline

    ### asked for a password ###
    receive = client_socket_read(socket, -1, -1)[1].decode()
    client_socket_write(socket, "\r\n".encode()) # empty password + carriage return, newline

    ### logged-in message ###
    receive = client_socket_read(socket, -1, -1)[1].decode()

    ### trigger the camera, only works in Online Mode ###
    client_socket_write(socket, "SE8\r\n".encode())
    wait(3)

    triggerstatus = client_socket_read(socket, -1, -1)[1].decode()[:-2]

    if triggerstatus != "1":
        tp_log("Trigger failed: " + str(triggerstatus))
        return 0

    wait(1) # extra safety margin, can likely be removed

    client_socket_write(socket, (cel_data + "\r\n").encode())
    getvaluestatus, rec, _empty = str(client_socket_read(socket, -1, -1)[1].decode()).split("\r\n")

    if getvaluestatus == "1":
        rec = str(rec).split(",")
    else:
        tp_log("GetValue failed: " + str(getvaluestatus))

    client_socket_close(socket)

    return rec

```

| Input | Type | Description |
| --- | --- | --- |
| cel\_data | string | The `GVxyyy` get-value command. `x` is the column letter, `yyy` is the row number of the cell to read — e.g. `GVC013` reads cell C13. |

This returns a list of the comma-separated values in that cell. It’s commonly used to get an object’s X/Y position, rotation, and an ID number from the camera in one call. An empty result (`['']`) means the camera found no valid detection.

### 7. Use the result, and handle no-detection

```python
X_Y_R = get_data_from_cognex('GVC019')
if X_Y_R == ['']:
    tp_popup('No mold detected, please place mold in the detectable square', pm_type=DR_PM_MESSAGE, button_type=1)
    return 0

pos_x = float(X_Y_R[0])
pos_y = float(X_Y_R[1])
pos_r = float(X_Y_R[2])
mold_number = int(X_Y_R[3])

```

See [How to show pop-up messages on the Doosan teach pendant with tp\_popup](https://www.robotexchange.io/t/how-to-show-pop-up-messages-on-the-doosan-teach-pendant-with-tp-popup/4681) for more on `tp_popup()`.

## Troubleshooting

- **No response after connecting:** confirm the robot and camera are on the same IP subnet, and that `ip`/`port` match the camera’s actual settings.
- **Trigger fails:** the camera must be in **Online Mode** — it won’t respond to the `SE8` trigger command otherwise.
- **`GetValue failed`:** check that the job on the camera actually writes a value to the cell you’re reading, and that the cell reference (e.g. `GVC019`) is correct.

## Related

- [How to show pop-up messages on the Doosan teach pendant with tp\_popup](https://www.robotexchange.io/t/how-to-show-pop-up-messages-on-the-doosan-teach-pendant-with-tp-popup/4681)

* * *

_Rewritten and consolidated (Sept 2026) from the original student how-to’s: [Connect a Cognex camera to a Doosan robot](https://www.robotexchange.io/t/connect-a-cognex-camera-to-a-doosan-robot/2945), [How to Connect a Cognex camera to a Doosan robot](https://www.robotexchange.io/t/how-to-connect-a-cognex-camera-to-a-doosan-robot/3285)._
