OpenCom channel, baudRate, protocol, recvSize, sendSize
|channel||RS232 Channel (1 to 3)|
|recvSize||Receive buffer size (Max. 1024, Do not use a variable)|
|sendSize||Send buffer size (Max. 1024, Do not use a variable)|
This command must be used to enable RS-232 communication.
The Cubloc has 2 or 4 channels for RS-232C communication, depending on the model. Channel 0 is typically used for monitoring and downloading, but it can also be used for RS-232 communication if monitoring is not needed. Downloading will still work regardless.
You may use any value between 2400 to 230400, but we are recommed one of the following values.
2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 76800, 115200, 230400
For the protocol parameter, please refer to the table below:
|Parity||Stop Bit||Bit||# of Bits|
|0||0 = NONE||0=1 Stop Bit||0||0 = 5 bit|
|0||1 = Reserve||1=2 Stop Bits||0||1 = 6 bit|
|1||0 = Even||1||0 = 7 bit|
|1||1 = Odd||1||1 = 8 bit|
OpenCom 1, 19200, 3, 30, 20 'Set to 8-N-1
The send and receive buffer size can be set with the OpenCom command. Each buffer can be as large as 1024 bytes, but be aware that the send and receive buffers consume data memory. So the larger the buffers, the fewer number of variables can be used in the program. Receive buffer sizes from 30 to 100 and send buffer sizes from 30 to 50 will suffice for most programs.
For the CB220 module, pins 1 and 2 can be used for channel 0. Ports 10 and 11 can be used for channel 1.
For the CB280 module, there are dedicated RS-232 ports. For channel 1, there are 2 types of outputs: +/-12V and TTL (+5/0V).
Please make sure to use only one of them at a time.
The following is a table of the 5V TTL signal pins for the CB400/CB405/CB405RT:
|Channel||I/O Port||5V TTL|
The CB400/CB405 has an internal MAX232 that can be used to convert any of the 5V TTL signals to +/- 12V level signals. The following is an example for connecting channel 3:
This allows any +/- 12V RS232 device to connect to TXE and RXE.