Digital dashboard with TM1638 and Arduino Nano v3

Dashboard, gauge projects etc.
Please use the image gallery for your pictures, a short tutorial can be found here.
The first image in the first post will be shown in the project gallery.

Digital dashboard with TM1638 and Arduino Nano v3

Postby tronicgr » Mon 9. Jul 2012, 16:51

This is a project that was trying to finish for years now, but was always stuck
on the complexity of the 7segment circuitry for a project like a car digital dashboard.

My attempt for f1 dashboard with atmega644 and custom built boards



About a month ago I discovered those neat 7segment displays based on the TM1638 chip
that are incredibly cheap and its layout is very close to the one I wanted. You can see them
here: http://www.dealextreme.com/p/8x-digital-tube-8x-key-8x-double-color-led-module-81873

To drive the display and connect it to x-sim through USO interface I used a also cheap Arduino module
compatible with Arduino Nano. See it here: http://dx.com/p/nano-v3-0-avr-atmega328-p-20au-module-board-usb-cable-for-arduino-118037

So the total cost of this project is only $19.98 !! :D






See it in action here:



And here a new video different camera:



And here with two TM1638 displays, were the second displays the PRM as numerical.







The wiring is very easy:

Prodigy's schematic (thanks Prodigy)




Here is the code for this first version. I hope next version will has some use for the buttons as well.

Code: Select all
// X-sim3dashboard v1  (using TM1638 display and Arduino Nano v3)
// Made by TronicGr (Thanos) 4-26-2012 for X-sim3
// Shared as Public Domain

// Serial parser example: R~a01~~95~S~a02~G~a03~
// Where:
// ~a01~ is 16bit value for rpm
// ~95~ is data value parameter for RPM_MAX divided by 100 to fit into a byte so actual value is 9500
// ~a02~ is 16bit value for speed
// ~a03~ is 8bit value for gear / neutral / reverse

// You can set the USO pause safely to 10ms for nice fast refresh rates!


#include <TM1638.h> //can be downloaded from http://code.google.com/p/tm1638-library/

// define a module on data pin 5, clock pin 4 and strobe pin 3
TM1638 module(5, 4, 3);

void setup() {
  //Create Serial Object
  Serial.begin(115200);
// initialize the screen:
module.clearDisplay();              //clears the display from garbage if any
String name = "TronicGr";           //sets a custom logo start up banner
module.setDisplayToString(name);    //prints the banner
delay(1500);                        //small delay 1.5 sec
module.clearDisplay();              //clears the display
}

void loop() {
int i;
char bufferArray[20];              // holds all serial data into a array
unsigned int rpm;                  //holds the rpm data (0-65535 size)
unsigned int rpmleds;              //holds the 8 leds values
unsigned int rpmmax;               //retrieves from x-sim USO this value as parameter divided by 100
unsigned int carspeed;             //holds the speed data (0-65535 size)
byte gear;                         // holds gear value data
byte d1;                           // high byte temp variable
byte d2;                           // low byte temp variable
byte rpmdata = 0;                  // marker that new data are available
byte speeddata = 0;                // marker that new data are available
byte geardata = 0;                 // marker that new data are available

if (Serial.available() >= 9)  {    //if 6 bytes available in the Serial buffer...
      for (i=0; i<9; i++) {         // for each byte
      bufferArray[i] = Serial.read();        // put into array
     }
  }
 
if (bufferArray[0] == 'R' ){      // if new bytes have been recieved

   d1 = bufferArray[1];      // store high byte of rpm
   d2 = bufferArray[2];      // store low byte of rpm
   rpm = ((d1<<8) + d2);               // concatonate bytes (shift 8 bits)
   rpmmax = bufferArray[3];            // retrieves the maxrpm value
   rpmmax = (rpmmax * 100)+500;        // multiplies the rpm data into thousants
   rpmdata=1;                          // we got new data!
}
if (bufferArray[4] == 'S' ){
   d1 = bufferArray[5];      // store high byte of speed
   d2 = bufferArray[6];      // store low byte of speed
   carspeed = ((d1<<8) + d2);          // concatonate bytes (shift 8 bits)
   speeddata=1;                        // we got new data!
}
if (bufferArray[7] == 'G' ){
   gear = bufferArray[8];         // retrieves the single byte of gear (0-255 value)
   geardata=1;                    // we got new data!
}
if (speeddata == 1) {
   module.setDisplayToDecNumber(carspeed, 0, false);  //displays numerical the speed
   speeddata=0;                     
}   
if (geardata == 1) {
   char* neutral = "n";                // sets the character for neutral
   char* reverse = "r";                // sets the character for reverse
   gear = gear - 127;                  // offset the 0 value in 8-bit
   if (gear >= 1 and gear <10 ){
      module.setDisplayDigit(gear, 0, false);   // displays numerical value of the current gear
   }
   if (gear == 0){
      module.setDisplayToString(neutral, 0, 0);  // displays the character for neutral
   }
   if (gear == 255){                        // -1 that reprecents reverse rollover to 255 so...
      module.setDisplayToString(reverse, 0, 0);  // displays the character for reverse
   }
   geardata=0;
}

if (rpmdata == 1) {
   
   rpmleds = map(rpm,0,rpmmax,0,9);    // distributes the rpm level to the 8 leds + 1 for shift change
   if (rpmleds==0){
     module.setLEDs(0b00000000 | 0b00000000 << 8);
   }
   if (rpmleds==1){
     module.setLEDs(0b00000000 | 0b00000001<< 8 );
   }
   if (rpmleds==2){
     module.setLEDs(0b00000000 | 0b00000011<< 8 );
   }
   if (rpmleds==3){
     module.setLEDs(0b00000000 | 0b00000111<< 8 );
   }
   if (rpmleds==4){
     module.setLEDs(0b00000000 | 0b00001111<< 8);
   }
   if (rpmleds==5){
     module.setLEDs(0b00000000 | 0b00011111 << 8);
   }
   if (rpmleds==6){
     module.setLEDs(0b00100000 | 0b00011111<< 8 );
   }
   if (rpmleds==7){
     module.setLEDs(0b01100000 | 0b00011111<<8 );
   }
   if (rpmleds==8){
     //module.setLEDs(0b11100000 | 0b000011111<<8 );}
     module.setLEDs(0b11111111 | 0b111111111<<8 );
   }
   rpmdata=0;
}
}





The serial parser can be for example: R~a01~~95~S~a02~G~a03~
Where:
~a01~ is 16bit value for rpm
~95~ is data value parameter for RPM_MAX divided by 100 to fit into a byte so actual value is 9500
~a02~ is 16bit value for speed
~a03~ is 8bit value for gear / neutral / reverse


Here is the saved profile that contains the math and the axis definitions for the rpm/speed/gear along with some photos of the settings.
x-sim3dashboard_lfs.zip
(131.81 KiB) Downloaded 3366 times


See here the 16bit setting for rpm (same for speed)


And here the 8-bit setting for the gear


The max math value for rpm


The max math value for speed


And the max math value for gear







The above video of a modification by vicpopo--> http://www.x-sim.de/forum/viewtopic.php?f=40&t=155&start=30#p5495



Newer version with bigger Gear Digit!







Thanos
User avatar
tronicgr
 
Posts: 624
Images: 11
Joined: Tue 20. Mar 2012, 22:10
Location: San Diego, CA
Has thanked: 130 times
Been thanked: 50 times

Re: Digital dashboard with TM1638 and Arduino Nano v3

Postby jessemoraes » Tue 17. Jul 2012, 14:14

Hi thanos

sorry for the noob question but,
could you explain how to wire up the arduino with the display?
and , can i use the arduino uno for this?
cars
jessemoraes
 
Posts: 1
Joined: Tue 17. Jul 2012, 13:21
Location: dublin
Has thanked: 0 time
Been thanked: 0 time

Re: Digital dashboard with TM1638 and Arduino Nano v3

Postby tronicgr » Tue 17. Jul 2012, 15:32

The wire connections are in the code. Any arduino is compatible!
User avatar
tronicgr
 
Posts: 624
Images: 11
Joined: Tue 20. Mar 2012, 22:10
Location: San Diego, CA
Has thanked: 130 times
Been thanked: 50 times

Re: Digital dashboard with TM1638 and Arduino Nano v3

Postby gabrielomar » Sun 29. Jul 2012, 05:24

tronic hello, as is done in order to see other data, such as back, fuel, etc. Thanks
gabrielomar
 
Posts: 2
Joined: Thu 24. May 2012, 02:51
Has thanked: 0 time
Been thanked: 0 time

Re: Digital dashboard with TM1638 and Arduino Nano v3

Postby tronicgr » Wed 1. Aug 2012, 17:13

What do you mean?

If you want more data on the screen you could modify the code to accept more data (x-sim axis/gauge information) and assign them to the buttons of the screen so you can choose what to display.

I provided the skeleton code for that, and its up to you or anyone that is interested to play with it, to adjust it to their needs. I simply don't have unlimited time in my hands to do everything. I hope you understand my position.

Thanos
User avatar
tronicgr
 
Posts: 624
Images: 11
Joined: Tue 20. Mar 2012, 22:10
Location: San Diego, CA
Has thanked: 130 times
Been thanked: 50 times

Re: Digital dashboard with TM1638 and Arduino Nano v3

Postby gabrielomar » Wed 1. Aug 2012, 21:14

thank you very much for the reply and sorry for my English, I use a translator.
I am working with codes. when you achieve a breakthrough in the project, I'll post.
  but I'm complicated because arduino novice and the sim. thanks
gabrielomar
 
Posts: 2
Joined: Thu 24. May 2012, 02:51
Has thanked: 0 time
Been thanked: 0 time

Re: Digital dashboard with TM1638 and Arduino Nano v3

Postby dearn » Tue 2. Oct 2012, 22:07

Hi Thanos!

Tnxs for the information that you've posted. I just buyed the parts and hope to get it within a few weeks :).

I will use your code as a solid base and i will post some updates here.

Grtz
Arno
http://www.ArcadeWinkel.nl | Arcade spare parts and kits
User avatar
dearn
X-Sim Stage 2 edition
 
Posts: 66
Images: 139
Joined: Mon 23. Jul 2012, 12:16
Location: Netherlands
Has thanked: 1 time
Been thanked: 3 times

Re: Digital dashboard with TM1638 and Arduino Nano v3

Postby jamesdio » Mon 5. Nov 2012, 09:26



All thanks to FergoTech (http://fergotech.net/diy-shift-lights-and-dashboard/) and tronicgr (viewtopic.php?f=40&t=155)

I just slightly modified their source code.

I'm going to post my source code and x-sim setup guide later here.

Thanks for watching. 8-)

P.S. Fake AutoMeter tacho. from China works really slow. I recommand you guys not to buy it.
jamesdio
X-Sim Supporter
 
Posts: 10
Joined: Thu 31. May 2012, 03:30
Has thanked: 2 times
Been thanked: 0 time

Re: Digital dashboard with TM1638 and Arduino Nano v3

Postby vicpopo » Tue 6. Nov 2012, 00:06

Hi Thanos ,

I'm happy because I achieved today programing the arduino nano v3 with your code.After a little bit concentration and reading web site about how to use programation Arduino I matched to test the dashboard as like you presented in this topic.
Many thanks to you because all you've done work , all you 've done is very functional and usefull and the last but not the least easy to make and cheap!! ;)
If you have some time I'm interested in realy understand how did parameterise xsim for displaying the right values on the display , for exemple the value for the calibration offset in Math setup for the Speed - 2147483648 !!??).I just noticed that if you change this the speed displayed is wrong !! :o
For the europeen driver which would like the speed in km/h and not in mph just change the maximum value in the extractor input from 104856 to 65154 .You didn't give this information Thanos I believe.
65154=104856/1,6 with 1,6 the rate between mph and km/h.
Clap clap clap for you Thanos
Best Regards
Last edited by vicpopo on Tue 6. Nov 2012, 00:59, edited 1 time in total.
User avatar
vicpopo
 
Posts: 645
Joined: Fri 20. Apr 2012, 18:04
Location: Strasbourg France
Has thanked: 39 times
Been thanked: 80 times

Re: Digital dashboard with TM1638 and Arduino Nano v3

Postby vicpopo » Tue 6. Nov 2012, 00:50

Hi Everybody,

A little video for the test as usual.

Enjoy ;)
User avatar
vicpopo
 
Posts: 645
Joined: Fri 20. Apr 2012, 18:04
Location: Strasbourg France
Has thanked: 39 times
Been thanked: 80 times

Next

Return to Peripheral Projects

Who is online

Users browsing this forum: No registered users and 2 guests