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

Simulated Wind using MonsterMoto and ArduinoUno

Discussion in 'SimTools compatible interfaces' started by SilentChill, May 15, 2015.

  1. HoiHman

    HoiHman Active Member

    Joined:
    Feb 1, 2015
    Messages:
    211
    Occupation:
    Mechanic
    Location:
    The Netherlands
    Balance:
    331Coins
    Ratings:
    +143 / 1 / -0
    I received the inductors but i'm totally in the dark how to make my fans quieter.

    I know how/where to put them in the electrical circuit of the seaflows, but can some one please help me out with the arduino code needed to run them at higher PWM settings. I have a 80mm fan and heatsinks on the MM.

    1. Do i need to change anything on the arduino/MM connection / pin settings?
    2. Can some one post the code needed for running higher PWM settings with simtools?
    Last edited: Apr 20, 2017
  2. HoiHman

    HoiHman Active Member

    Joined:
    Feb 1, 2015
    Messages:
    211
    Occupation:
    Mechanic
    Location:
    The Netherlands
    Balance:
    331Coins
    Ratings:
    +143 / 1 / -0
  3. SilentChill

    SilentChill Problem Maker

    Joined:
    Jul 19, 2014
    Messages:
    2,643
    Occupation:
    Railway Maintenance
    Location:
    Morecambe, Lancashire, England
    Balance:
    20,558Coins
    Ratings:
    +3,487 / 34 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    You put them between the MM and the Fans on the power cables.

    The code for different PWM is in a post on last page I think
    • Like Like x 1
  4. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    No pin changes or anything, as @SilentChill said, just put the inductors between the MM and the fans, and then use the code I posted in on the last post of the last page, just replace everything above "void loop()"
    • Like Like x 2
  5. HoiHman

    HoiHman Active Member

    Joined:
    Feb 1, 2015
    Messages:
    211
    Occupation:
    Mechanic
    Location:
    The Netherlands
    Balance:
    331Coins
    Ratings:
    +143 / 1 / -0
    Thanks Richard, but i seem run into a problem since it won't upload to my arduino.

    I have used this code posted by you on page 4:





    Replaced everything above "void loop" and the final code looks like this:





    It won't upload with these errors:




    I probably doing something wrong, but i have no idea what???
  6. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Yeah, I forgot that the SimTools code was defining some stuff up in the top

    You need to just replace the bits that control the PWM frequencies but leave in the rest of the stuff that SimTools needs. It is sort of the bit in the middle of the code that I posted. I am on my iPad so it is a bit hard to explain. I'll see if I can get something going tomorrow.

    I don't have the pro version of SimTools so I won't be able to test it but I can give you the code to try.
  7. HoiHman

    HoiHman Active Member

    Joined:
    Feb 1, 2015
    Messages:
    211
    Occupation:
    Mechanic
    Location:
    The Netherlands
    Balance:
    331Coins
    Ratings:
    +143 / 1 / -0

    hug: Thanks Richard, that would be great.
  8. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    YOLO. here goes nothing, I am not a programmer but at least it compiles.

    I left in all the pwmmodes so 0=980Hz 1=4KHz 2=8KHz 3=31KHz

    I have left it set on 8KHz, make sure you are using inductors and a heatsink. Use that your own risk, Do a small test first and check your temperatures, if you run it at 8KHz with no inductors then you have about 30 seconds before it overheats.

    8KHz works fine on the wind simulators I sell, I have sold quite a few with 8KHz and the suppressors and they run at around 25-35 degrees C. Mostly I sell to the iRacing community so I usually ship with the iRacing code set at 8KHz

    I haven't tested it because I don't have SimTools Pro yet.

    Code:
    #define BRAKEVCC 0
    #define CW   1
    #define CCW  2
    #define BRAKEGND 3
    #define CS_THRESHOLD 100
    
    int inApin[2] = {7, 4};  // INA: Clockwise input
    int inBpin[2] = {8, 9}; // INB: Counter-clockwise input
    int pwmpin[2] = {5, 6}; // PWM input
    int cspin[2] = {2, 3}; // CS: Current sense ANALOG input
    int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)
    int statpin = 13;
    
    // pwmMode - sets the PWM frequency, valid options as follows:
    // pwmMode = 0 will use 980Hz PWM, default mode which will work with all fan types, will cause coil whine if using a MM.
    // pwmMode = 1 will use 4kHz PWM, might reduce coil whine for blowers, use heatsinks on the MM - check MM temp at a low fan speed.
    // pwmMode = 2 will use 8kHz PWM, might be OK for blowers with active cooling on the MM - check MM temp at a low fan speed.
    // pwmMode = 3 will use 31kHz PWM, use with caution - not for blowers with MM as it will cause very high temps. Check MM temp at a low fan speed.
    // server fans - should be able to use pwmMode = 2 or 3.  If you are using the PWM control on the server fan, leave this at default 0.
    // if you have blowers with a monster moto, try pwmMode = 1 or 2 and check whether your monster moto temp at low speeds.
    int pwmMode = 2;        // value of 0, 1, 2 or 3 - modes 2 and 3 will overheat a Monster Moto if used with blowers
    
    // This just works with one variable from the Game Dash.
    int Speed ;
    int SpeedGameDash = 0;
    
    int bufferArray[4];
    
    void setup()
    
    {
       Serial.begin(9600);
    
       // initialize digital pins as outputs
       for (int i=0; i<2; i++)
       {
          pinMode(inApin[i], OUTPUT);
          pinMode(inBpin[i], OUTPUT);
          pinMode(pwmpin[i], OUTPUT);
          digitalWrite(inApin[i], LOW);
          digitalWrite(inBpin[i], LOW);
       }
    
       // disable timer0's interrupt handler - this will disable Arduino's time keeping functions such as delay()
       TIMSK0 &= B11111110;
      
       if (pwmMode == 1)
       {
          // Set pins 5 & 6 to Phase-correct PWM of 3.9 kHz (prescale factor of 8)
          TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00); // phase-correct PWM
          TCCR0B = _BV(CS01);  // prescaler of 8, gives frequency 61kHz/8/2 = 3.9kHz
       }
       else if (pwmMode == 2)
       {
          // Set pins 5 & 6 to Fast PWM of 7.8 kHz (prescale factor of 8)
          TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM01) | _BV(WGM00); // fast PWM
          TCCR0B = _BV(CS01);  // prescaler of 8, gives frequency 61kHz/8 = 7.8kHz
       }
       else if (pwmMode == 3)
       {
          // Set pins 5 & 6 to Phase-correct PWM of 31.25 kHz (prescale factor of 1)
          TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00); // phase-correct PWM
          TCCR0B = _BV(CS00); // prescaler of 1, gives frequency 61kHz/1/2 = 31.25kHz
       }
       else
       {
          // Set pins 5 & 6 to Fast PWM of 980Hz (prescale factor of 64)
          TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM01) | _BV(WGM00); // fast PWM
          TCCR0B = _BV(CS01) | _BV(CS00);  // prescaler of 64, gives frequency 61kHz/64 = 980Hz
       }
    }
    
    
    void loop(){
      //****************************** READ DATA FROM SERIAL ******************************
    
        ReadData();
        CalcPWM();
    
                           
    motorGo(0, CW, Speed);        //Motor1
    motorGo(1, CW, Speed);      //Motor2
    if (Speed=0 , motorOff);
    
    }
    
    void motorOff(int motor)
    {
    // Initialize braked
    for (int i=0; i<2; i++)
    {
       digitalWrite(inApin[i], LOW);
       digitalWrite(inBpin[i], LOW);
    }
    analogWrite(pwmpin[motor], Speed);
    }
    
    void motorGo(uint8_t motor, uint8_t direct, uint8_t Speed)
    {
    if (motor <= 1)
    {
       if (direct <=4)
       {
         // Set inA[motor]
         if (direct <=1)
           digitalWrite(inApin[motor], HIGH);
         else
           digitalWrite(inApin[motor], LOW);
    
         // Set inB[motor]
         if ((direct==0)||(direct==2))
           digitalWrite(inBpin[motor], HIGH);
         else
           digitalWrite(inBpin[motor], LOW);
         analogWrite(pwmpin[motor], Speed);
       }
    }
    }
    
    void ReadData(){
      if (Serial.available() == 4)  {    //if 4 bits available in the Serial buffer...
       
            int i;
            for (i=0; i<4; i=i+1) {       // read and label each byte.
                   bufferArray[i] = Serial.read();
             }
       
             if (bufferArray[0]  == 'S'){
               SpeedGameDash = ((bufferArray[1]-48)*100) + ((bufferArray[2]-48)*10) + // Take values 1-3.
                                   ((bufferArray[3]-48)*1);
                    if (SpeedGameDash > 255){
                                    SpeedGameDash = 255;
                    }         
               
               //Serial.print("You have set the Speed to a Value of:");
               //Serial.println(SpeedGameDash);
          }
        }
    }
    void CalcPWM() {
    
        if (SpeedGameDash > 0){
        int oldSpeed = Speed;
        Speed = map(SpeedGameDash, 0 , 255 , 0 , 255);
        if (oldSpeed != Speed){
        //Serial.print("Fan Speed set to :");
        //Serial.println(Speed);
        analogWrite(11,Speed);
      }
      }
    }
    • Like Like x 4
    • Winner Winner x 2
    • Informative Informative x 1
  9. HoiHman

    HoiHman Active Member

    Joined:
    Feb 1, 2015
    Messages:
    211
    Occupation:
    Mechanic
    Location:
    The Netherlands
    Balance:
    331Coins
    Ratings:
    +143 / 1 / -0
    Thanks a lot Richard, you're awesome :thumbs
    • Agree Agree x 1
  10. MyTPioneer

    MyTPioneer New Member Gold Contributor

    Joined:
    Jan 22, 2017
    Messages:
    23
    Occupation:
    Database Developer
    Location:
    United States
    Balance:
    301Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    Awesome work guys. I'm wondering if anyone can take a quick look at my settings and see if they can determine what I am missing. I've pasted a link to the thread below.

    To summarize, I'm able to see In and Out digits in Game Dash, but nothing ever appears to make it to the Arduino. If I turn on the Serial Monitor on the Arduino and insert a Serial.println inside the if (Serial.available() == 4) condition, the statement never gets called, as if there are never 4 bits in the buffer. I've tried enabling Virtual Output, and it seems to work find.

    https://www.xsimulator.net/community/threads/2dof-with-fans-uno-mm.9788/page-2#post-130118

    Thanks for any suggestions.

    MyTPioneer
  11. paulopsx2

    paulopsx2 Active Member

    Joined:
    Apr 2, 2016
    Messages:
    615
    Location:
    brasil
    Balance:
    635Coins
    Ratings:
    +163 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino, Motion platform
    please.... WHATS a good motor or blades for do that?
  12. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Hey guys. I have fully tested the 8KHz code and it works fine with my wind simulators.

    If you are going to use 8KHz on your own DIY wind simulators then MAKE SURE you are using inductors OR ELSE THEY WILL OVERHEAT

    make sure you are using inductors and a heatsink. Use that your own risk, Do a small test first and check your temperatures, if you run it at 8KHz with no inductors then you have about 30 seconds before it overheats.

    Seaflo 4" blowers is what I use.
    • Like Like x 2
  13. paulopsx2

    paulopsx2 Active Member

    Joined:
    Apr 2, 2016
    Messages:
    615
    Location:
    brasil
    Balance:
    635Coins
    Ratings:
    +163 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino, Motion platform
    Is it possible to put any info about this project, some pics, wires, more detailed "step by step" ? thanks !
  14. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,071
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    148,118Coins
    Ratings:
    +10,888 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    There are 16 pages of detail in this thread, including hardware, code, photos and even 3D printed parts files, if you want an easier solution then perhaps you can contact @Avenga76 and buy a setup.
    • Agree Agree x 1
  15. Avenga76

    Avenga76 Well-Known Member

    Joined:
    Jun 29, 2014
    Messages:
    518
    Occupation:
    Network Engineer
    Location:
    Auckland, New Zealand
    Balance:
    3,261Coins
    Ratings:
    +853 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    That's correct. If you read through the thread then I have posted tons of photos and diagrams of how to wire everything. I have detailed information about what parts to use and how things like the inductors work and are wired.

    Have a read of the whole thread, everything you need is in there in tons of detail. It is too long to make a step by step when all the info is available if you read through the thread.

    And as @noorbeast said, if it is too difficult then I sell a whole range of assembled wind simulators, all the way from just the controller boxes all the way up to fully assembled turn key, plug and play wind simulators.
    • Agree Agree x 1
  16. Zed

    Zed VR Simming w/Reverb Gold Contributor

    Joined:
    Apr 4, 2017
    Messages:
    1,040
    Location:
    USA
    Balance:
    5,841Coins
    Ratings:
    +1,040 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    About that buy a wind generator from Avenga76 - I bought one of his setups and don't regret it for a second! Got the fans locally to save on shipping but otherwise, got the full kit.

    The build quality is top notch, you can pick the level of completion, and at the time I did, I did not have a 3D printer. The 3D printed parts are beautiful and he told me it takes about a week of continuous operation to print the parts. The velocity stacks are 4" at the base and probably 5" or more at the throat. The flow straighteners have honeycomb vanes in them and he can make them with or without mounting lugs. Things of beauty all.

    It was my first step down the slippery slope of motion and demystified a lot and let me experiment with SimTools (Pro) and plugins before opening the wallet for all the motion parts.

    And wind is a trip no matter how you get it going - especially in VR. It is just that much extra immersion, but also really changes VR. Just practical matters especially in summer, it gets warm in the headset. With wind you get air circulation that keeps eye irritation and heat from being issues at all. I can go for hours continuous now.
    • Like Like x 1
  17. cruzebabuze

    cruzebabuze Active Member

    Joined:
    Jan 30, 2013
    Messages:
    145
    Balance:
    135Coins
    Ratings:
    +41 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    would your code work with an iBT-2 controller instead of MM? Thank you
  18. SilentChill

    SilentChill Problem Maker

    Joined:
    Jul 19, 2014
    Messages:
    2,643
    Occupation:
    Railway Maintenance
    Location:
    Morecambe, Lancashire, England
    Balance:
    20,558Coins
    Ratings:
    +3,487 / 34 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    No sorry
  19. cruzebabuze

    cruzebabuze Active Member

    Joined:
    Jan 30, 2013
    Messages:
    145
    Balance:
    135Coins
    Ratings:
    +41 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    thank you
  20. paulopsx2

    paulopsx2 Active Member

    Joined:
    Apr 2, 2016
    Messages:
    615
    Location:
    brasil
    Balance:
    635Coins
    Ratings:
    +163 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino, Motion platform