MB Serial Slave Demon.vi

Modbus LabVIEW VI

MB Serial Slave Demon.vi

The serial slave demon constantly scans the serial port for commands from the master. When it detects a command from the master, it updates the memory tables with data and also responds to the master's query for data. You must use the slave API to access the data in the tables.

Serial Port Setup (RT Only) is required to configure the serial port on the RT system (if running Pharlap RT OS).
VISA resource name out is the resource to which a VISA session is opened and its class. The class matches that of the VISA resource name input. For more information about VISA resource names, refer to the NI-VISA Help.
Baud Rate is the rate of transmission. The default is 9600.
Data Bits is the number of bits in the incoming data. The value of data bits is between 5 and 8. The default value is 8.
Parity specifies the parity used for every frame to be transmitted or received. This input accepts the following values:
0 No parity (default)
1 Odd parity
2 Even parity
3 Mark parity
4 Space parity
Stop Bits specifies the number of stop bits used to indicate the end of a frame. This input accepts the following values:
10 1 stop bit
15 1.5 stop bits
20 2 stop bits
Flow Control sets the type of control used by the transfer mechanism. This input accepts the following values:
0 None (default)—The transfer mechanism does not use flow control. Buffers on both sides of the connection are assumed to be large enough to hold all data transferred.
1 XON/XOFF—The transfer mechanism uses the XON and XOFF characters to perform flow control. The transfer mechanism controls input flow by sending XOFF when the receive buffer is nearly full, and it controls the output flow by suspending transmission when XOFF is received.
2 RTS/CTS—The transfer mechanism uses the RTS output signal and the CTS input signal to perform flow control. The transfer mechanism controls input flow by unasserting the RTS signal when the receive buffer is nearly full, and it controls output flow by suspending the transmission when the CTS signal is unasserted.
3 XON/XOFF and RTS/CTS—The transfer mechanism uses the XON and XOFF characters and the RTS output signal and CTS input signal to perform flow control. The transfer mechanism controls input flow by sending XOFF and unasserting the RTS signal when the receive buffer is nearly full, and it controls the output flow by suspending transmission when XOFF is received and the CTS is unasserted.
4 DTR/DSR—The transfer mechanism uses the DTR output signal and the DSR input signal to perform flow control. The transfer mechanism controls input flow by unasserting the DTR signal when the receive buffer is nearly full, and it controls output flow by suspending the transmission when the DSR signal is unasserted.
5 XON/XOFF and DTR/DSR—The transfer mechanism uses the XON and XOFF characters and the DTR output signal and DSR input signal to perform flow control. The transfer mechanism controls input flow by sending XOFF and unasserting the DTR signal when the receive buffer is nearly full, and it controls the output flow by suspending transmission when XOFF is received and the DSR signal is unasserted.
Termination Char calls for termination of the read operation. The read operation terminates when the Termination Char is read from the serial device. 0xA is the hex equivalent of a linefeed character (\n). Change the termination char to 0xD for message strings that terminate with a carriage return (\r).
Enable Termination Char prepares the serial device to recognize termination char. If TRUE (default), the port is set to recognize the termination character. If FALSE, the serial device does not recognize the termination char.
Timeout specifies the maximum time period, in milliseconds, that the VI waits for the slave's response before throwing an error.
Slave Address represents the address of the slave on the MODBUS network. The masters use this address to communicate with the correct slave.
VISA resource names specifies a array of all the resources to be opened and used to connect to masters. For example, you can use two serial ports to connect a slave to multiple masters. Because this is an array of strings, you can use a VISA property node to extract the VISA resource name from a VISA Session control. Refer to MB Serial Slave Example.vi for an example.
Modes selects which type of MODBUS frame to use. This is an array of clusters. Each array location corresponds to the mode setting for the corresponding VISA session in the VISA resource names array.

RTU
Data is represented in binary format (8 data bits).

ASCII
Data is represented in ASCII, so it is human readable (7 data bits).

Timeouts specifies the maximum time period, in milliseconds, that the slave waits for the master's response before throwing an error. Each location in the array represents the setting for the corresponding VISA resource from the VISA resource names array.
Period represents the duration of a MODBUS cycle, or how often the slave scans the serial ports.