1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Tutorial Arduino RevBurner driving a tachometer.

Discussion in 'DIY peripherals' started by jamesdio, Oct 11, 2014.

  1. jamesdio

    jamesdio Member

    Joined:
    Feb 4, 2009
    Messages:
    66
    Location:
    Seoul, Korea
    Balance:
    763Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN5, SimforceGT, Motion platform, 4DOF
    There is very little current for the signal.

    I think you can use ULN2003.
  2. MAYA One

    MAYA One Member

    Joined:
    Jul 7, 2015
    Messages:
    36
    Location:
    china
    Balance:
    468Coins
    Ratings:
    +16 / 0 / -0
    My Motion Simulator:
    2DOF, SCN5
    Thank you so much !!
  3. Masilicondrio

    Masilicondrio New Member

    Joined:
    Apr 18, 2016
    Messages:
    10
    Occupation:
    Programmer
    Location:
    Uruguay
    Balance:
    186Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    Arduino
    Im using arduino nano and only 1x 2.2K resistance and 1 diode...
    Its alive!!!! only with 5v signal :O

    Working with Project Cars but have problems with Dirt Rally Plugin :(

    • Like Like x 2
  4. MAYA One

    MAYA One Member

    Joined:
    Jul 7, 2015
    Messages:
    36
    Location:
    china
    Balance:
    468Coins
    Ratings:
    +16 / 0 / -0
    My Motion Simulator:
    2DOF, SCN5
    Hi @jamesdio. This tachometer code can be used in X-SIM?I can't write code:grin
  5. Meawto

    Meawto Sorry for bad English ;'(

    Joined:
    Aug 10, 2015
    Messages:
    96
    Location:
    Thailand
    Balance:
    - 336Coins
    Ratings:
    +43 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    hi can you help me to driving a speedometer with gamedash

    i'm very poor in coding. now i use your code with my tachometer. its work very well !!

    can you help me for this speedometer

    thanks

  6. jamesdio

    jamesdio Member

    Joined:
    Feb 4, 2009
    Messages:
    66
    Location:
    Seoul, Korea
    Balance:
    763Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN5, SimforceGT, Motion platform, 4DOF
    sorry for the late reply.

    Yes, you can use any transistor for this application.
  7. jamesdio

    jamesdio Member

    Joined:
    Feb 4, 2009
    Messages:
    66
    Location:
    Seoul, Korea
    Balance:
    763Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN5, SimforceGT, Motion platform, 4DOF

    Does your speedometer work like tachometer which works with PWM signal?

    I would like to know the specification of your speedometer.
  8. Meawto

    Meawto Sorry for bad English ;'(

    Joined:
    Aug 10, 2015
    Messages:
    96
    Location:
    Thailand
    Balance:
    - 336Coins
    Ratings:
    +43 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    i got it from my friend. have nothing except wire (has 1 wire for signal) i think its works with PWN signal like tachometer
  9. Meawto

    Meawto Sorry for bad English ;'(

    Joined:
    Aug 10, 2015
    Messages:
    96
    Location:
    Thailand
    Balance:
    - 336Coins
    Ratings:
    +43 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I have tried coding by use your code and the gauge are works fine on 1 gauge standalone

    but i still have some problem when i run 2 gauges (tacho&speedo).

    the gauge can run only one (in my video speedometer run,when tachometer was crash)

    can you help me :)

    Code:
    /* 
    Arduino code for simple rev. burner
    */
    
    //    This code is emulating the signal of ignition coil.
    //     ex) 4 cylinder, 4-cycle engine. (2 combustion cycle/rev.)
    //
    //     1 rpm = 0.5 combustion cycle/min.cylinder = 1/120 combustion cycle/sec.cylinder.
    //     => 1/120 Hz/cylinder (Combustion cycle = signal for ignition So, 1 combustion cycle/sec. = 1Hz)
    //     => 1 rpm with 4 cylinder = 1/120 Hz/cyclinder * 4 cylinder = 1/30 Hz
    //
    //     => 1 RPM = 1/120 hz/cylinder
    //
    //    Following the formula above, Hz vaue per 1 rpm would be..
    //    * 2 cylinder = 1/60 Hz
    //    * 4 cylinder = 1/30 Hz
    //    * 8 cylinder = 1/15 hz/rpm
    
    // Serial parser for Interface - Output : M<Dash2>
    // Serial parser for Shutdown - Output : Z00
    // M : rpm              (16bit - hexadecimal output)
    // Z : clear            (to clear display and max rpm value)
    //
    // for dashboard
    // Pin D3 : STB0 - strobe
    // Pin D4 : CLK - clock
    // Pin D5 : DIO - data
    
    int i;
    double cylinder = 4;           // cyliner count for Tachometer.
    double divideUnit = 120;         // 1/120 hz/(rpm * cylinder)
    double hzPerRpm = cylinder / divideUnit;
    int rpmtone;
    int pinTacho = 5;
    unsigned int rpm;           // holds the rpm data (0-65535 size)
    unsigned int rpmmax = 5000; // retrieves from rpm live with minimum setting on initialization and Shutdown - Output
    byte rpmdata = 0;           // marker that new data are available
    /////////////////////////speedo///////////////////////////////
    double speedhz1 = 98;     
    double speedhz2 = 180;
    double hzPercarspeed = speedhz1 / speedhz2;
    int carspeedtone;
    int pinSpeedo = 6;
    unsigned int carspeed;           // holds the carspeed data (0-65535 size)
    unsigned int carspeedmax = 5000; // retrieves from carspeed live with minimum setting on initialization and Shutdown - Output
    byte carspeeddata = 0;           // marker that new data are available
    
    ////////////////////////////////////////////////////////////////////////////////
    // INITIALIZATION
    ////////////////////////////////////////////////////////////////////////////////
    void setup()
    {
      // serial initialization
      Serial.begin(9600);
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////// Main Loop ////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////
    void loop()
    {
    
      // read input data
      readSerialData();
    
      // generate signal and send to tacho
      tacho();
      // generate signal and send to Speedo
      Speedo();
    
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    // Procedure: wait for complete trame
    ////////////////////////////////////////////////////////////////////////////////
    void readSerialData()
    {
      byte Data[5]={
        '0','0','0','0','0'  };
    
      // parse the buffer
      if (Serial.available()>4){
        Data[0]=Serial.read();                   // read command
        if (Data[0]=='Q'){                       // if carspeed data
          Data[1]=Serial.read();                 // store high byte
          Data[2]=Serial.read();                 //
          Data[3]=Serial.read();                 //
          Data[4]=Serial.read();                 // store low byte
          carspeed = NormalizeData(Data);
          carspeeddata=1;                             // we got new data!     
          if (Serial.available()>4){
            Data[0]=Serial.read();               // re-read command
          }
        }
        if (Data[0]=='M'){                       // if rpm data
          Data[1]=Serial.read();                 // store high byte
          Data[2]=Serial.read();                 //
          Data[3]=Serial.read();                 //
          Data[4]=Serial.read();                 // store low byte
          rpm = NormalizeData(Data);
          rpmdata=1;                             // we got new data!     
          if (Serial.available()>4){
            Data[0]=Serial.read();               // re-read command
          }
        }
        if (Data[0] == 'Z' ){                          // if Shutdown - Output
          Serial.flush();
        }           
      }
      if (Serial.available()>40) Serial.flush();
    }
    
    ////////////////////////////////////////////////////////
    void tacho()
    ////////////////////////////////////////////////////////
    { 
      if (rpmdata == 1) {         
        // auto set max rpm
        // with filter of negative value
        // reported from 65535 to down in some games
        if (rpm>rpmmax && rpm<50000) {
          rpmmax=rpm;
        }
      
        // rpm gauge gets messy movements below 100 rev.
        if(rpm>50000){
          rpm = 0;
        }
    
        // Tacho range : from 0 to 10000, we will use 0 to 320 hz.
        //rpmtone = map(rpm,0,10000,0,320);
        rpmtone = (int)(rpm * hzPerRpm);
      
        // if hz. value goes over 320, then,,
        if(rpmtone > 320) {
          rpmtone = 333;
        }
    
        //It is not possible to generate tones lower than 31Hz. For technical details,
        // see Brett Hagman's notes. (https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation#Ugly_Details)
        if(rpmtone < 31) {
          rpmtone = 31;
        }
    
        // For debugging.
        if(rpm>500){  
          tone(pinTacho, rpmtone);
        }
        else{
          noTone(pinTacho);
        }
        ;
    
        rpmdata=0;
      }
    }
    ////////////////////////////////////////////////////////
    void Speedo()
    ////////////////////////////////////////////////////////
    { 
      if (carspeeddata == 1) {         
        // auto set max carspeed
        // with filter of negative value
        // reported from 65535 to down in some games
        if (carspeed>carspeedmax && carspeed<50000) {
          carspeedmax=carspeed;
        }
      
        // carspeed gauge gets messy movements below 100 rev.
        if(carspeed>50000){
          carspeed = 0;
        }
    
        // Speedo range : from 0 to 10000, we will use 0 to 320 hz.
        //carspeedtone = map(carspeed,0,10000,0,320);
        carspeedtone = (int)(carspeed * hzPercarspeed);
      
        // if hz. value goes over 320, then,,
        if(carspeedtone > 320) {
          carspeedtone = 333;
        }
    
        //It is not possible to generate tones lower than 31Hz. For technical details,
        // see Brett Hagman's notes. (https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation#Ugly_Details)
        if(carspeedtone < 31) {
          carspeedtone = 31;
        }
    
        // For debugging.
        if(carspeed>10){  
          tone(pinSpeedo, carspeedtone);
        }
        else{
          noTone(pinSpeedo);
        }
        ;
    
        carspeeddata=0;
      }
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    // Function: convert Hex to Dec
    ////////////////////////////////////////////////////////////////////////////////
    unsigned int NormalizeData(byte x[5])
    ////////////////////////////////////////////////////////////////////////////////
    {
      unsigned int result;
    
      for (int i=1; i<5; i++)
      {
        if (x[i]>47 && x[i]<58 ){   //for xA to xF
          x[i]=x[i]-48;
        }                     
        if (  x[i]>64 && x[i]<71 ){ //for x0 to x9
          x[i]=x[i]-55;             
        }
      }  
      result = (x[1]*16*16*16+x[2]*16*16+x[3]*16+x[4]);
      return result;
    }
    
    
  10. it_pixy

    it_pixy New Member

    Joined:
    Sep 29, 2016
    Messages:
    9
    Location:
    macau
    Balance:
    251Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SimAxe, Arduino, SimforceGT, Motion platform, 4DOF, 6DOF
    my gamedash show this sentence "the interface connected to con3 is not detected" What should I do?
  11. jamesdio

    jamesdio Member

    Joined:
    Feb 4, 2009
    Messages:
    66
    Location:
    Seoul, Korea
    Balance:
    763Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN5, SimforceGT, Motion platform, 4DOF
    I think you'd better check COM Port number on Dashboard output setting if the port number is correct or not.
  12. choclo

    choclo Member

    Joined:
    Sep 27, 2016
    Messages:
    34
    Location:
    Vienna
    Balance:
    388Coins
    Ratings:
    +28 / 1 / -0
    Could you please stop putting this things on here!!!
    My Shopping cart is getting bigger and bigger ;-)
    nice Job!
  13. it_pixy

    it_pixy New Member

    Joined:
    Sep 29, 2016
    Messages:
    9
    Location:
    macau
    Balance:
    251Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SimAxe, Arduino, SimforceGT, Motion platform, 4DOF, 6DOF
    I was ardunio board, the output is COM3, I imported the procedures? To the ardunio COM3 normal work,

    But when I open gamedash, set the output is COM3, open the LFS, and then enter the gamedash settings, the phrase "the interface connected to con3 is not detected", then said to the ardunio COM3 BUSY,

    What should I do?
    Last edited: Oct 8, 2016
  14. Meawto

    Meawto Sorry for bad English ;'(

    Joined:
    Aug 10, 2015
    Messages:
    96
    Location:
    Thailand
    Balance:
    - 336Coins
    Ratings:
    +43 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    any idea to make 2 gauges work together ? :(
  15. djgroove

    djgroove New Member

    Joined:
    Apr 3, 2017
    Messages:
    8
    Location:
    Turkey
    Balance:
    236Coins
    Ratings:
    +2 / 0 / -0
    Hi, I have a problem with GameDash 2.0. When I open the program I do the port settings and save but I can not setup the game name. I can not set any game to the program. And also interface output. What should I do ?
  16. alejandroads

    alejandroads New Member

    Joined:
    Sep 3, 2017
    Messages:
    10
    Location:
    Unated States
    Balance:
    106Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino
    Hi Guys!, there is possible to make PWM in output? I want to drive a fan whit the RPM, like wind effect whit speed , but using RPM for get PWM in output of Arduino.
    Cheers !
  17. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,438
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    144,458Coins
    Ratings:
    +10,730 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  18. alejandroads

    alejandroads New Member

    Joined:
    Sep 3, 2017
    Messages:
    10
    Location:
    Unated States
    Balance:
    106Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino
    Hello noorbeast, I read that wind section, but I couldn't find any information or code using RPM for PWM output ,in that section show how to have wind effect but works whit speed data. Or maybe if somebody can help me whit a code for have PWM instead frequency signal (tone) in Arduino output.
  19. cazsan

    cazsan Member

    Joined:
    Oct 1, 2015
    Messages:
    40
    Occupation:
    Programmer
    Location:
    France
    Balance:
    444Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    Arduino
    Hello there!

    I tried to replicate this and I'm facing weird issue I can't solve.
    If someone have any idea I'd really pleased.

    Here are the links to the parts I use:
    The tacho itself boots. I'm able to play with it using external buttons and such. That a good first step.
    I figured out that my power source voltage is correct (12V) but the others are wrong (7.4 instead of 2.5 to 3.0V)...

    I wired the Boost gauge too (based on youtube video from amstudio) and I'm getting also a weird buzzer sound, which makes it barely untestable.

    I uploaded a video on youtube showing what's happening for my rig : here.

    I also ordered a standard diode but It's slow shipping so I'm still testing with current zener diodes I have.
    If you might have some time to look at the following video. Thanks in advance.
  20. abs

    abs Active Member Gold Contributor

    Joined:
    Mar 3, 2011
    Messages:
    331
    Occupation:
    consultant
    Location:
    Montreal
    Balance:
    784Coins
    Ratings:
    +65 / 0 / -0
    My Motion Simulator:
    3DOF, SCN5
    Hello, there is 2 type of tip120 Darlington (NPN and PNP). I am not sure what is the difference and you used . could you help?
    thanks