Internal documentation for hardware testing of MinimalModbus using DTB4824¶
Usage:
$ python3 test_deltaDTB4824.py -h
usage: test_deltaDTB4824.py [-h] [-a] [-r] [-b BAUD] [-d DEVICE]
Run tests with a Delta DTB4824 instrument
options:
-h, --help show this help message and exit
-a Use ASCII mode
-r Use RTU mode (default). Overrides -a flag.
-b BAUD Baud rate. Defaults to 38400 bit/s
-d DEVICE Device name. Defaults to "/dev/ttyUSB0"
Hardware testing of MinimalModbus using the Delta DTB temperature controller.
For use with Delta DTB4824VR.
Recommended test sequence¶
- Run the tests under Linux, Windows and Mac OS
- Use 2400 bps and 38400 bps
- Use Modbus ASCII and Modbus RTU
Sequence:
- 38400 bps RTU
- 38400 bps ASCII
- 2400 bps ASCII
- 2400 bps RTU
Settings in the temperature controller¶
To change the settings on the temperature controller panel, hold the SET button for more than 3 seconds. Use the ‘loop arrow’ button for moving to next parameter. Change the value with the up and down arrows, and confirm using the SET button. Press SET again to exit setting mode.
Use these setting values in the temperature controller:
- SP 1 (Decimal point position)
- CoSH on (ON: communication write-in enabled)
- C-SL rtu (use RTU or ASCII)
- C-no 1 (Slave number)
- BPS (see the DEFAULT_BAUDRATE setting below, or the command line argument)
- LEN 8
- PRTY None
- Stop 1
When running, the setpoint is seen on the rightmost part of the display.
USB-to-RS485 converter¶
BOB-09822 USB to RS-485 Converter:
- https://www.sparkfun.com/products/9822
- SP3485 RS-485 transceiver
- FT232RL USB UART IC
- FT232RL pin2: RE^
- FT232RL pin3: DE
DTB4824 terminal | USB-RS485 terminal | Description |
---|---|---|
DATA+ | A | Positive at idle |
DATA- | B | Negative at idle |
Sometimes after changing the baud rate, there is no communication with the temperature controller. Reset the FTDI chip by unplugging and replugging the USB-to-RS485 converter.
Function codes for DTB4824¶
From “DTB Series Temperature Controller Instruction Sheet”:
- 02H to read the bits data (Max. 16 bits).
- 03H to read the contents of register (Max. 8 words).
- 05H to write 1 (one) bit into register.
- 06H to write 1 (one) word into register.
Manual testing in interactive mode (at the Python prompt)¶
Use a setting of 19200 bps, RTU mode and slave addess 1 for the DTB4824. Run these commands:
import minimalmodbus
# Adjust if necessary.
instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1, debug=True)
instrument.read_register(4143) # Read firmware version (address in hex is 0x102F)
-
test_deltaDTB4824.
_box
(description: Optional[str, None] = None, value: Any = None) → None[source]¶ Print a single line in a box.
-
test_deltaDTB4824.
show_current_values
(instr: minimalmodbus.Instrument) → None[source]¶ Read current values via Modbus.
-
test_deltaDTB4824.
verify_value_for_register
(instr: minimalmodbus.Instrument, value: int) → None[source]¶ Write and read back a value to a register, and validate result.
Also read back several registers.
- Args:
- instr: Instrument instance
- value: Value to be written
-
test_deltaDTB4824.
verify_state_for_bits
(instr: minimalmodbus.Instrument, state: int) → None[source]¶ Write and read back a value to a bit, and validate result.
Also read back several bits.
- Args:
- instr: Instrument instance
- state: Value to be written (0 or 1)
-
test_deltaDTB4824.
verify_readonly_register
(instr: minimalmodbus.Instrument) → None[source]¶ Verify that we detect the slave reported error when we write to an read-only register.
-
test_deltaDTB4824.
verify_two_instrument_instances
(instr: minimalmodbus.Instrument, portname: str, mode: str, baudrate: int) → None[source]¶