How to Connect PM1200 to Arduino Mega 2560

To know if everithing is connected in the right way do a simple test ( as you have the usb-to-485 converter ).
Connect everything together mega->converter->485bus<-usb-to-485<-pc ( leave also the pm1200 connected it won't hurt and it will be ready for the next step )
On the pc use a 'terminal' ( teraterm or the like ) configured to communicate with the usb-to-485 converter at 9600,8,E,1
On the arduino use the following sketch that transmits every 5 seconds a message and echoes what it receives
This is to test that communication over 485 is ok ( A and B are connected correctly ) and to test if the RX/TX of arduino converter are connected correctly

On the teraterm you should see a message every 5 seconds, on the arduino serial debug you sould see echoed everything you write in teraterm

/*

  Test 485 converter.

*/


void setup()
{
  Serial.begin(9600); // use Serial (port 0) for serial debug
  Serial.println("Starting Serial1 test");
  
  Serial1.begin(9600, SERIAL_8E1);  // use Serial1 (port 1) for testing converter communication
}

unsigned long prevMillis;
int i = 0;

void loop()
{
  unsigned long m = millis();
  if ( m > prevMillis + 5000)
    {
    Serial1.print("msg : ");
    Serial1.println(i++);
    }
  
  if (Serial1.available())            // If anything comes in Serial1...
    {Serial.write(Serial1.read());}   // ...it is echoed in Serial
}

I tired with Tera term, but text appears Cannot open COM3. Access denied

if com3 is the usb-485 converter, make sure you close any apps using it ( for example modbus scanner, in case of the scanner it should be enough to disconnect it ).
In your pc you should have a com port to address the usb-485 adapter and a com port to address arduino ( do not confuse both ), take a note of which is which

Buy an RS485 converter with DE/RE pins.
Connect everything as you did in post #1.
define TxEnablePin 2
Connect RE and DE to pin 2
Use the program in post #1

See post #12