Building the Wake-up Circuit

The wake-up circuit is a simple (and most definately not the nicest) way of allowing your Multitainer to go to sleep and wake up at a specific time.

The reason why we need this circuit is based on the fact that either the MT BIOS or Win98 (not sure which) doesn't allow you to shutdown or hibernate your machine and wake it up on a schedule.

How it works

If you are just interested in using the circuit without knowing how it works, you can jump directly to the building section.

The circuit has connections to the serial port and the power switch jumper on the motherboard. The circuit is controlled by commands sent down the serial port. The protocol and baud rate etc are discussed in detail in the Protocol section below.

Generally, the circuit is used as follows:

  • Initialise on start-up of your program, this has the effect of killing any timer that may be running (in case you turn on the machine manually).
  • When you want to sleep, calculate the time until you want to wake up. Send the commands to set the timer, start the timer and then shutdown the machine.
  • When the time is up, the circuit will raise and lower the power line, causing the machine to start up. If the machine is already started this will cause it to hibernate, so it is important to initialise the circuit to kill the timer on start up.


  • The counter in the circuit is not very clever or accurate, and so you need to calibrate the circuit when its first used. This allows the PC side code to take into account the inaccuracy in the counting.

    Components

  • PIC16F84A or equivalent
  • MAX 232
  • 5 x 0.1uF capacitor
  • 4 x 470 Ohm resistor (2 optional)
  • 4 MHz oscillator
  • 9-pin D type female connector
  • 2 x LED (optional)

    Circuit Diagram


    Protocol

    Below are the settings for the serial port connection to the circuit.

    BAUD rate19200
    Data bits8
    ParityNone
    Stop bits1
    Flow controlNone


    Below is a list of the commands and expected responses. The values in quotes eg 'T' mean the byte value is the ASCII value of the char T. x and y are the delay values. These are discussed more in the Calibration section.

    Byte 0Byte 1Byte 2Byte 3DescriptionAnswer
    'I''N'INitialise'O' 'K'
    'S''T'xySet Timer'T' 'S' x y
    'B''T'Begin Timer'T' 'B'

    PIC Program

    The PIC chip is controlled using a very basic JAL program. The source and hex files can be downloaded below. The source is available under the GPL and some code to help talking to the device under Windows is also included.

    Telling MTV How to Use the Circuit

    MTV can be told to use the circuit by setting attributes to the MTV node in config.xml:
    
    <?xml version="1.0" encoding="UTF-8"?>
    <MTV useWakeupCircuit="yes" wakeupCalibration="1022">
    .
    .
    .
    </MTV>
    		
    You need to provide a calibration value because the PIC chip isn't very accurate. MTV will aim to wake up 10 minutes before the start of a programme. I am considering the best method of adding auto calibration, so that the circuit gets more accurate, the main problem with this is that MTV currently does not know if it has been woken up by you or the circuit and so using it would contaminate the calibration.

    Download

    The source and hex files along with the circuit diagram can be downloaded here: mtv_wakeup_1.zip

    Back