I am trying to interface this sensor, https://www.robotous.com/forcetorquesensor (RTF60-HA01-C), with the Arduino Mega. The sensor has an input voltage of 5Vs and communicates using CAN/RS232/RS422. I am using the RS232 and have connected wires properly and have tried to establish Serial Communication using the below code.
#include<String.h>
# define BuffSize 32
byte buff[BuffSize];
unsigned char data_field[16];
byte comm[11] = {0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA};
// SOP == 0x55, EOP == 0xAA, Checksum == summation of each data in data_field
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial2.begin(115200);
for (int i = 0; i < BuffSize; i++) {
buff[i] = 13; //Number to initialise buffer
}
}
void loop() {
// put your main code here, to run repeatedly:
Serial2.write(comm, 11);
//Serial.println(Serial2.available());
if (Serial2.available() > 0) {
//int read = Serial2.readBytes(buff, BuffSize);
String output = "";
for(int i=0;i<BuffSize;i++){
buff[i]=Serial2.read();
output = output + buff[i] + "|";
}
//Serial.println(read);
Serial.flush();
Serial.println(output);
Serial.println();
}
}
The output I receive is just 0s and the occasional 10. Like below
0|0|0|0|0|0|0|0|10|0|0|0|0|0|0|0|0|10|0|0|0|0|0|0|0|0|10|255|255|255|255|255|
I am new to this and hope this is not a stupid question. Let