Code
#include <SoftwareSerial.h>
const int txPin = 1; // TX pin on the MAX3232 module
const int rxPin = 0; // RX pin on the MAX3232 module
SoftwareSerial mySerial(txPin, rxPin);
void setup() {
Serial.begin(38400); // Set the baud rate to 38400
mySerial.begin(38400); // Set the baud rate for the MAX3232 module}
void loop() { if (mySerial.available() > 0) {
char c = mySerial.read();
Serial.write(c); }}
Hardware used
-Arduino Mega2560
-Rs232 to TTL module using Max3232(Tx on pin 1,Rx on pin 0, vcc 3.5)
-IDE 1.8.19
-1M rs232 cable from master to rs232to ttl converter module
Data Format and required set up
RS-232 communication settings
The serial interface is according to RS-232C and fulfills the following requirements:
Baud rate: 38 400 ,Data length:8 bits ,Stop bits: 1,Parity: Even ,Data format:Binary ,Handshake: None
Command/Response format
SCI commands are always in ASCII format, unless stated otherwise. The response can be in either ASCII or binary format, as specified per command.
solated RS-232 serial ports. 9 pin D-Sub female connector: output from master
- – ,2. RXD_ISO ,3. TXD_ISO ,4. DTR_ISO ,5. GND_ISO ,6. – ,7. RTS_ISO ,8. – ,9. –
Note that DTR_ISO and RTS_ISO are permanetly high (active).
*Signal Handshake protocol *
The following control characters are used, in order to control the data flow from the SCI:
= 0416 :End of transmission. General character to be used to define the end of an instruction or end of an ASCII response from the SCI. Note: An ASCII string is not null terminated.
= 1B16 :Issued by the computer to interrupt the data transfer from the SCI. Upon reception of ESC, SCI aborts transmission and any running command, e.g. RADC, and sends the error message “Command aborted by ESC”. Transmission is restarted upon reception of the next valid command.
:Calculated checksum. Checksum is sent either as one byte or two bytes; one byte in binary answer or two bytes in ASCII answer.
Performance requirements
The SCI needs to receive any character within set timeout, otherwise the previous characters are ignored.
Support for different SCI Protocol versions
The SCI provides a mechanism for selecting between different protocol versions. The following commands are
used:
• Read Highest Protocol Version, RHVE: Requests information about the highest available SCI Protocol version
for the current System SW version.
• Read Protocol Version, RPVE: Requests information about the SCI Protocol version currently in use.
• Set Protocol Version, SPVE: Configures SCI to use a specific Protocol version.
The lowest selectable protocol version is SCI Protocol version 0001. This protocol version is selected at startup
and when the RCTY command is received.
The difference between protocol versions are that:
• Existing channels can be deleted
• New channels can be added
• The configuration, or switch parameters, for existing channels can be changed
• New commands can be added.
Design/compatibility considerations for driver developers
Command RCCO, shall be used to get the list with actual channels and corresponding
configurations.Use code tags to format code for the forum