Author Topic: VAN bus interfacing (to read car speed and engine RPM Peugeot 206 1.4 HDI 2002)  (Read 95176 times)

0 Members and 2 Guests are viewing this topic.

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
EDIT: An early prototype has been created. It still needs some polishining, but seems to work:

Really nice job, that looks very slick  :-+
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
Thank you guys.
@yvesdm3000 The source code is not yet in a shape to be published as it has some bugs which I would like to resolve first. In the meanwhile I implemented writing on the bus, you can take a look at the code here: https://github.com/morcibacsi/esp32_rmt_van_tx

It is working on the bench with a multifunction display, however something is wrong with the wiring, as it does not work when I connect both of the CAN_H and CAN_L lines. I attached there the schema which is working for me. Need to investigate it why. Maybe those who are better with electronics than me could take a look what is wrong.

https://youtu.be/SQ3sJHYcR4E
 

Offline bagou91

  • Contributor
  • Posts: 11
  • Country: fr
Hello,
I am a French user.
I am interested in the work on the VAN bus of the car radio for my Peugeot 206 with RD3.
I try to simulate CDC changer with Arduino.

I use the morcibacsi 's library https://github.com/morcibacsi/arduino_tss463_van: It works fine for send frame ID E24 and 8A4 on VAN: I can to use RD3 without BSI.
RD3, EMF-B display and Arduino interface (TSS463+driver Alcatel2840) are connected.

I bought an Yatour MP3 bluetooth box that simulate CDC.
In attachment, dump frames with RD3 and CDC.

I would like to simulate CDC with Arduino, but I can't to send frame data CDC for simulate CDC with Arduino...
In my sketch Arduino, I add this:
Code: [Select]
//4E CB 86 C0 0E 46 0B 80 38 18 8C 07 00 80
uint8_t packet[12] = { 0x86, 0xC0, 0x0E, 0x46, 0x0B, 0x80, 0x38,  0x18,  0x8C,  0x07,  0x00,  0x80 };
VANInterface->set_channel_for_transmit_message(4, 0x4E, 4, packet, 12, 0);
VANInterface->disable_channel(4);
This code are repeated every second.

But push button CDC on RD3 does nothing.

Can you help me ?

Thank you
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
Hi,

Well... I think that the CDC message (4EC) is not a "write type" message that is why sending it with the set_channel_for_transmit_message() method won't do anything. I think that the frame type you need is the Reply Request frame with immediate reply (it can be found on the 20th page in the datasheet of the TSS463). Basically this message is generated by two participants. The requesting module (radio) will send the SOF (0E) and the identifier (4EC) and the rest of the message is generated by the requested module (CD changer). Unfortunately my library won't display these 'half frames' but I think it is actually there when you have the yatour disconnected. It should look something like this:

0E 4E CF 97 68

(where the  97 68 are the checksum bytes)

And if you have the yatour connected it will fill the bytes between the identifier and the checksum.

So at first I would suggest you to build my ESP32 based reader to check if this half-frame is there when you have the yatour disconnected (that reader just dumps the data from the VAN line). And if it is there then I would move forward to check how is it possible with the TSS463 to program this type of message to reply to the request with an in-frame reply.
Unfortunately I did not had the time to fully figure out and implement all message types, so the library is not 100% percent complete (it may also contain some bugs). But I would be happy if somebody could fill these missing gaps.
 

Offline bagou91

  • Contributor
  • Posts: 11
  • Country: fr
Ok.
I will to buy the IC sn65hvd230....
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
Actually you can connect the VAN line to the ESP32 directly, I used it like that for a few weeks and it worked. The CAN transceiver is there for the 5V-3.3V conversion. You can also build a small voltage divider, that also works. That way you don't have to wait for the CAN transceiver.
 

Offline bagou91

  • Contributor
  • Posts: 11
  • Country: fr
I have an ESP8266.
Is it possible to compile your sketch for this board ?
I tried to compile with Arduino IDE software for board esp8266 but I have errors.
Or what software you use to compile ?
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
The code works only on an ESP32 as the library depends on its peripheral named RMT. The ESP8266 does not have this peripheral that is why you couldn't compile it. I use Visual Studio and a plugin named Visual Micro for developing, but it uses the Arduino in the background to compile so the Arduino IDE should also work
« Last Edit: August 26, 2019, 09:12:38 am by morcibacsi »
 

Offline bagou91

  • Contributor
  • Posts: 11
  • Country: fr
OK so I must to buy an ESP32 rmt... :)
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
Any ESP32 developer board will work.
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
I checked the CD changer related information, and with this sketch it seems to work (at least you can change to the CD changer, and it will count from 01:00 to 01:59):

Edit: The seconds are in BCD so you have to convert it for correct output on the display.

Code: [Select]
#include "VanMessageSender.h"
const int VAN_PIN = 7;

AbstractVanMessageSender *VANInterface;
unsigned long currentTime = millis();
unsigned long previousCdcTime = millis();
volatile uint8_t seconds = 0;
volatile uint8_t headerByte = 0x80;


void IncrementHeader()
{
    if (headerByte == 0x87)
    {
        headerByte = 0x80;
    }
    else
    {
        headerByte++;
    }
}

void IncrementSeconds()
{
    seconds++;
    if (seconds == 60)
    {
        seconds = 0;
    }
}

uint8_t DecToBcd(uint8_t input)
{
    return( (input/10*16) + (input%10) );
}

void AnswerToCDC()
{
    uint8_t status = 0xC3; //playing
    uint8_t cartridge = 0x16;
    uint8_t minutes = 0x01;
    uint8_t trackNo = 0x17;
    uint8_t cdNo = 0x02;
    uint8_t trackCount = 0x21;
   
    uint8_t packet[12] = { headerByte, 0x00, status, cartridge, minutes, DecToBcd(seconds), trackNo, cdNo, trackCount, 0x3f, 0x01, headerByte };
    VANInterface->set_channel_for_immediate_reply_message(0, 0x4E, 0xC, packet, 12);
}

void setup(){
    VANInterface = new VanMessageSender(VAN_PIN);
    VANInterface->begin();
}

void loop() {
    currentTime = millis();
    if (currentTime - previousCdcTime >= 1000)
    {
        previousCdcTime = currentTime;

        IncrementSeconds();
        IncrementHeader();

        AnswerToCDC();
    }
}
« Last Edit: September 01, 2019, 06:36:00 pm by morcibacsi »
 

Offline bagou91

  • Contributor
  • Posts: 11
  • Country: fr
Hello,

Thanks you very much for your research of the good trame to send   :D
It works !

When I press the button CDC, it enable :)
Here the dump with Arduino that simulates CDC:
Code: [Select]
Arduino VAN bus monitor using TSS463C
Channel: 1:  8C 49 8A C1 2E
Channel: 2:  55 4B 80 C6 8F 1E C1 98 78 18 DD 07 3F FF FF BC 0E 06 01 80 38 18 0C 07
Channel: 1:  8C 49 8A C1 0C
Channel: 2:  8A 4B 80 C6 8F 1E C1 98 78 18 DD 03 3F FF FF BC 0E 06 01 80 38 18 0C 03 00 80 30 0C 8E 06 09 80
Channel: 3:  8C 49 8A C1 0C
Channel: 0:  4E CA 85 C0 0C CE 0B C0 80 FB 1E 0C 21 0F
Channel: 1:  8C 49 8A C1 3C
Channel: 2:  55 4B 83 C3 4D 1E C1 C2 C0 1C DD 03 3F FF FF AE 03 80 80 0C 0E 03 80 80
Channel: 0:  4E CA 80 C0 0E C6 0B 80 38 1A 1D 07 08 A3
Channel: 0:  4E CA 84 C0 0C C7 05 90 18 17 0B C0 81 0C
Channel: 0:  4E CA 80 C0 18 CE 0B C0 81 9E 1E 0C 27 1E
Channel: 0:  4E CA 81 C0 18 CE 0B C0 81 BE 1E 0C 27 1F
Channel: 0:  4E CA 85 C0 0E C6 0B 80 38 1B 1D 07 08 A3
Channel: 1:  98 49 00 80 0E 06 7F
Channel: 2:  4D 4B 85 C1 6D 0E 06 09 81 7A 3F 3F 3B
Channel: 0:  4E CA 80 C0 18 CE 0B C0 82 18 1E 0C 27 1E
Channel: 0:  4E CA 84 C0 0E C6 0B 80 38 3C 1D 03 08 A3
Channel: 0:  4E CA 80 C0 0E C6 0B 80 38 3D 1D 07 08 A3
Channel: 0:  4E CA 81 C0 0C C7 05 98 18 26 8B E0 81 0C

The EMF display: CD2 - track 17 - time 1.00++
and total: 21 tracks
« Last Edit: September 01, 2019, 04:40:36 pm by bagou91 »
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
I'm glad you succeeded. It is worth to check if you feed the audio lines on pins 18-20 of the blue mini iso on the head unit if it produces sound or not. I updated the library on github, take note that I changed the arguments of the methods and now you can define the identifiers as they are (you don't have to split them to two bytes).

Example:

Code: [Select]
    VANInterface->set_channel_for_immediate_reply_message(2, 0x4EC, packet, 12);

Instead of:

Code: [Select]
    VANInterface->set_channel_for_immediate_reply_message(2, 0x4E, 0xC, packet, 12);
« Last Edit: September 07, 2019, 05:51:35 pm by morcibacsi »
 

Offline bagou91

  • Contributor
  • Posts: 11
  • Country: fr
Thanks you for this update !

I tested audio from CDC pins: it's ok.
Audio outputs with ampli of RD3.
« Last Edit: September 02, 2019, 06:14:36 pm by bagou91 »
 

Offline adv

  • Contributor
  • Posts: 10
  • Country: fr
Hi gentlemen, salut à tous !  ;D

I recently found the morcibacsi's gitHub and already ordedred @ Ali, an esp32 and the CAN adapter to build my own sniffer/injector  :-+ thank you man for this awesome work, I wish I had the same skills to perform such work... then found this thread.

My goal is really simple, (could seem useless at your eye), I have a 406 coupé, and I replaced the Clarion radio by a Blaupunkt. Because of that I lost the radio name on the ODB (ordinateur de bord) or central display monitor. I would like to display a text instead like " I love my 406" or anything else to "fill" the screen as it's almost empty now, with just clock top right and fuel related data at the bottom.

Has anyone already decode in which data frame the radio station name is sent from the radio to the central display ?

If not I'll have to find out.

If you have an idea let me know  ;D

Thank a lot, merci beaucoup.

Antoine.
« Last Edit: November 04, 2019, 08:49:21 am by adv »
 

Offline bagou91

  • Contributor
  • Posts: 11
  • Country: fr
Bonjour adv

Désolé de te dire cela, mais tu n'as pas dû bien rechercher sur le sujet... :--
Avec un peu plus de recherches approfondi, tu la trouveras.
La trame pour la partie affichage radio RDS a été décodé et trouvable dans plusieurs des réponses apportées.
Et oui il faut lire les 4 pages...

Pour le remplacement de ton poste et la perte des infos, je suppose que c'est parce que tu l'as remplacé par un non origine PSA (VDO/Clarion).
 

Offline adv

  • Contributor
  • Posts: 10
  • Country: fr
Salut Bagou, désolé ça commence mal, je suis un habitué des forums et je sais que la recherche est le premier des trucs à faire mais dans les 4 pages je n'ai rien vu qui parlait de RDS et d'ailleurs j'ai fait une recherche sur RDS, tu n'as pas a être désolé ! Je viens de refaire un tour sur le site de Graham: http://graham.auld.me.uk/projects/vanbus/packets.html#554

Et là je trouve ça ahaaaa:
Databyte   81   D3   91   53   4B   59   52   4F   43   4B   20   81
Meaning   Header   Preset Info   Byte 2   SKYROCK{space}   Footer

Bon à suivre quand j'aurai reçu le matériel.
Ta supposition était bonne. Bon certes les autoradio de seconde monte ne sont pas super integrés mais j'ai un son autrement meilleur que l'origine.
A+


For English users: Bagou repplied I didn't watch the entire subject and this this matter has already been discused, I double checked but did not really find any subject talking about station name, latter I found more explanations on Graham's webpage about IDEN 554 where teh station name is sent.
I will investigate in this direction.

Thank you all !
« Last Edit: November 04, 2019, 10:49:19 am by adv »
 

Offline bagou91

  • Contributor
  • Posts: 11
  • Country: fr
Oui effectivement si tu recherches sur des termes précis comme "RDS" tu risques de ne rien trouver.
Pour ma part, j'avais lu les 4 pages + les divers liens et PJ pour en arriver à ma demande par rapport à la trame du CDC...

Regardes et fouilles le github de morcibacsi, tu trouveras des dump de frames et son décodage.
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
I will take a look on how to write RDS data to the display on this week. I suspect that first you need to send a message with the iden 8D4 to fool the display that the radio is on. After that the screen will start to ask the headunit with iden 554 for the RDS data. And that is the place where you can prepare a reply for that message type with your custom text.
« Last Edit: November 04, 2019, 03:30:49 pm by morcibacsi »
 

Offline adv

  • Contributor
  • Posts: 10
  • Country: fr
Köszönöm morcibacsi  8)

Quand à toi bagou, si j'ai bien compris tu arrives a leurrer l'autoradio pour lui faire croire que tu as un changeur et tu injectes le son via l'entrée audio du changeur c'est ça ?
Couplé à un récepteur BT a 5$ d'aliexpress ça mets un coup de jeune au poste d'origine !
 

Offline bagou91

  • Contributor
  • Posts: 11
  • Country: fr
Oui c'est tout à fait ça  :D
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
I have included an example in the github repository on how to display custom RDS text on the display. The length of the text is very limited, however I think it is possible to send multiple messages with the letters shifted to the left so it looks like the text is scrolling. I didn't want to ruin your fun so I pass the opportunity to you to play around with the scrolling text possibility. :) If you manage to have it working then please share it.
 
The following users thanked this post: adv

Offline beduino

  • Regular Contributor
  • *
  • Posts: 137
  • Country: 00
I have included an example in the github repository on how to display custom RDS text on the display.

Hello,
Very interesting stuff there  :-+

I think it could be very interesting to display gear choosen.
I've some idea howto do it based on engine RPM and vehicle speed, but strugle to read VAN bus using MCP2561 since MCP2551 is not recomended for new designs.

Maybe someone had success of using one of those high-speed CAN transceivers, but not with Arduino, but custom design with AVR MPUs?
For the moment all I need is engine RPM and vehicle speed - It could be also helpfull if we were able to know when clutch is "off" between gear change?
When talking about vehicle speed, probably there must be somewhere wheel rotation sensor eg. in Peugeot 206 to calculate vehicle speed based on this information? Does anyone knows how vehicle speed is sensed eg. in Peugeot 206?

It could be cool to do it and display on custom display or maybe even in aka HUD mode reflected on front windshield  ::)
 

Offline morcibacsi

  • Regular Contributor
  • *
  • Posts: 72
  • Country: hu
I successfully used sn65hvd230 with ESP32 to read the VAN bus. The clutch information has not yet found on the VAN comfort bus. It might be possible that it is only presented on the CAN bus between the BSI and the ECU. The source of the speed information is either the ABS sensors or the speed sensor located on the gearbox if no ABS installed.
 

Offline beduino

  • Regular Contributor
  • *
  • Posts: 137
  • Country: 00
The source of the speed information is either the ABS sensors or the speed sensor located on the gearbox if no ABS installed.
It looks like speed sensor located on the gearbox could be better than ABS sensors, since all we need to know is ratio between engine RPM vs gearbox output speed probably sensed the same as lower RPM.

Vehicle speed than is probably calculated by the means of wheel size (diameter) which can be slightly different based on tyre pressure etc.

Anyway, my car has ABS installed, but I'd like to sense rather gearbox output RPM, so probably in cars with ABS installed still gearbox sensing must be available eg. in the case of ABS failure, I guess?

I've Saleae logic analyser so maybe it is time to try sniff some VAN (CAN signals) from Peugeot 206 HDI (the same as thread author pointed out at the begining), but a there any some kind of database to compare with?
Isn't this comunication encrypted somehow and similar within lets say Peugeot 206 line starting from 2002 year model I own?

I can also try write AVR MPU code to filter out other messages on VAN bus, but howto recognize those one related to engine RPM and gearbox output speed?
Maybe when we see some real data captured myself therer will be something similar to what you already did, however I saw there were some differencies in what you captured in comparision to this information mentioned in this thread: http://graham.auld.me.uk/projects/vanbus/protocol.html   ?

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf