RS232 Interface with Scale, TX not working

Status
Not open for further replies.

chrisl

New member
Hi all, new to the forum, thank you for any guidance you can provide.

I am trying to get the Teensy 4.1 to interface automatically with an Ohaus AR3130 scale via its RS 232 port. I am using a Max3232 converter board to convert the RS232 levels to 3.3 TTL levels. The scale can send values over the RS 232 port by manually pressing the "Print" button, or by sending "P" to it's RX channel. The scale can also be tared remotely by sending "T". To get the system working, I am using the "T" as a test command because it is easy to check the scale display to see if it has been tared.

PJRC question.png

The system behaviour is unstable. Using a logic analyzer, I have been able to read the "T" that I have remotely sent at the RX channel of the scale. However, this has been intermittent, and random. (ie, if I disconnect and reconnect the logic analyzer probe, I can no longer read anything I send. It can also be disrupted by other events, like unplugging and replugging the RS 232 connector.

RX readings at the Teensy, seem to be OK. However, if I configure the Teensy serial port with Serial(9600,SERIAL_8N1_RXINV), it starts streaming readings. I use the Invert logic configuration because that's what seems to decode the data properly.
RX Channel 0.PNG

TX readings at the Teensy, and at the RX channel of the scale. As mentioned earlier, sometimes I can read at the scale, and sometimes I can not.
RX Channel 1 2.jpg

Even when the "T" was sent correctly, it still did not tare the scale. Looking at the scale manual, the approach I am taking seems to be correct. Any insight would be hugely appreciated.
rs232 commands.PNG
 

Attachments

  • PJRC question.png
    PJRC question.png
    19.7 KB · Views: 48
Serial(9600,SERIAL_8N1_RXINV)
This is the USB Serial. You may want to try Serial2 :)

If that doesn't solve the problem, you'll have to show us some code - or better, all the code.
It needs to be broken down to a minimalistic example.
 
Here's my code and a photo of my setup. The wires on the right side are not connected to anything, they were for connecting to a stepper but I've removed that feature just to get the scale working. The serial port was defined correctly.

View attachment 24448


Code:
#define SCALE_SERIAL Serial2

void setup() {
   //USB serial 
  Serial.begin(9600);
  //Serial port of the scale
  SCALE_SERIAL.begin(9600,SERIAL_8N1_RXINV_TXINV);
}

void loop() {

  byte scale_byte;
  byte in_byte;
  byte cr = 13;
  byte space = 32;
  byte newline = 10;

  //For sending print commands over the serial monitor to the scale. 
  while (Serial.available())
  {   
    in_byte = Serial.read();
    //Sends "T" to the scale to TARE
    
    {
      Serial.write("Sent to scale: ");
      Serial.println(in_byte);

      SCALE_SERIAL.write(in_byte);   
    }    
  }

  //Receiving data from scale
  while (SCALE_SERIAL.available())
  {
    scale_byte = SCALE_SERIAL.read();
    Serial.print("Scale sent: ");
    Serial.println(scale_byte);

  }

}
 
Last edited:
Are the yellow and green wires soldered on to the board at the right? It looks like they are jumper wires whose pins might just be pushed into the holes in the board.

Pete
 
Status
Not open for further replies.
Back
Top