laurynas / volvo_crankshaft

Volvo V50 RTI Crankshaft project
MIT License
50 stars 6 forks source link

Wiring #7

Open tequitotortilla opened 3 years ago

tequitotortilla commented 3 years ago

Hi Laurynas!

Such a great project, it has been great so far! I'm currently wiring up my pro micro to everything. I already tested it and had the same results as shown in your YT video where you can see the screen getting up. With that project, the RTI is connected using the Tx pin of the pro micro. (had to swap serial with serial1 because I cheaped out and did not get the Arduino version). Now when looking at the .ino file in this repo I get a little confused; please correct met if i am wrong. I deduct from the code that the RTI display is now wired via pin 10 with ground still to ground. Now I think the MCP2003 Rxd pin should be connected to the Pro Micro Tx pin. And the MCP Txd pin should be connected to the Pro Micro Rx pin. MCP2003 CS pin to 15 and with no FAULT pin on the 2003, I think pin 17 (RX led) is not connected. Wiring the Pi directly to acc power in the car is a bad idea since you will be pulling the plug instead of a graceful shutdown. I see in the .ino script that you have implemented a Pi power button too. Which I assume turns the Pi on and off so it can stay wired to the battery 12V. I am not sure how this is connected to the Pi? I was hoping you could help me out here. When the Pi is shut off is will not give power to usb (right?) so how is the Pro Micro powered to receive the signal to turn the Pi on? I will wire the screen driver board to acc power since it does not need to be powered when the car is off.

Thank you for sharing this amazing project for everyone. Kind regards from Amsterdam, Niels

tequitotortilla commented 3 years ago

Update: I've connected everything up and installed it in the car. Unfortunately the steering wheel buttons are not working. I've wired my MCP2003 Vbb -> 12v Vss -> ground Lbus -> Car lin bus (pin 2 from media system) CS -> 5v powered pin on the arduino Rx -> arduino Tx Tx -> arduino Rx

If I understand the documentation of the mcp correctly this should be working.

laurynas commented 3 years ago

Hi @tequitotortilla, sorry for delayed answer.

The pin numbers are configured in the arduino source code: https://github.com/laurynas/volvo_crankshaft/blob/main/volvo_crankshaft.ino#L17

You can also try the this simple debugger: https://github.com/laurynas/volvo_linbus

I was doing my project on Volvo V50, I'm not sure if all models use the same codes. I think other models, like S80 uses CAN-Bus for steering wheel buttons: https://luuk.cc/p/vD2f/Android_Auto_on_Volvo_RTI

Erik187v commented 2 years ago

Hi Laurynas!

Wiring the Pi directly to acc power in the car is a bad idea since you will be pulling the plug instead of a graceful shutdown. I see in the .ino script that you have implemented a Pi power button too. Which I assume turns the Pi on and off so it can stay wired to the battery 12V. I am not sure how this is connected to the Pi? I was hoping you could help me out here. When the Pi is shut off is will not give power to usb (right?) so how is the Pro Micro powered to receive the signal to turn the Pi on? I will wire the screen driver board to acc power since it does not need to be powered when the car is off.

Thank you for sharing this amazing project for everyone. Kind regards from Amsterdam, Niels

Did you solve how the power to the rpi and arduino is controlled?

From what i can tell the arduino starts and shutsdown the rpi on ignition but i have the same question as you do, if the arduino is powered by the rpi how does it start the pie?

what am i missing?

kind regards

tequitotortilla commented 2 years ago

Hi Erik, I did solve the issue in the end by just shutting down the power on the RPi with the ignition. It is not very graceful but in one of the processes the RPi was set to only read not write on storage. If systems get corrupted with ungraceful shutdowns it is mostly because the system was interrupted while (re)writing system files. Because the system is read only that does not happen and it reduces the chance of a corrupted system. Mine is stull running after 6 months at least. Although I never got the steering wheel buttons to work :(

Lukasguy commented 2 years ago

Did you ever try connecting the Rxd pin of the MCP to the Rx input of the arduino? Rxd stands for Rxdevice (I think) and according to the datasheet it's an output. Thus Rxd has to be connected to Rx and Txd has to be connected to Tx (which is confusing because normally it's the other way around). The typical applications section 1.4 also shows this. I would test & verify this myself but I'm still in the testbench phase, though I will run into this later.

Also thank you Laurynas for this project! It has been a huge inspiration for me to integrate Carplay into my C30!

Erik187v commented 2 years ago

Hi Erik, I did solve the issue in the end by just shutting down the power on the RPi with the ignition. It is not very graceful but in one of the processes the RPi was set to only read not write on storage. If systems get corrupted with ungraceful shutdowns it is mostly because the system was interrupted while (re)writing system files. Because the system is read only that does not happen and it reduces the chance of a corrupted system. Mine is stull running after 6 months at least. Although I never got the steering wheel buttons to work :(

Its figured it out, he left out the transistor and some resistors acting as a power switch, shorting pin 5 and 6 to turn on the PI when its off and using a shutdown script turning it off gracefully with the pin is high (stays low when ignition is on because the pins is shorted). I used a BC574 and 2x 1k ohm resistors to act as a switch. instead of using the output from the arduino as he did you could hook it upp directly to the cars ignition as i did with a regulator in between!

Script example - shutdown after 15min when iginition goes off and cancel if it goes on before 15min (I did some modifications where i turn off the LCD directly and on again if ignition goes live so if i stop for gas i dont have to wait for the pi to boot).

! /usr/bin/env python

import time import RPi.GPIO as GPIO import subprocess GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False)

pin = 3 // pin 5 is gpio 3

GPIO.setup(pin, GPIO.IN, GPIO.PUD_UP)

while True: button_state = GPIO.input(pin) if button_state == GPIO.HIGH: subprocess.call(['shutdown', '-h', '15'], shell=False) print ("Ignition off") else: subprocess.call(['shutdown', '-c'], shell=False) print ("Ignition on") time.sleep(5)

wiring https://ibb.co/hCQfXMJ

Regulator 12v -> 5v: (https://www.amazon.se/ARCELI-AMS1117-3-3-sp%C3%A4nningsregulator-avst%C3%A4ngningsbar-str%C3%B6mf%C3%B6rs%C3%B6rjningsbuljong/dp/B07MY2NMQ6/ref=asc_df_B07MY2NMQ6/?tag=shpngadsglede-21&linkCode=df0&hvadid=476494280050&hvpos=&hvnetw=g&hvrand=11235609586753939146&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=1012475&hvtargid=pla-966668914992&psc=1)

Erik187v commented 2 years ago

Did you ever try connecting the Rxd pin of the MCP to the Rx input of the arduino? Rxd stands for Rxdevice (I think) and according to the datasheet it's an output. Thus Rxd has to be connected to Rx and Txd has to be connected to Tx (which is confusing because normally it's the other way around). The typical applications section 1.4 also shows this. I would test & verify this myself but I'm still in the testbench phase, though I will run into this later.

Also thank you Laurynas for this project! It has been a huge inspiration for me to integrate Carplay into my C30!

Im also installing Carplay on my C30 using Open Auto. But the biggest problem for us is that we need to keep the original LCD! But not anymore, hit me up if u want the option to stream the ICM instead, i'd be happy to help out!

Bye bye crappy LCD : https://www.youtube.com/shorts/r7sB46zHM6A

laurynas commented 2 years ago

Hey, sorry, missed most of the discussion :) Just my 5 cents - I'm using my solution almost daily. There is no graceful shutdown, just the hard power off. Works fine for more than a year.. :)

And yes, I have connected MCP serial to Arduino: https://github.com/laurynas/volvo_crankshaft/blob/main/media/sketch_bb.png

Pabiloboss commented 2 years ago

Hi guys! This is an amazing job @laurynas !!!

I first begun with luukesselbrugge´s project, since I own a volvo s80, but after digging the web and researching technical docs I finally decided to follow your way. My S80 is a P3 and it comes with premium sound, which I love, but navi is ra....ish.

Indeed, the P3's steering wheel controls run over LIN bus (I remember some doubts about it in some other issue pages).

Ok, not to making this a neverending post, I´ll go to the point. I´m a retired old school programmer who has never dealt with electronics so, any code for me is affordable (even not being familiar) but pins, voltages and so on.... I always played with devices already plugged by other guy.

After this intro let me ask you about my dilemma: I read thoroughly all steps for LIN debugger (https://github.com/laurynas/volvo_linbus), understood what it does and tried it on my car using a MCP2004A. It works like a charm! I got loads of code lines and let me tell you your V50 SWM key codes are identical to my S80´s. Now I´m going to implement your whole project and I got stuck in the very beginning of the code. I cannot run any code I can´t understand (it´s like a principle for me) and in my view, I miss a few pins to define. I´m pretty sure there´s something I miss or simply don´t know, since I´m beginner to electronics. What I´m missing is rx, tx and fault pin for the mcp. I see CAN BUS pins to controlling the screen but MCP´s are missing for me. So I don´t know what to pin where... :(

I hope you can through some light for me on this. @Lukasguy @tequitotortilla @Erik187v I would appreciate your help as well.

Thank you guys!

Erik187v commented 2 years ago

I hope you can through some light for me on this. @Lukasguy @tequitotortilla @Erik187v I would appreciate your help as well.

Thank you guys!

From what understand reading the documentation of MCP2004 the fault pin is not needed to read lin-bus, but if it is just set any digital pin to high like CS pin on setup..

tx rx pin is a bit confusing cuz mcp is opposite according to documents. U connect tx arduino to tx mcp and so on.

the tc rx pins for the mcp u find in the mcp documentation.

the tx rx pin on arduino bords vairy. On my teensy 4 "Serial1" (tx/rx) its 0 and 1. So to this is not something you decide your self like other pins, its hardcoded...

so short answere: connect tx to tx, rx to rx.

mcp tx/rx u find in documentation.

arduino tx/rx u find in a pinout of your board wich pinns it uses for "serial1"

you do not need to specify these pinns in the ino. They are in the core library

Pabiloboss commented 2 years ago

Thanks @Erik187v , it makes sense, and you've saved me a lot of time trying to figure this out. I'll give it a try this evening and I'll tell you

Pabiloboss commented 2 years ago

Last thing that I am confused about.... Can High pins to arduino pin 10 (Tx) or the other way around? @Erik187v I´m right now in the car.... :)

Pabiloboss commented 2 years ago

Guys, after a couple of days struggling with it, arduino is not sending anything to the raspberry (or the raspberry does not listen) When I used the arduino with the mcp2004 as a linbus reader, it worked like a charm, but nothing happens with the volvo_crankshaft.ino. Most likely I´m doing something wrong, pretty sure, but I have no clue where to start debugging. The only modification I´ve done is to substitute RX_LED 17 for the LED_BUILTIN, obviously not defining it and swapping RX_LED for LED_BUILTIN in the three lines it appears. RTI_TX_PIN 10 pinned to RTI Screen on CAN HIGH RTI_RX_PIN 16 pinned to RTI Screen on CAN LOW

MCP connected as Erik told me before.

Any idea? suggestion?

Lukasguy commented 2 years ago

For the RTI screen, you need to connect the TX pin of the arduino to the serial pin (I think it's pin 4) of the RTI Screen module. No need for CAN or LIN in this case. Also you should never connect anything to CAN for this project. Only LIN, which the MCP2004 is used for to decode the steering wheel controls.

Are you sure you can read the steering wheel controls using the MCP? The code converts them into keyboard presses, so you have to connect the USB to the raspberry pi so the arduino acts as a keyboard

Pabiloboss commented 2 years ago

Thanks @Lukasguy.

For the RTI screen, you need to connect the TX pin of the arduino to the serial pin (I think it's pin 4) of the RTI Screen module. No need for CAN or LIN in this case. Also you should never connect anything to CAN for this project. Only LIN, which the MCP2004 is used for to decode the steering wheel controls.

But if I understood well, Arduino´s TxRx (ports 0 and 1 in my micro) are linked to MCP2004´s TxRx with CS_PIN pinned to Arduino´s 15, FAULT not linked. And then RTI´s screen pins 2, can high, and 3 can low (as in VIDA software), pinned respectively to Arduino´s 10 and 16, NO PLUGGED TO CAR´s CAN BUS, just between both, Arduino and the Screen Module.

I´m pretty sure there is something wrong with my pin diagram since this software worked for you all. I tried VOLVO_LINBUS again and again, works like a charm, but as soon as I upload volvo_crankshaft to Arduino and pin all stuff accordingly, It simply does not work.

According to my suspicion, I modified the serial1 availability code as follows: if (Serial1.available()) { read_lin_bus(); Serial.println("Serial1 available"); } else { Serial.println("Serial1 NOT available"); }

As you can guess it always returns NOT available and I haven´t gone deeper since I don´t have much time right now.

Are you sure you can read the steering wheel controls using the MCP? The code converts them into keyboard presses, so you have to connect the USB to the raspberry pi so the arduino acts as a keyboard

Yes, in fact, using the volvo-linbus.ino I got all the steering wheel control codes through both, Arduino IDE´s terminal and a specific windows app for reading serial ports, just to double check.

Any help would be more than appreciated guys. I am pretty sure the problem are my wiring skills. As I told you previously, I am an old school programmer but talking about electronic design I am a donkey.... @tequitotortilla @Erik187v @laurynas

Erik187v commented 2 years ago

I dont use the rti part since i replaced the original icm so i cant help with that in sorry.

as long as the wires are right u could debug with any linbus reader. There is plenty out there with better support! As long as u have it reading linbus u can work on the software for the keyboard ur self. Its the best way to tackle this. I decided to use another linbus frame and built my kerboard handeler my self and just skipped the rti part.

but to make it easier for u i would suggest that. Try another clean linbus reader slave source and build upon that instead

Pabiloboss commented 2 years ago

I dont use the rti part since i replaced the original icm so i cant help with that in sorry.

That's dreat! That was my first idea, to replace the icm, but I have the premium sound system which is dawm good but, unluckily, all configurations go through the original icm, so I ended up just replacing the Navi...

Erik187v commented 2 years ago

I dont use the rti part since i replaced the original icm so i cant help with that in sorry.

That's dreat! That was my first idea, to replace the icm, but I have the premium sound system which is dawm good but, unluckily, all configurations go through the original icm, so I ended up just replacing the Navi...

I still use the original amplifier and i kept the icm module ans hijack the lcd signal and display it as a overlay on my setup. I can still use the original configuration and menus i just dont have the old lcd

https://youtu.be/h19fsgQmMdM

Pabiloboss commented 2 years ago

I still use the original amplifier and i kept the icm module ans hijack the lcd signal and display it as a overlay on my setup. I can still use the original configuration and menus i just dont have the old lcd

https://youtu.be/h19fsgQmMdM

Simply amazing! Great job! I look forward to seeing your progress! Even though it´s not my goal (I rather like navi on top of the dashboard), if you´d like to test your project on a S80 P3 just let me know. I´m more than willing to collaborate, @Erik187v

Pabiloboss commented 2 years ago

Guys, I had the suspicion, but now I´m sure. In P3 configuration, at least my S80´s, rti screen is managed via low speed CAN BUS. I've been through VIDA and it is crystal clear. So now I´ll make my own research and CAN sniff so I can modify laurynas code accordingly. I´ll let you know when sorted out.