Readers will learn about serial scripting with the Serial mPort device. Several example scripts are listed later in the article.
"Scripts" can be configured to be sent out the mPort Serial port. The scripts are "1-way", meaning the specified script is simply transmitted out the serial port and data is not received and interpreted (it does not behave like "Expect" scripting).
Multiple commands are separated by new-lines, and a 10 millisecond delay is inserted between multiple messages.
The default data format is ASCII. If the script begins with the string "MODBUSRTU " (MODBUS in all capitals plus a single space character), then the data is treated as a Modbus RTU message and the appropriate Modbus CRC is appended to the message before transmitting.
Scripts are sent from the mFi Controller to the mPort Serial using Telnet, so the mFi Controller should be inside the firewall (or if external to the firewall, the appropriate ports must be opened).
Some simple examples follow; please see your connected device's documentation for further information.
The ADAM-4021 takes ASCII commands and outputs the specified voltage.
#AA(data)<cr> AA = address = 01 (data) = 000 to FFF
The Testequity heat chamber has a serial port that can receive ASCII commands, such as commands to set the target temperature.
|Message (including CRC)||Target Temperature|
The Temco T3-4A0 is a Modbus device with 4 analog outputs (0-10v) and 8 relays. Commands can be sent from the mPort Serial to set analog voltage levels or to turn relays on or off.
byte1: address (254 is default) byte2: command (06 = write register) byte3-4: address (AO1 = 108 => 0x006C, … , AO4 = 111) bytes5-6: value (5v = 2048 => 0x0800) bytes7-8: CRC
|Message (CRC added by mPort)||Voltage|
Multiple messages can be specified in a single script. In this example, the analog output of the T3-4A0 was tied to the input of a 0-10v dimmable fluorescent ballast. A time delay is added by the mPort Serial between each message, causing the light to gradually move to the target brightness.