1. 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!
  2. 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
  3. 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 here. Do not following these rules will lead to permanent exclusion from this website: Read the forum 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:
    702Coins
    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:
    426Coins
    Ratings:
    +15 / 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:
    144Coins
    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:
    426Coins
    Ratings:
    +15 / 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. RodrigoOp

    RodrigoOp New Member

    Joined:
    Jun 7, 2016
    Messages:
    26
    Occupation:
    Teacher
    Location:
    Chle
    Balance:
    267Coins
    Ratings:
    +23 / 0 / -0
    My Motion Simulator:
    2DOF, Arduino
    Hi, I can't get tip120's at my local electronics store, can replace with tip-31c?
  6. RodrigoOp

    RodrigoOp New Member

    Joined:
    Jun 7, 2016
    Messages:
    26
    Occupation:
    Teacher
    Location:
    Chle
    Balance:
    267Coins
    Ratings:
    +23 / 0 / -0
    My Motion Simulator:
    2DOF, Arduino
    Hi, i follow your post but have a problem.
    without MATH * 10 only can handle up to 5000 rpm,
    with MATH * 10 when I push the pedal, drops to 0.

    do you have any cludes?
  7. Meawto

    Meawto Sorry for bad English ;'( Gold Contributor

    Joined:
    Aug 10, 2015
    Messages:
    96
    Location:
    Thailand
    Balance:
    - 226Coins
    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

  8. jamesdio

    jamesdio Member

    Joined:
    Feb 4, 2009
    Messages:
    66
    Location:
    Seoul, Korea
    Balance:
    702Coins
    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.
  9. jamesdio

    jamesdio Member

    Joined:
    Feb 4, 2009
    Messages:
    66
    Location:
    Seoul, Korea
    Balance:
    702Coins
    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.
  10. Meawto

    Meawto Sorry for bad English ;'( Gold Contributor

    Joined:
    Aug 10, 2015
    Messages:
    96
    Location:
    Thailand
    Balance:
    - 226Coins
    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
  11. Meawto

    Meawto Sorry for bad English ;'( Gold Contributor

    Joined:
    Aug 10, 2015
    Messages:
    96
    Location:
    Thailand
    Balance:
    - 226Coins
    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;
    }
    
    
  12. it_pixy

    it_pixy New Member

    Joined:
    Sep 29, 2016
    Messages:
    9
    Location:
    macau
    Balance:
    206Coins
    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?
  13. jamesdio

    jamesdio Member

    Joined:
    Feb 4, 2009
    Messages:
    66
    Location:
    Seoul, Korea
    Balance:
    702Coins
    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.
  14. choclo

    choclo Member

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

    it_pixy New Member

    Joined:
    Sep 29, 2016
    Messages:
    9
    Location:
    macau
    Balance:
    206Coins
    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
  16. Meawto

    Meawto Sorry for bad English ;'( Gold Contributor

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

    djgroove New Member

    Joined:
    Apr 3, 2017
    Messages:
    10
    Location:
    Turkey
    Balance:
    197Coins
    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 ?
  18. alejandroads

    alejandroads New Member

    Joined:
    Sep 3, 2017
    Messages:
    10
    Location:
    Unated States
    Balance:
    113Coins
    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 !
  19. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    14,748
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    108,992Coins
    Ratings:
    +8,896 / 43 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  20. alejandroads

    alejandroads New Member

    Joined:
    Sep 3, 2017
    Messages:
    10
    Location:
    Unated States
    Balance:
    113Coins
    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.