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

[HELP] Arduino code for simple simulator

Discussion in 'Miscellaneous' started by Ralph Manuel, Sep 7, 2014.

  1. Ralph Manuel

    Ralph Manuel Member

    Joined:
    Aug 8, 2014
    Messages:
    50
    Balance:
    600Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    Arduino
    Hi! I'm using Simtools and developing my own simulator and got confused with the 2DOF arduino code of @RacingMat. My simulator is only 1 DOF (pitch) and uses 1 motor.

    I am confused with some conditions in the code like the condition of direction. Also the function NormalizedData().

    Please help. Thanks! :)

    Ralph M.
    architectural.jpg
  2. soraz

    soraz Member

    Joined:
    Mar 5, 2013
    Messages:
    68
    Location:
    Noale VE, Italia
    Balance:
    5,158Coins
    Ratings:
    +79 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    i think you can use 'pitch' for motor movement
    the function convert numeric characters in hexadecimal value; es. the two characters 2F (2= 0x32 or 50 dec and F= 0x46 or 70 dec) are converted in hex value 2f (47 in dec)
    • Agree Agree x 1
    • Winner Winner x 1
  3. Ralph Manuel

    Ralph Manuel Member

    Joined:
    Aug 8, 2014
    Messages:
    50
    Balance:
    600Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    Arduino
    This part is where I'm confused with.

    Code:
    int NormalizeData(byte x[3])
    ////////////////////////////////////////////////////////////////////////////////
    {
      int result;
    
      if ((x[2]==13) || (x[2]=='R') || (x[2]=='L'))  //only a LSB and Carrier Return or 'L' or 'R' in case of value below 16 (ie one CHAR and not 2)
      {
        x[2]=x[1];  //move MSB to LSB
        x[1]='0';     //clear MSB
      }
      for (int i=1; i<3; 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;              
        }
      }
      // map the range from Xsim (0 <-> 255) to the mechanically authorized range (potMini <-> potMaxi)
      result=map((x[1]*16+x[2]),0,255,potMini,potMaxi);
      return result;
    }
  4. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    hello!

    Like @soraz explained,
    - you will only use 1 motor
    - in Simtools, it will be linked to Pitch effect (go to FAQ to see the pitch roll and other definitions)
    - with the motomonster, you will only use 1 output
    - with Arduino, no need to modify the code!
    - yes, it is used to convert hex from Simtools into decimal for arduino.

    After reading and re-reading the manuals and quick step by step guide, you'll master this building!
    yours
    Mat
    • Informative Informative x 1
  5. Ralph Manuel

    Ralph Manuel Member

    Joined:
    Aug 8, 2014
    Messages:
    50
    Balance:
    600Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    Arduino
    Oh! I thought I will have to modify the arduino code. I will not modify the code. I will just upload it to the
    arduino and that's it.

    Later on, I will also do my 2DOF simulator. But for now, my developed game supports pitch only.


    Thanks my friend! :)
    • Like Like x 1
  6. ferslash

    ferslash Active Member

    Joined:
    Feb 8, 2011
    Messages:
    495
    Balance:
    4,798Coins
    Ratings:
    +181 / 2 / -0
    what game are you willing to use with that bike sim?

    best regards

    fer
  7. Ralph Manuel

    Ralph Manuel Member

    Joined:
    Aug 8, 2014
    Messages:
    50
    Balance:
    600Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    Arduino
    Hi @ferslash. I'm developing my own game for my project in school and it is a bicycle ride game.
    I just explore new things :)
    • Like Like x 1
    • Winner Winner x 1
  8. ferslash

    ferslash Active Member

    Joined:
    Feb 8, 2011
    Messages:
    495
    Balance:
    4,798Coins
    Ratings:
    +181 / 2 / -0
    woooooooooooooow, man, i really would like to see your game... even do, please consider sharing it :D

    there is a game called torx, it is a race game, but... they have some track editors, and with them you can select some goole maps roads, as far as i understood in a cople of clicks you could create the virtual tour of france to use it in a game... maybe like yours :D

    (what are you studing? which technology are you using for your game?)

    fer
  9. Ralph Manuel

    Ralph Manuel Member

    Joined:
    Aug 8, 2014
    Messages:
    50
    Balance:
    600Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    Arduino
    @ferslash Dude, I'm using Unity game engine. After I'm done with the game and also with the simulator I will share it
    . This game is just a virtual tour of my country that provides a 3d model of some tourist spots of my country.
    :)
    • Like Like x 1
    • Winner Winner x 1
  10. ferslash

    ferslash Active Member

    Joined:
    Feb 8, 2011
    Messages:
    495
    Balance:
    4,798Coins
    Ratings:
    +181 / 2 / -0
    nice!

    how long did it took you to learn unity?

    where are you from ?

    your mexican friend

    fer
  11. Ralph Manuel

    Ralph Manuel Member

    Joined:
    Aug 8, 2014
    Messages:
    50
    Balance:
    600Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    Arduino
    I started to study Unity since April this year. I'm just a newbie in game development and my game is not that advanced and nice unlike the other game that you will see nowadays. I'm from Philippines and I'm just a college student.
    • Winner Winner x 1
  12. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    just use the original code and connect on motor.. dou you have the plugin for your game?