Dreamcast fan mod with an Arduino

Discussion in 'Sega Dreamcast Development and Research' started by Compupaq, Jul 21, 2015.

  1. Compupaq

    Compupaq Member

    Joined:
    Dec 21, 2014
    Messages:
    7
    Likes Received:
    8
    I was originally going to use a 555 timer to emulate the fan signal like in the random project man blog post, but after hours of doing calculations for resistor and capacitor values and pricing out the parts, I got fed up. Then I found out that an Arduino can output square wave signals, so I figured I'd try one of those out.

    To make sure I made the square wave signal as close as possible to an actual fan, I measured it with an oscilloscope.

    [​IMG]

    The oscilloscope shows each high and low state lasting for 2ms (with a .4ms switching time that I forgot to add into my original calculations). So each high and low cycle takes 4ms, which becomes 250 cycles/second or 250Hz. This is a little bit faster than the 7Hz that was estimated from the random project man blog.

    So I programmed an Arduino Pro Mini to output a 250Hz square wave on pin 9. I bought a clone from Microcenter for $4, but it can be found even cheaper on ebay (make sure to get the 5V version). The cost difference between this and building a 555 timer is pretty negligible. Although, if you need the USB adapter to program it, it raises the price a little more.

    [​IMG]

    Then I tested it with the oscilloscope to make sure it's working.

    [​IMG]

    Here it is installed

    [​IMG]

    The Arduino is wired up to 5V and ground on the PSU and the signal wire on the fan plug (the fan's currently unplugged for testing purposes). I also made a video of the Dreamcast running with the fan unplugged. I unplug the Arduino for a few seconds to show that the Dreamcast will shut off without it.



    Now just about any 5/12V fan can be used in the Dreamcast without having to worry about it turning off. The Dreamcast won't be able to tell if the fan actually does stop, so it may overheat if that happens. In the final version of the mod, I plan to have the Arduino wired up to the fan plug to make it look cleaner. The Arduino draws less current than the stock fan, so there shouldn't be any issues. I'll have to wire up the fan elsewhere.

    I'll also probably change the frequency to 200Hz to account for the .4ms of transition time I forgot earlier. The beauty of using an Arduino to generate the signal as opposed to a 555 timer is that I don't have to replace physical parts to change the frequency. I just need to modify the program and re-upload it.
     
  2. citrus3000psi

    citrus3000psi Housekeeping, you want towel?

    Joined:
    Nov 8, 2013
    Messages:
    1,051
    Likes Received:
    418
    is it not possible to alter the tach signal from the fan so the dreamcast can read it with the micro?
     
    Last edited: Jul 21, 2015
  3. Compupaq

    Compupaq Member

    Joined:
    Dec 21, 2014
    Messages:
    7
    Likes Received:
    8
    It most likely is possible, I'll have to do some experiments with it. The method I posted is just a quick and dirty way of bypassing the safety measure put in the Dreamcast so you can use any fan you want, even ones that don't have an RPM signal wire.

    If you were really inclined, you could also set up the Arduino to control the fan speed based on the temperature inside the Dreamcast. I just started messing with Arduinos. Once I get more experience with it, I can start doing more fun stuff with it.
     
    justice99 likes this.
  4. justice99

    justice99 Spirited Member

    Joined:
    Nov 18, 2011
    Messages:
    123
    Likes Received:
    24
    Very nice work!

    What if I don't plug any fan, will the DC still work? I mean it will be generating a signal?

    I'm very interested by your mod.

    Btw you can get 2 x (Arduino+Usb programmer) for 4.5dollars shipped.
     
    Last edited: Jul 22, 2015
  5. Compupaq

    Compupaq Member

    Joined:
    Dec 21, 2014
    Messages:
    7
    Likes Received:
    8
    Yeah, it'll still generate a signal. If you look in the picture where I have it installed in the dreamcast, the stock fan is unplugged. There's no communication between the arduino and the fan. As long as the arduino has power and is wired up to the signal wire on the fan plug, the dreamcast will stay on...up until it overheats :D

    That would work. It would also be nice to have one without the pin headers pre-soldered to the board, then I wouldn't have to use a bunch of electrical tape to cover up the pins.

    Although, if you're starting out with no arduino equipment, the nano 3.0 will probably be best as it has a mini usb port built in and only costs $2. Just about any arduino will work, as long as it's a 5 volt one. I didn't know until now that there was more than one miniature version available.
     
    justice99 likes this.
  6. Compupaq

    Compupaq Member

    Joined:
    Dec 21, 2014
    Messages:
    7
    Likes Received:
    8
    I made the changes I said I was going to in the first post. I wired the arduino to the fan port to make it look cleaner and lowered the frequency to 200Hz. It'll run fine on either 200Hz or 250Hz, it'll just emulate a 6000 or 7500 rpm fan, respectively. The fan generates 2 wave cycles for every 1 revolution. So a fan running at 6000 rpm will do 100 full revolutions per second, generating 200Hz.

    [​IMG]

    [​IMG]

    I was also able to run it with the fan plugged in (but with the signal wire cut on the fan). I don't have a replacement fan to stick in it yet. It appears the dreamcast has no issues running both the fan and the arduino off the fan plug, or at least no issues came up during the half hour I tested it playing Shenmue.
     
    Turranius likes this.
  7. justice99

    justice99 Spirited Member

    Joined:
    Nov 18, 2011
    Messages:
    123
    Likes Received:
    24
    So basically, if I want to do your mod I just have to buy an arduino and to send the code above ?

    Can you details where should I put different wires?

    Thanks in advance.
     
  8. citrus3000psi

    citrus3000psi Housekeeping, you want towel?

    Joined:
    Nov 8, 2013
    Messages:
    1,051
    Likes Received:
    418
    His code is saying to hookup pin 9 on the arduino to the dreamcast tach input.
     
    justice99 likes this.
  9. justice99

    justice99 Spirited Member

    Joined:
    Nov 18, 2011
    Messages:
    123
    Likes Received:
    24
    Ok thanks, I will buy a few and try them.
     
  10. Turranius

    Turranius Site Supporter 2015

    Joined:
    Apr 18, 2015
    Messages:
    108
    Likes Received:
    33
    kazade and justice99 like this.
  11. LordFenixNC

    LordFenixNC Peppy Member

    Joined:
    Aug 24, 2014
    Messages:
    300
    Likes Received:
    72
    If you guys create a full system that is not expensive.. I would totally buy one...
     
  12. Helder

    Helder Site Supporter 2014,2015

    Joined:
    Apr 6, 2013
    Messages:
    981
    Likes Received:
    54
  13. Turranius

    Turranius Site Supporter 2015

    Joined:
    Apr 18, 2015
    Messages:
    108
    Likes Received:
    33
    I've tested this now. Powering the arduino on 5v from the dreamcast works but only leaves 4.5v on the 5v out rail on the arduino, so running a fan directly from the arduino is not working. Only reason to do what is to provide a female fan connector on it so its easy to replace it though. It can still be connected directly to the DC PSU instead..

    Anyway, it works by fooling the fan check and it checks the temperature every second. The idea is:
    1: Send fan signal
    2: Every second, check temperature.
    3: Temperature too high, stop the fan signal. This should cause the dreamcast to shut down by itself.

    Currently. I've not found a way to stop the signal though. Even a delay in the script does not stop it as a "tone" keeps running no matter what, until you either shut off the arduino or stops the signal with a noTone. The noTone does not seem to work though as the DC keeps running even if I send it... In fact, I've not been able to shut down the DC via the arduino at all, part from pulling the fan check wire physically...
    Only tested noTone for about an hour yesterday though, but I've got no experence with arduinos from before so..

    Here is what I've got so far.

    Code:
    /*   Dreamcast fan emulator with LM35 sensor shutdown.
       Purpose: Fake a fan signal for the dreamcast, allowing
       any fan to be connected.
       In order to not overheat, it also uses a LM35 sensor to
       stop the signal should the dreamcast get to hot.
       Stopping the signal causes the dreamcast to shut down itself.
       v0.1alpa: Works but does not stop the signal. Even a delay(20000)
       in the script does not stop it.
    */
    
    const int syncPin = 2;  // Pin used to send fake fan signal.
    const int maxHeat = 28;  // Max heat in Celsius before stopping signal.
    const int LM35Pin = 7;  // Which pin is LM35 connected to
    
    // Variables for blinking the led:
    const int ledPin =  13;  // the number of the LED pin
    int ledState = LOW;  // ledState used to set the LED
    long previousMillis = 0;  // will store last time LED was updated
    
    // The follow variable is a long because the time, measured in miliseconds
    // will quickly become a bigger number than can be stored in an int.
    long interval = 1000;  // interval at which to blink (milliseconds) and check temp.
    
    float temp;  // Needed for conversion to celsius.
    void setup() {
      pinMode(ledPin, OUTPUT);  // Set the pin for the led.
      pinMode(syncPin, OUTPUT); // Set the digital pin as output:
      Serial.begin(9600);  // Set the serial port up
      tone(syncPin,200);  // Start sending the fan tone.
    }
    
    void loop()
    {
      // here is where you'd put code that needs to be running all the time.
    
    
      // check to see if it's time to blink the LED and check temp; that is, if the
      // difference between the current time and last time you blinked
      // the LED is bigger than the interval at which you want to blink the LED.
      unsigned long currentMillis = millis();
      if(currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis; 
    
      // if the LED is off turn it on and vice-versa:
      if (ledState == LOW)
      ledState = HIGH;
      else
      ledState = LOW;
    
      // set the LED with the ledState of the variable:
      digitalWrite(ledPin, ledState);
    
       // Read the temprature and convert to Celsius
      temp = analogRead(LM35Pin);
      temp = temp * 0.48828125;
    
       // Print the current temprature
      Serial.print("Temp = ");
      Serial.print(temp);
      Serial.print("*C / ");
      Serial.print(maxHeat);
      Serial.println();
    
       // Check if the temp is higher then the max we defined as maxHeat.
      if (temp > maxHeat) {
      Serial.println("Temp too high. Shutting down!");
      noTone(syncPin); // Stop the tone. This should cause the dreamcast to shut off (does not work right now)
    
        // Mostly for debug purposes to see what the current temp is. Blink led faster.
      while(temp > maxHeat){
      temp = analogRead(LM35Pin);
      temp = temp * 0.48828125;
      digitalWrite(ledPin, HIGH);
      delay(500);
      digitalWrite(ledPin, LOW);
      delay(500);
      Serial.print("HIGH Temp = ");
      Serial.print(temp);
      Serial.print("*C / ");
      Serial.print(maxHeat);
      Serial.println();
      }
      }
      }
    }
    
    
     
    Last edited: Aug 18, 2015
  14. Compupaq

    Compupaq Member

    Joined:
    Dec 21, 2014
    Messages:
    7
    Likes Received:
    8
    Instead of using noTone, could you use tone(syncPin,200,1000) (the last argument being duration)? Just call that in the loop instead of the setup. That way, you can check every second to see if it's below maxHeat, then call tone(syncPin,200,1000) again to recreate the signal. If it's above maxHeat, you don't call it and the signal stops.

    For the power issue, are you hooking up the fan to a single pin on the arduino? Each pin outputs a max of 40mA, so you may need to combine a few of them to get the current needed to run the fan, although it's not recommended to use an arduino for power output.
     
  15. Turranius

    Turranius Site Supporter 2015

    Joined:
    Apr 18, 2015
    Messages:
    108
    Likes Received:
    33
    Good idea. I'll try that.

    And no worries about the power. I wont power anything through the Arduino. =)
     
  16. Turranius

    Turranius Site Supporter 2015

    Joined:
    Apr 18, 2015
    Messages:
    108
    Likes Received:
    33
    Bah. Can't get it to stop. Wondering if there is something wrong with my arduino..

    Even something simple like this keeps the dreamcast on 24/7 instead of the 10 seconds it should be...

    Code:
    const int syncPin = 2;  // Pin used to send fake fan signal.
    
    void setup() {
      // put your setup code here, to run once:
    tone(syncPin,200,10000);  // Start sending the fan tone.
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
    }
    
     
    Last edited: Aug 19, 2015
  17. justice99

    justice99 Spirited Member

    Joined:
    Nov 18, 2011
    Messages:
    123
    Likes Received:
    24
    Thanks again.

    Anyone can upload HQ pictures because I really don't know what to wire and where.

    Thanks in advance.
     
  18. Coatezy

    Coatezy Coatezy

    Joined:
    Mar 14, 2016
    Messages:
    1
    Likes Received:
    0
    Hey,

    Did anyone manage to get their Arduino to shut the Dreamcast down? I've tried sending no tone and a tone at 50Hz. Neither work. Another crazy observation is that if a simply take a short length of wire that is not attached to anything and attach it to the tacho pin the console while fire up. The console will shut down when the wire is removed. My only guess is that the wire is creating some resistance.

    I don't have an oscilloscope but I can read Hz on my multimeter. It reads ~200Hz from the stock fan when running and 50Hz from then stock fan when I hold the fan still. If anyone does has an oscilloscope and can test the stock fan when stopped I'd be very grateful.

    TL;DR A simply length of wire is enough to spoof the stock fans tachometer.
     
  19. TriMesh

    TriMesh Site Supporter 2013-2017

    Joined:
    Jul 3, 2008
    Messages:
    2,324
    Likes Received:
    750
    OK, on my unit, the fan output with the fan running is a square wave at about 258Hz with a low level of about 100mV and high voltage of 4.28V duty cycle is around 50%, although there is a fairly large amount of jitter. The output generates two pulses for each complete revolution of the fan rotor. This fan was a Mineba (NMB) 1204KL-01W-B49

    The second fan I tried was similar - the frequency was slightly lower (about 244Hz), there was less jitter and the voltage swing was between about 700mV and 4.4V. The output had the same 2 pulses per rev characteristic that the first fan did. This second fan had no obvious manufacturer marking, just the P/N UDQFHAB05F electrical rating and lot code.

    With either fan, the console would shut down in about 7s if the pulse stream stopped, irrespective of if the actual signal level was high or low.

    So, to answer your question, just outputting a constant DC level - either high or low - should result in the console shutting down. I suspect the 50Hz you were seeing was mains pickup.
     
  20. Turranius

    Turranius Site Supporter 2015

    Joined:
    Apr 18, 2015
    Messages:
    108
    Likes Received:
    33
    I gave up on it after my last posts =(
     
sonicdude10
Draft saved Draft deleted
Insert every image as a...
  1.  0%

Share This Page