I've asked this before so I thought I'd start again with just the basic and get it printing correctly before moving on.
I've gone through the Serial tutorial by Robin2 and this how I've got this far.
It all seems to be working but sometimes there seem to be a 3/4 second delay in it displaying the data according to the serial monitor where I've added a time stamp. All the data seems to be displaying correctly but it's just the delay in between it displaying the data.
This is from the manual.
The Pro 3600 has an ASCII-format RS-232 compatible serial port for remote angle readout.
The T&B Ansley 609-1027 connector on the back of the Pro3600 mates with industry
standard cables. Angles are calculated and transmitted every 8/15 second (533 msec).
1 GND N/A Signal Ground.
2 TD Output Transmits serial data bits (9600 baud, one stop bit, no
parity). Hi impedance except during transmission bursts.
5 REQ Input RS-232 input; high signal requests data output.
9 BATT+ Either Power input, or output if battery is installed in unit.
3, 4, 6-8, 10 Unused.
If REQ is high when power is applied or the unit is turned on, and it remains high, an output occurs every 8/15 second.
If REQ is ever low or floating and the unit is on, outputs occur as a result of subsequent low-to-high transitions on REQ,
provided REQ remains high for at least 100 msec. The output rate does not exceed one every 8/15 second.
This is the code that I've got working
// Example 3 - Receive with start- and end-markers
/*********
#### TX CODE ####
Wireless SPI-TRONIC Pro 3600 Digital Protractor
General Information
The Pro 3600 has an ASCII-format RS-232 compatible serial port for remote angle readout.
The T&B Ansley 609-1027 connector on the back of the Pro3600 mates with industry
standard cables. Angles are calculated and transmitted every 8/15 second (533 msec)
Angle Output Format:
The ASCII angle output may be read by a computer, or may directly drive a printer. Measured
angles cover a full 360° range and the readout is between -180.00° and +180.00°.
Format:
<sign> XXX.XX <carriage return><line feed>
examples:
+ 124.50
+ 32.70
+ 9.38
- 4.32
- 179.9
*********/
#include <HardwareSerial.h>
HardwareSerial MySerial(1);// MySerial.begin(9600, SERIAL_8N1, 16, 17);
const byte numChars = 9;
char receivedChars[numChars];
uint8_t broadcastAddress[] = {0X24, 0X6F, 0X28, 0XB3, 0XF3, 0XE0}; //MAC adress been sent to
boolean newData = false;
typedef struct Data_struct {
int test = 10;
char receivedChars[numChars]; // an array to store the received data
} Data_struct;
Data_struct Data;
void setup() {
Serial.begin(115200);
MySerial.begin(9600, SERIAL_8N1, 16, 17);
Serial.println("<Arduino is ready>");
}
void loop() {
recvWithStartEndMarkers();
showNewData();
}
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char Plus_sign = '+';
char Minus_sign = '-';
char endMarker = '\n';
char rc;
while (MySerial.available() > 0 && newData == false) {
rc = MySerial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
Data.receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
Data.receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if ((rc == Plus_sign) || (Minus_sign)) {// Start Maker either plus/minus start bit
recvInProgress = true;
}
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(Data.receivedChars);
newData = false;
}
}
And this is the data been displayed.
22:37:30.929 -> This just in ... - 0.47
22:37:30.969 -> This just in ... - 0.47
22:37:32.009 -> This just in ... - 0.47 // 2 second dely
22:37:32.009 -> This just in ... - 0.47
22:37:34.689 -> This just in ... - 0.47
22:37:34.689 -> This just in ... - 0.47
22:37:34.689 -> This just in ... - 0.47
22:37:34.689 -> This just in ... - 0.47
22:37:34.689 -> This just in ... - 0.47
22:37:35.729 -> This just in ... - 0.47
22:37:35.729 -> This just in ... - 0.47
22:37:39.442 -> This just in ... - 0.47
22:37:39.482 -> This just in ... - 0.47
22:37:39.482 -> This just in ... - 0.47
22:37:39.482 -> This just in ... - 0.47
22:37:39.482 -> This just in ... - 0.47
22:37:39.482 -> This just in ... - 0.47
22:37:39.482 -> This just in ... - 0.47
22:37:40.522 -> This just in ... - 0.47
22:37:40.522 -> This just in ... - 0.47 //4 second delay
22:37:44.254 -> This just in ... - 0.47
22:37:44.254 -> This just in ... - 0.47
22:37:44.254 -> This just in ... - 0.47
22:37:44.254 -> This just in ... - 0.47
22:37:44.254 -> This just in ... - 0.47
22:37:44.254 -> This just in ... - 0.47
22:37:44.254 -> This just in ... - 0.47
22:37:45.334 -> This just in ... - 0.47
22:37:45.334 -> This just in ... - 0.47
22:37:46.374 -> This just in ... - 0.47
22:37:46.374 -> This just in ... - 0.47
22:37:49.056 -> This just in ... - 0.47
22:37:49.056 -> This just in ... - 0.47
22:37:49.056 -> This just in ... - 0.47
22:37:49.056 -> This just in ... - 0.47
22:37:49.056 -> This just in ... - 0.47
22:37:51.176 -> This just in ... - 0.47
22:37:51.176 -> This just in ... - 0.47
22:37:51.176 -> This just in ... - 0.47
22:37:51.176 -> This just in ... - 0.47
22:37:51.696 -> This just in ... - 0.47
22:37:53.816 -> This just in ... - 0.47
22:37:53.816 -> This just in ... - 0.47
22:37:53.816 -> This just in ... - 0.47
22:37:53.856 -> This just in ... - 0.47
22:37:54.899 -> This just in ... - 0.47
22:37:54.899 -> This just in ... - 0.47
22:37:55.939 -> This just in ... - 0.47
22:37:55.978 -> This just in ... - 0.47
22:37:57.568 -> This just in ... - 0.47
22:37:57.568 -> This just in ... - 0.47
22:37:57.568 -> This just in ... - 0.47
I did read this topic here which I found very interesting and tried some of the code, Reading the string type code seemed to work great but then it messed up the PCD8544 by printing it over 2 lines.
https://forum.arduino.cc/index.php?topic=733177.0
Am I missing something or doing something wrong ?