Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: RS232 Interface with Scale, TX not working

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Posts
    4

    RS232 Interface with Scale, TX not working

    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.

    Click image for larger version. 

Name:	PJRC question.png 
Views:	17 
Size:	14.0 KB 
ID:	24439

    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.
    Click image for larger version. 

Name:	RX Channel 0.PNG 
Views:	11 
Size:	19.2 KB 
ID:	24437

    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.
    Click image for larger version. 

Name:	RX Channel 1 2.jpg 
Views:	13 
Size:	20.3 KB 
ID:	24438

    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.
    Click image for larger version. 

Name:	rs232 commands.PNG 
Views:	10 
Size:	21.9 KB 
ID:	24440
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	PJRC question.png 
Views:	9 
Size:	19.7 KB 
ID:	24436  

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,282
    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.

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,282
    ..and..can you show us a photo? Is everything soldered?

  4. #4
    Junior Member
    Join Date
    Apr 2021
    Posts
    4
    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.

    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 by chrisl; 04-14-2021 at 05:47 PM. Reason: clarify photo

  5. #5
    Junior Member
    Join Date
    Apr 2021
    Posts
    4
    Sorry, I couldn't add the photos in the previous post. Here's the overall setup:
    Click image for larger version. 

Name:	20210414_0917551.jpg 
Views:	12 
Size:	143.0 KB 
ID:	24449

  6. #6
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,607
    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

  7. #7
    Junior Member
    Join Date
    Apr 2021
    Posts
    4
    They are female connectors which connect to male connectors that are soldered.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •