Texas Instruments has a very cool little MSP430 development kit, in the form of a watch. It’s called the Chronos. At the recent MSP430 seminars they had a 50% off offer, so for $25 I purchased one with the intent of modifying its software.
The really neat thing about this watch is that it contains what might be the best air-pressure sensor (altimeter / barometer) on the market today – the VTI SCP1000. The sensitivity of this thing is remarkable when you read the datasheet, and I’ve seen it for real in practice. It can repeatedly resolve to less than a metre in altitude. I’ve played with it, holding it above my head while peering at the altitude readout, then holding it at my feet and reading it, then back above my head, etc. It’s kinda like magic watching the altimeter change, up and down, as you do this. The SCP1000 is now considered an obsolete component by VTI (very unfortunate), but it’s in the watch and it works very well.
My desire was to replicate an “altitude accumulator” function I used to have on an old Casio watch many years ago. The way it works is you enable / zero the accumulator, then it tracks your upwards-vertical distance, adding it all up. So if you go on a hike where you’re going up, then down, then up again, etc, it’s automatically summing up all those uphills you’ve done, so you can see your total vertical gain at the end of your adventure. I found it a really nice feature for hiking, biking and skiing.
The MSP430 Chronos Programming Toolset
Initially I wanted to use the OpenChronos toolset for writing the altitude accumulator. OpenChronos uses MSPGCC. Unfortunately I had a very hard time getting MSPGCC to work properly on my machine and gave up. This was unexpected because I’ve used GCC a fair bit on different machines. Searching the forums seemed to indicate I wasn’t the only one with problems. It does work for some people, and no doubt given enough time and effort I would have succeeded as well, but for a quick little project I didn’t want to spend more time getting the tools installed than actually coding.
So I downloaded and installed the free 30-day evaluation version of Code Composer Studio from the TI website. It includes the IDE, compiler, programmer, etc.
Modified TI Chronos Software
After downloading the latest version of the stock software from the TI website and confirming I could rebuild it and program the watch with it, I set about removing everything I didn’t want. This included all the wireless functions (both SympliciTI and BlueRobin) and everything that depended on them, the accelerometer, the power-on test mode, etc. The reason was twofold.
- I wanted to simplify the watch’s menus to only those things I actually cared about. Any unnecessary menu items would only clutter the menus and make the watch more difficult to use.
- Ideally I wanted to cut the code size down to a point where it would fit within the free code-size-limited version of Code Composer Studio.
Removing the wireless functions means that the watch cannot be wirelessly updated with new software. The watch needs to be opened and the little USB programming dongle physically plugged into the watch. This is very easy to do.
This file is the Chronos code as downloaded from the TI website, with files in this directory modified:
ez430_chronos/915MHz – Unrestricted CCS Platinum
In other words, I cheated like crazy and simply modified an existing project set of files, rather than creating a new set of project files.
The new top-line menu structure is:
Time -> Alarm -> Temperature -> Altitude -> Altitude_Accumulator
One problem with the default TI software is it uses the top line for altitude display. The top line is only 4 digits, so when the altimeter is set to “feet”, it can only display a max of 9999 feet, which if you live around the mountains really isn’t high enough. So now I have the altimeter display “ALT” on the top line, and the altitude on the 5 digit bottom line.
To change the altimeter display between metres (default) and feet, press-and-hold the top-left button while in altimeter mode. You’ll see the metres/feet icon flash; use the right-side up and down buttons to select which you want, then the top-left button to enter it in. Then the altimeter reading will be flashing – use the up / down buttons to set the altimeter, press the top-left button to enter it in. That’s it. (As an aside, the TI software had a minor bug where if the watch was set to feet when adjusting the altitude, the altimeter pressure table would be incorrectly set, due to a poor feet-to-metres conversion. This revised code now uses the correct value of 3.28 feet in a metre.)
The altitude accumulator is the next menu item, and by default it’s disabled, so the display will show “ALTA” on the top line and “off” on the bottom. Press and hold the top-left button to make the “off” start flashing, then use up/down to switch it on and press the top-left button to lock your selection in. When you have the altitude accumulator enabled the display will change.
“ACCA” is the accumulated altitude (so far). “PEAK” is the peak altitude reached (so far). “DIFF” is the difference between your starting altitude (when you turned the altitude accumulator on) and your current altitude. In this example I went for a little bike ride and the display is set in metres. You can see I did 424 metres of vertical climbing, reached a peak altitude of 338 metres, and now I’m back at my starting point, the watch saying I’m only 1 metre above the altitude I started off from. Use the up/down buttons to switch between these 3 altitude-accumulator displays.
To turn off the altitude accumulator function, it’s much the same as turning it on. Press and hold the top-left button from any of these three displays until an “on” appears flashing, then use the up/down buttons to select “off” and press the top-left button to enter it in.
How It Works
It’s a little bit convoluted, so bear with me.
Once per minute the watch takes an altitude measurement, and updates the “peak” altitude if required. That’s pretty straightforward.
A “simple” way of accumulating altitude would be to take an altitude measurement, compare it to the previous altitude measurement from a minute ago, and if we’re now higher than the previous altitude, add the difference (the recent altitude gain) to the altitude accumulator.
The huge problem with this scheme is it accumulates errors like crazy. Any given altitude reading will have some error associated it. Imagine you’re on the flat, not going up nor down. For many reasons your measured altitude can vary: 100 m, 99 m, 100 m, etc. In the simple scheme all those little “noise” altitude changes would be added in.
“Easy!”, you say. Just put in a threshold – don’t add the altitude change unless it’s above a certain threshold. For example 5 metres. So now the 100 m, 99 m, 100 m, etc, wouldn’t trigger any accumulation. Fine, but now “slow and steady” altimeter rises won’t get collected either. If you’re slowly hiking up a gentle hill, unless you can exceed that altitude threshold each and every minute, a lot of your elevation changes will go unrecorded. Hmm.
This software works a different way. It looks for “peaks” and “valleys”, and it doesn’t add to the accumulator until you’ve gone over a peak (except for when displaying results, which we’ll mention in a moment). So imagine you’re going uphill, then down, then up again, over rolling terrain. The watch has your starting elevation, and it sees you’re climbing. At some point the watch gets a maximum altimeter reading when you’re at the top of the hill, then as you descend it sees lower altimeter values. It realises you’ve crested the hill and at that point adds your total gain (starting-point to hill-crest) to the accumulator. When it sees you’ve reached the valley bottom and the altimeter has begun to rise again, it remembers that low-point reading, so it can again measure your elevation gain from that most-recent valley-bottom-altitude the next time you reach a crest.
To minimise false hills and valleys detections, it has a threshold, stored as a #define, so that once you crest a hill (for example) you need to drop a certain number of metres elevation before the watch will declare that was a crest and add to the accumulator. Otherwise, just standing still the “noise” on the altimeter measurements could cause false peak/valley detections.
When displaying the accumulator result, the number displayed is the total in the accumulator plus any elevation you’ve done to this point. If you’ve only just started off for example, the accumulator may contain zero (because you haven’t crested any hills yet) but your current elevation is above your starting elevation, so that elevation difference is what is displayed.
Yes, it’s a bit convoluted to describe, but by searching for peaks and valleys, and recording the differences between them, we’re able to get much more accurate total measurements compared to the “simpler” accumulator schemes.
Other Changes & New Code Size
There are a few other changes. Temperature is only in degrees C now (degrees F is gone). 12/24 time display selection is gone – it’s only 12H time now (with AM/PM icons of course).
The code size is showing roughly 14,500 bytes of “text” (code) plus 1098 bytes of data, for a total of a hair under 16k. I think the code-size-limit for the free CCS is 16k, so I suspect this code might just squeak in, but I haven’t personally tried it out to confirm.
It’s Not Perfect
I haven’t fully worked out how the TI display code works – it has some strange (to me) complexities, and similarly with button-presses (they may be the same thing). Anyway, sometimes you might have to press a button more than once to make the display change, even though the watch went “beep” when you pressed the button. Also sometimes the bottom display line may be overwritten by the date temporarily when looking at the altitude-related numbers. Nothing major – just some minor quirks. I’d like to better understand how their button-handling system works and their display-system works so I can fix these little quirks. I’d also like to take several altitude measurements and average them, to improve accuracy, but I found doing that caused the watch to reset (watchdog I guess) so the current code only takes a single altimeter reading each minute. For a quick bit of code however, this current version works fine and is eminently useable.
Support seems to be a weak point with this fun little toy. The TI Chronos wiki lists both the TI “E2E” forums and a google groups forum for support. I’ve personally posted quite different questions on both of those forums, and (at the time of writing) not had a single reply on either. So you need to be aware that you’re largely left to your own devices if you want to modify the software running inside the watch.
Having said that, it’s not that hard to do the basics, and as you can see, add something new and interesting to the watch. For the money it’s a great deal of fun, and where else can you say, “I programmed my own watch!”.