×

Sale ends todayGet 30% off any course (excluding packages)

Ends in --- --- ---

Fun DIY CAN Bus gauge project

Off Topic Discussion

Forum Posts

Courses

Blog

Tech Articles

If it's not really about tuning or wiring. Then it belongs in here.

= Resolved threads

Author
13897 Views

Not really tuning related but I thought I share a little project I recently completed with my Link G4+

I wanted some better instrumentation, with peak hold and some display flexibility and frankly putting together a set of decent gauges seemed a bit pricey.

After a fair amount of head scratching I put together a fairly budget (£50) combination of a arduino microcontroller and an oled display, and wired this to the CAN Bus output on the G4+. I managed to mount this fairly discretely in the standard instrument cluster.

Happy to share details of the components and code if anyone is interested in doing something similar

Little demo video https://www.youtube.com/watch?v=LW7UfCKVBoY

Alex

I am interested in learning more on your CANbus project. email is paul@proefrock.net

Thanks

Paul

Alex

I am interested in learning more on your CANbus project. email is paul at proefrock dot net

Thanks

Paul

(hope you can decipher the email address. I didn't realize the forum would actually format my address so I had to edit rather than get hit with a bunch more spam)

That's nice! Can you share some details here?

That's great Alex! Nice work!

I've just been doing some testing with Plex Tuning's new uSDM which offers similar functionality in a commercial product for those who aren't up to piecing the parts together and writing their own code. It's surprisingly similar to what you've made there.

Attached Files

Thanks for the positive comments guys :)

That plex job looks nicely done, its tempting to get carried away with sexy graphics but really you just need big clear numbers like that. There's a UK company that make a nicely designed CAN display http://www.jti.uk.com/toucan/ , bit pricey for me though.

So the bits i used were:

This integrated Arduino/CAN bus board, Michael was very patient helping me out with mynoob questions:

http://www.hobbytronics.co.uk/leonardo-canbus

And this adafruit display

http://makersify.com/products/adafruit-oled-breakout-board-16-bit-color-1-5-w-microsd-holder

I also sourced a proper automotive grade LM2940 power regulator chip (a few quid on ebay).

http://www.ebay.co.uk/itm/LM2940T-LM2940CT-TO-220-LDO-regulator-with-without-heatsink-22uf-47uf-caps-/291802613577?var=&hash=item43f0ca8749

The soldering is fairly straightfoward, just follow the instructions really. I emailed Link for the pinout on the RS232/CAN Bus port on the board as that's not documented anywhere.

There are a few gotchas with getting the link can bus configured to talk to the arduino, luckily pc link can display any errors on the can bus which helps diagnose things. The arduino board didn't like anything above 250kbs, no big deal but it took a while to diagnose, and you need to process messages you pick up from the bus quickly or the Link will shut it down.

I modified an instrument cluster I had spare, hacked out the 4wd gauge, and used some nylon PCB standoffs to fix the display in its place and wedged/hot glued the power reg and arduino behind. I also wired up the factory radio tuner buttons to spare inputs on the arduino for display/peak/reset functions - easy to set the inputs as pull ups and have the tuner buttons pull them low since that's how the tuner buttons work already. Finally I added a usb cable connected through the back of the instruments to allow reprogramming - handy given the amount of trial and error involved.

I'm no electronics engineer or microcontroller programming expert,in fact this is the first arduino project I've attempted, but what I have lashed together seems pretty reliable so far.

That's freaking awesome!! great job!

Well done, with no real experience in that area you have done a really good job.

Thinking about doing something similar but outputting to the AV input on a car stereo...possibly using either a Raspberry PI or Arduino.

Guage art do an interesting device https://gaugeart.com

It looks like it outputs can data to a av/hdmi. Could be good if you are running a double din screen head unit.

The arduino atmel microcontrollers aren't up to any serious graphical work, too slow, too little memory. Rasberry Pi would do it just a much bigger software stack to work with.

If you want to roll your own, and keep the codi simple, you can couple an arduino with dedicated graphics hardware . http://www.4dsystems.com.au do some interesting stuff. Basically you build your ui in their software tool then just send the basic data to it from the arduino. Ironically the graphics hardware is easily powerful enough to do the whole job without the arduino, just much more complicated to do it that way.

Hello

I like this so much i've ordered a few bits.

No idea on how to program it as this will be my first arduino project

Any chance you could send me the file of the software so it at least give's me a start point

I don't want a big aftermarket dash and really like the setup you've done, it will also be going into a Skyline of mine and maybe my Supra as well

Kind regards

Geoffrey

No worries, let me know if you need any help, I've attached the arduino code as a txt file, as the ino file type isn't allowed.

Key things are getting all the pin allocations right - you can use whatever pins you want but the code needs to match.

The code looks a mess tbh and some of the comments may be wrong, I just hacked away until it worked lol. Anyway the important bits are in setup and loop function. Most of the rest is making the graphics and switches work how I wanted. I have wired up SPI for the display which includes an SD card reader, and the CAN chip is also on the SPI bus (connections are on the circuit board with the LeoCAN), a couple of input pins for switches to cycle the two display styles and alternate peak/realtime or press both together to reset peaks.

BUT the CAN bus code is actually very simple you really only need a few lines to make that work

This is the CAN library

#include

Setup the chip select pin for the SPI to address the CAN chip

MCP_CAN CAN0(17); // Set CS to pin 17

Initialise the CAN chip in the setup function

while(CAN_OK!=CAN0.begin(CAN_250KBPS)) //initialise CAN bus keep retrying indefinitely until the CNAbus is online

{

//Serial.println("CAN init failed - retry..");

delay(100);

}

// Bytes 1 and 2 of mask/filter apply to CAN ID - whatever filters apply in your situation the less data you let through the better

CAN0.init_Mask(0, 0, 0xFFFC); // 0b1111 1111 1111 1100

CAN0.init_Filt(0, 0, 0x3E8); // 0b0000 0011 1110 1000

CAN0.init_Filt(1, 0, 0xFFFF); // 1111 1111 1111 1111 - FAIL

CAN0.init_Mask(1, 0, 0xFFFF); // 1111 1111 1111 1111

CAN0.init_Filt(2, 0, 0x0001); // 0000 0000 0000 0001 - FAIL

CAN0.init_Filt(3, 0, 0x0001); // 0000 0000 0000 0001 - FAIL

CAN0.init_Filt(4, 0, 0x0001); // 0000 0000 0000 0001 - FAIL

CAN0.init_Filt(5, 0, 0x0001); // 0000 0000 0000 0001 - FAIL

And then read the data in the loop function, I alternate between the two CAN IDs I want to read 1000 and 1001.

You have to mess around to get the bytes into sensible data type for offsets etc. And of course you need to know which bytes to read from which CAN streams based on how you setup you ECU to transmit. I'm reading map,ect,iat and oil pressure on CAN 1000 and Lambda and ATTESA 4WD pressure on CAN 1001. IAT and ECT are 8 bit (or 1 byte) so you can read straight out of the byte array rxBuf. The others all need more resolution and need to be 16 bits (2 bytes aka a "word").

if(CAN_MSGAVAIL == CAN0.checkReceive()) // check if data waiting

{

CAN0.readMsgBuf(&rxLen, rxBuf); // Read data: len = data length, buf = data byte(s)

rxId = CAN0.getCanId(); // Get message ID

if((rxId==1000)&&(nextId==1000))

{

nextId=1001;

boostvalue_li=word(rxBuf[2],rxBuf[3]);

...

ectvalue=rxBuf[4]-50;

iatvalue=rxBuf[5]-50;

...

oilpvalue=word(rxBuf[6],rxBuf[7]);

...

}

}

//read the alternate stream id1001

if((rxId==1001)&&(nextId==1001))

{

nextId=1000;

afrvalue_f=word(rxBuf[2],rxBuf[3]); //div by 1000 to give lambda then *14.68 for AFR

afrvalue_f=(afrvalue_f/1000)*14.7;

afrtarget_f=word(rxBuf[4],rxBuf[5]); //div by 1000 to give lambda then *14.68 for AFR

afrtarget_f=(afrtarget_f/1000)*14.7;

...

awdvalue=word(rxBuf[6],rxBuf[7]);

...

}

}

If it doesn't work check you have H and L the right way round. The Link has some handy diagnostic information that can tell you the CAN bus isn't playing nicely. You'll see I'm using 250kbs the Link supports up to 1mbs, but the CAN chip on the LeoCAN doesn't keep up.

Attached Files
  • cycle-canids-with-buttons-cycle2or6item-peak2or6item-toggle-but.txt
  • Attachments may only be downloaded by paid Gold members. Read more about becoming a Gold member here.

nice but does any one know the script for the gaugeart can video gauge Adapter https://gaugeart.com unit i would like to make one my self i think $550 is alot .

Hi Alex,

Do you have images of the way you wired all the component together?

We usually reply within 12hrs (often sooner)

Need Help?

Need help choosing a course?

Experiencing website difficulties?

Or need to contact us for any other reason?