Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Establish a LIN-Bus connection with USB-8476

Hi everyone,

I'm new to Labview and LIN-Bus, have read the LIN-Spec, the Hardware Manual and a lot of threads but am still stuck.

The situation is as follows:
I want to use a 8476-module and Labview 2013 to communicate with a product

 

The module is connected (via USB) to the PC and recognized by MAX. I assigned Port: LIN0 and Baudrate: 19200 (as specified for the product).

 

The connector of the product has the following pins:

  • 12 V plus potential
  • 12 V ground
  • LIN
  • Interlock in
  • Interlock out

I connected the 12V+ to VBat; the 12V- to both ground Pins and LIN to LIN. Also I connected a 12V-power supply (5A max) to the 12V+ and 12V-. So the first question is: is this it? Here it seems like some resistors and diodes need to be added; but as I read it from the NI-CAN Hardware and Software Manual, 4-26, this isn't needed on NI USB-Lin products.

 

I'm assuming that everything is correct by the means of hardware and will proceed.

I want the 8476 (or more specifically the .vi) to be the master, because I want to control the product. My understanding is, that this is possible with the example .vi's (e.g. LIN Master Send Header Frame an Receive.vi), by simply sending an ID (or more correctly: a Frame Header) to the BUS and having my product react to it. Is it that simple?

I had an ldf coming with the product, where the frames and signals are described:

LIN_description_file;
LIN_protocol_version = "2.0";
LIN_language_version = "2.0";
LIN_speed = 19.2 kbps;
Nodes {
	Master: PC, 5 ms, 0.2 ms;
	Slaves: ..., HEIZER;
}
Signals {
...
	Geraet_ein: 1, 0, PC, GERAET;
...
	Temp_Sensor: 8, 254, GERAET, PC;
...
}
Diagnostic_signals {
...
}
Frames {
...
	Ger_01: 28, PC, 4 {
...
		Geraet_ein, 8;

	Ger_02: 48, GERAET, 8 {
...
		Temp_Sensor, 48;
...
}
...
}
}
Diagnostic_frames {
...

Node_attributes {
...
	GERAET {
		LIN_protocol = 2.0;
		configured_NAD=0x5F;
		product_id=0x0006, 0x0000, 0x00;
		response_error =Geraet_ResponseError;
		P2_min = 10 ms;
		ST_min = 10 ms;
		configurable_frames {
			Ger_01 = 0x401C;
			Ger_02 = 0x4030;
		}
	}
}
Schedule_tables {
	main {
		Ger_01 delay 10 ms;
...
		Ger_02 delay 10 ms;
...
	}
}
Signal_encoding_types {
...
	Temp_Sensor_encoding {
		logical_value, 254, "Init";
		logical_value, 255, "Fehler";
		physical_value, 0, 220, 1, -50, "Unit_DegreCelsi";
	}
...	
		HZ_Off_On {
		logical_value, 0, "Aus";
		logical_value, 1, "Ein";
	}
}
Signal_representation {
...
	Temp_Sensor_encoding: Temp_Sensor
...
	HZ_Off_On: Geraet_ein
...
}

In order to read "Temp_Sensor" my assumption was that I need to send the Header-ID "48" to the BUS because of

Frames {
    Ger_02: 48, GERAET, 8 {

With "LIN Master Send Header Frame and Receive.vi" it seems possible to "Write Header Frame", but the problem starts with the fact, that It won't accept the "ArbitrationId: 48". Then I thought this might be hexadecimal, and with "ArbitrationId: 30" there is something happening (see screenshot), but I'm still getting no response from the slave.

So, I'd be thankful if somebody could tell me where I am going wrong!
Thanks!

Download All
0 Kudos
Message 1 of 9
(8,023 Views)

Small step achieved!

Out of chance, I wrote the Header Frame twice within a few seconds (double click) and suddendly there's an answer. A few seconds later the slave gives a different answer (see screenshot). Now, sometimes by Frame Type it says "LIN BUS Error", sometimes it's "LIN Full Frame". I don't know why, but on the other hand the answer is always the same, so maybe no reason to worry?

What's bothering me now:
Somewhere here I found the lfd-Example-.vis, including Convert LDF Frame.vi and Convert Data to LDF Frame.vi. The first one translates the frame response into statuses and seems to work. With the second one I hoped to be able to create response messages I could send from the Slave Task of the master to the bus, in order to control the slave. Sadly the "Data frame out" is always  0x0x0x0x0x0x0x0. Has anyone an idea what might be wrong?

0 Kudos
Message 2 of 9
(7,965 Views)

You can interpret the bus error frame on page 446 (roughly) of the NI-CAN user manual: http://www.ni.com/pdf/manuals/370289n.pdf

 

You are getting 0xC008, which is an invalid checksum bit for most of the errors. My guess is that you have your interface configured for classic checksum when you need enhanced checksum (or vice versa). You configure this using ncSetAttr.

Message 3 of 9
(7,952 Views)

Thank you GPIB_Guru! I really forgot to configure enhanced checksum.
Now I always get the full frame as response, as soon as I send the requesting header frame (0x30) a second time (as seen in screenshot).

 

Sadly, I still can't send commands to the slave. I changed my .vi a little bit in order to try different frames and get an immediate answer (.vi attached). But it looks like this can't be solved by "try and error", and I'll have to understand the communication first 🙂

Is my assumption correct, that I need to send a full frame with the header-ID=28 and the spefics of all signals in the Slave Response Frame?

0 Kudos
Message 4 of 9
(7,912 Views)

Hello...Im having the same issue as you...could you share how you fix the issue please, Im stuck in the same step as you and Im not able to go forward.

 

Thanks in advance.

0 Kudos
Message 5 of 9
(6,896 Views)

Hi Renegaxiola_AE!

My slave device was defective..... With a new one, the "LIN Master Send Full Frame and Receive"-vi worked.

 

But I couldn't solve the problem that the Header Frame had to be sent twice and it wasn't easy to find out what the full frame had to look like for my slave to give the expected reaction.

Maybe I can help a little better if you describe the exact point at which you're stuck.

0 Kudos
Message 6 of 9
(6,878 Views)

Hi, thanks for your response...where Im stuck is that, doesnt matter which ID I sent, the response is always "Lin BUS Inactive" I havent been able to fix it.

0 Kudos
Message 7 of 9
(6,863 Views)

Do you have any documentation of the slave device, that states which the ID should be? Did you try sending the frame twice?


Maybe someone might help if you specify the problem a little better.

0 Kudos
Message 8 of 9
(6,848 Views)

I already had reply from my slaves (Frame ID=0x0D, with responses from slaves with 0x0E and 0x12), it is a lamp what I want to control, but looks like Im getting progress.

 

Attached are the request(0x0D) and responses from my two slaves(0x0E and 0x12), hope this is correct. 🙂

0 Kudos
Message 9 of 9
(6,846 Views)