Example for the RS232 Library
To use the RS232 Communication on Q.station blocks in test.con, it is highly advised to install the latest test.con Version (V6.0.0 Build 07 at the time this document was written).
The RS232 library will not be loaded when creating a new project.
You can find out here, how you can load new libraries into your project…
The screenshot above shows a very simple program which writes an ASCII string by a push of a button through the interface converter connected to USB 1 (Port 100).
In this case the Read block will read this message back and feed this information into the variable “ReadPumpe” by a push of a button.
It is the result of the identical parameters for “StartofTransmission“ and “SOT_Read“. Also the parameters „EndofTransmission“ and „EOT_Read“ are identical.
The baudrate and the start of transmission and end of transmission parameters need to match the specifications of the connected device. Please refer to the manual of your device for these parameters.
The following page contains a list of the standard ASCII symbols.
To read a Q.bloxx Module, the parameter SOT_Read needs to be a 61 for the ASCII symbol “=”.
According to the list above, you can see that the write block sends the following command:
$01Hallo<Carriage Return><Line Feed>
The read block filters out the $ symbol (number 36 in the table) as well as the carriage return (number 13) and the line feed (number 10). The block only passes the message “01Hallo” (without quotes) to its output.
The program above constantly triggers the Read block and writes these contents into a variable (Block number 15).
Description of the different RS232 function blocks
Open port
Accessing the parameter dialogue (right click on the block) opens up the connection settings.
These settings need to be identical to the settings of the connected device (This is regarding the device at the other end of the converter).
A bit input at the lower end of the block will try to open up a port at the specified address (Port 100 for USB1) with the specified baud rate (Bps).
You can access the help menu via right clicking the block to see the port numbers of the different USB connectors and to see the meaning of the status codes.
Close port
When giving a high signal at the bit input at the lower end of the block, the Port Close block closes the specified port.
The state output shows the actual status of the block through a number code.
Refer to the help file to access Information about the different states of the block.
Transmit
When given a high signal at the bit input at the lower left of the block, the Port Write block writes the combination of SOT, Data and EOT to the specified port.
To use more than one ASCII symbol for SOT or EOT you need to connect a vector.
Receive
The Port Read block continuously monitors the specified port and saves the last message, which fits the SOT and EOT settings. A high signal at the bit input at the lower left sends this message to the Data output.
For general information about the function block RS232 Communication on Q.station you can have a look at the function block help Supported baud rates, definition of states and supported port definitions.
A test on 20 Apr 2015 involved the following hardware:
- 2 ISK103 USB to RS485 Interface converters.
- 1 e.bloxx Module
- 1 Q.station
- 1 laptop
The e.bloxx module was connected to the Q.station and the Laptop via two ISK103 adapters.
The test.con example programs were loaded into the Q.station and monitored from the laptop. At the same time the Laptop monitored the RS-485 communication via GanTerm to see the communication and to understand the process.
The e.bloxx module responds to different SOT parameters than the parameters in the examples of this paper.
The string necessary to get the measurement data from the e.bloxx module looks as following:
$01R01/cr/lf
The $ symbol marks a request.
01 after the $ is the address of the module.
R requests an answer with measurement data.
01 is the number of the requested measurement channels.
If all settings are correct, the e.bloxx module will then send an answer, which looks like this:
=0.0000/cr/lf
The “=” symbol stands for the answer, it is the measured value of the channel
cr means Carriage Return.
lf means Line Feed.