ECUs and Tuning Discuss Engine Management, Tuning, & Programming

DIY CAN Gauge with Teensy 4.0

Thread Tools
 
Search this Thread
 
Old 04-05-2024, 11:28 AM
  #1  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default DIY CAN Gauge with Teensy 4.0

I am creating a DIY CANbus gauge that will pull info from the CAN lines coming from a MS3x and display any useful information I wish. I am roughly following the idea of an instructables post I found here. The main difference being they created the user interface (ui) in the raw code and are only pulling info from the sensors that are already in place.
The general functionality of these gauge will be a single 1.28" round display that can fit in any of the three small gauge spots in the miata dash, I am choosing to use the coolant temp hole. The idea is to have multiple screens that can be switched through to see different info about the car. The sky is the limit here as MS can broadcast just about anything you can dream of. A simple push button will need to be mounted to get the gauge to switch screens and can be incorporated in any way the user would like.

Hardware is as follows...
Amazon list Amazon list
Theres a few more "comfort" items on the list like soldering items and a 12v power source for testing.

It is very possible you may have a lot of this on hand already, which is great you can lower your all-in cost that way. You will also need a means of soldering wires and of course a computer to code on, perferably a laptop as the board will become difficult to remove once installed. You can also find the .stl files for the mount linked in the instructables above. Below is a preview of the ui's two screens that I have created and will be using, but following posts will show how to use the software to create custom screens and code screen switching functionality into the file that will be flashed to the teensy.



edit: added ui version 2 to github with afr

The next post will mark the beginning of the project and the organization should be as follows...
  1. Board and display soldering and wiring
  2. Initial software setup and coding.
    1. Display and Teensy Setup
    2. Squareline Studio Tutorial for ui
  3. Bench test display
  4. Canbus and functionality backend coding
  5. Connecting to cluster and CANbus

Last edited by Eli_Swer; 04-11-2024 at 02:40 PM. Reason: Formatting
Eli_Swer is offline  
Old 04-05-2024, 03:54 PM
  #2  
Tweaking Enginerd
iTrader: (2)
 
Ted75zcar's Avatar
 
Join Date: Mar 2013
Location: Boulder, CO
Posts: 1,783
Total Cats: 361
Default

Have a puttin-tat Sir and Godspeed.

Teensy is the bomb.
Ted75zcar is offline  
Old 04-06-2024, 11:17 AM
  #3  
Cpt. Slow
iTrader: (25)
 
curly's Avatar
 
Join Date: Oct 2005
Location: Oregon City, OR
Posts: 14,224
Total Cats: 1,145
Default

A really cool concept, I might tackle it if I didn't already have the Link unit.

You might consider making this all a shopping list on Amazon for easier 1-click, if you're smart you could even find a way to make a few pennies. Total came out to ~$150, but like you said there's a few places you could save some dollars.
curly is offline  
Old 04-07-2024, 11:39 AM
  #4  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default

Originally Posted by curly
A really cool concept, I might tackle it if I didn't already have the Link unit.

You might consider making this all a shopping list on Amazon for easier 1-click, if you're smart you could even find a way to make a few pennies. Total came out to ~$150, but like you said there's a few places you could save some dollars.
Goooood idea, maybe I'll get on that especially since I already have an Amazon list for myself.
Yes, definitely lots of money to be saved with the adhesive, tape, bolts, wiring, etc. Good news is I got my ui uploaded to the teensy successfully and it showing on my lcd display. Screen switching and dimmer features both work too.

I should have those first three parts written up this evening, including pictures and videos!!
Eli_Swer is offline  
Old 04-07-2024, 11:53 AM
  #5  
Junior Member
 
redursidae's Avatar
 
Join Date: Aug 2019
Posts: 167
Total Cats: 49
Default

This is super neat looking. Cat given! Interested to see what it looks like installed. Are you planning to make the code opensource/available?

@curly I've been wanting to code one of these since the CANChecked I use has some bugs with the Link. I can't promise a date, but when I get something written I'll make it open source.

ninja edit: I just saw the bottom of your post. Ignore my question.
redursidae is offline  
Old 04-07-2024, 12:46 PM
  #6  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default

LETS BEGIN
1. HARDWARE SETUP

Getting the teensy and LCD wired up together is not too difficult. Take your time, get the pins soldered into the teensy and wires to the display. If you will be following the rest of this thread the wires from the LCD can be connected to the Teensy as follows.
  • SCL to pin 13
  • SDA to pin 11
  • RES to pin 8
  • DC to pin 9
  • CS to pin 10
  • BLK to pin 7
Later these pins will be defined in our setup file, if for whatever reason you are using a different board and want to/have to use different pins, you can define them differently in the UserSetup.h file that we will tinker with later.


Eli_Swer is offline  
Old 04-07-2024, 01:11 PM
  #7  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default

2. Initial software setup and coding
You are going to need arduino IDE, which you can download from here. I am using version 2.3.2. You will also need to install "teensyduino" in order to load arduino sketches to your teensy. The link will walk you through the process.
A. Display and Teensy setup
Getting the display setup involves two key components, getting a library downloaded and setting up our speficic setup in the UserSetup.h file. Open arduino IDE and on the left side there will be a tab for your library manager. Open it, search for tft_eSPI and install the latest version. Next you need to use your file manager to navigate to your arduino folder that was installed with the IDE, find the libraries folder within that, then the TFT_eSPI folder within that and locate the UserSetup.h file. Open it with something like notepad and get ready to make some small edits.
  • Scroll down to line 44 and comment out the "#define ILI9341_DRIVER" line (i.e. put '//' in front of it) This is a common driver used with arduino but not the one we are using! Also note your line numbers may vary slightly.
  • Now UNcomment the line for driver "GC9A01_DRIVER" on line 64
  • Lines 204 - 210 comment out all the pin definitions for the ILI9341 display
  • Lines 215 - 220 uncomment all the pin definitions for our GC9A01 display and set them to the pins we connected them to above...
  • MOSI (SDA) to 11
  • SCLK (SCL) to 13
  • CS to 10
  • DC to 9
  • RST (RES) to 8
  • BL (BLK) to 7
Make sure to save the file before closing and you are ready to run some tests. Get your pins from the display plugged into the teensy and teensy plugged into your computer. Open arduino IDE and make sure your teensy is being recognized by arduino via tha board and port drop down next to your verify, upload, and debugging buttons. Go to File > Examples > TFT_eSPI > Tools and diagnostics and run the colour test example. Make sure your display is working and give yourself a high five.

Pictures of the finished .h file for your reference.


Last edited by Eli_Swer; 04-10-2024 at 11:14 AM.
Eli_Swer is offline  
Old 04-07-2024, 01:36 PM
  #8  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default

Some sneak peeks at the ui on the display before I put together a square line studio tutorial video.
Attached Files
File Type: mov
IMG_4300.mov (18.14 MB, 19 views)
File Type: mov
IMG_4301.mov (19.80 MB, 10 views)
Eli_Swer is offline  
Old 04-07-2024, 02:16 PM
  #9  
Junior Member
 
redursidae's Avatar
 
Join Date: Aug 2019
Posts: 167
Total Cats: 49
Default

Originally Posted by Eli_Swer
Some sneak peeks at the ui on the display before I put together a square line studio tutorial video.
I'm sold on the UI. What is the boot time at the moment?
redursidae is offline  
Old 04-07-2024, 03:18 PM
  #10  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default

Originally Posted by redursidae
I'm sold on the UI. What is the boot time at the moment?
After applying power to the teensy it takes just under 3 seconds for the display to power up. That is using usb power source. Might I have reason to believe that would be quicker with a 5v source directly to the Vin pin? Maybe. That will be the case upon final install. 12v source from car > 5v buck converter > Vin pin on teensy.

Not sure how quickly it might fetch values from the CANbus though.
Eli_Swer is offline  
Old 04-07-2024, 03:43 PM
  #11  
Junior Member
 
redursidae's Avatar
 
Join Date: Aug 2019
Posts: 167
Total Cats: 49
Default

That's not bad. The CANChecked takes about that long to start showing values. Tuned in for the rest of the development!
redursidae is offline  
Old 04-07-2024, 04:03 PM
  #12  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default

Appreciate it! Thinking I'll have time tomorrow to share the UI design in squareline studio and explain how to use its different features. Also will be sharing a touch of coding in arduino for screen switching and dimming function. I am definitely going to be making a video for it, I would just end up with too many screenshots if I tried to do a write up. Also, I've got the actual ui file as well as the squareline project for my exact gauge up in a GitHub . Although, you can't download the singular ui file, upload it to a teensy, and get rolling, downloading the squareline project and following my instructions for export from squareline studio will create all the files you need to get the gauge up and going.

edit- To succesfully download the SquarelineStudio project from github, download both the .spj and .sll files then when you go to import the project into Squareline select the .spj and open it.

Last edited by Eli_Swer; 04-08-2024 at 10:24 AM.
Eli_Swer is offline  
Old 04-09-2024, 02:57 PM
  #13  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default

2.b and 3. Squareline studio tutorial and bench testing the UI
Here is the link to the youtube video I made walking through the ui design process quickly and some functionality coding for the gauge and a quick demo. You can test the dimming function by shorting the dim pin to a ground pin on the teensy to dim. Then you can short it to a 3.3v pin on the teensy to bring the brightness back up. NOTE: DO NOT APPLY MORE THAN 3.3V TO ANY PIN ON THE TEENSY. The screen switching you can test by touching a ground pin to the screen switch pin on the teensy. Everytime you ground that pin the screen will switch. Another note: the values at the end of the startup animation and beginning of the main loop are different on purpose, I have been testing that start animation and I am getting ready to integrate CANbus broadcasting. I made those values different to make sure the code was running as intended. There is also some commented out CAN fetching code in that startup animation function in the ui file, ignore it for now (as of 4/9/24).

Last edited by Eli_Swer; 04-09-2024 at 03:11 PM.
Eli_Swer is offline  
Old 04-23-2024, 10:23 AM
  #14  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default

Updated ui, also on github.
Eli_Swer is offline  
Old 05-01-2024, 03:28 PM
  #15  
Newb
 
crxguy52's Avatar
 
Join Date: Apr 2023
Posts: 27
Total Cats: 18
Default

Found this on Facebook, super cool project! I'm making something similar to display GM CAN messages for LS\LFX swapped cars. I bought a Pi since I didn't want to deal with designing a UI for a microcontroller, but it looks like squareline takes care of all the hard work.
crxguy52 is offline  
Old 05-03-2024, 11:40 AM
  #16  
Newb
Thread Starter
 
Eli_Swer's Avatar
 
Join Date: Oct 2021
Posts: 20
Total Cats: 14
Default

Facebook, interesting. Mind sending the link lol, I didn't post anything there. Anyway yeah squareline is pretty easy but is not really being developed anymore. The library it uses (lvgl) stopped working with squareline a few software updates ago. It still works just fine but will fall out of date some day. Nextion displays and their software does something similar I think that may be EVEN easier.

Also as an update I nearly have my MS3x built. Been following brains instructions on trubokitty. Just need to finish the wiring harness, then I can get it in my car and iron out a base map. I will be messing with the CAN stuff after that!
Eli_Swer is offline  
Old 05-03-2024, 02:09 PM
  #17  
Newb
 
crxguy52's Avatar
 
Join Date: Apr 2023
Posts: 27
Total Cats: 18
Default

Originally Posted by Eli_Swer
Facebook, interesting. Mind sending the link lol, I didn't post anything there. Anyway yeah squareline is pretty easy but is not really being developed anymore. The library it uses (lvgl) stopped working with squareline a few software updates ago. It still works just fine but will fall out of date some day. Nextion displays and their software does something similar I think that may be EVEN easier.

Also as an update I nearly have my MS3x built. Been following brains instructions on trubokitty. Just need to finish the wiring harness, then I can get it in my car and iron out a base map. I will be messing with the CAN stuff after that!
I tried to go back and find it but I couldn't, I'm never able to find something again. Maybe someone linked to your thread since it was similar to what they were making. I'll have to look into Nextion, thanks for the recommendation. Looking forward to seeing it functinoal!
crxguy52 is offline  
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
shlammed
Fabulous Fabrication
170
09-26-2018 02:55 PM
Leveq
Media
0
11-17-2017 02:31 PM



Quick Reply: DIY CAN Gauge with Teensy 4.0



All times are GMT -4. The time now is 12:49 AM.