| Valid For | #Open_Serial |
|---|---|
| Applies To | All |
This instruction opens a serial port for use as a MODBUS slave.
#Open_Serial Port(PortNumber) ModbusSlave(
BaudRate,
Parity,
SlaveAddress,
MessageGap
{,
RAMUnprotectedStart,
RAMUnprotectedEnd,
OutputUnprotectedStart,
OutputUnprotectedEnd
}
)
"{}" denotes optional.
| Parameter | Option | Description |
|---|---|---|
| BaudRate | mandatory | The baudrate to be used. Legal values are 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, (230400, 460800)* |
| Parity | mandatory | May be either:
|
| SlaveAddress | mandatory | The ModBus slave address of the SPLat controller. Legal values are 1 through 247. May be changed later via ComDevAddr. |
| MessageGap | mandatory | See description here. Set to 0 for the default. |
| RAMUnprotectedStart | optional | Starting RAM address where master writes are permitted. Any attempt by the master to write before this address will be denied. Default is 255. |
| RAMUnprotectedEnd | optional | Ending RAM address where master writes are permitted. Any attempt by the master to write after this address will be denied. Default is 255. |
| OutputUnprotectedStart | optional | Starting output number where master writes are permitted. Any attempt by the master to write before this address will be denied. Default is 255. |
| OutputUnprotectedEnd | optional | Ending output number where master writes are permitted. Any attempt by the master to write after this address will be denied. Default is 255. |
This hash function sets the serial port up for use with the ModBusRTU slave. Once initiated and configured, the SPLat controller Firmware takes care of all the low level communications activity. ModBus documentation.
You should set these to match the device you are communicating with.
Port() is only available on SPLat 32 bit controllers (black boards).
Note that 32-bit controllers allow use of Modbus on multiple ports. It has been successfully tried with Master mode on one port and Slave mode on another.
*The (high speed baud rates) are only available on SPLat 32 bit controllers (black boards).
RAM and Output write protection is only available on SPLat 32 bit controllers. It provides a mechanism of ensuring a Modbus Master cannot write to RAM or Outputs that the slave wishes to protect. Both RAM and Output protection follow these conditions:
If any part of a Modbus Master WriteMultipleCoils or WriteMultipleRegisters command lies within the protected area, then the whole command will be rejected.
COM0 EQU 252 ;the TTL serial port
#Open_Serial Port( COM0 ) ModbusSlave( 38400, n, 10, 0, 0, 255, 255, 255 )
Use COM0 as a MODBUS Slave port, permit write to all RAM, block writes to all outputs.