Skip to content
Made in Poland
Global Shipping
Tutorials & Guides

回転計付き DIY Wind Simulator

バージョン 2.112 以降、プラットフォームマネージャーは風シミュレーターなどさまざまな DIY アクセサリーに対応しています。Arduino、STM32 Discovery などの電子工作プラットフォームで製作できます。

1 はじめに

バージョン 2.112 以降、プラットフォームマネージャーは風シミュレーターなどさまざまな DIY アクセサリーに対応しています。Arduino、STM32 Discovery などの電子工作プラットフォームで製作できます。 一般的な 3 線式 PC ファン、4 線式 PC ファン、または高性能なインラインブロワーから選べます。さらに、 お使いのボード用に用意された既製のモータードライバーシールドを使うことも、回路全体を自作することも できます。すべてはお持ちのスキルと予算しだいです。

この短い記事では、Arduino Uno、12V のインラインブロワー、プロトタイプシールド上に組む簡単な自作回路を 選びました。

警告
DIY プロジェクトはすべて、お客様ご自身の責任で行っていただくものです。DIY では、工具や作業手順に不慣れなことが危険につながります。とくに電子工作や機械加工をはじめ、こうした作業 に不安がある場合や経験が少ない場合は、ご自身で行うかどうかを今一度ご検討ください。MotionSystems とその従業員およびパートナーは、DIY プロジェクトの誤用や誤解による負傷について責任を負いません。

2 必要なもの

先に進む前に、次の条件を満たしていることを確認してください。

  • Arduino のプログラミングに慣れていること (IDE の使い方、プログラムのコンパイルと書き込みなど)
  • はんだ付けの道具があり、その使い方を知っていること
  • これは DIY プロジェクトであり、現状のまま、いかなる保証もないことを理解していること
  • 上記の免責事項と利用条件に同意すること

3 設計

この設計の特長は次のとおりです。

  • 単純なリード部品 (THT) のみを使用
  • インラインブロワーを最大 2 台まで制御、12V DC、1 台あたり最大 5A
  • コイル鳴きを抑えるための 14.5 kHz PWM
  • ファンの低速時でも過熱しない
  • PC との通信は USB 経由の RS232
  • 過熱保護なし
警告
この回路には過熱保護がありません。私たちの環境で過熱の問題は起きていませんが、 ブロワーを低速で回すときはトランジスタの温度に注意してください。

4 部品

  • Arduino Uno または互換ボード x1 (例 Maker Uno)
  • プロトシールド x1 (例 Iduino EX023)
  • トランジスタ IRL540NPBF x2
  • トランジスタ用 TO220 ヒートシンク x2
  • THT 抵抗 300R/0.1W x2
  • THT 抵抗 10k/0.1W x2
  • ショットキーダイオード 1N5822 x2
  • 電源 12V DC、5~10A x1
  • インラインブロワー 12V DC x1 または x2 (例 SFIB1-130-01)
  • ソケットとコネクタ 数個
  • オプション: シフトライト用の LED 1 個と 220R 抵抗 1 個

5 組み立て

プロトシールド上での組み立ては簡単で、特別な説明は不要です。トランジスタ、抵抗、ソケットを表面に、 ショットキーダイオードを裏面に取り付けるのが手軽です。組み立て後の例を以下の写真に示します。

6 プログラム

プログラムは、PC から 3 秒間新しいコマンドを受け取らないとすべてのファンを停止します。これは PC がクラッシュした場合の保護です。ファンの速度 (PWM) は電流の急変を避けるため、小刻みに増減します。

プログラムは風に関する 2 つのコマンド Lxx と Rxx に対応します。前者は左ファン、 後者は右ファンを制御します。ファンが 1 台だけの場合は左として接続してください。xx は常に 00 から 99 までの 2 桁の数字です。

プログラムは回転数に関するコマンド Exxxxx に 1 つ対応します。xxxxx は車両エンジンの現在の回転数で、常に 00000 から 99999 までの 5 桁の数字です。

小文字の exxxxx は同じ回転数を送り、さらにシフトライトを点灯します。Exxxxx は消灯します。LED は 220R の直列抵抗を付けて、ピン 12 と GND の間に接続してください。

7 ソースコード

Arduino IDE または Visual Studio Code で次のコードをコンパイルし、Arduino Uno ボードに書き込んでください。

/* * Copyright (c) 2021 MotionSystems.eu * * Licensed under: * Creative Commons Attribution-NonCommercial-NoDerivs (CC-BY-NC-ND) * https://creativecommons.org/licenses/by-nc-nd/4.0/ */ namespace AtmegaTimers{    static constexpr const struct Prescaler    {        uint8_t       clockSelectBits;        unsigned int  divider;        unsigned long limit;    } TIM1_PRESCALERS[] = {     // ATmega328P PDF, page 110        {                         _BV(CS10), 1,    65536ul * 1    }, // 0 0 1 | clk/1        {             _BV(CS11)            , 8,    65536ul * 8    }, // 0 1 0 | clk/8        {             _BV(CS11) | _BV(CS10), 64,   65536ul * 64   }, // 0 1 1 | clk/64        { _BV(CS12)                        , 256,  65536ul * 256  }, // 1 0 0 | clk/256        { _BV(CS12) |             _BV(CS10), 1024, 65536ul * 1024 }, // 1 0 1 | clk/1024    }, TIM2_PRESCALERS[] = {    // ATmega328P PDF, page 131        {                         _BV(CS20), 1,    256ul   * 1    }, // 0 0 1 | clkT2S/1        {             _BV(CS21)            , 8,    256ul   * 8    }, // 0 1 0 | clkT2S/8        {             _BV(CS21) | _BV(CS20), 32,   256ul   * 32   }, // 0 1 1 | clkT2S/32        { _BV(CS22)                        , 64,   256ul   * 64   }, // 1 0 0 | clkT2S/64        { _BV(CS22)             | _BV(CS20), 128,  256ul   * 128  }, // 1 0 1 | clkT2S/128        { _BV(CS22) | _BV(CS21)            , 256,  256ul   * 256  }, // 1 1 0 | clkT2S/256        { _BV(CS22) | _BV(CS21) | _BV(CS20), 1024, 256ul   * 1024 }, // 1 1 1 | clkT2S/1024    };     template <size_t N>    void findPrescaler(const Prescaler (&prescalers)[N],                       unsigned long reqTimerTicks,                       uint8_t&  clockSelectBits,                       uint16_t& period)    {        clockSelectBits = 0;        period          = 0;         for (const auto& prescaler : prescalers)        {            if (reqTimerTicks <= prescaler.limit)            {                clockSelectBits = prescaler.clockSelectBits;                period = static_cast<uint16_t>(reqTimerTicks / prescaler.divider - 1);                break;            }        }    }} namespace PwmGeneratorTIM1{    static constexpr const int OUTPUT_PINS[] = { 9, 10 };     static constexpr const unsigned int DUTY_MAX = 1023ul;     void init(unsigned int freq_Hz)    {        auto timerTicks = static_cast<unsigned long>(clockCyclesPerMicrosecond() * 1000000ul / 2)                          / (max(1u, freq_Hz));         uint8_t  clockSelectBits = 0;        uint16_t pwmPeriod = 0;        findPrescaler(AtmegaTimers::TIM1_PRESCALERS, timerTicks, clockSelectBits, pwmPeriod);         TCCR1A = 0; // clear control register         pinMode(OUTPUT_PINS[0], OUTPUT);        TCCR1A |= _BV(COM1A1); // Compare output mode         pinMode(OUTPUT_PINS[1], OUTPUT);        TCCR1A |= _BV(COM1B1); // Compare output mode         ICR1   = pwmPeriod;        TCCR1B = _BV(WGM13) | // PWM, phase and frequency correct                 clockSelectBits;    }     inline void setPwmDuty(int pin, unsigned int duty)    {        unsigned long tmp = ICR1; // get maximum period        tmp *= min(duty, DUTY_MAX);        tmp >>= 10; // 0 to 1023        static_assert(DUTY_MAX == 1023ul, "");         switch (pin)        {            case OUTPUT_PINS[0]: OCR1A = tmp; break;            case OUTPUT_PINS[1]: OCR1B = tmp; break;            default:                          break;        }    }} namespace FreqGeneratorTIM2{    static constexpr const int OUTPUT_PIN = 11;     inline constexpr unsigned long periodToTick(unsigned long period_us)    {        return period_us * clockCyclesPerMicrosecond() / 2;    }     void init()    {        pinMode(OUTPUT_PIN, OUTPUT);    }     void setPeriodInTicks(unsigned long timerTicks)    {        if (timerTicks == 0)        {            TCCR2A &= ~_BV(COM2A0); // Do not toggle OC2A on compare match            return;        }         uint8_t  clockSelectBits = 0;        uint16_t compareValue    = 0;        findPrescaler(AtmegaTimers::TIM2_PRESCALERS, timerTicks, clockSelectBits, compareValue);         OCR2A  = compareValue;     // OCR2A is PB3, mapped to Arduino Uno pin 11 (OUTPUT_PIN)        TCCR2A = (_BV(WGM21) |     // 2 Clear Timer on Compare Match (CTC) Mode                 ( _BV(COM2A0)));  // Toggle OC2A on compare match        TCCR2B = clockSelectBits;    }} namespace ShiftLight{    // An LED with a 220R series resistor to GND; use a transistor for anything drawing more than ~20 mA    static constexpr const int OUTPUT_PIN = 12;     void init()    {        pinMode(OUTPUT_PIN, OUTPUT);        digitalWrite(OUTPUT_PIN, LOW);    }     inline void set(bool on)    {        digitalWrite(OUTPUT_PIN, on ? HIGH : LOW);    }} namespace{    enum    {        BlowerLeft  = 0,        BlowerRight = 1,         BlowersCount = 2,         BusyWaitTimeout       = 5,        InactivityTimeout     = 3000,        PwmDutyUpdateInterval = 20,         SerialSpeed = 115200,         PwmFrequency = 14500, // Incorrect value might overheat the transistor        PwmDutyMin   = 100,   // Minimum PWM that makes any sense for blower        PwmDutyMax   = 1023,  // It has to be <= PwmGeneratorTIM1::DUTY_MAX,                              // put less than DUTY_MAX if the power supply turns off        PwmDutyStep  = 40,         RpmHzFor3000 = 200, // TODO: Change this value to match your RPM gauge!         MaxSpeedFromPC             = 99,        MaxBlowerSpeedDigitsFromPC = 2,        MaxRpmDigitsFromPC         = 5    };     static_assert(static_cast<unsigned int>(PwmDutyMax) <= PwmGeneratorTIM1::DUTY_MAX, "");    static_assert(RpmHzFor3000 >= 200, "Value less than 200 will cut anything below 1000 RPM");     static struct    {        int current;        int required;    } g_pwmDuties[] = {        { 0, 0 },        { 0, 0 }    };     static unsigned long g_rpmReqTicks        = 0;    static unsigned long g_dataReceivedMark   = 0;    static unsigned long g_pwmDutyUpdateMark  = 0;     bool isDataAvailable()    {        auto mark = millis();        while (Serial.available() == 0)        {            if (millis() > mark + BusyWaitTimeout)            {                return false;            }        }        return true;    }     bool readNumberFromSerial(long& value, int maxDigits)    {        value = 0;        for (int i = 0; i < maxDigits; ++i)        {            if (! isDataAvailable())            {                return false;            }             auto tmp = Serial.read();            if (! isDigit(tmp))            {                return false;            }             value *= 10;            value += (tmp - '0');        }        return true;    }} void setup(){    PwmGeneratorTIM1::init(PwmFrequency);    PwmGeneratorTIM1::setPwmDuty(PwmGeneratorTIM1::OUTPUT_PINS[0], 0);    PwmGeneratorTIM1::setPwmDuty(PwmGeneratorTIM1::OUTPUT_PINS[1], 0);     FreqGeneratorTIM2::init();    FreqGeneratorTIM2::setPeriodInTicks(0);     ShiftLight::init();     Serial.begin(SerialSpeed);} void loop(){    auto ok   = readData();    auto mark = millis();     if (ok)    {        g_dataReceivedMark = mark;    }    else if (mark > g_dataReceivedMark + InactivityTimeout)    {        for (int i = 0; i < BlowersCount; ++i)        {            g_pwmDuties[i].required = 0;        }         g_rpmReqTicks = 0;        ShiftLight::set(false);    }     FreqGeneratorTIM2::setPeriodInTicks(g_rpmReqTicks);     auto diff = mark - g_pwmDutyUpdateMark;    if (diff < PwmDutyUpdateInterval)    {        return;    }     g_pwmDutyUpdateMark = mark;     // To compensate not perfect intervals    auto step = static_cast<int>(PwmDutyStep * diff / PwmDutyUpdateInterval);    for (int i = 0; i < BlowersCount; ++i)    {        auto& info = g_pwmDuties[i];        if (info.required == 0)        {            info.current = 0;        }        else if (info.required > info.current)        {            info.current = min(info.required, info.current + step);        }        else        {            info.current = max(info.required, info.current - step);        }         PwmGeneratorTIM1::setPwmDuty(PwmGeneratorTIM1::OUTPUT_PINS[i], info.current);    }} bool readData(){    if (! isDataAvailable())    {        return false;    }     auto cmd = Serial.read();     switch (cmd)    {        case 'L': return readDataBlower(BlowerLeft);        case 'R': return readDataBlower(BlowerRight);        case 'e': ShiftLight::set(true);  return readDataRpm();        case 'E': ShiftLight::set(false); return readDataRpm();        default:  return false;    }} bool readDataBlower(int blowerIndex){    long speed = 0;     if (readNumberFromSerial(speed, MaxBlowerSpeedDigitsFromPC))    {        g_pwmDuties[blowerIndex].required = 0 == speed            ? 0            : map(speed, 1, MaxSpeedFromPC, PwmDutyMin, PwmDutyMax);         return true;    }     return false;} bool readDataRpm(){    long rpm = 0;     if (readNumberFromSerial(rpm, MaxRpmDigitsFromPC))    {        // Engine off: no pulses, rather than a division by zero        static constexpr const auto FACTOR = 1000000ul * 3000/*rpm*/ / RpmHzFor3000;        g_rpmReqTicks = rpm == 0 ? 0 : FreqGeneratorTIM2::periodToTick(FACTOR / static_cast<unsigned long>(rpm));         return true;    }     return false;}

8 ライセンス

このファイルは Creative Commons Attribution - NonCommercial - NoDerivatives 4.0 International - CC BY-NC-ND 4.0 のもとで提供されます。

あなたは本素材を共有できます。すなわち、どのような媒体や形式でも複製し再配布できます。 ライセンスの条件に従うかぎり、許諾者がこれらの自由を取り消すことはできません。

ただし、次の条件に従ってください。

  • 表示 - 適切なクレジットを表示し、ライセンスへのリンクを提供し、変更があったかどうかを示す必要があります。合理的な方法であれば行えますが、許諾者があなたやあなたの利用を推奨していると示唆するような方法はいけません。
  • 非営利 - 本素材を営利目的で利用してはいけません。
  • 改変禁止 - 本素材をリミックスしたり、改変したり、加工したりした場合、改変後の素材を頒布してはいけません。
  • 追加的な制約の禁止 - ライセンスが認めることを他者が行うのを法的に制限するような法的条件や技術的手段を適用してはいけません。

9 初回起動 - Arduino

  1. プロトシールドはまだ Arduino に接続しないでください。
  2. ForceSeatPM を終了します。
  3. ボードを PC に接続します。
  4. ファームウェアを書き込みます。
  5. Arduino IDE でシリアルモニタを開きます (ツール/シリアルモニタ)。
  6. ボーレートに 115200 を設定します。
  7. ボードに L20 を送信します。
  8. Maker Uno をお使いの場合、L9 の LED が 2 秒間点灯し、その後自動的に消灯します。

10 初回起動 - プロトシールド

  1. プロトシールドはまだ Arduino に接続しないでください。
  2. インラインブロワーをプロトシールドに接続します。
  3. 電源を接続します。この回路に逆接続保護はありません。
  4. 主電源を入れます。
  5. インラインブロワーは回り始めては「いけません」。
  6. テスターで、電源ソケットの + と - の間が 12V DC であることを確認します。
  7. テスターで、インラインブロワー 1 の電源と電源の GND の間が 12V DC であることを確認します。
  8. テスターで、インラインブロワー 2 の電源と電源の GND の間が 12V DC であることを確認します。

11 Arduino + プロトシールド

  1. 主電源を切ります。
  2. プロトシールドを Arduino に取り付けます。
  3. 主電源を入れます。
  4. Arduino を PC に接続します。
  5. Arduino IDE でシリアルモニタを開きます (ツール/シリアルモニタ)。
  6. ボーレートに 115200 を設定します。
  7. ボードに L20 を送信します。左のインラインブロワーが回り始めます。
  8. ボードに R30 を送信します。右のインラインブロワーが回り始めます。
  9. トランジスタの温度を確認します。この回路に過熱保護はありません。

12 ForceSeatPM の設定

  1. ForceSeatPM を起動します。
  2. デバイスを開き、デバイスを追加を押します。
  3. DIY Wind Sim, RPM 対応は任意を選びます。
  4. ボードを接続したポートを選び、ボーレートを 115200 に設定し、製作した装置が駆動する機能を選びます。選択肢は DIY Wind、DIY RPM + Wind、DIY Shift Light + RPM + Wind です。
  5. 保存します。アクセサリーはデバイス一覧に独自の項目として並び、シリアルプロトコルの参照はそのページにあります。
  6. ForceSeatPM からお好きなゲームを起動し、髪に受ける風をお楽しみください。
情報
アクセサリーの入り切りは、デバイス一覧にある各行のメニューの有効にすると無効にするで行います。 2 つのアクセサリーが同じポートを使うことはできません。