Modbus – Relaisbord
Hardware
BESTELLEN
Wellicht ken je deze boards wel voor de microcontroller, daar worden ze geschakeld via een hoog/laag signaal, dit board is geschikt om via modbus RS485 aan te sturen.
Technische Specificaties (ENG)
- DC 12V power supply (voltage range 9-13V )
- Standby current (all relays closed) 12MA, 1 relay open 40MA, 2 relays open 67MA, 3 relays open 95MA,4 relays open 121MA,5 relays open 147MA,6 relays open 173MA, 7 relays open 198MA,8 relays open 223MA
- “open” “close” “Momentary” “Self-locking” “Interlock” “Delay” 6 Commands
- MODBUS RTU command
- Under the “Delay” command ,the maximum delay is 255 seconds
- MODBUS commands can be made serial HyperTerminal (serial assistant) OR “Modbus Poll” Enter;
- Under the MODBUS command mode, it can support up to 64 devices in parallel
- Maximum load: 10A / 250VAC, 10A / 125VAC, 10A / 30VDC, 10A / 28VDC, 10A / 12VDC
Standaard modbus instellingen
- 9600 Band
- 8 Data bits
- None Parity
- 1 Stop Bit
Instellen van het mobus adres:
Het instellen van een adres van dit relaisbord (4 kanaals) gebeurt met DIP switch A0-4 (5 bit), hiermee zijn 32 adressen mogelijk:
Met DIP 6 (A5) stel je het modbus/AT commando instelling in
- A5 uit = AT commando
- A5 aan = Modbus RTU
Let op: Bij gebruik van het 8x relais bord hebben wij geconstateerd dat DIP 6 (A5) naar beneden (uit) moet staan voor modbus!
Mobus registers
MODBUS 06 Command (Control command ,HEX):
Bytes Number | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
MODBUS Definitions | Slave ID | Function | Address | Data | CRC Check | |||
Function | Device Address | Function | Channel number | Command | Delay time | CRC Check | ||
Open | 0x00-0x2F | 0x06 | 0x0001-
0x0008 |
0x01 | 0x00 | 2Bytes CRC | ||
Close | 0x00-0x2F | 0x06 | 0x0001-
0x0008 |
0x02 | 0x00 | 2Bytes CRC | ||
Toggle (Self-locking) | 0x00-0x2F | 0x06 | 0x0001-
0x0008 |
0x03 | 0x00 | 2Bytes CRC | ||
Latch (Inter-locking) | 0x00-0x2F | 0x06 | 0x0001-
0x0008 |
0x04 | 0x00 | 2Bytes CRC | ||
Momentary (Non-locking) | 0x00-0x2F | 0x06 | 0x0001-
0x0008 |
0x05 | 0x00 | 2Bytes CRC | ||
Delay | 0x00-0x2F | 0x06 | 0x0001-
0x0008 |
0x06 | 0x00-0xff | 2Bytes CRC |
Remarks:
- Momentary mode, delay time is 1 seconds
- Delay mode, delay time is 0-255 seconds
Return command:
- Command is active, return to send commands; instruction is invalid no return.
MODBUS 03 Command (Read status command ,HEX):
Bytes Number | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
MODBUS Definitions | Slave ID | Function | Address | Data | CRC Check | |||
Function | Device Address | Function | Starting register address | Register length | CRC Check | |||
Read Channel 1 State | 0x00-0x2F | 0x03 | 0x0001
|
0x0001
|
||||
Read Channel 2 State | 0x00-0x2F | 0x03 | 0x0002 | 0x0001
|
||||
Read 2 consecutive channels status | 0x00-0x2F | 0x03 | 0x0001-0x0003 | 0x0002
|
||||
Read 3 consecutive channels status | 0x00-0x2F | 0x03 | 0x0001-0x0002 | 0x0003
|
||||
Read all 8 channels status | 0x00-0x2F | 0x03 | 0x0001 | 0x0008
|
Read status command returns (function code 03, HEX format):
Bytes length | 1 | 1 | 1 | 2 | |
MODBUS Definitions | Slave ID | Function | data length | data | CRC16 Check |
Function | Device Address | Function | data length | Relay state
0x0001 open 0x0000 close |
CRC16 Check |
Channel 1
open |
0x00-0x1F | 0x03 | 0x02
|
0x0001 | |
Channel 1
close |
0x00-0x1F | 0x03 | 0x02
|
0x0000 | |
Channel 2
open |
0x00-0x1F | 0x03 | 0x02
|
0x0001 | |
Channel 2
close |
0x00-0x1F | 0x03 | 0x02
|
0x0000 | |
Channel 1 open
Channel 2 open |
0x00-0x1F | 0x03 | 0x04
|
0x0001 0x0001 | |
Channel 1 open
Channel 2 close |
0x00-0x1F | 0x03 | 0x04
|
0x0001 0x0000 | |
Channel 1 close
Channel 2 open |
0x00-0x1F | 0x03 | 0x04
|
0x0000 0x0001 | |
Channel 1 close
Channel 2 close |
0x00-0x1F | 0x03 | 0x04
|
0x0000 0x0000 |
Voorbeeld schakelen (uit de handleiding)
Examples (Slave ID is 1,DIP switch state)
Channel 1 Open: 01 06 00 01 01 00 D9 9A
Channel 1 Close: 01 06 00 01 02 00 D9 6A
Channel 1 Toggle: 01 06 00 01 03 00 D8 FA
Channel 1 Latch: 01 06 00 01 04 00 DA CA
Channel 1 Momentary: 01 06 00 01 05 00 DB 5A
Channel 1 Delay 10 seconds : 01 06 00 01 06 0A 5B AD
Channel 1 Delay 100 seconds: 01 06 00 01 06 64 DA 41
Channel 2 Open: 01 06 00 02 01 00 29 9A
Channel 2 Close: 01 06 00 02 02 00 29 6A
Channel 2 Toggle: 01 06 00 02 03 00 28 FA
Channel 2 Latch: 01 06 00 02 04 00 2A CA
Channel 2 Momentary: 01 06 00 02 05 00 2B 5A
Channel 2 Delay 10 seconds: 01 06 00 02 06 0A AB AD
Channel 2 Delay 100 seconds: 01 06 00 02 06 64 2A 41
Read state (assuming that the channel 1 is open, the channel 2 is close).
Read channel 1 state: 01 03 00 01 00 01 D5 CA
Return open: 01 03 02 00 01 79 84
Read channel 2 state: 01 03 00 02 00 01 25 CA
Return close: 01 03 02 00 00 B8 44
Read channel 1 and channel 2 state: 01 03 00 01 00 02 95 CB
Return channel open and channel 2 close: 01 03 04 00 01 00 00 AB F3
Voorbeeld schakelen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#!/usr/bin/env python # Modbus aansturen # Apparaat: Relaisbord # # Script gemaakt door S. Ebeltjes (domoticx.nl) import pymodbus import serial from pymodbus.pdu import ModbusRequest from pymodbus.client.sync import ModbusSerialClient as ModbusClient #initialize a serial RTU client instance from pymodbus.transaction import ModbusRtuFramer method = "rtu" port = "/dev/ttyUSB0" baudrate = 9600 stopbits = 1 bytesize = 8 parity = "N" timeout = 1 retries = 2 try: client = ModbusClient(method = method, port = port, stopbits = stopbits, bytesize = bytesize, parity = parity, baudrate = baudrate, timeout = timeout, retries = retries) connection = client.connect() except: print "Modbus connectie error / Relais bord" def aan1(appid): try: data = client.write_register(0x0001, 0x0100, unit=appid) except: print "Modbus register error (relais)" return 0 def uit1(appid): try: data = client.write_register(0x0001, 0x0200, unit=appid) except: print "Modbus register error (relais)" return 0 # Schakelen aan1(1) #SlaveID 1, Relais 1 aan #uit1(1) #SlaveID 1, Relais 1 uit |
Voorbeeld schakelen in Python 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#!/usr/bin/env python # Modbus aansturen met Python 3 # Apparaat: Relaisbord # # Script gemaakt door S. Ebeltjes (domoticx.nl) from pymodbus3.client.sync import ModbusSerialClient method = "rtu" port = "/dev/ttyUSB0" baudrate = 9600 stopbits = 1 bytesize = 8 parity = "N" timeout = 1 retries = 2 try: client = ModbusSerialClient(method = method, port = port, stopbits = stopbits, bytesize = bytesize, parity = parity, baudrate = baudrate, timeout = timeout, retries = retries) except: print ("Modbus connectie error / Relais bord") def aan1(appid): try: data = client.write_register(0x0001, 0x0100, unit=appid) except: print ("Modbus register error (relais)") return 0 def uit1(appid): try: data = client.write_register(0x0001, 0x0200, unit=appid) except: print ("Modbus register error (relais)") return 0 # Schakelen aan1(1) #SlaveID 1, Relais 1 aan #uit1(1) #SlaveID 1, Relais 1 uit |
[#/handleidingen/modbus_relaisbord” ]