Using Fardriver's LIN protocol

Hi, I tested the great code made by trufinv, thank you for that!
Unfortunaly, I run into problems reading real values. The code compiles well on an NANO, I get some HEX code but nothing where I can read values... I use a fardriver ND72680.
I connected the SIF wire to PIN 2 and the NANO Ground to the fardriver's Ground.
Did I do something essentially wrong ?
Is the code maybe not compatible for the fardriver model ?
Is the usage of the CAN an alternative and if yes, has anyone documentation and/or code examples ?

Thank you guys in advance an Regards,
Claudius (Germany)
I also use it on a nd72680 and it runs just fine. just keep in mind that controller emits a huge amount of EMI. the sif output is usually the brown wire
 
A little update. I played around a bit with the "one wire" display output and was able to decode the data with a simple arduino nano.
Here's some rough test code, nothing fancy, just a simple proof of concept but it works well for me.
Protocol documentation in previous post.



#define sif_pin 2
short battery = 0;
short current = 0;
short currentPercent = 0;
short rpm = 0;
long faultCode = 0;
bool regen = false;
bool brake = false;
unsigned long lastTime;
unsigned long lastDuration = 0;
byte lastCrc = 0;
byte data[12];
int bitIndex = -1;
void setup() {
Serial.begin(115200);
pinMode(sif_pin, INPUT);
lastTime = micros();
attachInterrupt(digitalPinToInterrupt(sif_pin), sifChange, CHANGE);
}
void loop() {
// put your main code here, to run repeatedly:
}
void sifChange() {
int val = digitalRead(sif_pin);
unsigned long duration = micros() - lastTime;
lastTime = micros();
if (val == LOW) {
if (lastDuration > 0) {
bool bitComplete = false;
float ratio = float(lastDuration) / float(duration);
if (round(lastDuration / duration) >= 31) {
bitIndex = 0;
} else if (ratio > 1.5) {
// bit value 0
bitClear(data[bitIndex / 8], 7 - (bitIndex % 8));
bitComplete = true;
} else if (1 / ratio > 1.5) {
// bit value 0
bitSet(data[bitIndex / 8], 7 - (bitIndex % 8));
bitComplete = true;
} else {
Serial.println(String(duration) + "-" + String(lastDuration));
}
if (bitComplete) {
bitIndex++;
if (bitIndex == 96) {
bitIndex = 0;
byte crc = 0;
for (int i = 0; i < 11; i++) {
crc ^= data;
}
if (crc != data[11]) {
Serial.println("CRC FAILURE: " + String(crc) + "-" + String(data[11]));
}
if (crc == data[11] && crc != lastCrc) {
lastCrc = crc;
for (int i = 0; i < 12; i++) {
Serial.print(data, HEX);
Serial.print(" ");
}
Serial.println();
battery = data[9];
battery = data[9];
current = data[6];
currentPercent = data[10];
rpm = ((data[7] << 8) + data[8]) * 1.91;
brake = bitRead(data[4], 5);
regen = bitRead(data[4], 3);

Serial.print("Battery %: " + String(battery));
Serial.print(" Current %: " + String(currentPercent));
Serial.print(" Current A: " + String(current));
Serial.print(" RPM: " + String(rpm));
if (brake) Serial.print(" BRAKE");
if (regen) Serial.print(" REGEN");
Serial.println();
}
}
}
}
}
lastDuration = duration;
}

Do you think it'd be easy to take this code, which is freaking awesome to find btw, and output all this via some sort of CAN transceiver to a CAN capable display ?
 
Do you think it'd be easy to take this code, which is freaking awesome to find btw, and output all this via some sort of CAN transceiver to a CAN capable display ?
Sure, on my ebike I send the votol data to my KT display. On my motorcycle I send fardriver data to my stock supersoco rs485 display via a rs485 adapter. You just need to match the protocols.
 
Sure, on my ebike I send the votol data to my KT display. On my motorcycle I send fardriver data to my stock supersoco rs485 display via a rs485 adapter. You just need to match the protocols.
That's good to hear. I'm trying to get votol/fardriver data piped over to my CAN BUS only display, but I can't get the manufacturer of the display to share any details about type of CAN bus protocol they use. Is it pretty much universal ? I'd just like to translate voltage, current, motor temp etc to CAN bus signals for this thing... It's a Chaojie display.
 
Dunno about fardrivers but Votol does expose a lot of data on CAN continuously, I just haven't decoded it yet. You call also ask it for a specific frame with essentials. It's all done pretty badly with frame id reuse, though, so it's unlikely you'll get a screen to work with that without some translation layer in the middle.
 
Yeah I have a fardriver without canbus functionality, just SIF or one-line, or whatever it's called. It seems pretty flexible to what it can output on that one wire, but my $100 display that was very deceptively advertised, only displays speed. I'd like to see all the other stats it can display, but apparently that's only available with a canbus fardriver. So I was trying to see if I can program an ESP32 to do the translation...
 
Sure, on my ebike I send the votol data to my KT display. On my motorcycle I send fardriver data to my stock supersoco rs485 display via a rs485 adapter. You just need to match the protocols.
Which rs485 adapter do you use ?
 
Can you share some images of the wiring and connection just wanted to see what mistakes I am making.
1744867027781.png
The module is similar to this one, as I said, the cheapest I could get. I don't have any photos of the wiring. You just need to control DE and RE with your arduino/esp for sending/receiving on the rs485 channel, I think I soldered them together. Just ask ChatGPT, I don't remember the specifics, it's like a thing you do once and then forget about it.
 
Back
Top