Trying to connect an old GF300 A&D scale to an Arduino UNO through the 25 pin printer port.
My serial connnection is:
15 characters long excluding the terminator (CRLF). The header consist of 2 characters in position 1 and 2 and indiactes the statuse of the scale ST, US, OL or QT, followed by a comma in position 3, and the polarity sign (+or -) in position 4. Characters 5-12 will be the numerical weight followed by the unit of measure in positons 13-15. All of this is followed by the terminator CRLF. It has downloaded without issue.
An example of the character string would be:
ST,+00012.78 gCRLF. This would indicate a stable positive reading of 12.78 grams. I have included my code.
I have wired the Arduino through the breadboard.
Sketch below. I manually hit the print key to output. I ma getting nothing on the serial monitor. I am wondering if I am using the RX and TX connections correctly.
#include <SoftwareSerial.h>
SoftwareSerial scaleSerial(0, 1); // RX, TX - adjust the pin numbers as needed
String incomingLine = ""; // Declare incomingLine to store the received line
void setup() {
Serial.begin(9600); // Set your preferred baud rate for the Arduino IDE Serial Monitor
scaleSerial.begin(2400); // Set baud rate to 2400 bps for the A&D GF-300 scale
}
void loop() {
if (scaleSerial.available()) {
// Read the incoming byte from the scale
char incomingByte = scaleSerial.read();
// Check if the received byte is the end of the line (newline character)
if (incomingByte == '\r' || incomingByte == '\n') {
// Process the custom-formatted data when a complete line is received
processCustomFormat();
} else {
// Accumulate characters to form a complete line
incomingLine += incomingByte;
}
}
}
void processCustomFormat() {
// Check if the incoming line has exactly 15 characters (excluding terminator)
if (incomingLine.length() >= 15) {
// Extract information from the incoming line
String header = incomingLine.substring(0, 2);
String separator = incomingLine.substring(2, 3);
String polaritySign = incomingLine.substring(3, 4);
String weightData = incomingLine.substring(4, 12);
String unitOfMeasure = incomingLine.substring(12, 15);
// Print the received data in the desired format
Serial.print("Header: ");
Serial.println(header);
Serial.print("Separator: ");
Serial.println(separator);
Serial.print("Polarity Sign: ");
Serial.println(polaritySign);
Serial.print("Weight Data: ");
Serial.println(weightData);
Serial.print("Unit of Measure: ");
Serial.println(unitOfMeasure);
Serial.println(); // Print a newline for readability
}
// Clear the accumulated line for the next iteration
incomingLine = "";
If the scale has a 25 pin serial port then it is almost certainly using RS232 for its serial connection. This is completely incompatible with the TTL voltage levels provided by the Arduino.
You need an RS232 to TTL converter between the 2 devices
Remember RS323 is a bit picky in that Tx expects a listner Rx and Rx expects a tallker Tx. There are other pins as well such as CTS, DTR, etc. No idea if they were used. Over the years I have seen several combinations. You can get the service manual from: A&d GF-300 Manuals | ManualsLib That should tell you.
I have the connections right, I believe this is RS232C and the voltages are too high for my Arduino UNO. I was using a PB on the breadboard for print and Re-zero. The re-zero works, and I believe the print button is working, but I can't get anything ot print. I changed the Rx, Tx, to pins 10,11 and wired them for Rx to Tx and vice versa. Still nothing. I do not have a TTL convertor. If I understand correctly, I need the convertor to lower the voltage level. I am a bit lost, but will keep researching.
Whilst there were large Centronics parallel printer ports there were also 2 flavours of serial ports, one with 9 pins and one with 25 pins so all bets are off
I am a little lost. I tried using the diode and resistors from runaway_pancake. Still not working. I am not understanding how to use the TTL. It is a simople pinout for the scale. I changed the code around.
#include <SoftwareSerial.h>
SoftwareSerial scaleSerial(8,9); // RX, TX - adjust the pin numbers as needed
String incomingLine = "";
void setup() {
Serial.begin(2400); // Set baud rate for the Serial Monitor
scaleSerial.begin(2400);
Serial.println("Setup complete. Waiting for incoming data...");
}
void loop() {
if (scaleSerial.available()) {
char incomingByte = scaleSerial.read();
if (incomingByte == '\r' || incomingByte == '\n') {
Serial.println("Received End of Line. Processing...");
processCustomFormat();
} else {
incomingLine += incomingByte;
}
}
// Your main code here, without delay
}
void processCustomFormat() {
if (incomingLine.length() >= 15) {
Serial.println("Processing Custom Format...");
String header = incomingLine.substring(0, 2);
String separator = incomingLine.substring(2, 3);
String polaritySign = incomingLine.substring(3, 4);
String weightData = incomingLine.substring(4, 12);
String unitOfMeasure = incomingLine.substring(12, 15);
Serial.println("Hello, Print Part of Program!");
Serial.print("Header: ");
Serial.println(header);
Serial.print("Separator: ");
Serial.println(separator);
Serial.print("Polarity Sign: ");
Serial.println(polaritySign);
Serial.print("Weight Data: ");
Serial.println(weightData);
Serial.print("Unit of Measure: ");
Serial.println(unitOfMeasure);
Serial.println();
} else {
Serial.println("Incomplete or invalid line. Discarding...");
}
// Clear the accumulated line for the next iteration
incomingLine = "";
}
I get the message "Setup complete, waint for incoming data" , so the program is at least reading. Obviously have no incoming data.
I ahave connected Scale Pin1, or Frame ground, to the ground on the UNO. RX, or Pin 2, is connected to Arduion DO9,the designated UNO TX pin. The Scale TX, or Pin 3, is connected to Arduino DO8, the designated RX Pin. I have wired the Scale pins 18 and 19 to the signal ground pin through pushbuttons. The reset works fine. I am not getting anything at all when I hit print. I have put the diodes and resistors in place to reduce the voltage coming in to the arduino.