I have a question for splitting engine control system string data from a serial port. The communication protocol description is below.
Example:
To retrieve the data displayed on the LCD screen of the FADEC. If the command is RSD
, then the output would be:
**C7h 2Ch 52h 53h 44h 2Ch 0Dh**
C7h -> Sync
2Ch -> “,” Separator
52h -> “R”
53h -> “S”
44h -> “D”
2Ch -> “,” Separator
0Dh -> CR, last byte.
The ECU will return two strings. The first, a copy of the command received, followed by the data requested. In the above example, it will return:
**C7h, RSD, 0Dh**
C7h -> Sync byte
2Ch -> “,” Separator
Payload in ASCII “TrimLow EGT 20CRpm 50.000Pw=124”
2Ch -> “,” Separator
0Dh -> CR, last byte.
I read all the data on the screen in string format. When I send RCV
to the ECU, it will return RPM, temperature, pump voltage, battery voltage and throttle according to the above form.
Xicoy description: ( Command, Meaning, Payload)
RCV Read Current Values RPM, EGT in ºC, Pump Power, Voltage of Battery,Throttle %
byte veri[]= { 0xC7, 0x2C, 0x52, 0x43, 0x56, 0x2C, 0x0D }; // for RCV
And datasheet (page 5-6-7): http://www.xicoy.com/SerialAdapt1_0.pdf
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
int i=0;
byte veri[]= { 0xC7, 0x2C, 0x52, 0x43, 0x56, 0x2C, 0x0D }; // RCV
int myTimeout = 100;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
mySerial.setTimeout(myTimeout);
}
void loop() {
Serial.println(mySerial.readString());
for(i=0;i<7;i++)
{
mySerial.write(veri[i]);
}
}
How can I separate RPM, EGT °C, pump voltage, battery voltage and throttle % in the data packet that is coming back from the ECU? After the discrimination process, I will send it to LabView via the second serial port. The RPM values can be 6 digits (approx. 120000 RPM) and the exhaust gas temperature is 3 digits (EGT 800 °C), the figures may be missing because all are zero except throttle value. Can you share a sample? Thanks.
Picture: