I'm new to this, so thank you for your patience!
I'm trying to make an old system talk to a new vacuum controller called an MKS. I have the manuals for the 2 MKS systems but no Manual or any details on the Utility card it connects to. the programming language is in the manuals and seems to be the same. the utility card baud rate is 4800 and the new MKS lowest is 9600. Both are 8 data bits, 1 stop bit, No parity, No hardware handshaking for the two MKS systems. I would upload the Manuals but it won't let me due to new user.
example of the communication should be like this @0651:1E-10
but this is what i get
03:56:18.468 -> FFFFFFFF
03:56:18.468 -> FFFFFFFF
03:56:18.501 -> FFFFFFFF
or
03:43:26.294 -> -1
03:43:26.294 -> 255
03:43:26.294 -> 255
03:43:26.294 -> 255
03:43:26.294 -> 0
03:43:26.294 -> -1
#include <SoftwareSerial.h>
#define SERIAL_8N1 0x06
void setup() {
// Configure Serial1 to receive at a higher baud rate (e.g., 9600)
Serial1.begin(9600, SERIAL_8N1);
// Configure Serial2 to transmit at a lower baud rate (e.g., 4800)
Serial2.begin(4800, SERIAL_8N1);
// Optionally, you can print a message to the serial monitor
Serial.begin(9600, SERIAL_8N1); // Use Serial for debugging
Serial.println("Baud Rate Converter Started");
}
void loop() {
// read from port 1, send to port 0:
while (Serial1.available()) {
Serial2.write(Serial1.read());
Serial.println(Serial1.read());
}
// read from port 0, send to port 1:
while (Serial2.available()) {
Serial1.write(Serial2.read());
Serial.println(Serial2.read());
}
}
Why are you including SoftwareSerial when you are not using it?
< edit >
while (Serial1.available()) {
Serial2.write(Serial1.read());
Serial.println(Serial1.read());
}
You are reading two bytes when there may only be one available, and you are sending only every other byte to each port. Use Serial1.peek() instead of the first Serial1.read().
(sorry, a bit slow this morning, will get it edited correctly eventually)
Noticed another problem. read() returns an int, so the println() will print the numeric value of the character, not the ASCII character itself. Unless that is what you want, you need to either cast the read() to char, or use write() instead of println(), in which case you would need to send the carriage return and linefeed afterwards.
Be careful! They offer both RS-232 and RS-485 communications options. Neither will work with your Arduino without a conversion adapter. Which communications option does your controller have?
Could be true. The RS-232 standard called for +3 to +25 volts and -3 to -25 volts. The revised standard, RS-232C reduced the high values to +12 and -12. The original was for vacuum tubes(valves). The revised for transistors. The alternation between + and - came from teletype systems which used the same system as the telegram system that used Morse code! The basic reason was the need for distance between stations.
Yes, but also the logic level is inverted. You can use RS-232 voltages, usually, with nothing but a current limit resistor on the input side, but your code needs to use the opposite high/low.
Some software serial allows you to say, there are microprocessors where you can do the inversion with an i/o control bit.
So it needs to be like this? without the Software serial?
void loop() {
// read from port 1, send to port 0:
while (Serial1.available()) {
char c = Serial1.read();
Serial2.write(c);
Serial.println(c);
}
// read from port 0, send to port 1:
while (Serial2.available()) {
char c = Serial2.read();
Serial1.write(c);
Serial.println(c);
}