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 Driving DIY cluster gauges with GameDash

Discussion in 'DIY peripherals' started by RacingMat, Oct 9, 2014.

  1. eaorobbie

    eaorobbie Well-Known Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,574
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    20,429Coins
    Ratings:
    +1,684 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    You will get better timings and smoothness without using libraries, due to all use a blocking function, more noticeable as you add more gauges or function to your code.
  2. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,960Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Okay, I'll make a stress test with more motors
    as soon as possible... :eek:
    I have to finish my new DIY wheel first
    • Like Like x 1
  3. welen123

    welen123 Member Gold Contributor

    Joined:
    Jan 10, 2015
    Messages:
    98
    Location:
    HongKong
    Balance:
    35Coins
    Ratings:
    +57 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Hi,RacingMat,I get a X27 589 stepper motor ,and I used a test program to run it ,but it was not run in your code ,I have tried to input the values from 0-255,but it just rotate a little,what style of input value is correct ? and could you picture your gamedash setting? I dont know the rules of gamedash,and I cant find a detailed introductions of the gamedash, Thank you very much!

    I found a function in the code is "map(Rpm, 0, 255, 0, TotalSteps)",but the I can't find the "map()" was define ,so is this in some library file? maybe it's the problem .
    Last edited: Feb 10, 2015
  4. tombo

    tombo Active Member

    Joined:
    Oct 5, 2013
    Messages:
    269
    Location:
    Germany
    Balance:
    2,442Coins
    Ratings:
    +246 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino
  5. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,960Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    @welen123 :
    what kind of "test program" do you use?

    here a screenshot I did
    gameDash Rules editor switec.PNG
  6. welen123

    welen123 Member Gold Contributor

    Joined:
    Jan 10, 2015
    Messages:
    98
    Location:
    HongKong
    Balance:
    35Coins
    Ratings:
    +57 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Thank you for your help ,I get the map function means.
  7. welen123

    welen123 Member Gold Contributor

    Joined:
    Jan 10, 2015
    Messages:
    98
    Location:
    HongKong
    Balance:
    35Coins
    Ratings:
    +57 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Code:
    //----------------------------------------------------------------------
    // https://github.com/clearwater/SwitecX25
    //
    // This is an example of using the SwitchX25 library.
    // It zero's the motor, sets the position to mid-range
    // and waits for serial input to indicate new motor positions.
    //
    // Open the serial monitor and try entering values
    // between 0 and 944.
    //
    // Note that the maximum speed of the motor will be determined
    // by how frequently you call update().  If you put a big slow
    // serial.println() call in the loop below, the motor will move
    // very slowly!
    //----------------------------------------------------------------------
    
    #include <SwitecX25.h>
    
    // standard X25.168 range 315 degrees at 1/3 degree steps
    #define STEPS (315*3)
    
    // For motors connected to pins 3,4,5,6
    SwitecX25 motor1(STEPS,4,5,6,7);
    
    void setup(void)
    {
      // run the motor against the stops
      motor1.zero();
      // start moving towards the center of the range
      motor1.setPosition(STEPS/2);
     
      Serial.begin(9600);
      Serial.print("Enter a step position from 0 through ");
      Serial.print(STEPS-1);
      Serial.println(".");
    }
    
    void loop(void)
    {
      static int nextPos = 0;
      // the motor only moves when you call update
      motor1.update();
     
      if (Serial.available()) {
        char c = Serial.read();
        if (c==10 || c==13) {
          motor1.setPosition(nextPos);
          nextPos = 0;
        } else if (c>='0' && c<='9') {
          nextPos = 10*nextPos + (c-'0');
        }
      }
    }
    
    the code is a example in the in the SwitecX25_master file in the libraries . the motor will rotate to the Target Location when I input a number between 0-945.
    • Like Like x 1
  8. welen123

    welen123 Member Gold Contributor

    Joined:
    Jan 10, 2015
    Messages:
    98
    Location:
    HongKong
    Balance:
    35Coins
    Ratings:
    +57 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    here is a video ,maybe someone can help me with it.
  9. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,960Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    the example code you posted cannot work with gamedash!
    Did you test the code I posted?

    Did you setup the same baud speed for Arduino and windows Comport and GameDash?
  10. welen123

    welen123 Member Gold Contributor

    Joined:
    Jan 10, 2015
    Messages:
    98
    Location:
    HongKong
    Balance:
    35Coins
    Ratings:
    +57 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Yes ,I tried the code you posted,the video showing the situation by your code ,maybe its the wrong rules of the gamedash with live for speed.how can I make the output value to a" byte"type. because your code define the Rpm to a byte.
    I have find the problem,its the rules setting.and I change the range of the byte to 0-150 ,and it works now.
    Last edited: Feb 12, 2015
  11. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,960Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    • Like Like x 2
  12. r-driver

    r-driver New Member

    Joined:
    Mar 14, 2015
    Messages:
    2
    Balance:
    210Coins
    Ratings:
    +0 / 0 / -0
    hi RacingMat.i follow your topic.this is a good project.i want to make a dashboard too,i use 5 wire stepper motor with uln2003 driver ( motor model is 28byj48) this motor is slower than switec x25, but i use my motor just for test.
    i used your arduino code,its very good,my stepper worked.but this code is general.we should define some axis for speedometer and tachometer and etc.
    i dont know anything about coding.how can i find a complete code for dashboard.
    thank you.
  13. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,960Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Thank you!

    you can wait for me to implement the 5 motors code: it's on my todo list (among other items...)
    or you can learn to code, it's very interesting!
  14. r-driver

    r-driver New Member

    Joined:
    Mar 14, 2015
    Messages:
    2
    Balance:
    210Coins
    Ratings:
    +0 / 0 / -0
    thank you for reply.i will wait for your code.
  15. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,960Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    @r-driver : please post some pictures meanwhile or a video of your system! it will motivate me :)
  16. tombo

    tombo Active Member

    Joined:
    Oct 5, 2013
    Messages:
    269
    Location:
    Germany
    Balance:
    2,442Coins
    Ratings:
    +246 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino
    Hello,
    since i finally got the Dash output with Rbr working ( Big Thanks to Soraz) i can continue my work with the steppers. I was able to get it working with two motors.
    At the momeent everything is connectet with loose wires, so i was not able to film the real dashboard ingame too.

    @RacingMat you need motivation?
    i made a little video of my 2 motors. At the end they are going crazy because of i crash. I didn't look at the screen.

    If i set the output manually in Gamedash it is very accurate.

    Edit: I made a Video with rbr screen:


    At the moment i run them at 5v directly from Arduino Io. For me and Rbr its fast enough.
    ANd sorry for the bad driving. It's with keyboard :p
    • Like Like x 4
    Last edited: Jun 14, 2015
  17. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,960Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    @tombo : thanks for the sharing! it's motivating :)

    RBR gauge is not round so it's difficult too check the correct matching... but looks good indeed!
  18. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,960Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    @tombo : it looks really good! congrats

    thanks for sharing the Photoshop link: i'll paste it in the first post