Pages: 1 [2] 3
Author Topic: FIS Control, Arduino, Grabbing Variables from Memory  (Read 31859 times)
adam-
Hero Member
*****

Karma: +124/-33
Offline Offline

Posts: 2179


« Reply #15 on: August 08, 2015, 11:53:51 AM »

So, got the Arduino to connect to the canbus, with the coolant level check warning coming up, I receive:
18   0   255   0   0   0   0   0   

With the warning disabled, I receive:
6   0   255   0   0   0   0   0     (something like that, I can't remember now), will check in a bit.

That's just using the basic Read example from Arduino and getting the baud rate correct.  Assuming that's connecting to the 000 address?

Will have to inspect to the code to see how to read other addresses.
Logged
adam-
Hero Member
*****

Karma: +124/-33
Offline Offline

Posts: 2179


« Reply #16 on: August 10, 2015, 03:25:31 AM »

I've written up a little code that I'm going to try at home.  It seems that the 3LB protocol is just a 3 wire (SPI) interface.  It communicates between the cluster and the radio for the navigation.

After doing some reading, the OEM radio communicates down the Clock, Data and Enable line - which is illustrated on the back of the radio.  This harness is in the form of a green plug that would go into the radio, and make its way to the cluster.

Tracing the wires with the help of the internet, it makes its way to the cluster to the green plug - namely pins 30, 31, 32, with the labels clock, data and enable respectfully.

I'm going to connect the Arduino's clock, data and enable pins to the appropriate cluster pins to see what the outcome is.

Once I can get data on the screen, I have to work how the Nav system takes control of the whole screen, and how I can go from there.

I've ordered a TTL cable that will allow me to connect to the k-line, so once I can display data, I can use the TTL cable to connect to the ECU to get logging.

I'm getting somewhere.  I now want to know how I can use the whole LCD screen - assuming it still works through the CLK, DAT, ENA lines, but how do I use it from initial ignition on so that I can create a new Welcome screen.

I'll get the cluster hooked up when I get home and let you know.
Logged
ZZottel
Newbie
*

Karma: +5/-0
Offline Offline

Posts: 12


« Reply #17 on: August 10, 2015, 05:41:59 AM »

A TTL cable is not what you need to interface the K line. Or do you mean KKL cable?
Logged
adam-
Hero Member
*****

Karma: +124/-33
Offline Offline

Posts: 2179


« Reply #18 on: August 10, 2015, 05:48:40 AM »

http://arduinodev.com/hardware/obd-kit/

Basically a KKL cable.  It seems to be FTDI based.
Logged
adam-
Hero Member
*****

Karma: +124/-33
Offline Offline

Posts: 2179


« Reply #19 on: August 20, 2015, 01:20:27 PM »

Compiled code for this but still not getting to far.  I've connected:

//data MOSI  pin -> uno: 11
//clk  SCK     pin -> uno: 13
//ena           pin -> uno: 2

So far, nothing.  The top of the cluster is still black, but not sure if it needs to be in the car to "wake up", or if it'll respond from the bench.

Obviously because I'm using the Uno, ZZottel's code doesn't transfer across because he's used a different AVR.  I'm convinced that the timings are wrong, but this is still way over my head.

[quote code]
#include <SPI.h>
//spi version:
//http://arduino.cc/en/Reference/SPI
//data MOSI pin -> uno/due: 11,mega: 51
//clk  SCK  pin -> uno/due: 13,mega: 52
//ena       pin -> uno/due/mega 2
#define useSPI

//nospi version:
//data pin 4
//clk  pin 3
//ena  pin 2

//WRITE TO CLUSTER
#define FIS_WRITE_ENA 2
#ifndef useSPI
#define FIS_WRITE_CLK 13
#define FIS_WRITE_DATA 11
#endif
#define FIS_WRITE_PULSEW 50
#define FIS_WRITE_STARTPULSEW 50
#define FIS_WRITE_START 15 //something like address, first byte is always 15
//END WRITE TO CLUSTER

//#define BINCODE 000011111011111010101010101110111011011010111100101100111010101010111101101011001011001110110000101010011011111010110100101101101011111010010011
//                000011111011111010101010101110111011011010111100101100111010101010111101101011001011001110110000101010011011111010110100101101101011111010010011

//int BINCODE[144]={
//0,0,0,0,1,1,1,1,
//1,0,1,1,1,1,1,0,
//1,0,1,0,1,0,1,0,
//1,0,1,1,1,0,1,1,
//1,0,1,1,0,1,1,0,
//1,0,1,1,1,1,0,0,
//1,0,1,1,0,0,1,1,
//1,0,1,0,1,0,1,0,
//1,0,1,1,1,1,0,1,
//1,0,1,0,1,1,0,0,
//1,0,1,1,0,0,1,1,
//1,0,1,1,0,0,0,0,
//1,0,1,0,1,0,0,1,
//1,0,1,1,1,1,1,0,
//1,0,1,1,0,1,0,0,
//1,0,1,1,0,1,1,0,
//1,0,1,1,1,1,1,0,
//1,0,0,1,0,0,1,1};

//WRITE TO CLUSTER
String FIS_WRITE_line1="";
String FIS_WRITE_line2="";
long FIS_WRITE_rotary_position_line1=-8;
long FIS_WRITE_rotary_position_line2=-8;
char FIS_WRITE_CHAR_FROM_SERIAL;
int FIS_WRITE_line=1;
long FIS_WRITE_last_refresh=0;
int FIS_WRITE_nl=0;
int FIS_WRITE_ENA_STATUS=0;
//END WRITE TO CLUSTER

//WRITE TO CLUSTER
void FIS_WRITE_sendTEXT(String FIS_WRITE_line1,String FIS_WRITE_line2);
void FIS_WRITE_sendByte(int Bit);
void FIS_WRITE_startENA();
void FIS_WRITE_stopENA();
//END WRITE TO CLUSTER

void setup(){
//WRITE TO CLUSTER
pinMode(FIS_WRITE_ENA, OUTPUT);
digitalWrite(FIS_WRITE_ENA,LOW);
#ifndef useSPI
pinMode(FIS_WRITE_CLK, OUTPUT);
digitalWrite(FIS_WRITE_CLK, LOW);
pinMode(FIS_WRITE_DATA, OUTPUT);
digitalWrite(FIS_WRITE_DATA, LOW);
#endif
Serial.begin(19200);
//END WRITE TO CLUSTER
}

void loop(){
//WRITE TO CLUSTER
if (Serial.available()) {
        FIS_WRITE_CHAR_FROM_SERIAL=(char)Serial.read();
        Serial.print(FIS_WRITE_CHAR_FROM_SERIAL);
        if (FIS_WRITE_CHAR_FROM_SERIAL == '\n') {
          FIS_WRITE_nl=1;
          if (FIS_WRITE_line==1){
            FIS_WRITE_line=2;
          } else {
            FIS_WRITE_line=1;
           }
        } else {
          if (FIS_WRITE_line==1){
              if (FIS_WRITE_nl){
                FIS_WRITE_nl=0;
                FIS_WRITE_line1="";
                FIS_WRITE_rotary_position_line1=-8;
                }
              FIS_WRITE_line1+=FIS_WRITE_CHAR_FROM_SERIAL;
          } else {
              if (FIS_WRITE_nl){
                FIS_WRITE_nl=0;
                FIS_WRITE_line2="";
                FIS_WRITE_rotary_position_line2=-8;
                }
               FIS_WRITE_line2+=FIS_WRITE_CHAR_FROM_SERIAL;
          }
        }

 }
   
  int FIS_WRITE_line1_length=FIS_WRITE_line1.length();
  int FIS_WRITE_line2_length=FIS_WRITE_line2.length();
  String FIS_WRITE_sendline1="        ";
  String FIS_WRITE_sendline2="        ";

 
   
    //do rotary and refresh each 0.5second
    //refresh cluster each 5s
    if(millis()-FIS_WRITE_last_refresh>500 && !FIS_WRITE_line1_length || !FIS_WRITE_line2_length){
    FIS_WRITE_startENA(); //try to enable
     if (FIS_WRITE_ENA_STATUS){ //enable set to HIGH, good to go
      if (FIS_WRITE_line1_length>Cool{
      for (int i=0;i<8;i++){
        if (FIS_WRITE_rotary_position_line1+i>=0 && (FIS_WRITE_rotary_position_line1+i)<FIS_WRITE_line1_length) {
          FIS_WRITE_sendline1=FIS_WRITE_line1[FIS_WRITE_rotary_position_line1+i];
        }
      }
       if (FIS_WRITE_rotary_position_line1<FIS_WRITE_line1_length){
              FIS_WRITE_rotary_position_line1++;
       } else {
              FIS_WRITE_rotary_position_line1=-8;
              FIS_WRITE_sendline1="        ";
       }
     } else {
       FIS_WRITE_sendline1=FIS_WRITE_line1;
     }
     if (FIS_WRITE_line2_length>Cool{
      for (int i=0;i<8;i++){
        if (FIS_WRITE_rotary_position_line2+i>=0 && (FIS_WRITE_rotary_position_line2+i)<FIS_WRITE_line2_length) {
          FIS_WRITE_sendline2=FIS_WRITE_line2[FIS_WRITE_rotary_position_line2+i];
        }
      }
       if (FIS_WRITE_rotary_position_line2<FIS_WRITE_line2_length){
              FIS_WRITE_rotary_position_line2++;
       } else {
             
              FIS_WRITE_rotary_position_line2=-8;
       }
     } else {
       FIS_WRITE_sendline2=FIS_WRITE_line2;
     }
      // Serial.println("refresh");
      FIS_WRITE_sendTEXT(FIS_WRITE_sendline1,FIS_WRITE_sendline2);
      FIS_WRITE_last_refresh=millis();
      FIS_WRITE_stopENA();
    //end refresh
     }
  }
//END WRITE TO CLUSTER 
}

//WRITE TO CLUSTER
void FIS_WRITE_sendTEXT(String FIS_WRITE_line1,String FIS_WRITE_line2) {
  int FIS_WRITE_line1_length=FIS_WRITE_line1.length();
  int FIS_WRITE_line2_length=FIS_WRITE_line2.length();
    if (FIS_WRITE_line1_length<=8){
        for (int i=0;i<(8-FIS_WRITE_line1_length);i++){
          FIS_WRITE_line1+=" ";
          //Serial.println(FIS_WRITE_line1);
        }
    }
    if (FIS_WRITE_line2_length<=8){
      for (int i=0;i<(8-FIS_WRITE_line2_length);i++){
        FIS_WRITE_line2+=" ";
      }
    }

int crc=(255-FIS_WRITE_START+FIS_WRITE_line1[0]+FIS_WRITE_line1[1]+FIS_WRITE_line1[2]+FIS_WRITE_line1[3]+FIS_WRITE_line1[4]+FIS_WRITE_line1[5]+FIS_WRITE_line1[6]+FIS_WRITE_line1[7]+FIS_WRITE_line2[0]+FIS_WRITE_line2[1]+FIS_WRITE_line2[2]+FIS_WRITE_line2[3]+FIS_WRITE_line2[4]+FIS_WRITE_line2[5]+FIS_WRITE_line2[6]+FIS_WRITE_line2[7])%256;
#ifdef useSPI
  SPI.begin();
  SPI.setDataMode(SPI_MODE2);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV128);
  #endif
FIS_WRITE_sendByte(FIS_WRITE_START);
FIS_WRITE_sendByte(255-FIS_WRITE_line1[0]);
FIS_WRITE_sendByte(255-FIS_WRITE_line1[1]);
FIS_WRITE_sendByte(255-FIS_WRITE_line1[2]);
FIS_WRITE_sendByte(255-FIS_WRITE_line1[3]);
FIS_WRITE_sendByte(255-FIS_WRITE_line1[4]);
FIS_WRITE_sendByte(255-FIS_WRITE_line1[5]);
FIS_WRITE_sendByte(255-FIS_WRITE_line1[6]);
FIS_WRITE_sendByte(255-FIS_WRITE_line1[7]);
FIS_WRITE_sendByte(255-FIS_WRITE_line2[0]);
FIS_WRITE_sendByte(255-FIS_WRITE_line2[1]);
FIS_WRITE_sendByte(255-FIS_WRITE_line2[2]);
FIS_WRITE_sendByte(255-FIS_WRITE_line2[3]);
FIS_WRITE_sendByte(255-FIS_WRITE_line2[4]);
FIS_WRITE_sendByte(255-FIS_WRITE_line2[5]);
FIS_WRITE_sendByte(255-FIS_WRITE_line2[6]);
FIS_WRITE_sendByte(255-FIS_WRITE_line2[7]);
FIS_WRITE_sendByte(crc);
#ifdef useSPI
  SPI.end();
#endif
FIS_WRITE_stopENA();
}

void FIS_WRITE_sendByte(int Byte){
#ifdef useSPI
  SPI.transfer(Byte);
#else
  shiftOut(FIS_WRITE_DATA,FIS_WRITE_CLK,MSBFIRST,Byte);
#endif
}

void FIS_WRITE_startENA(){
  if (!digitalRead(FIS_WRITE_ENA)) {
  digitalWrite(FIS_WRITE_ENA,HIGH);
  delayMicroseconds(FIS_WRITE_STARTPULSEW);
  digitalWrite(FIS_WRITE_ENA,LOW);
  delayMicroseconds(FIS_WRITE_STARTPULSEW);
  digitalWrite(FIS_WRITE_ENA,HIGH);
  delayMicroseconds(FIS_WRITE_STARTPULSEW);
  FIS_WRITE_ENA_STATUS=1;
  }
}

void FIS_WRITE_stopENA(){
 digitalWrite(FIS_WRITE_ENA,LOW);
 FIS_WRITE_ENA_STATUS=0;
}
//END WRITE TO CLUSTER

[/quote]

Using that for code, but I'm getting nothing.  Just wanting something that'll display "Hello world" so I can understand the timings, that's all.

Gads.
Logged
ZZottel
Newbie
*

Karma: +5/-0
Offline Offline

Posts: 12


« Reply #20 on: August 22, 2015, 03:42:55 PM »

You are using the hardware SPI of the Arduino Uno.
The Uno has a 16 MHz clock.
You set the SPI divider to 128.
This results in an SPI clock of 125 kHz.
The 3LB is between 7 and 8 kHz.
Logged
adam-
Hero Member
*****

Karma: +124/-33
Offline Offline

Posts: 2179


« Reply #21 on: August 24, 2015, 07:57:40 AM »

Thanks man.  I'm going to have a look tonight to see how I can get the bus to go that low, first impressions show that it won't.

If it's not obvious, this is my first venture with custom hardware and software combined.  I have no past experience with SPI's, buses, ports, timings, etc, and all of this is massively new to me.

I'm going to keep reading and if you want, you can keep supplying snippets of advice, its fantastic! Smiley
Logged
adam-
Hero Member
*****

Karma: +124/-33
Offline Offline

Posts: 2179


« Reply #22 on: August 26, 2015, 12:05:59 AM »

So I did a bit of reading last night, discovered that the SPI divider is obviously the divider against the crystal clock speed.  In case of the Uno - which is 16MHz, a divider of 128 would result in a clock speed of 125kHz.

Since the SPI of the clocks is between 7 and 8kHz, I'd need a larger divider.  You can half the clock speed of the Uno, but its a bad method of programming, so I'm not going to go down that road.

Spent a good while researching bit banging, so seem to have a few ideas that I'm going to try.  I'll need to buy a sillyscope to help with matching the outputs.

All this prescaler, WGM12, DDRB is giving me a headache, but I'm going to plod on.  Trying to understand Port outputs, etc is difficult as I have no past experience with it.

I guess all of these questions are for an Arduino forum, rather than here though.  Just like to keep the thread updated with progress. Smiley
Logged
Tesla
Newbie
*

Karma: +0/-2
Offline Offline

Posts: 8


« Reply #23 on: October 20, 2016, 07:36:52 PM »

 Just like to keep the thread updated with progress. Smiley
Hi there!  Any updates?
  (@adam-)
« Last Edit: October 23, 2016, 06:36:37 PM by Tesla » Logged
funnix
Full Member
***

Karma: +1/-0
Offline Offline

Posts: 76


1.8t AUM


« Reply #24 on: October 20, 2016, 11:00:19 PM »

I'm very interested, too.
Logged
bennyboi
Jr. Member
**

Karma: +2/-0
Offline Offline

Posts: 33


« Reply #25 on: November 16, 2016, 12:21:40 AM »

http://secuduino.blogspot.co.uk/2011/10/fis-seat-leon-cupra-english.html
Logged
Tesla
Newbie
*

Karma: +0/-2
Offline Offline

Posts: 8


« Reply #26 on: November 19, 2016, 07:16:23 PM »

@bennyboi  Thanks for the link!
Just what I'm looking for.
Logged
Eintopf
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 4


« Reply #27 on: February 01, 2018, 11:03:55 AM »

Hello, is there any update?
Logged
adam-
Hero Member
*****

Karma: +124/-33
Offline Offline

Posts: 2179


« Reply #28 on: February 02, 2018, 12:34:05 AM »

Yes, I have a fully working FIS control on GitHub.
Logged
Eintopf
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 4


« Reply #29 on: February 03, 2018, 03:06:27 PM »

This works in a rs4 b5 2001 with can bus?
Logged
Pages: 1 [2] 3
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Page created in 0.062 seconds with 17 queries. (Pretty URLs adds 0.001s, 0q)