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 Download Package Now!
  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 12cm 12V 7segments gear indicator with GameDash

Discussion in 'DIY peripherals' started by RacingMat, Aug 30, 2014.

  1. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hi guys!

    I have got a 4 inches 7-segment LED and arduino: let's start a Gear Indicator!

    sku_301973_1.jpg
    12cm x 7cm
    2010710232236333.jpg
    The closer specs are these :
    http://www.led-display.cc/Single-Di...4-Inch-Single-Digit-7-Segment-LED-Display.htm

    I bought TPIC6c595 : a power logic 8-bit shift register

    This works with common anode and can sink high voltage (50V and 150mA) http://www.ti.com/lit/ds/symlink/tpic6b595.pdf
    It will need only one resistor per segment (less soldering! than transistor + 2 resistors)

    Here is the schematic between arduino and 6c595
    common anode 6c595 schematic.png

    Some pictures of the protoboard:
    racingmat 7 segment (1).jpg

    the board lost in the middle of the giant LCD :D
    racingmat 7 segment (2).jpg


    Here is a video of the arduino driving the display:
    - no Simtools connection yet at this stage
    - only a simple counter
    - using SPI library (faster than ShifOut library)​



    Here is the arduino code
    Code:
    /*
    Shift Register Example for 74HC595 shift register by Tom Igoe
    Digital Pot Control by Tom Igoe
    Thanks to Heather Dewey-Hagborg for the original tutorial, 2005
    Thanks to CrossRoads!
    by RacingMat 09-2014
    */
    // include the SPI library:
    #include <SPI.h>
    
    byte fontArray[] = {
    // dp-a-b-c-d-e-f-g
    0b11101110, // 0
    0b00101000, // 1
    0b11001101, // 2
    0b01101101, // 3
    0b00101011, // 4
    0b01100111, // 5
    0b11100111, // 6
    0b00101100, // 7
    0b11101111, // 8
    0b01101111, // 9
    0b00010000, // DP
    };
    
    //Pin connected to Data in SER IN pin 2 of 6c595
    const int dataPin = 11;
    //Pin connected to latch pin (SRCK)pin 15 of 6c595
    const int latchPin = 13;
    //Pin connected to clock pin (RCK) pin 10 of 6c595 as the slave select
    const int slaveSelectPin = 10;
    
    void setup() {
    // set the Pins as output:
    pinMode(dataPin, OUTPUT);
    pinMode(latchPin, OUTPUT);
    pinMode (slaveSelectPin, OUTPUT);
    Serial.begin(9600);
    // initialize SPI:
    SPI.begin();
    // take the SS pin low to select the chip:
    digitalWrite(slaveSelectPin,LOW);
    
    }
    
    void loop() {
    for (int i=0; i <= 10; i++){
    delay(500);
    digitalWrite (slaveSelectPin, LOW); // << RCLK line goes low
    SPI.transfer (fontArray[i]); // << SRCLK goes high-low 8 times to output 8 bits of data
    digitalWrite (slaveSelectPin, HIGH); // data outputs change on this rising edge << RCLK line goes high to move data into output register
    }
    }
    Arduino
    What Arduino do you need?
    a small arduino nano v3 is enough
    3€ on ebay
    or on dx.com http://www.dx.com/fr/p/nano-3-0-atmel-atme...-arduino-152052

    Any model fits, you only have to check that there is a USB socket.

    For example, Pro Mini Arduino at 2€ doesn't fit
    as it has no USB port and requires a FDTI cable...
    Pro Mini atmega328 Board 5V 16M Arduino

    1/ Final arduino code
    I'm using a trick to speed up the reading of serial information
    As i'm sending only 2 informations Shift light and Gear,
    i'm not adding 'S' or 'G' in front of data.
    I'm just reading data and if it's below let's say 12, it's a gear value (0 to 9)
    if it's above 12 it's the shift light data.
    that's why I conveniently choose @ and ? ascii characters in GameDash formulaes.
    Let's read this arduino code to figure it out !
    Code:
    /*
    Shift Register Example for 74HC595 shift register by Tom Igoe
    Digital Pot Control  by Tom Igoe
    Thanks to Heather Dewey-Hagborg for the original tutorial, 2005
    Thanks to CrossRoads!
    by RacingMat 09-2014
    */
    // include the SPI library:
    #include <SPI.h>
    
    byte fontArray[] = {
      // dp-a-b-c-d-e-f-g
      0b11101110, // 0        
      0b00101000, // 1            
      0b11001101, // 2
      0b01101101, // 3
      0b00101011, // 4
      0b01100111, // 5
      0b11100111, // 6
      0b00101100, // 7
      0b00000000, // OFF empty
      0b00000001, // REVERSE SPEED
    };
    byte LEDarray; //computed order that will be sent to the LED display
    
    //Pin connected to Data in SER IN pin 2 of 6c595
    const int dataPin = 11;
    //Pin connected to latch pin (SRCK)pin 15 of 6c595
    const int latchPin = 13;
    //Pin connected to clock pin (RCK) pin 10 of 6c595 as the slave select
    const int slaveSelectPin = 10;
    
    void setup() {
      // set the Pins as output:
      pinMode(dataPin, OUTPUT);
      pinMode(latchPin, OUTPUT);
      pinMode (slaveSelectPin, OUTPUT);
      Serial.begin(115200);
      // initialize SPI:
      SPI.begin();
      // take the SS pin low to select the chip:
        digitalWrite (slaveSelectPin, LOW); // << RCLK line goes low
        SPI.transfer (fontArray[9]);  //  << SRCLK goes  high-low 8 times to output 8 bits of data
        digitalWrite (slaveSelectPin, HIGH); // data outputs change on this rising edge << RCLK line goes high to move data into output register
    
    }
    
    void loop() {
    int Gear;
    int RpmMax;
    int Temp; // used if data (Gear and RPMMax) need to be switched
    
    if (Serial.available() > 1)  {
    //RpmMax indicates if RPM is over the maximum
    //GameDash calculates if RPM is > RpmMax -> false -> GameDash sent ? -> ascii 63 -> minus 48 = 15
    //if RPM > RpmMax is true -> GameDash sent @ -> ascii 64 -> minus 48 = 16
    //hence RpmMax is always > 12
    //and gear is always < 12
    // GameDash sends value from 0 to 8 and replaces Reverse (GTLegend = -1) by 9
             RpmMax = Serial.read()-48;
             Gear = Serial.read()-48;
             Serial.flush();
            if (RpmMax < 12) { Temp=Gear; Gear=RpmMax; RpmMax=Temp;}// data are switched
    //If RpmMax is true, then combine the gear number array plus Dot segment by a logical operation
    //else display only the gear digit
            if (RpmMax==16) {LEDarray = fontArray[Gear] | 0b00010000;} else {LEDarray = fontArray[Gear];}
    
        digitalWrite (slaveSelectPin, LOW); // << RCLK line goes low
        SPI.transfer (LEDarray);  //  << SRCLK goes  high-low 8 times to output 8 bits of data
        digitalWrite (slaveSelectPin, HIGH); // data outputs change on this rising edge << RCLK line goes high to move data into output register
      }
    }
    2/ setting up GameDash
    icones  DASHSimtools.png

    interface dash.png

    Screenshot of GTL plugin showing what each data represents in the game
    I'm using only Gear and RPM in this tutorial
    dash1.PNG

    gear : just replacing reverse which is "'-1' in GTL by a single character '9'
    dash rules Gear.PNG

    RPM : math calculation to determine if RPM is over a limit or not
    then replacing 0 or 1 by other ascii characters to fit to the simple arduino code
    dash rules RPM.PNG

    Now you have everything available to do exactly the same!

    I put some useful links about GameDash in this FAQ
    http://www.xsimulator.net/community/faq/game-dash-app-beta.29/

    3/ Video
    Here is a video showing how well synchronized it is between GT Legends and the LDC display :)

    Thanks @value1 for the plugin and @yobuddy for GameDash !

    :popcorn

    __________________________________________________________
    __________________________________________________________

    Can someone help me to setup a "giant" gear indicator ?

    I have got a 4 inches 7-segment LED and arduino
    but the LED are 12v driven...

    I have googled some links but too old: some components are no longuer available...
    Do you know how to drive a common anode 12v 7-segment with Arduino ?

    Thanks!!
    Mat
    • Like Like x 7
    Last edited: Oct 13, 2014
  2. Ads Master

    Ads Master

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

    soraz Member

    Joined:
    Mar 5, 2013
    Messages:
    69
    Location:
    Noale VE, Italia
    Balance:
    5,050Coins
    Ratings:
    +78 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    have you consider to use a big square 8x8 led matrix link this ? -->

    [​IMG]
  4. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Last edited: Feb 27, 2015
  5. prilad

    prilad Well-Known Member SimAxe Beta Tester SimTools Developer

    Joined:
    Apr 29, 2012
    Messages:
    381
    Location:
    Dubna, Russia
    Balance:
    9,073Coins
    Ratings:
    +483 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    @RacingMat , you can try this schematics - one npn and two resistors for any LED segment

    led.png
    • Agree Agree x 2
  6. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Thanks @prilad !
    Good, it's rather cheap: BC547CG 0,11€ + resistors

    I have read that ULN2803 darlington array could work but not sure... R0403636-06.png
  7. soraz

    soraz Member

    Joined:
    Mar 5, 2013
    Messages:
    69
    Location:
    Noale VE, Italia
    Balance:
    5,050Coins
    Ratings:
    +78 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    • Like Like x 1
    • Winner Winner x 1
    • Informative Informative x 1
  8. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    • Like Like x 1
    Last edited: Apr 30, 2015
  9. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Here is the schematic between arduino and 6c595

    common anode 6c595 schematic.png
    • Informative Informative x 1
  10. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hi!

    Some pictures of the protoboard:
    racingmat 7 segment (1).jpg

    the board lost in the middle of the giant LCD :D
    racingmat 7 segment (2).jpg

    Next steps :
    1/ coding arduino
    2/ testing with GameDash
    • Like Like x 4
  11. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    146
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    379Coins
    Ratings:
    +94 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    where did you buy these giant led segment dislays?
  12. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Here is a video of the arduino driving the display:
    - no Simtools connection yet at this stage
    - only a simple counter
    - using SPI library (faster than ShifOut library)​



    Here is the arduino code
    Code:
    /*
    Shift Register Example for 74HC595 shift register by Tom Igoe
    Digital Pot Control by Tom Igoe
    Thanks to Heather Dewey-Hagborg for the original tutorial, 2005
    Thanks to CrossRoads!
    by RacingMat 09-2014
    */
    // include the SPI library:
    #include <SPI.h>
    
    byte fontArray[] = {
    // dp-a-b-c-d-e-f-g
    0b11101110, // 0
    0b00101000, // 1
    0b11001101, // 2
    0b01101101, // 3
    0b00101011, // 4
    0b01100111, // 5
    0b11100111, // 6
    0b00101100, // 7
    0b11101111, // 8
    0b01101111, // 9
    0b00010000, // DP
    };
    
    //Pin connected to Data in SER IN pin 2 of 6c595
    const int dataPin = 11;
    //Pin connected to latch pin (SRCK)pin 15 of 6c595
    const int latchPin = 13;
    //Pin connected to clock pin (RCK) pin 10 of 6c595 as the slave select
    const int slaveSelectPin = 10;
    
    void setup() {
    // set the Pins as output:
    pinMode(dataPin, OUTPUT);
    pinMode(latchPin, OUTPUT);
    pinMode (slaveSelectPin, OUTPUT);
    Serial.begin(9600);
    // initialize SPI:
    SPI.begin();
    // take the SS pin low to select the chip:
    digitalWrite(slaveSelectPin,LOW);
    
    }
    
    void loop() {
    for (int i=0; i <= 10; i++){
    delay(500);
    digitalWrite (slaveSelectPin, LOW); // << RCLK line goes low
    SPI.transfer (fontArray[i]); // << SRCLK goes high-low 8 times to output 8 bits of data
    digitalWrite (slaveSelectPin, HIGH); // data outputs change on this rising edge << RCLK line goes high to move data into output register
    }
    }
    @tadythefish : I got several of them from junk... you can PM me
    • Like Like x 1
  13. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Here is a video showing how well synchronized it is between GT Legends and the LDC display :)

    Thanks @value1 for the plugin and @yobuddy for GameDash !

    :popcorn
    • Like Like x 4
  14. value1

    value1 Nerd Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Jan 9, 2011
    Messages:
    2,136
    Location:
    Zug, Switzerland
    Balance:
    7,268Coins
    Ratings:
    +3,105 / 11 / -1
    My Motion Simulator:
    2DOF, DC motor, JRK, Joyrider
    Yes, indeed, it's great to see that they all work nicely together!
    Well done, @RacingMat! :thumbs
    • Agree Agree x 1
  15. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Setting up GameDash
    icones  DASHSimtools.png

    interface dash.png
    dash2.PNG

    Screenshot of GTL plugin showing what each data represents in the game
    I'm using only Gear and RPM in this tutorial
    dash1.PNG

    gear : just replacing reverse which is "'-1' in GTL by a single character '9'
    dash rules Gear.PNG

    RPM : math calculation to determine if RPM is over a limit or not
    then replacing 0 or 1 by other ascii characters to fit to the simple arduino code
    dash rules RPM.PNG
    • Like Like x 1
  16. Matth.Gyver

    Matth.Gyver New Member

    Joined:
    Oct 8, 2014
    Messages:
    13
    Balance:
    208Coins
    Ratings:
    +6 / 0 / -0
    Nice tutorial RacingMat, as usual.
    Is there a list of plugin compatible or we should browse each plugin in the libraryfor get the information ?
  17. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I have added the arduino: the tutorial is complete now
    Thanks for the compliment! Hope this help

    Final arduino code
    I'm using a trick to speed up the reading of serial information
    As i'm sending only 2 informations Shift light and Gear,
    i'm not adding 'S' or 'G' in front of data.
    I'm just reading data and if it's below 12, it's a gear value (from 0 to 9)
    if it's above 12 it's the shift light data.
    that's why I conveniently choose @ and ? ascii characters.
    Let's read this arduino code to figure it out !

    Code:
    /*
    Shift Register Example for 74HC595 shift register by Tom Igoe
    Digital Pot Control  by Tom Igoe
    Thanks to Heather Dewey-Hagborg for the original tutorial, 2005
    Thanks to CrossRoads!
    by RacingMat 09-2014
    */
    // include the SPI library:
    #include <SPI.h>
    
    byte fontArray[] = {
      // dp-a-b-c-d-e-f-g
      0b11101110, // 0        
      0b00101000, // 1            
      0b11001101, // 2
      0b01101101, // 3
      0b00101011, // 4
      0b01100111, // 5
      0b11100111, // 6
      0b00101100, // 7
      0b00000000, // OFF empty
      0b00000001, // REVERSE SPEED
    };
    byte LEDarray; //computed order that will be sent to the LED display
    
    //Pin connected to Data in SER IN pin 2 of 6c595
    const int dataPin = 11;
    //Pin connected to latch pin (SRCK)pin 15 of 6c595
    const int latchPin = 13;
    //Pin connected to clock pin (RCK) pin 10 of 6c595 as the slave select
    const int slaveSelectPin = 10;
    
    void setup() {
      // set the Pins as output:
      pinMode(dataPin, OUTPUT);
      pinMode(latchPin, OUTPUT);
      pinMode (slaveSelectPin, OUTPUT);
      Serial.begin(115200);
      // initialize SPI:
      SPI.begin();
      // take the SS pin low to select the chip:
        digitalWrite (slaveSelectPin, LOW); // << RCLK line goes low
        SPI.transfer (fontArray[9]);  //  << SRCLK goes  high-low 8 times to output 8 bits of data
        digitalWrite (slaveSelectPin, HIGH); // data outputs change on this rising edge << RCLK line goes high to move data into output register
    
    }
    
    void loop() {
    int Gear;
    int RpmMax;
    int Temp; // used if data (Gear and RPMMax) need to be switched
    
    if (Serial.available() > 1)  {
    //RpmMax indicates if RPM is over the maximum
    //GameDash calculates if RPM is > RpmMax -> false -> GameDash sent ? -> ascii 63 -> minus 48 = 15
    //if RPM > RpmMax is true -> GameDash sent @ -> ascii 64 -> minus 48 = 16
    //hence RpmMax is always > 12
    //and gear is always < 12
    // GameDash sends value from 0 to 8 and replaces Reverse (GTLegend = -1) by 9
             RpmMax = Serial.read()-48;
             Gear = Serial.read()-48;
             Serial.flush();
            if (RpmMax < 12) { Temp=Gear; Gear=RpmMax; RpmMax=Temp;}// data are switched
    //If RpmMax is true, then combine the gear number array plus Dot segment by a logical operation
    //else display only the gear digit
            if (RpmMax==16) {LEDarray = fontArray[Gear] | 0b00010000;} else {LEDarray = fontArray[Gear];}
    
        digitalWrite (slaveSelectPin, LOW); // << RCLK line goes low
        SPI.transfer (LEDarray);  //  << SRCLK goes  high-low 8 times to output 8 bits of data
        digitalWrite (slaveSelectPin, HIGH); // data outputs change on this rising edge << RCLK line goes high to move data into output register
      }
    }
    • Like Like x 1
    • Useful Useful x 1
  18. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    1,942
    Location:
    Marseille - FRANCE
    Balance:
    18,309Coins
    Ratings:
    +1,858 / 16 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I dunno
    Maybe @value1 @prilad @eaorobbie could answer to this?
    I could add the list in the FAQ maybe...
  19. value1

    value1 Nerd Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Jan 9, 2011
    Messages:
    2,136
    Location:
    Zug, Switzerland
    Balance:
    7,268Coins
    Ratings:
    +3,105 / 11 / -1
    My Motion Simulator:
    2DOF, DC motor, JRK, Joyrider
    Well, anyone volunteering to compile such a list?
  20. Nick Moxley

    Nick Moxley Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    2,779
    Occupation:
    Owner/Operator- Moxleys Rantals
    Location:
    Winnipeg Manitoba Canada
    Balance:
    19,116Coins
    Ratings:
    +2,486 / 29 / -2
    My Motion Simulator:
    2DOF, 3DOF, DC motor, JRK
    Whats this Giant display worth ? ?

    And what are Arduino boards and all the accessories needed worth ?
  21. Matth.Gyver

    Matth.Gyver New Member

    Joined:
    Oct 8, 2014
    Messages:
    13
    Balance:
    208Coins
    Ratings:
    +6 / 0 / -0
    I'll do the job ;-)
    • Like Like x 1