Files
ch32v003-ext-board/README.md

49 lines
1.2 KiB
Markdown

# CH32-16-CH-EXT
A simple CH32V003-based extension board providing 16 outputs (2x 74HC595), primarily designed for controlling [Chinese 16-relay modules](https://www.uctronics.com/download/Amazon/U604302_print.pdf) ([archive](https://web.archive.org/web/20220709045418/https://www.uctronics.com/download/Amazon/U604302_print.pdf)) over RS485. Uses 64-byte internal flash page for state persistence.
KiCad hardware design files are in the `hw` directory.
![photo](img/ch32_extension_photo.jpg)
![render](img/ch32_extension.png)
## comm protocol
uses Modbus RTU protocol over RS485
### Config
```
Baud Rate: 9600
Data Bits: 8
Stop Bits: 1
Parity: None
```
### Modbus
- Function Code: 0x06 (Write Single Register)
- Default Slave Address: 0x01
- Register Map:
- Register 0x0000: Output Control Register (16 bits for controlling 16 relays)
### Outputs
Each bit in the control register corresponds to one output:
- Bit 0 controls Output 1
- Bit 1 controls Output 2
- etc.
### Msg
```
Byte 0: Slave Address (0x01)
Byte 1: Function Code (0x06)
Byte 2: Register Address High (0x00)
Byte 3: Register Address Low (0x00)
Byte 4: Data High Byte
Byte 5: Data Low Byte
Byte 6: CRC Low Byte
Byte 7: CRC High Byte
```