Archive for the 'Embedded systems' Category

Useful code excerpts for the MSP430F2012

Sunday, June 29th, 2008

Here are a couple little code excerpts that took me some time to figure out. I’m hoping that Google might help the rest of the world’s MSP430F2012 programmers save 5 minutes. (If they all find it, a total savings of 55 minutes!)

The MSP430F2012 defaults to a clock speed of 1 MHz, sourced from an onboard DCO. In order to get the DCO to be accurate, you have to load calibration constants from flash.

BCSCTL1 = CALBC1_1MHZ; // DCO calibration: set range
DCOCTL = CALDCO_1MHZ; // DCO calibration: set DCO step and modulation

Then you can initialize the timer to count in increments of 100 ms.

TACCTL0 = CCIE; // CCR0 interrupt enabled, compare mode
TACCR0 = 50000;
TACTL = TASSEL_2 + ID_1 + MC_1; // SMCLK as source; divide by 2; up mode

Anyway, I hope this is useful to someone out there.

DIY solar computer system, part 1

Friday, December 7th, 2007

Like a lot of semi-urban computer enthusiasts who plan on living for a few decades after the onset of global warming, I have a few computers that are always on, and I wish that I could find an economically viable way of reducing the emissions generated as a side effect of the power they require. Also, when the hard times come and grid power gets flaky or drops out entirely, it would make the local warlord happy if I could use a computer to calculate optimal irrigation ditch depths, or the like. (Note to self: learn to use abacus while leisure time still exists.)

Typically, solar arrays in urban or suburban areas are tied by an inverter to the local power grid. Such inverters cost a few thousand dollars; they both allow excess power to be released to other consumers and enable the use of AC appliances without any modifications. I live in a rented property, so installing a large solar array on the roof with an inverter in the basement is not an option. But, maybe I could run a smaller array without an inverter for DC loads only.

DC vs. AC
Computers, generally designed to connect to AC power, have as their first component a switching power supply that turns AC from the wall into DC. If I had a solar array, it would output DC, which would be converted to AC by the inverter, and then back to DC by each computer’s power supply, losing energy at each step. I call this “dumb”– why not just run the computers off of the DC directly?

The problem is that if you run the computers just off DC from the solar panel, the computers die when the sun is occluded by a cloud or a planet (at night, for example).

An alternative architecture
The system I’m building has a 24 V DC power supply fed from the grid at its core. This will run in parallel with whatever solar panel I eventually set up. For starters, I have replaced the ATX power supply that came with my desktop with a DC/DC converter from Ituner.com. I then power that from a beautiful DIN-mount Sola SDN 10-24-100P supply that I got off Ebay for $33.00 ($45.82 with shipping).

Sola SDN 10-24-100P power supply

For the DC/DC converter, I looked at the pico-PSU, but rejected it in favor of the slightly larger M2-ATX-HV.

The DC-DC converter strapped in place

The M2-ATX-HV had a few advantages:

  • My PC has an ATX12V power supply; I wasn’t sure that it would run with a standard ATX supply. ATX12V has a second connector with 4 pins, which the M2-ATX-HV provides.
  • The HV version allows a wider input voltage. The Sola supply is nominally a 24 V supply, but I want to be able to run off both 12 V and 24 V supplies, plus a few volts on either side.
  • Slightly higher power– with its original supply, my PC idled around 85 W, and I could get it to draw 150 W by ripping a CD while keeping both cores busy, one transcoding a variable bit rate mp3 to constant bit rate, the other compiling the Python interpreter. For reference, the CD drive used around 35 W. The DC/DC converter I got is rated for 140 W. As a pleasant surprise, the new supply is substantially more efficient, and the system, including the loss in the Sola supply, now draws only 65 W at idle.
  • The M2-ATX-HV is a bit bigger, but my PC case is pretty large, so that wasn’t a concern. Including all the cables and shipping, I paid $96.40 for the M2-ATX-HV– about $30 for the advantages listed above.

    Side view, case open, 24 V DC supply

    Stage 1 complete
    The DC system has been working reasonably well for a few weeks now. Next, I have to find a cheap way to test current sharing with a solar panel, as I don’t want to commit the full $700 or whatever for a 180 W panel until I have more evidence that it will work. I’m off to the beach to start collecting sand for a little homebrewed Czochralski action.