Balance (Mettler) readout using RS232

Hello,
I am trying to read out the weight displayed on a Mettler PB1502 balance. Maybe there is somebody out there who is a bit more experienced in doing that or has experience running RS232 compatible devices on Arduino.

The balance is set to the following parameters: baud 9600, DataBits 8, Parity None, Handshake OFF and is connected to the Arduino Leonardo board using a RS232 cable and the following "Shield": SparkFun RS232 Shifter - SMD - PRT-00449 - SparkFun Electronics.
In another forum I found that Arduino only supports DataBits 8, StopBits1, Parity None, FlowControl None - I don't know weather this is correct or weather it is possible to modify these settings on the Arduino.
In addition the balance's manual points out Pins 7 and 8 as CTS and RTD for the Handshake. Due to the fact that these pins are not connected on the Shield and because of the fact that they are turned off in the balance this should not matter.

When running the code below, the Rx LED on the Shield is blinking -> so there is something sent to the balance - problem is that there is no response. I only receive "-1"; the Tx LED is not blinking. When removing the comment from "// if (Serial1.available() > 0) {" there is nothing received.

Any help would be awesome,
Thanks!

int Read_Data = 0;       // read values from balance

void setup() {
  
  //Initialize Serial and wait for port to open:
  Serial.begin(9600); // start USB Serial connection
  Serial1.begin(9600);// start RS232 balance connection
  while (!Serial) {
    ; // wait for Serial port to connect via USB. Needed for Leonardo only
    }
}

void loop() {

    /*
    Commands (Mettler manual)
    --> Command    SI                          Send the current net weight value, irrespective of balance stability.
    --> Responses  S_S_<WeightValue>_<Unit>    Stable weight value in unit actually set under host unit (page 17). 
    */

//send command to balance to read weight
Serial1.print(0x53);  //S
Serial1.print(0x49);  //I
Serial1.print(0x0d);  //CR
Serial1.print(0x0a);  //LF

    
//  if (Serial1.available() > 0) {
    Read_Data = Serial1.read();
    Serial.println(Read_Data, DEC);
//  }

delay(200);

}
1 Like

A potential hitch in your get-along...

With regard to level shifting, this board does not have a MAX232 or equivalent, so it does not comply with the classical RS232 spec (0 = Space = +12V, 1 = Mark = -12V). Instead, its input will accept RS232 voltages on the input and shift them (-12V [mark] –> VCC, +12V [space] –> GND). For its output, it merely inverts the signal (VCC->GND, GND->VCC) so you must be using a newer UART that will tolerate this.

In other words, you will very likely be able to receive from the scale but you may not be able to send to the scale.

Do you have access to a USB to RS-232 converter so you can run tests from a PC?

The output (to the balance RX) of that Sparkfun RS232 Shifter switches between Vcc (5V) and a voltage below zero (created with the serial TX output of the Mettler balance). It is a smart circuit, but it is not according the classical specs as Coding Badly wrote.

Do you have a PC with a serial port ? Try to connect that, and see if you are able to see the respons by the Mettler balance.

If the Mettler balance is set for no handshake, you are fine if both the Arduino and the balance are set to 9600,N,8,1.
That is the default for the Arduino. They can be changed if you need to.

I would suggest to keep the wait for the serial port. But you have to open the serial monitor of the Arduino IDE to let the sketch continue after the wait.

You have to check the Serial1.available() for the balance data. So please remove those comments in the loop() function.

Your sketch is not working as expected. You send "SI" 5 times a second, and test for a single received character. So the balance is going haywire. Could you send "SI" at the bottom of setup(), and get the received characters in loop() ?

Perhaps like this:

  delay( 2000);
  //send command to balance to read weight
  Serial1.print("SI\r\n");

Hello,

first of all thanks for the hints. So if I understood correctly, there might be an issue with the 5V from the Arduino and the (probably) 12V from the balance?

I hooked up the balance to a PC COM Port and used Hyperterminal with the following setup: 9600, 8, N, 1, Xon/Xoff
After pressing "OK" the balance weight is displayed continuously:

S S 0.00 g
S S 0.00 g
S S 0.00 g
S D 0.03 g (here I started pressing on the balance)
S D 3.51 g
S D 54.36 g
S D 94.07 g
S D 135.44 g
S D 175.23 g
S D 209.86 g
...

According to the Hyperterminal result, the "send command" is not necessary and I can simply listen to the broadcast from the balance.

In addition I also changed the code as recommended - removed the comments - but this did not work.

void loop() {

    /*
    Commands (Mettler manual)
    --> Command    SI                          Send the current net weight value, irrespective of balance stability.
    --> Responses  S_S_<WeightValue>_<Unit>    Stable weight value in unit actually set under host unit (page 17). 
    */

//send command to balance to read weight
Serial1.print("SI\r\n");
Serial.print("SI\r\n");   // will just display the sent command in the serial monitor

delay(500);
    
  if (Serial1.available() > 0) {
    Read_Data = Serial1.read();
    Serial.println(Read_Data, DEC);
  }

delay(2000);

}

Maybe a little more explanation what I want to do with the program:
The program will switch a feeder on/off once a preset weight is reached (therefore the weight-reading has to be very fast).
That's also the reason why I cannot put the "send command" in the setup() because the weight shall be read continuously when the sketch is running later.

Thanks

Does the PC work without the Xon/Xoff (that is software handshake)? Since the Arduino doesn't use Xon/Xoff.

I use HyperTerminal or this program: Q Serial Terminal download | SourceForge.net

You send "SI" and read only one character.
Do you need to send "SI" at all ?
If you don't, you could just echo all characters to the serial monitor.

void loop() {
  char c;

  // echo all received characters to test the communication.
  if (Serial1.available() > 0) {
    c = Serial1.read();
    Serial.print( c);        // use character for readable text
  }
}

You could run that test. You could also test it with the computer serial port. That is perhaps easier to check the wiring.

But you should buy a normal RS232-to-ttl-level converter. At least to have one at hand.

Hi,
sorry, forgot to write that the PC works with all the 3 settings for handshake - so "None" is also working.
I tried the new code but no luck with it.

Regarding the RS232 TTL converter: so it is important to have the MAX3232 chip onboard and the one I have might be the problem SparkFun RS232 Shifter - SMD - PRT-00449 - SparkFun Electronics? I found this one http://www.miniinthebox.com/de/rs232-serial-to-ttl-converter-module_p481725.html which also has a MAX3232 onboard?! (I don't want to order to through China - takes too long)

That is a good one.
It needs power to work. It is 3.3 - 5V, so that's good with all the 5V and 3.3V Arduinos.

OK, then I'll order that one.
We'll see how it works...

After a long time of absence, and some quite disappointing tests with the RS232 TTL converter I give it another try. I set the balance to send mode so that it is transmitting the weight over the RS232 continuously. I tested it with the Hypertherminal on a PC and received the data.

Now to the Arduino. I have a converter with 8 out/inputs (Vcc, Rx, Tx, Gnd, T2I, R2O, R2I, T2O). I connected the Vcc, Rx, Tx and Gnd to the Arduino Lenoard (Tx, Rx Pins 0&1) and used the code from the post above send the data to the Serial Monitor. Result: nothing, except that the MAX3232 on the converter board is getting really hot. I also exchanged the Rx, Tx cables but same result.

Any ideas???

Leave Rx and Tx unconnected. With just power (Vcc and Gnd) does the MAX3232 get hot?

The MAX3232 is getting hot without the Tx, Rx connected, too. I tried the 5V and 3V Vcc but same result (maybe not that bad with the lower voltage).

I can't tell if that is or is not normal. Mostly it seems to be not normal...
https://www.google.com/search?q=MAX3232+is+getting+hot

Most folks believe wrong / bad capacitors or a failed chip is the reason. There is frequent mention of "hot plugging" and "connected to RS-232" so...

Does the MAX3232 get hot when it is connected to the balance?

It is getting hot with and without the balance connected - seams as if there is something wrong with the TTL board. I tried to read out something different but I could not find a device that has the same RS232 port for the connection.

darkwaiter:
It is getting hot with and without the balance connected - seams as if there is something wrong with the TTL board.

That's the way I'm leaning. But I'm otherwise out of ideas.

I suggest asking here... General Electronics ...if a warm MAX2323 is normal. If you do decide to post a question in General Electronics please mention and include a link to this thread.

I am trying to control a powder filler while reading the serial output from a metler balance. I am having trouble reading the balance output on the arduio leonardo via a max3232 converter, but am able to read it fine on my computer in putty (similar to hyper terminal).

Were you able to get things working? any help would be appreciated.

My converter chip is also getting crazy hot. The one I am using is this one.

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=221263135179

https://www.google.com/search?q=max3232+is+getting+hot

...wrong capacitors or damaged / defective chip seems to be the most common conclusion.

I found this thread,

http://forum.arduino.cc/index.php?topic=179514.0

and I don't really understand what they did, but I have gone through the checks the user is talking about and all have passed as his did except the balance connection.

Anyway someone could explain like I am five whats going on in that thread

To solve the problem @srose82 crossed the RS232 TX and RX lines. It's called a "null modem".

I don't recall that being an issue with Mettler scales. What kind of cable are you using between the scale and the PC?

tested the voltage across the capacitors

C1 = 4.5V
C2 = 4.4V
C3 & C4 = 8.8V

does that seem right?