• "Mwoah" - Kimi Räikkönen
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Dear Guest. Follow RaceDepartment on Twitter, Facebook, Instagram, Twitch, Steam and YouTube.

Easy DIY wind simulator for Assetto Corsa

Discussion in 'Sim Racing Hardware' started by Insert Coin, Apr 1, 2017.

  1. Insert Coin

    Insert Coin

    Messages:
    333
    Ratings:
    +110
    Do you want to feel the wind blowing when you drive your open wheeler in Assetto Corsa? Now you can!

    In short: ACFan sends speed of car in AC to Arduino Uno R3, which controls PWM fan(s). No PWM whine. Hardly any CPU load.

    Scythe GlideStream 120 PWM SC (silent)


    Delta AFB1212SH fans (more wind, noisier)


    Sanyo San Ace 120 9SG1212P1G03 (only one fan, loud!)

    I needed to clamp the fan to the desk or it would fly away :laugh:.
    Don't mind the driving, I'm not used to an Xbox controller.

    I would like to present my little project: a wind simulator for Assetto Corsa. Most wind simulators use an Arduino combined with a separate motor controller, which can be expensive if you use larger fans. My project also uses an Arduino, but with standard PWM PC case fans. A PWM fan has a motor controller built into the fan. The Arduino just sends a PWM signal to the fan and this will control the speed of the fan. This way there are less parts needed and the project is kept simple.

    Credits
    It’s not an original idea of me, I just combined two ideas: using an Arduino to control a PWM fan and using an existing interface between Assetto Corsa and the Arduino. There is no PWM whine coming from the fan because a 25 KHz PWM signal is used.

    I would like to thank afremont for his PWM logic, see https://forum.arduino.cc/index.php?topic=155089.45

    I would like to thank mongo56 for his ‘ACFan’ executable and source code, see https://www.reddit.com/r/oculus/comments/2b8d3m/assetto_corsa_fan_control/

    ACFan
    The program ACFan is the interface between Assetto Corsa and an Arduino. ACFan reads the shared memory of AC: the speed of the car and the steering input. When the car is idle, it sends value 30 to the Arduino. As soon as the cars starts rolling, it sends between 61 and 100 to the Arduino, depending on the speed of the car. ACFan also varies the values a bit when you are steering to simulate wind direction changes.

    Arduino
    I have modified the sketch (program) mongo56 made for the Arduino, it now uses PWM to control the speed of the fan. It has a startup sequence built in which speeds up the fan in a few seconds so you know the Arduino is doing its job. After that it continuously translates the values sent by ACFan to a usable PWM value, between 0 and 79.
    Remark: when there is no PWM signal sent to the fan, it will run at top speed.

    Fans to use
    Most fans cannot stop completely, even with a PWM signal at zero. The Scythe GlideStream 120 PWM SC fans I chose have a speed of 300 to 1500 RPM. This means there will always be some wind blowing when the car stops (= 300 RPM). At best you can use fans with a broad RPM range: a low minimum and high maximum RPM value. This way the fan will produce a higher wind speed difference at high and low car speed.
    The Delta and Sanyo have a minimum RPM of 0.
    The Sanyo fan will only start after reaching a higher minimum PWM threshold, but still has a fairly low minimum RPM.

    You need as much air flow as you can get, this is the CFM (Cubic Feet per Minute) value of the fan: a higher CFM value means more air flow. The Scythe fan produces 85 CFM and the Delta AFB1212SH fan produces 113 CFM. There are PWM fans which can produce 260 CFM like the Sanyo San Ace 120 9SG1212P1G03, but they produce a lot of noise! Check the dB value of the fan to see how much noise it produces: 29.5 dB for the Scythe fan, 46.5 dB for the Delta fan and a whopping 64 dB for the Sanyo fan (that’s LOUD, see video above). A small fan with a high RPM value will also make a lot of noise. A larger fan is recommended: lower noise and it also spreads the air flow better.
    My recommendation is to use the Delta fans: more wind, not too loud.

    Power
    A high CFM fan needs more power. The Scythe fan I chose draws 0.22 Amps at 12V. If you use two of them you need a 12V power adapter which can deliver at least 0.5 Amps (0.22 x 2).
    Power supply.jpg

    The Delta AFB1212SH fan draws 0,83 Amps maximum, if you use two of them you need a 2 Amps power adapter (0,83 x 2).
    The 260 CFM Sanyo fan I mentioned draws 4 Amps, so if you use that one you need a much bigger power adapter: 4 Amps or 8 Amps if you use two fans (but then the neighbors will complain about the noise :D).

    To avoid damaging the Arduino the power to the fans in my project is connected directly to the power adapter, it is not running through the Arduino. The Arduino is only controlling the speed.

    More fans
    You can use as much fans as you want: by connecting the PWM signal from the Arduino to each fan the speed will be controlled of all fans. Do check if you need a bigger power adapter.

    I’m using two fans as shown in this picture:
    Two fans.jpg

    The fans are tie wrapped together with a piece of tube in the middle, so you can angle the fans a bit inward.

    What do you need?
    I have added the price I paid for it.
    • Arduino Uno R3 (clone), 13 euro
    • Arduino Uno frame (mini case) is recommended, 5 euro
    • USB cable type B, 0.50 euro
    • 12V power adapter of at least 0.5A (2A recommended), 5 euro
    • Multicolored Dupont wires (a kit of male / male, male / female, female / female is handy), about 6 euro
    • Two Scythe GlideStream 120 PWM SC (SY1225HB12MS-RKP) fans (or just one), 8.79 euro each
      or
      two Delta AFB1212SH fans (eBay), about 10 euro each.
      I do not recommend the Sanyo fans: too loud.
    • 3 pin tumbler switch, 0.75 euro. Alternative: use a power socket with a switch in which you plug the adapter
    • 4-pin PWM fan splitter cable (Y-cable) if you use more than one fan: build it yourself or buy this one
    • Pin header, 0.25 euro
    Total costs: 48.09 euro (50,51 when Delta fans are used). Shipping costs excluded.

    Programming
    • Download the Arduino IDE (programming environment) at https://www.arduino.cc/en/Main/Software and install it.
    • Connect the Arduino to your PC using the USB cable.
    • Check Windows’ device manager to see which COM port the Arduino is using.
    Start the Arduino IDE and
    • click on Tools – Board and select Arduino Uno
    • click on Tools – Port and select the COM port you found in the device manager
    • click on Tools – Programmer and select USBasp
    Delete all shown source code in the IDE (all text) and paste my sketch into the IDE:
    Code:
    // Arduino UNO sketch
    // Insert Coin
    // April 1, 2017
    //
    // Thanks to afremont for his PWM logic,
    // see https://forum.arduino.cc/index.php?topic=155089.45
    //
    // Thanks to mongo56 for his idea ACFan and source code,
    // see https://www.reddit.com/r/oculus/comments/2b8d3m/assetto_corsa_fan_control/
    
    String incomingValue;
    int myval;
    unsigned int x;
    
    const int PWMPin = 3;
    
    void setup() {
      myval = 0;
      Serial.begin(9600);
     
      // generate 25kHz PWM pulse rate on Pin 3
      pinMode(PWMPin, OUTPUT);   // OCR2B sets duty cycle
      // Set up Fast PWM on Pin 3
      TCCR2A = 0x23;     // COM2B1, WGM21, WGM20
      // Set prescaler
      TCCR2B = 0x0A;   // WGM21, Prescaler = /8
      // Set TOP and initialize duty cycle to zero(0)
      OCR2A = 79;    // TOP DO NOT CHANGE, SETS PWM PULSE RATE
    
      // start-up sequence: let the user know we are working OK
      // start fan at lowest speed
      OCR2B = 0;   // duty cycle for Pin 3 (0-79) generates 1 500nS pulse even when 0 :(
      // wait for the fan to power down
      delay(1000);
      // ramp up fan speed by increasing duty cycle every 50mS, takes 4 seconds
      for(x = 0; x < 80; x++) {
        OCR2B = x;    // set duty cycle
        delay(50);
      }
    
      // wait a bit
      delay(1000);
      // set fan to lowest speed
      OCR2B = 0;   // duty cycle for Pin 3 (0-79) generates 1 500nS pulse even when 0 :(
    }
    
    void loop() {
    
      // waiting for data coming from ACFan.exe
      // which retrieves the speed from Assetto Corsa,
      // converts it to a string and sends it to the Arduino
      if(Serial.available() > 0)
      {
        char ch = Serial.read();
        // check for new line and add the char if it isn't
        if (ch != 10){
          incomingValue += ch;
        }
        else
        {
          // Serial.println(incomingString);
          int val = incomingValue.toInt();
     
          // See ACFan.cpp:
          // ESC value between 30 and 180 (30 = initial startup)
          // adjust this to fit your ESC/motor and liking
          // 61 was the value my motor started running
          // 350 was my max speed in Assetto Corsa (in kmh)
          // 50 was an arbitary multiplier to normalise the output values between ~61-100
          // also added a bit of variance with steerAngle so that when you turn in you get a little less "wind"
     
          if (val > -1 && val < 181)
          {
           myval = (val - 60) * 2; // to get a variance between 0 and 79 instead of 61 and 100
    
           // check if out of bounds
           if (myval < 0) {
            myval = 0;
           }
           if (myval > 79) {
            myval = 79;
           }
    
           // set the fan speed (duty cycle)
           OCR2B = myval;
          }
          // clear the input string that came from ACFan
          incomingValue = "";
        }
      }
    
    }
    
    Click on the icon with the arrow pointing right, this will compile the sketch and send it to the Arduino. If there are no errors shown in red you can now close the IDE.

    Connecting the fans
    Connect the power adapter and the fans like this:

    Schema.jpg

    Dsc01412.jpg

    Dsc01415.jpg

    Dsc01414.jpg

    Dsc01413.jpg



    Pin 3 of the Arduino is connected to the PWM pin of the fan (the orange wire on the fan).
    The GND of the power adapter is connected to the GND of the Arduino and the black wire of the fan.
    The + of the power adapter is connected to the red wire of the fan. A switch in this wire is handy to power off the fans after racing.
    My son (thanks man!) did all the soldering and made a Y-cable which splits the power and PWM signal to both fans, but you can buy a ready made.

    Dsc01419.jpg

    Testing the hardware
    Plug in the power adapter and switch it on. The fans should start running.
    Press the reset button on the Arduino, this will initiate the startup sequence: the fans will run faster and faster and drop to the lowest speed in about 4 seconds time.

    Connecting to Assetto Corsa
    Download the program ACFan.exe which you can find in the binary folder here: https://drive.google.com/drive/folders/0B-23DIE-A8sUYXowYTlXXzBpR00
    Save ACFan.exe in a folder, for example in C:\AC.
    Create a shortcut to C:\AC\ACFan.exe on your desktop.
    Right click the shortcut, go to Properties and add the COM port to the target, for example “C:\AC\ACFan.exe” com5 and click on OK.
    Start Assetto Corsa and start a practice run. Tip: keep Assetto Corsa running in a small window so you can see the game and the output ACFan at the same time. While driving you should see numbers between 61 and 100; 30 when your car doesn’t move.
    The fans should blow accordingly.
    Note: when you run the game as administrator, you may need to run ACFan as administrator as well.

    I hope you will be blown away :D. Let me know what you think. Feel free to ask.

    Insert Coin
     
    Last edited: Aug 12, 2017
    • Like Like x 7
  2. Mr Chip

    Mr Chip
    A lot of gear, little idea....... Premium

    Messages:
    164
    Ratings:
    +84
    Nice, love it!

    I don't race open wheelers much, but this could be a good way to help keep cool with Rift on :thumbsup:
     
  3. RinusDirtRally

    RinusDirtRally
    First to complete DR and longest playtime award. Premium

    Messages:
    193
    Ratings:
    +111
    Nice guide, mate. I love it too. Maybe a project for in the future. Bookmarked it.
     
  4. Paul Blythe

    Paul Blythe

    Messages:
    190
    Ratings:
    +113
    Nice little project ... certainly a good way to keep cool with the Rift.

    Just wondering if there's any way of using this with other sims also?
     
  5. Vantage9

    Vantage9

    Messages:
    2
    Ratings:
    +0
    Yes, the Xsimulator guys have it working for all kinds of games. Anything that's supported by SimVibe. I've been researching ways to tackle this project as a programming newbie, and the SimVibe route seemed like the most user-friendly, but its somewhat expensive software if you're only using it for Assetto. This solution looks like it might be easier and cheaper, I'll think I'll give it a shot first.

    https://www.xsimulator.net/community/threads/simulated-wind-using-monstermoto-and-arduinouno.6876/
     
  6. Vantage9

    Vantage9

    Messages:
    2
    Ratings:
    +0
    Total idiot question here, but I'm using this project as my intro to Arduino. My only real experience with electrical circuits is with wiring LEDs of various types & applications, and I've always had to be concerned with using resistors to not blow out the LEDs.

    If I use a power supply that's more than I need, or if I only use 1 Fan, do I need to be concerned with sending too much juice to the Fans? If not, I think I have everything I need to test this out right away...
     
  7. Insert Coin

    Insert Coin

    Messages:
    333
    Ratings:
    +110
    A power supply doesn't push the amps, it only delivers as requested. As an example you can use a 20 Amps power supply and connect a 0.5 Amp fan. The power supply will deliver 0.5 (as requested by the fan), not 20. In this case you're using a much too expensive power supply, that's all. So no fireworks ;).
     
  8. Mr Latte

    Mr Latte
    Premium

    Messages:
    619
    Ratings:
    +250
    Nice, enjoyable read @Insert Coin.

    Think a lot might like this little mod sir.
    I'd like to see a solution that can be bought with interconnecting cables, so no soldering to work with 4 pin fans.

    Such may be found here if you can direct to something suitable for no soldering?

    I've imported to UK from this company for suitable cables to replace the noisy fans in Behringer Inuke amps. Couldnt find the cables in UK/Europe and they seem to do a LOT of stuff. Appreciate if a solution hassle free if a bit more expensive is found.
     
    Last edited: Apr 5, 2017
  9. Insert Coin

    Insert Coin

    Messages:
    333
    Ratings:
    +110
    Post updated: videos added using Delta AFB1212SH fans and a Sanyo San Ace 120 9SG1212P1G03 fan. Also updated the text with the specs of those fans.

    Regarding soldering, consider this to avoid most of it:
     
  10. museumsteve

    museumsteve

    Messages:
    461
    Ratings:
    +169
    Look up Symprojects fan board..plug n play and works with just about all current sims
     
    • Like Like x 1