Hello!
I am trying to use 2 of the https://www.robotshop.com/ca/en/cytron-rs232to-uart-converter.html converters to get a readout from an OP-900B scale.
(Manual available here: https://www.globalindustrial.com/site/images/optima/op-900-manual.pdf )
I am connecting the Cytron RX - Mega Serial3 TX, Cytron TX - Mega Serial3 RX, Cytron GND - Arduino GND and Cytron 5+ - MEGA 5+
In the scale manual, the setting C18 should be on mode 3, and I am sending it a command of R (through Serial3.print(“R”) in an attempt to cause a reading.
I have tried multiple different variations of code and using the C18 mode 1 to just continuously output data with no avail. Any assistance would be greatly appreciated. Thank you.
The code I have been using is here:
const int BAUD_IDE = 9600;
const int BAUD_LOAD_CELL = 9600;
const byte numChars = 15;
char receivedChars[numChars];
boolean newData = false;
unsigned long currentMillis;
unsigned long timerStart;
unsigned int timerDuration = 10000;
void setup() {
Serial.begin(BAUD_IDE);
Serial3.begin(BAUD_LOAD_CELL);
Serial.println("");
timerStart = millis();
//delay(250);
}
void loop() {
currentMillis = millis();
if ((currentMillis - timerStart) > timerDuration) {
timerStart = currentMillis;
requestLoadCellData();
}
recvWithStartEndMarkers();
if (newData == true) {
Serial.print("Data received from scale … ");
Serial.println(receivedChars);
newData = false;
}
}
void requestLoadCellData() {
Serial3.print(“R”);// ***** request to scale, you may need to remove the newline \n or carriage return \r
}
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = 0x02; //ASCII STX
char endMarker = 0x0A; //ASCII LF
char rc;
while (Serial3.available() > 0 && newData == false) {
rc = Serial3.read();
if (recvInProgress == true) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
if (rc == endMarker) {
receivedChars[ndx] = ‘\0’; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}
Hey @God_of_hammers
Welcome to the RobotShop Community!
Have you verified if the serials are properly installed, using a Serial Loopback?
You can take a look here on how to do this:
If you are using UC00A, UC00B, or FTDI cable, or any UART devices, did you ask the questions: Is the UART working? Is the transmit pin is transmitting data? Is the receive pin receive data? You want to check whether the UART device is...
Thanks for the reply AudioVOX
I actually found the source of the problem to be that I was using a cable to reach the scale, and somehow the cable was the reason there was no data transfer, be it that it was a busted cable or it swapped RX/TX internally.
Thanks!