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. 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

CarDashX : TM1638 sketch for GameDash

Discussion in 'Official Companion Apps' started by vthinsel, Aug 26, 2015.

  1. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Hello !

    While the motion rig is moving slowly pieces by pieces, I have worked on an arduino sketch to drive a TM1638 thanks to the GameDash companion.

    Code:
    Serial syntax: [command letter][decimal number]
    // Yx : Start module with intensity set to x (1-7)
    // Sx : Speed update (decimal notation)
    // Gx : Gear update (decimal notation)
    // Rx : RPM update (decimal notation)
    // Ox : oil temp
    // Wx : water temp
    // Fx : fuel
    // Lx : lap
    // Px : position
    // Tx: max RPM (sent by some games)
    // Z0A : Stop and clear module
    
    The command will be processed when a new one starts. For example, RPM will be updated on the module once a new command such as S will start
    Serial data to start with max luminosity set (5), speed=95, RPM=4250, gear=2 (last caracter is to finish processing of RPM, can be anything except a digit)
    Y5S95G2R4250R
    
    If gear is negative, the reverse is assumed and 'r' is displayed
    If gear is 0, neutral is assumed and 'n' is displayed
    
    3 buttons of the module are used:
    button 1 : cycle values for left dashboard part
    button 2 : cycle values for right dashboard part
    button 3 : toggle speed multiplier by 3.6 (needed by some games such as Kart Racing Pro. Can be done externally also in dash setting)
    button 4 : toggle between RPM leds showing full range (mode 0) or 75%-100% (mode 1)
    button 5 : number of red LEDS to display (0-8)
    button 6 : Reset maxrpm. Usefull when rpm goes to hig values with no reason and rpm LEDs are then less usefull.
    button 8 : show current settings and save to EEPROM. Second digit shown indicates if speed multiplier is on (1) or off (0), third digit indicates RPM led mode
    
    
    I'll post a video soon.

    Attached Files:

    • Like Like x 6
    • Winner Winner x 2
    • Agree Agree x 1
    Last edited: Jan 20, 2016
  2. Ads Master

    Ads Master

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
  3. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Gamedash settings:
    upload_2015-8-26_23-5-18.png

    No output rules are needed as you can see.
    I developped this sketch using ProjectCars and KartRacingPro.

    I started to use Visual Studio 2015 Community together with the visualmicro plugin for arduino. Wonderfull integration ! I'll look at the debugging options which look sweet....
    • Like Like x 2
    Last edited: Nov 3, 2015
  4. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Video here.
    Nothing special, it's a car dash after all :rolleyes:

    Now I'll have to ask a friend with a 3D printer to make a nice case using this as a basis http://www.thingiverse.com/thing:106804
    I also ordered some nano arduino boards to make integration easier.

    As a bonus the visual studio arduino integration. Even managing libraries updates for you.... so cool....
    upload_2015-8-27_11-19-14.png
    • Like Like x 2
    • Winner Winner x 1
  5. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    More info here on the dashboard assembly.
  6. zigzag49

    zigzag49 Active Member

    Joined:
    May 27, 2014
    Messages:
    251
    Balance:
    561Coins
    Ratings:
    +220 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino
    Hi First of all congratulations, I have a question for the code does it work for arduino uno and with all the games integrating the dashboard in the plugin? Thank you
  7. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Hello,

    Yes, it will also work on UNO as I developped it on UNO first. UNO and nano are roughly the same except for the number of pins.
    If there is a dashboard plugin, it should work. I tested it with ProjectCars mainly.
  8. zigzag49

    zigzag49 Active Member

    Joined:
    May 27, 2014
    Messages:
    251
    Balance:
    561Coins
    Ratings:
    +220 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino
    Ok merci je vais tester , donc il n'y a rien à marquer dans dash ....etc ?

    Ok thank you I will test, so there is nothing to score in dash1.... etc?
  9. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Correct. No math, no padding, .....
  10. zigzag49

    zigzag49 Active Member

    Joined:
    May 27, 2014
    Messages:
    251
    Balance:
    561Coins
    Ratings:
    +220 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino
  11. prodigy

    prodigy Burning revs

    Joined:
    Oct 27, 2013
    Messages:
    457
    Location:
    Croatia
    Balance:
    6,641Coins
    Ratings:
    +398 / 4 / -0
    My Motion Simulator:
    2DOF, 3DOF, AC motor, SCN5, JRK
    Hello @vthinsel , thank you for this nice sketch.
    How to change LED colors?

    I would like to have only last LED in red color and first 7 LED in green.
    Right now it is 5 green and 3 red.
  12. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Hello,
    It is in the
    module1.setLEDs(0XFF00);
    the value drives the leds which are turned up: the first byte is for RED, the second for green. If both are on, then it is orange.
    Change as follow:

    if (rpmleds == 6) {
    module1.setLEDs(0X003F);
    }
    if (rpmleds == 7) {
    module1.setLEDs(0X007F);
    }
    if (rpmleds == 8) {
    module1.setLEDs(0X807F);
    }
    if (rpmleds == 9) {
    module1.setLEDs(0XFF00);
    }
  13. prodigy

    prodigy Burning revs

    Joined:
    Oct 27, 2013
    Messages:
    457
    Location:
    Croatia
    Balance:
    6,641Coins
    Ratings:
    +398 / 4 / -0
    My Motion Simulator:
    2DOF, 3DOF, AC motor, SCN5, JRK
    @vthinsel Thank you, this is working good. :thumbs

    I would like to ask if there is possibility to set min RPM value?
    That LEDs don't light up from the start, but from 4000 RPM for example.

    So if the car has 6000 RPM, the leds would be spread nicely through last 2000 rpm.
    Now, when it goes from zero, the first 5-6 leds are always light up, just last two leds are changing.
  14. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    That's easy to change in the code:
    rpmleds = map(carrpm, 0, rpmmax * 1.1, 0, 10); // distributes the rpm level to the 8 leds + 1 for shift change

    Replace the first 0 to the min value. This should produce the result you want.
    rpmleds = map(carrpm, 4000, rpmmax * 1.1, 0, 10); // distributes the rpm level to the 8 leds + 1 for shift change
    • Informative Informative x 1
    • Useful Useful x 1
  15. prodigy

    prodigy Burning revs

    Joined:
    Oct 27, 2013
    Messages:
    457
    Location:
    Croatia
    Balance:
    6,641Coins
    Ratings:
    +398 / 4 / -0
    My Motion Simulator:
    2DOF, 3DOF, AC motor, SCN5, JRK
    @vthinsel
    Thank you once more for your help and making me better understand the code.

    Eventually after some testing I did this change:
    rpmleds = map(carrpm, rpmmax * 0.75, rpmmax * 1.0, 0, 10);

    It is more independent of the chosen car, it will always light up from last 25% of the RPM.
    When I was putting exact number like 4000, it was working good for normal cars, but switching to F1 it was not good and also for the Karts.

    Cheers
    :cheers
  16. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Nice trick. Like this it is the dynamic last 25% of the RPM zone.
    Maybe I'll update some logic config to implement this nice behavior.
    • Like Like x 1
  17. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    So I have updated and reviewed the code.
    Two new buttons are used, to match the good ideas from @prodigy :thumbs
    - button 4 to toggle RPM display mode on LEDS : mode 0 will reproduce the full 0-100% rpm value on the LEDS. mode 1 will reproduce only the 75%-100% rpm range on the LEDS.
    - button 5 : choose the number of RED LEDS to display. Can be 0 to 8.

    I also optimized couple of things
    I updated the first post with the new code.

    Cheers !
    • Like Like x 1
    • Winner Winner x 1
    • Informative Informative x 1
  18. prodigy

    prodigy Burning revs

    Joined:
    Oct 27, 2013
    Messages:
    457
    Location:
    Croatia
    Balance:
    6,641Coins
    Ratings:
    +398 / 4 / -0
    My Motion Simulator:
    2DOF, 3DOF, AC motor, SCN5, JRK
    Hi @vthinsel your new additions are working great :thumbs

    If you want to make the code even better, I have another suggestion :grin

    Since there are 2 more free buttons, it will be good to have an option to reset maxRPM with a button. Why? It happened to me few times, for example, if the car has 6000 RPM limit, when you drive in 3rd gear at high RPMs and you suddenly switch to 2nd gear, the RPM will shortly jump to 8000-9000, and the dashboard will save this as the maxRPM. Then when you continue to drive, when you reach 6000 limit, the last few LEDs will not light up because the car cannot reach 9000 RPM again.

    Also, another small problem I saw today is with RaceRoom Experience game. The LEDs didn't work at all and when I switched to see RPM on the digits, there were smaller numbers like 450 etc., so I figured out that it must be multiplied with * 10. In the game dash settings, I've added "math * 10" to Dash2, so it calculated correctly, but LED's were still not lighting up. What it can be?

    [​IMG]
  19. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    I fully agree with the reset RPM button. An auto reset would be even better but requires some thinking before. Next version is on its way ...
    Have you sorted out your issue on race room ? Looks good from game dash captute
  20. prodigy

    prodigy Burning revs

    Joined:
    Oct 27, 2013
    Messages:
    457
    Location:
    Croatia
    Balance:
    6,641Coins
    Ratings:
    +398 / 4 / -0
    My Motion Simulator:
    2DOF, 3DOF, AC motor, SCN5, JRK
    Yes, it works with Raceroom too, once I restarted the game and dashboard.
    It also works with Dirt Rally, it was some other problem with GameEngine setup, but now it works.
    This is the list of the games I have tested:

    WORKING
    Assetto Corsa - needed to write "math - 1" in Dash3 output to show correct gears

    Dirt Rally
    - needed to switch R<dash2>G<dash3> in interface output to R<dash3>G<dash2> because RPM is on Dash3. Also needed to write "replace 10 -1" in Dash2 Output for Gear, because switching to reverse returns number 10 on the dash and it stays like that.

    Rfactor 2
    Raceroom Experience
    - needed to write "math * 10" into Dash2 output to show correct RPM
    Stock Car Extreme
    Project Cars
    iRacing
    Richard Burns Rally
    Live for Speed


    NOT WORKING
    Dirt 3 - Dash data not enabled in plugin
    F1 2013 - Dash data not enabled in plugin
    Last edited: Nov 4, 2015
  21. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    376
    Location:
    FRANCE
    Balance:
    5,167Coins
    Ratings:
    +476 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Version 1.2 available in first post with reset RPM on button 7.
    One more button to assign, if you have ideas :grin
    • Like Like x 1