morcibacsi / esp32_rmt_van_rx

ESP32 RMT peripheral Vehicle Area Network (VAN bus) reader
MIT License
30 stars 9 forks source link

MCP2551/TJA1050 option #1

Closed tinwhisker closed 4 years ago

tinwhisker commented 5 years ago

Apparently the MCP2551 and TJA1050 CAN tranceivers can happily sit in the VAN bus. It may also offer:

The RXD pin should reflect the same data you skim from VAN-H, but with the bonus of handling the differential lines, etc.

I look forward to playing with your project later! I'll also try the TJA1050 as the have one spare.

Edit: Added reference to the TJA1050 by Philips. Pin-compatible, so whichever is easier to obtain.

morcibacsi commented 5 years ago

Hi, thanks for the info. Actually when I started to write the library I was experimenting with a SN65HVD230 CAN transceiver (as it is a 3.3V device) and it seemed to work, but it was not reliable (maybe it was a software bug), but later I stopped receiving messages so I ditched it. Maybe it was just a faulty hardware. Anyway I ordered a new transceiver, and when it arrives I'll check it again just to be sure. Propably I should also include some kind of schemantic in the start page. (Or if you have one, a pull request is very welcome :)) In the meanwhile I also started to write a library for writing to the bus. When it is ready I'll upload it also. But I have to get my head around the various message types as for now it is a little bit shady which one should be used when. Do you have any specific projects in mind regarding the VAN bus?

tinwhisker commented 5 years ago

I'll have a look at the SN variety if the TJA part doesn't work. Likewise, I'll have a shot at the schematic when I'm free.

My project is a replacement centre screen for my 206. It started last year as I have a few GLCD's kicking around; but as projects go, got left to the side. It'll also emulate the CDC, hopefully utilising the BT part of the ESP32.

So:

morcibacsi commented 5 years ago

Nice project. I also want to replace the display in my 307 with one from a newer car with CAN bus communication. So I have to read the VAN messages and translate them to the corresponding CAN message. This way I can throw away the old headunit and have a working RD45 unit with bluetooth from a Peugeot 308. I already have the first "kind-of working" version. I made a short video about it which can be found on youtube: https://www.youtube.com/watch?v=Dn4H4G8d5yQ

MacRaeMac commented 5 years ago

I am very rockie about this electronic things, but I am interesting to do similar with your project @morcibacsi. Would you like to share more detail:

morcibacsi commented 5 years ago

@MacRaeMac I added a simple schematics which I am using in my car. You need nothing special, the ESP32 is just a simple devboard. A SN65HVD230 type CAN transceiver is also an ordinary one. Both of them can be bought on ebay or aliexpress. I have exactly the same as in the picture I uploaded.

MacRaeMac commented 5 years ago

many thanks, how about sending CAN message to RD4/45 display? would you help provide the schematic?

morcibacsi commented 5 years ago

@MacRaeMac Basically it's the same. The difference is that the RD45 has a quadlock type connector rather than an iso one, but you can find the pinout for that on Google easily.

karolp1993 commented 5 years ago

I'm using MCP2551 with VAN and everything works fine. @morcibacsi VAN messages that you're sending to RD43 need to be edit somehow? Or you just forward frames? IMO, the best option is to use RT6. In lift 307 just works P&P.

morcibacsi commented 5 years ago

@karolp1993 RD43 uses a completely different protocol, and messages. To be able to turn on the radio, you need to send the ignition signal on CAN bus to it. And to not have beeping from your speakers the correct VIN number also need to be sent. Actually to have a working radio and display only these two things are needed. To have the warning messages, trip computer, air conditioning displayed on the new screen you need to translate (or map) the VAN frames to the corresponding CAN frames. Actually with these frames mapped I believe it could be possible to use an RT6 unit inside a pre-facelifted Peugeot 307 or in 206s also.

karolp1993 commented 5 years ago

Huh, just like I thought. So you sit in car and monitor VAN frames? How do you know how CAN frames looks like? My friend and I are working with VAN but we are using STM32. I've got few ideas but it's necessary to learn how to send VAN messages to car. We would like to make comfort blinkers (now I've "analog" module in my 307), follow me home from light sensor (like in facelifted 307) and few other features (yes, I know that are other VAN buses in car ;) ). Translate from VAN to CAN radio units it's also an interesting idea. I think that CAN frames are very similar or even the same in every newer units (RD4, RD45 or RT6) because in facelifted 307 BSI RD45 or RT6 unit is not available but works properly.

morcibacsi commented 5 years ago

Well I have a spare RD3 headunit, an odometer, a bsi, a com2000 and some of them are hooked up together on bench, so for basic stuff I can experiment with those. But there are cases when I need to be in the car. So I go there, I capture packets with timestamps, capture a video also with timestamps, and later I can 'replay' them without having to be in the car. I have a small application which inserts the captured packets to an SQL database, so I can query the various packets easily. There is a very good description about the VAN frames which can be found here and there on the internet. I also have an Arduino Pro mini board with a TSS463C and I am able to send basic VAN messages with that. For the CAN bus messages in PSA cars there is also a pretty good guide here: http://autowp.github.io/ Actually I have a plan to implement writing the VAN on ESP32 also but most propably it will take some time because I'd like to eliminate the bugs from my VAN-CAN translator first.

karolp1993 commented 5 years ago

Nice. I've also got COM2000, BSI, odometer and RD3 under the desk :D

morcibacsi commented 5 years ago

@karolp1993 If you are open to collaboration I am happy to help with your project (with testing and coding) and I am also open to help by sharing my libraries with you regarding the head unit and the screen.

MacRaeMac commented 5 years ago

@morcibacsi I would like to join too, I have RD45 HU and display, my car is first gen 307 so definitely using VAN protocol, I have plan to make something VAN2CAN translator.

Is it possible if we replace ESP32 using ESP8266? since it is smaller and cheaper, I saw on your schematic we need only 2 data pin to communicate it should be sufficient

morcibacsi commented 5 years ago

@MacRaeMac Actually it is not possible, the ESP8266 does not have an RMT peripheral which is needed to read the VAN protocol and also lack a CAN peripheral which is needed to communicate with the HU and the display.

tinwhisker commented 5 years ago

To add, it is possible, but probably not reliably.

You could use the principles of CNlohrs usb example, but the effort to get something useful - you may as well use an AVR or the ESP with suitable peripherals.

morcibacsi commented 5 years ago

Well if you are speaking in theory on what is possible, then yes, of course it is possible to write code to whatever MCU to read the VAN bus. But as this library is about reading VAN bus with an ESP32 then my answer is still the same: it is not possible to use use an ESP8266 with this library. And also it does not make any sense to add support for ESP8266 to this library as that MCU lacks features which this library heavily depends on. As MacRaeMac wrote his intention is to write a VAN2CAN translator... and ESP8266 does not have any features which is needed for that (nor CAN nor RMT). He can hook up the needed hardware to it to have that working but that would have nothing to do with this library. But I have to admit that it would be a nice project to do, but actually considering the ~2 USD difference between the two hardware it just simply does not worth it.

karolp1993 commented 5 years ago

@karolp1993 If you are open to collaboration I am happy to help with your project (with testing and coding) and I am also open to help by sharing my libraries with you regarding the head unit and the screen.

My project is not developed to that stage which let us do something together. For now we have a simply receiver (tested on dashboard only) - code for STM was wrote by my friend, I've to make some circuit board for that and frame interpreter on PC (Python maybe). Then we could try to connect to the BSI or the car. But I will be happy to help with your project.

tinwhisker commented 5 years ago

@morcibacsi Of course theoretically, though all of the parsing and eManchester decode would leave the reader just the exercise of handling interrupts as fast as they can.

All out of the scope here of course - I need my ESP32 to do a fair bit of other work too!

tinwhisker commented 5 years ago

@karolp1993 probably the most useful thing is to keep the VAN parsing and CAN parsing independent, with suitable interfaces.

My own goal is to parse the VAN as fully as possible, so that I can extend the project later if needed. (I have PSA diagnostic cable, so should be able to invoke extra stuff too)

SERGIO0004 commented 5 years ago

Hello, Thank you for sharing your project. I´m try to make a adapter to use a citroen xsara steering wheel control to control a android car radio. I use a arduino nano and mcp 41100. Is posible to use this proyect with an arduino nano and a mcp2551? Thank you. Now i try to use other project with a tss463 with arduino. This: https://github.com/lazarov-g/vanreader.

morcibacsi commented 5 years ago

@SERGIO0004 Hi, this library supports ESP32 only. If you want to use an Arduino Nano you can check my other library here: https://github.com/morcibacsi/arduino_tss463_van It is based on lazarov-g's work.

SERGIO0004 commented 5 years ago

Ok. Thank you. I will check it.

morcibacsi commented 5 years ago

Hi, I created a library for writing the bus, you can check it here: https://github.com/morcibacsi/esp32_rmt_van_tx https://youtu.be/SQ3sJHYcR4E 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.

morcibacsi commented 4 years ago

Back to the topic: I can confirm, that MCP2551 is working fine to read the bus. It is even good for writing with a TSS463. Schematics can be found in this repository: https://github.com/morcibacsi/PSAVanCanBridgeHW/tree/v1.4