+++
title = "Modbus - PID Control"
weight = 5
categories = "Modbus"
+++

# PID Controllers

The PID controller target temperatures can be set as follows:

- PID 1 : Address 10
- PID 2 : Address 11
- PID 3 : Address 12

## Set Target temperature on PID 1 to 100Degc

- **Address** : 10 (```0x10```)
- **Function** : 6 (WRITE_REGISTER)
- **Values** : 0 - Max Temperature (280)

**TCP Sequence**

```c
d2 8d 00 00 00 06 01 06 00 0A 00 10
                   +  +  +    +
                   |  |  |    |
                   |  |  |    +----> Value (2 bytes) = 00 10 (16 Degc)
                   |  |  |
                   |  |  +----> Address (2 bytes) = 20 or 0x0014
                   |  |
                   |  +--> Function Code (Always 6)
                   |
                   +--> Slave - ID (Always 1)
```

## Set Target temperature on PID 2to 100Degc

- **Address** : 11 (```0x0B```)
- **Function** : 6 (WRITE_REGISTER)
- **Values** : 0 - Max Temperature (300)

**TCP Sequence** 

```c
d2 8d 00 00 00 06 01 06 00 0B 00 10
                   +  +  +    +
                   |  |  |    |
                   |  |  |    +----> Value (2 bytes) = 00 64 (100 Degc)
                   |  |  |
                   |  |  +----> Address (2 bytes) = 18 or 0x000B
                   |  |
                   |  +--> Function Code (Always 6)
                   |
                   +--> Slave - ID (Always 1)
```


## Set Target temperature on PID 3 to 100Degc

- **Address** : 12 (```0x0C```)
- **Function** : 6 (WRITE_REGISTER)
- **Values** : 0 - Max Temperature (300)

**TCP Sequence**

```c
d2 8d 00 00 00 06 01 06 00 0C 00 10
                   +  +  +    +
                   |  |  |    |
                   |  |  |    +----> Value (2 bytes) = 00 10 (16 Degc)
                   |  |  |
                   |  |  +----> Address (2 bytes) = 0C or 0x000C
                   |  |
                   |  +--> Function Code (Always 6)
                   |
                   +--> Slave - ID (Always 1)
```

### Testing with Modbus Poll

![](setPID100.JPG)

### Testing with Hercules

![](setPID100_TCP.JPG)
