You may want to check this thread out. http://forums.bimmerforums.com/forum...to-Can-signals
It has been tested a bit more than the method in this thread (though both should work). Just depends on what way you want to go and what you are comfortable with.
Here is an in car test.
It is a similar program to what is used in the video in post one. But the hard ware is improved. And AC sensing is also part of the package.
thaniel
So, I have a '96 M62 in a 2000 E46 328. Any chance this might be a solution to sort the temp and tach?
Yah the tach pickup is generic/configurable so it doesn't really matter what engine it's from. Installed one a few weeks ago into an LS1 E46 M3.
Another thought, if the engine you have is OBDII compliant you could pickup OBDII messages over the ISO bus (TXDI) then transmit the corresponding messages to the E46 via the can bus. Both work.
Thaniel
Wouldn't picking the messages up through OBDII be way too slow for this type of data?
From the observations I have using OBDII data for real time, it only seems to be good for stuff like temperatures and levels. Anything that changes in fairly dynamic manner, like RPM or Oil Pressure, it would be too slow to work with in real time over OBDII...
- 96 328is 6.0L. (LS1 to LS2 build thread: http://forums.bimmerforums.com/forum...ad.php?2098938)
- 96 328is 5.7L. (LS1 build thread: http://forums.bimmerforums.com/forum....php?t=1289987)
- 95 ///M3 6.0L. (LS2 build thread: http://forums.bimmerforums.com/forum....php?t=1619249)
- 97 ///M3. (e46 Fender Flares/track car build thread: http://forums.bimmerforums.com/forum....php?t=1727098)
- 96 328is (Dual Fuel Pump to Surge Tank thread: http://www.bimmerforums.com/forum/sh...ad.php?1964025)
That was my initial thought too. And in at least one of my tests this was true (landrover Discovery I). But to my surpise it keeps up pretty decent. Here's a video of my cluster being driven off a LS1 that was in my E36 (VPW OBDII protocol).
And here is a E46 cluster being driven by an Renault Laguna (can bus protocol)
And here is one being run of an LS3 in and E46 (Can Bus Protocol)
I know I've recorded one of my test cluster being driven by a E46 (ISO protocol) and I think it was still ok. (E46 uses the ISO protocol) But I tried it on my Landrover Discovery (Lucas electronics) which also uses the ISO Protocol and it worked but I wouldn't want to use it.
For Can to Can stuff the speed is high enough there is no issue. With the other protocols it depends how fast the ECU will respond OBDII requests.
There is more than one solution that will work.
Thaniel
Last edited by Thaniel; 11-18-2014 at 05:33 PM.
Hello, i have a bmw e46 with a engine from bmw e36 that has 60-2 trigger wheel. When i use your code the rpm goes around and make no sense at all.
//********************* sense RPM from pin 2 ***************
//Called from interupt command
void RPM_sense() //Capture RPM time from pin 2
{
timePULSE = micros(); //Captures current clock time
timeRPM = timePULSE - timePULSE2; //Captures pulse width time
timePULSE2 = timePULSE; //Save current clock time for next time
//60sec/#pulses for 1 rev * 1million (for micro seconds)/ time for 1 pulse
RPM = 60 / p_REV * 1000000 / timeRPM; //multiply for more than one pulse measured (60-36forLS1)
rMSB = RPM/40; // MSB of RPM value
}
What are the values i should change to in your code?
EDIT: The rpm signal from my e36 engine gives 9.8v when i turn on the ignition. Any solution on that?
Last edited by forsberg; 04-04-2015 at 07:45 AM.
Congrats to getting that far. To answer your question directly p_REV is the variable that I store the number of pulses per rev that it will count. it is currently set for 4 pulses per rev or something like that. If you are sending a a 60-2 signal then it would be crazy. The code is designed for an evenly spaced pulse signal (notice the LS1 to E46 subject line :-) ).
I'd recommend using the tach output from the DME and not the crank signal. And be careful with your voltages and circuit going to the arduino. It can only take 5 V max.
Thaneil
Hi All
Great thread, there's some really good info here. Thaniel you've done some epic work mate.
First off. I hope this all makes sense I'm coming at it with a software/electronics background rather than a automotive one.
I'm currently trying to help out a mate who is swapping an S85 into a E85 Z4. Unfortunately he's having a problem getting the stock Z4 instrument cluster to fire up.
He's been told by his contact at BMW that it needs a CAN bus rpm message for it to get going. The problem is his aftermarket ECU doesn't have enough outputs remaining to generate it (apparently the V10 uses a lot!!).
From what I've been reading in this thread I _think_ we can feed the crank pulse into a microcontroller and use that (connected a CANSPI) to put the rpm message onto the existing Z4 CAN bus.
Our current understanding of the problem is that we only need the rpm message as the other messages for the instruments (speed, warning lights etc) are being generated elsewhere in the existing Z4 CAN bus system. We're not totally sure how true that is, but for now just getting the tacho working would be a start.
I just have a few questions. Hopefully Thaniel is reading as they are mostly related to his code.
1) The first one is the biggy......Is what I'm suggesting totally crazy? I just wanting to make sure I've not misunderstood something really basic about what is going on here.
Assuming I've not lost it.......
2) Does anyone know how many pulses the S85 puts out for 1 rev? In Thaniels code I this is p_Rev, it's set to 2 but I'm not sure if this is the same for all engines.
3) The rpm interrupt handler doesn't seem to be setting the LSB, is there a reason it doesn't need to?
4) Also in the rpm interrupt handler the MSB is being set to the engine rpm / 40, I'm just wondering how 40 was derived? Sorry this is just me being a software engineer and having a fear of magic numbers.
5) Another magic number one. When converting the CAN bus rpm message back you say to divide the value by 6.42, is the value not already in rpm?
Sorry for the brain dump. Any help would be greatfully appreciated.
Hi thanks for the compliments.
We need to connect up through email to discuss the specifics of your project. But yes it is entirely possible. Just finished putting the finishing touches on a z4 project.
If you haven't already loo hart
http://www.bimmerforums.com/forum/sh...an-bus-project
the formulas you ask about are there. Anyway I'll pm my e-mail and we can talk.
thaniel
Hello Thaniel, Jose from California do you think you can tell me wat arduino are you using? How do you program it and hpwndo you wire it up workin on e46 me with ls3 swap
Hi Thaniel,
First of all well done for your great work!
Is the E46 similar to the E90 regarding the format of CAN messages and CAN-Bus? Because I was wondering if I can use the attached PDF file to see if the gauges work or not on my E90 Instrument Cluster. However, the problem is that the when I downloaded the PDF file, it could not be loaded. Is it possible if you PM me the file so that I can further experiment on my project?
Thanks in advance and really appreciate your help!
Robert
There's a separate thread for E90 CAN.
I found this thread about the E90: https://www.bimmerforums.com/forum/s...65-E87-)/page2
Is it this one that you are referring to or maybe there is another thread?
Robert
Wow very great Project!!!! What Hardware do i need for only operate the rpm and Speed needle? first not over can
There are some suggestions in this thread: https://www.bimmerforums.com/forum/s...an-bus-project
If doing an engine swap getting the engine data in is much harder than driving the gauges. And that's not covered in the thread linked.
Great job! This makes life a lot easier
I've been playing around with this code for use in an LS1 swapped RX8 and it was a great starting point.
A few things to note if you plan on doing this.
1. Using an mcp_can library cleans things up greatly, the setup Thaniel has worked great for me for a year when I used the ELM solution, but when I decided I did not want the OBD bus tied up so I could tune and use my cluster at the same time, I moved to the analog solution which got a bit muddier.
2. If you use an Arduino Uno with a Sparkfun CAN Shield, you will have issues with interrupt timing. The MCP2515 chip on the shield uses interrupt 0 (Pin 2) which will make your rpm needle jump. There are also only 2 external interrupt pins on the Uno (I needed interrupts for both speed and rpm so I was eukered).
3. An Arduino Mega does have more external interrupts available, but a Sparkfun can shield does not plug and play. You must transfer the SPI pins from the uno pinout to the mega pinout.
4. If you have a thermistor based coolant temperature sender, you need to create a voltage divider circuit and do some math to get the curve for actual temperature. I soldered a 4.7kohm resistor between 5V and the Analog pin I planned on using for temperature reading on the bottom of the board. I used Excel to plot the voltage divider circuit and compare to the integer output of the program. I then made a chart comparing the integer output to the appropriate Byte range of the gauge. Ended up with a logarithmic formula to fit the curve and input this to the program. Implemented a moving average to smooth out spikes.
My current solution is not elegant hardware wise, but it works great and is super stable, it was pieced together with what I had laying around:
I used 2 Arduinos (Uno and Nano) and a CAN MCP2515/MCP2555 chipset to handle the system. I effectively split Thaniel's sketch into 2 parts. I'm using the Uno to take all the data in and process it (RPM interrupt, Speed interrupt, Analog in temperature, Check Engine signal). I then connected the I2C SDA/SCL lines (A4/A5) to the Nano. the Nano is on a CAN breakout board and it takes serial data from the Uno via I2C and it simply sends the CAN message to the cluster.
The future solution is a bit more elegant. I plan on running a bluepill STM32 chip (super fast) in which any pin can be used as an interrupt and a CAN board bringing the 2 part sketch back into a single sketch. Just have to wait the month for the parts to arrive from overseas.
Hope this helps some people.
I thought I had it licked but after all of that I still got the occasional jump in the tach. After scoping the signal and playing with different software filters, I had the best luck with implementing an RC low-pass circuit on both VSS and Tach signal wires. I was hoping that the signal from the PCM was conditioned well enough to avoid this, but I guess not. My RC circuit has a 4.7k resistor inline with the signal wires and a 100nf ceramic capacitor to ground. This creates a cutoff frequency of 339Hz. This provides a maximum RPM signal of 10,170RPM with 2PPR and a maximum Speed of 305MPH at 4000 pulses per mile.
I did also change my logic to use the FreqMeasure library spread over my 2 arduinos (Can only measure 1 pulse on an AVR Uno. I did modify the library to do 2 frequencies on a Mega, but it's untested in-car at this moment). The hardware timers are reacting super accurately vs external interrupt pins in my experience. I may port his FreqMeasureMulti logic to an STM32 or just use a Teensy 3.2 for a single board solution if the Mega doesn't work: https://www.pjrc.com/teensy/td_libs_FreqMeasure.html
My Arduino Mega library for dual frequency capture using hardware timers on pin 48 and pin 49 https://drive.google.com/open?id=1uL...K3epSNC-YEA1sQ
Bookmarks