Friday, December 04, 2009
uForth 0.99 -- almost there....
A bit fatter, but more capable... Plus there is some initial refactoring of the code. Download the latest here .
Monday, November 02, 2009
case statements in uForth
case .. of .. endof .. endcase was surprisingly easy to implement:
And, an example:
\ Variable used to keep track of how many 'of' clauses we have.
\
variable _endof
: case ( n -- )
0 _endof !
[compile] >r
; immediate
: of ( n -- )
[compile] r@
[compile] =
postpone if
; immediate
: endof ( -- )
_endof incr
postpone else
; immediate
: endcase ( -- )
_endof @ 0 do postpone then loop
[compile] r>
[compile] drop
; immediate
And, an example:
: test ( number -- )
case
1 of ." one" endof
2 of ." two" endof
3 of ." three" endof
." none"
endcase
;
Friday, October 30, 2009
Hexbug + MSP430 = Robotrophic Parasitism
It's been almost 2 years since I wrote about my interest in Biotrophic Parasitism in robotics...
In what I am calling Robotrophic Parasitism, the parasite (in this case a MSP430 based $3 EZ430-T2102), and the host (an original $10 Hexbug) live happily together.
In this case, the parasite was minimally invasive: the EZ430 lives between the battery switch and the Hexbug circuit, controlling the power. It also has a bi-directional line tapped to the antenna sensors so it can detect a "bump" or steer (the original hexbug only turns clockwise).
The parasite seeks light and steers the bug in that direction. When you first apply power, the parasite turns the hexbug clockwise (up to 6 times) looking for any light bearing direction. It then drives the hexbug in that direction. If the light wanes, it will then do another set of clockwise searches looking for a stronger light source.
I've got some fine tuning to do...
The parts list:
- 1 EZ430-T2102 board.
- 1 Hexbug.
- 1 photoresistor and 1 voltage dividing 1/8 watt resistor (from my parts bin).
- 1 TS5A3127DBVRG4 analog switch (free sample from TI).
Total Cost: ~ $15
This is the first of (hopefully) many Hexbug Robotrophic Parasites!
Wednesday, October 28, 2009
Tuesday, October 27, 2009
uForth 0.96 -- getting closer...
I've simplified uforth.c in this release. Some words coded in C were moved to core.f and init.f.
This made the C code smaller, so you can now compile uForth with the free IAR MSP430 Kickstart Edition!
Still no DOES> (not sure how to do this without dictionary rewriting which is a no-no in my MSP430 flash approach).
It is nicely shaping up though. I am really enjoying rewriting parts of uforth.c in uForth itself (see core.f and init.f in the distribution).
Downloads are here.
Friday, October 16, 2009
uforth 0.921 -- more pre-release goodness
Visit uforth for the latest "on your own for now" pre-release. I've included a link to a prebuilt binary for the MSP430 ez430-rf2500 board.
It's more robust and comprehensive. Plus it supports direct word compiles to the MSP430 flash.
It weighs just over 8KB flash + 900 bytes RAM. It support an 8KB (4096 cell) dictionary, so there is plenty of room to play.
The PC/Unix version still works well too. I use it for new dictionary development and create a TI file of the compiled dictionary for the MSP430.
Nothing automated yet and very little documentation. But, hey you can define words, loop and do some "meta" stuff.
Wednesday, October 07, 2009
uForth 0.7 pre-release
Last night I finally made some progress with compiling to the MSP430 flash dictionary: I can now compile words on the MSP430!
I also moved the MSP430 development to the more widely available (and cheaper!) ez430RF module (MSP430F2274 based).
Unoptimized, the VM/interpreter is 6.6KB and the RAM footprint is 844 bytes (essentially leaving room for 90 one cell variables on the MSP430F2274). I made the dictionary 4092 words (~8KB) to leave room for C app code. The uForth dictionary is (by architecture) limited to 32KB.
Sunday, October 04, 2009
Development Support words for uForth
Support words shouldn't be in the core. As smaller as it could be to write in C, I am resisting the urge of making the core larger. Take for instance "words". It is very, very useful for debugging but not so useful in a "finished" system. Why should it eat precious RAM or Flash if you don't need it?
Here is a quick definition of words in uForth. You can place it in init.f (for BOOTSTRAP versions) or pass it to "uforth_interpret()". It depends on a few words I've already shipped in init.f:
( Implementation of words in pure uForth! )
create _ ( dummy "known length" entry )
variable last_word
variable ccnt ( keep track of # of characters on a line)
: words ( -- )
_ 6 - @ last_word ! ( We know where the prev word link is inside of _ )
0 ccnt !
last_word @ ( pointer to last word )
begin
dup ( keep it on the stack )
1+ count 63 and dup ccnt +! ( get length of word's name )
ccnt @ 70 > if cr 0 ccnt ! then ( 70 characters per line )
type 32 emit 32 emit ( print word's name )
2 ccnt +! ( add in spaces )
@ ( get prev link from last word )
dup -1 = ( -1 link means no more words! )
until
drop ;
Friday, October 02, 2009
Simulating MSP430 I/O on PC uForth (Solution?)
One horrible solution (but may work for me) is to simulate the MSP430 I/O under PC uForth.
Keep in mind: uForth is about scripting, not about writing system level Forth stuff on an MCU. It is meant for slinging around C functions and libraries. I don't intend on doing much bit banging in uForth. There will be no UART driver, no interrupt handler, no deep notion of MSP430 power modes. SwiftX Forth (and others?) is the best fit for that.
I want to take existing C app (maybe already running on an MSP430) and manipulate it.
However, some times I may want to toggle some ports. I can do this with a minimal RAM_DICT uForth on the MCU. That may be adequate. This would allow me to hack the MSP430. Maybe I should create a special "hackers" dictionary for the MCU that allows me to bit bang ports and interact with peripherals. (This *should* be a writable dictionary.. try blinking an LED without some sort of DO .. LOOP construct -- this requires compilation!)
If I really do need the ability to do bit banging in the full "scripted application", I should be able to simulate it on the PC uForth. This wouldn't be a full MSP430 simulation, but maybe just enough so that I can compile the word, test it (maybe textual output: "LED bit0/port1 is ON!") and then dump/flash the dictionary.
Just a thought... but, uh it sounds oh so "batchy".
uForth MSP430isms
I'm trying to figure out how to best do uForth word compilation on the MSP430. Right now, if you want to do that you must use the RAM_DICT option (RAM based dictionary). This is inconvenient at best. A typical MSP430 part will have between 1KB to 8KB of RAM. Your initial dictionary may be larger than that!
Then there is the problem that compilation often involves rewriting memory (resolving BEGIN, DO .. LOOP references, etc). The MSP430 main memory is divided into 512 byte segments. And, each segment must be erased before writing (technically, you can write twice safely without an erase). What if the word definition spans two segments? I would need at least 512 bytes of RAM for buffering. Will I need more?
Another approach is to use a "tethered" development environment. With this, I would attach the PC uForth to the MSP430 uForth, compile the word locally and send the byte codes to the MSP430 to be flashed. This simplifies Flashing since there doesn't need to be a concern for rewriting bytes. However, this means that the PC and MSP430 uForths must be tightly bound.
SwiftX Forth takes a more formal tethered approach, but I like the more standalone nature of uForth right now.
The batch approach I take right now is to develop and test the word on the PC uForth, dump the dictionary and recompile the MSP430 Forth with this dictionary (flash based). The big problem with that can be summarized by the following example -->
: led-on bit0 port1 mem! ;
Ugh. There is no analogue for this on the PC uForth. My only recourse is to use a RAM based MSP430. But, after defining "port1", "mem!", etc. a 1KB RAM MSP430 part won't be big enough to support the dictionary. (And, obviously, using a Flash based MSP430 uForth, I won't be able to define led-on !)
Solution to follow... hopefully...
Thursday, October 01, 2009
uForth 0.4 ... more preliminary madness
Still very, very alpha. But here is another tarball: version 0.4
I got FLASH based MSP430 support working. No interactive compiling into Flash, but you can build a dictionary on the PC and then rebuild the MSP430 version with a Flash based dictionary.
Default still uses RAM_DICT under MSP430. The quick reference is still the best way to make sense of what you've downloaded.
Wednesday, September 30, 2009
uForth preliminary release... very, very alpha
This probably won't be usable for anyone and it isn't organized well at all. In fact, you could view it as a drunken pseudo-intellectual ramble captured as source code. It may mean something, or it just could be plain useless. For me, personally, it is an achievement.
I am sitting here right now, enjoying a Taylor Fladgate 10 year old Tawny Port, listening to a heady mix of Abdullah Ibrahim, Michael Franti, Dinosaur Jr. and Arcade Fire, considering if I should release this.
Aw, hell. If you want to muck with it, go ahead. Here is the (probably uncompilable) tarball of uForth.
P.S. I actually got it to run on an MSP430 today (via Rowley Crossworks). I can't promise support, nor can I promise a steady stream of releases, although it is geared to become the basis of some stuff at my day job.
Sunday, September 27, 2009
u4th - Forth for microcontrollers
Okay, I got tired of searching and waiting. I decided to roll my own "portable" Forth targeted for microcontrollers with limited resources. I want to do a Forth that would work on MSP430s, ARM Cortex and desktop PCs.
This would be more of a "scripting" Forth vs a full bottom up programming language. It would expect to be embedded in C and able to call C functions (like a scripting language!).
Right now I have something working on both a PC and MSP430 (simulator). u4th is written in C and makes no presumption about I/O (you can extend and add UART support, but it is happy to just work with a dictionary and an init() function). It supports a RAM or ROM/Flash resident dictionary (but no Flash writing support built in). It compiles a position independent dictionary that can be transfered to/from a PC and MCU without modification.
It does not implement ANSI Forth.. it is it's own beast geared for scripting, not system building.
I have a few more things to add (no DO .. LOOP yet) , but right now it runs (interpreter + VM) just under 4KB RAM (with a 2KB RAM resident dictionary -- so if the dictionary is Flash based, we are talking well under 2KB RAM!) and around 7KB of program (flash resident code).
More to follow!
/todd
Wednesday, August 26, 2009
compose-tex vs AFT
I've been doing some AFT hacking for a person who needed some text support. There are many AFT alternatives out there these days but he says that AFT hits the spot because it produces LaTeX as well as HTML.
There are some decent LaTeX to HTML converters out there too (have been for years).
I've been thinking about making a simple "free-ish text" converter that produces only LaTeX. It would be a LaTeX helper of sort. It would allow a casual user the ability to produce very high quality print without the learning curve of LaTeX.
The trick is, the "almost free text" format markup would have to be beautiful. The idea is "beautiful plain text in", "beautiful print out".
What if everyone could produce beautiful print? What would you typeset?
Friday, July 03, 2009
Thursday, July 02, 2009
Colorforth as inspiration
I always keep up the best I can with what Chuck Moore (inventor of Forth) is up to. I've always found colorforth to be fascinating.
Mr. Moore has started a couple of blogs. Of particular interest is his recent blog for tracking progress with his latest creation.
This reminds me why playing with hardware is so much fun. I am a bare-metal guy at heart, although there isn't much opportunity for doing this type of work (for me) these days.
How do I make a career out of bare metal progamming? Forth gives me some of this thrill. I like to poke and peek hardware to see it work. Something about batch compiling/loading (C and C++) through an IDE loses that feel.
I don't really want to "roll my own" Forth these days. Language design as a thrill has come and pass.
I got a buzz out of using SwiftX Forth (for the MSP430) at work a while back. Getting an unsupported MSP430 (the MSP430F5XX) working with SwiftX was a blast.
If I can scrape together $395 for a SwiftX MSP430 license (for non-work use), I'd like to kickstart an idea I had for doing a Simpliciti clone in Forth.... but my wife's van needs new tires :-(
Monday, June 15, 2009
More on (embedded) C++
Interesting paper regarding using C++ for embedded work by Stroustrup. I wonder how much of this is taken to heart by embedded developers.
Thursday, June 11, 2009
Evaluating the Cortex-M3
So, I have 2 evaluation kits: the stm32circle and the stm32-performancestick. Each under $100 and each with interesting features and annoyances. I've spent around $130 between the two.
I suppose it would have made more sense to just get the Olimex header board ( STM32-H103) for $40, a $70-100 JTAG, and GCC, but the point of the evaluation excercise is NOT to spend hours doing the "let's build everything from scratch". When the right integrated environment is chosen it sometimes worth the money. I still (and will continue to) do my source code editing in emacs but I have become pampered by the often richer experience of debugging with a decent IDE.
I would still like to just use emacs + gdb + gcc for development, but while I'm learning the chip I'd rather have an IDE with integrated documentation and GUI hand holding. My days of grunting manly about how I built all my tools by hand and debug via gdb command line is probably over. I will probably never replace my beloved emacs (used mainly out of habit) for editing and browsing code, but the point here is to hit the ground running and focus on the Cortex.
So far... stm32circle and Raisonance is nice, but I have no interest in CircleOS, so I've yet to see what it offers me in turns of raw EABI programming. Raisonance Ride is limiting me to 32KB debugging. I suppose I won't be using a lot of the advanced features of the stm32circle (color LCD, sound, etc) but it is a very rich platform (for only $40).
The smt32-performance sticks comes through Hitex (which is promising me unlimited debugging after I send them email). No response yet. The older license key (I am using the most up to date version of the debugger) doesn't work. They said I should email them a request for a new license. I was able to run their "dashboard" which allows me to do some performance/power tests. This is very informative.
At some point I will choose one or the other to do some development with. I guess I am hoping that the stm32circle will "win". Ride7 looks nice (reminds me of Crossworks). I need to see how well it does without forcing me into CircleOS.
I'll post updates in the next couple of days.
Monday, June 08, 2009
Forth on the Cortex-M3?
I can't seem to find any Forth running on a Cortex-M3 (let alone an ARM Thumb). This is the reason why I started to look at C++ again. I'm getting sick of plain old C -- great for little things, but I have bigger fish to fry.
I won't bother to convince myself that I have time to craft/port a Forth to the Cortex. However, I wonder if porting a Forth written in C is an acceptable compromise?
Hmm...
Sunday, June 07, 2009
Stroustrup's new book
I swore I would never do C++ programming again (3 yrs ago). Never say never. I realize that I miss some of the abstractive capabilities compared to C. I don't miss OO, I miss Generic Programming.
I was browsing Reiters a couple of weeks ago and was shocked to find this book. C++ as a first language? I was intrigued. I think that Stroustrup is a good concise writer and I wondered what an "intro to programming" book would look like (coming from his hands).
I purchased the book last week.
The book is interesting. I don't know how well it would do with a newbie, but I tend to like his no-bullshit approach. It is quite refreshing. He is very pragmatic and I liked how STL (generic programming) takes a front seat.
I am also a fan of Alexander Stepanov. He has a book coming out this month. I've already pre-ordered it.
This nicely meshes wth my current interest in Cortex M3 microcontrollers. I don't want to resort to C programming when I start messing with my Primer.
Friday, June 05, 2009
IAR, STL and the MSP430
Apparently, the IAR MSP430 compiler supports C++'s STL. My jaw drops.
In my previous post, I alluded to the desire to try generic programming on a Cortex M3. Out of curiosity, I wondered whether or not it would be possible/practical to do C++ on an MSP430.
Well, after some deep digging I've found that IAR has "some" C++ support that includes the STL!
How efficient can it be? Well, I don't like resorting to dynamic memory allocation when I don't have to (and certainly not on an MSP430) but I decided to give some basic STL algorithms a try. I am less concerned about performance than about code size. STL is (undeservedly, IMHO) notorious about being a source of bloat.
Here is the sample code:
#include <msp430x54x.h>#include <numeric>#include <functional>static volatile int res;int main( void ){int a[] = { 9, 1, 5, 6, 7, 8};// Stop watchdog timer to prevent time out resetWDTCTL = WDTPW + WDTHOLD;res = accumulate(a,a+sizeof(a)/sizeof(int),0);res = accumulate(a, a+sizeof(a)/sizeof(int), 1, multiplies<int>());return 0;}
This compiles to 250 bytes of CODE, 162 bytes of DATA and 12 bytes of CONST with default compile settings. (Some of the DATA is pre-sized stack and heap.)
With the highest optimization settings this compiles to 180 bytes of CODE, 162 bytes of DATA and 12 bytes of CONST.
I am impressed.
Sure this was a contrived test, but I am amazed that I could even do this.
Is this more efficient than a hand written accumulator? No. There are function calls here that wouldn't exist if I were to do it by hand. However, this may scale better than I could muster by hand: By cherry picking STL algorithms I am choosing to be more type "aware". I am also avoiding writing stuff like:
for (int i=0; i < sizeof(a)/sizeof(int); i++)res += a[i];
Simple, right? But do you see the two potential problems? First, I never initialized "res". Second, I introduced another variable "i". While the STL code has the overhead of function calls, it uses the more space efficient technique of incrementing through "a" rather than indexing.
I'm not planning on using the STL for any real MSP430 work. That would be overkill. But the Cortex M3 is a different issue...
Wednesday, June 03, 2009
C++ on ARM Cortex-M3?
I've been wondering how many people use C++ on ARMs. I don't mean C++ as in a "better C", but C++ in full (sans dynamic memory management and exception handling -- both casting non-determinism on systems seeking deterministic behavior).
The embedded development community/industry seems stuck in C. (I'm talking truly embedded here -- not Linux gumsticks, not "single board computers", etc.)
How about C++ with STL (but without vector and other containers that use new/malloc)?
Does this buy you anything?
There has to be an alternative to C. I wish it was Forth, but there doesn't even seem to be a Forth for Cortex.
I love C, but it doesn't scale very well (when it comes to abstractions and type safety).
How would generic programming (templates) look on an MCU? Would I be able to come up with a template that would let me abstract away SPI and UART code?
Is Embedded C++ (with templates) inevitable?
The prospect almost makes me want to buy this: http://www.digikey.com/scripts/dksearch/dksus.dll?Detail&name=497-6049-ND&enterprise=12 (a Cortex M3 demo/devkit for < $40).
Tuesday, May 26, 2009
Biotrophic Parasitic Computing and sensor nets
Biotrophic Parasitic Computing is still fascinating to me. The parasite needs to be efficient and highly adaptable. Now, in addition, I think the parasite should be able to communicate with others (or a hive host). Low power sensor net technology comes into play.
The smallest parasite will be the EZ430-T2012. It's tiny and cheap. It will need to be programmed in C (I'm avoiding assembly).Given that most new RF modules (like TI Chipcons and Zigbees) don't require much from outside microcontrollers, I could probablyget away with using a small parasite.
The next step up is the EZ430-RF2500T. It is more expensive (it includes an RF module). It can be programmed in Forth (SwiftX).
Each has its own particular appeal. I want to get back into Forth programming (I can't do this on the T2012 -- not enough RAM),but the T2012 is cheap ($3 a board) and hence has a certain ubiquity. If I go with C, I can code both using Protothreads as my primary means of abstraction.
The advantage to using Forth on the RF2500T is that it will force me to understand the CC2500 RF module. I can't rely on a C library. I get the same advantage using C on the T2012 since it doesn't have enough space for a C library (like Simpliciti).
Eventually I'll roll my own board.
The smallest parasite will be the EZ430-T2012. It's tiny and cheap. It will need to be programmed in C (I'm avoiding assembly).Given that most new RF modules (like TI Chipcons and Zigbees) don't require much from outside microcontrollers, I could probablyget away with using a small parasite.
The next step up is the EZ430-RF2500T. It is more expensive (it includes an RF module). It can be programmed in Forth (SwiftX).
Each has its own particular appeal. I want to get back into Forth programming (I can't do this on the T2012 -- not enough RAM),but the T2012 is cheap ($3 a board) and hence has a certain ubiquity. If I go with C, I can code both using Protothreads as my primary means of abstraction.
The advantage to using Forth on the RF2500T is that it will force me to understand the CC2500 RF module. I can't rely on a C library. I get the same advantage using C on the T2012 since it doesn't have enough space for a C library (like Simpliciti).
Eventually I'll roll my own board.
Forth and Microcontrollers
My second computer programming language was Forth. My first was BASIC. I picked up Forth sometime around 1984. I used it first on Commodore 64 and then on a DEC2060 to do some graphic hacks for a Tektronix terminal (am I showing my age now?). I remember tightly constrained resources. Despite spending a lot of time on a timesharing system (DEC20) I spent my youth trying to get every ounce of performance out of the likes of Commodore 64s and Atari STs.
By 1989 I had moved on. I became a UNIX junkie. C became my "base" language and I had adopted TCL as my "scripting" language by 1995. Over the years I've dipped my toe in many other languages including Perl, Python, Lisp, Smalltalk, Logo, Awk, Java, Lua, C++, Standard ML, etc. By 2004 my main languages were TCL, C and (sometimes) Awk. That is, whenever I could get away with using them.
So, now I am at full circle of sorts. I work with 8/16 bit microcontrollers (tightly constrained resources!) and my primary language is C.
Over the years I kept abreast of what Forth was up to. Chuck Moore is something of a hero of mine. Of course, in the past 20 years I've dabbled in creating my own Forths (mostly in C).
It was only recently that I've actually came back to actually using Forth to write applications/systems.
Forth is not dead, IMHO. However, while I don't think that it will make any resurgence, it does make me wonder why the Microcontroller world is still stuck using C.
Tuesday, April 14, 2009
If a tree falls in the forest... (SwiftX Forth)
I just finished an initial targetting of SwiftX Forth to the MSP430F5438. I had to massage the older MSP430 configuration files that already existed to the "new" MSP430Fx architecture.
I am sure I didn't get everything right, although I managed to at least resize the interrupt vector table and define all of the major ports/registers. Nothing too impressive, but I managed to get a blinking LED app running :-)
My original intent for playing with SwiftX Forth was to see if I could utilize it for board level testing within one of my day job projects. We don't have an effective way of poking/peeking all of the peripherals without writing a C app. With SwiftX Forth we should be able to write a host (PC) resident test app that pokes and peeks through JTAG. When I say "app" I really mean a handful of Forth words that test various aspects of the board. Plus there is the added benefit of the interactivity of Forth. Forth isn't resident on the MSP430, its just on the PC side doing JTAG.
One thing led to another and I found myself doing an actual "port" of SwiftX to the MSP430F5438 this evening. It is an eval version of SwiftX I am messing with, but if it proves to be a useful tool for work we will be giving Forth Inc. some money.
I haven't done this much Forth in over 20 years!
Friday, April 10, 2009
Quote of the day
"I am a design chauvinist. I believe that good design is magical and not to be lightly tinkered with. The difference between a great design and a lousy one is in the meshing of the thousand details that either fit or don't, and the spirit of the passionate intellect that has tied them together, or tried. That's why programming---or buying software---on the basis of "lists of features" is a doomed and misguided effort. The features can be thrown together, as in a garbage can, or carefully laid together and interwoven in elegant unification, as in APL, or the Forth language, or the game of chess."
-- Ted Nelson
Nuts, renegades and visionaries
Monday, March 30, 2009
Why embedded operating systems are a dead end...
With the (re)rise of concurrency (in particular concurrent processors), embedded operating systems are a dead end. This is especially true in robotics.
Why?
Once you get linux (or whatever) running on your embedded hardware (robot?) , you then spend some time getting all of the interrupts right and then compile your high level control language into C (and then compile that into the target MCU) and then... you emulate concurency via threading/tasks. If you go beyond C, you are probably running in a general purpose VM to boot.
For every lift of a mechanical leg, a megabyte or so of code abstraction, translation and OS task switching takes place. Ugh.
What is the alternative?
Very High Level Languages compiled directly to (or interpreted tightly within a simple VM upon) hardware with an inter-device messaging protocol. I want my Lisp/Oz/Haskell/Erlang/etc running on bare metal, baby! (And all programmed from within Emacs running on my laptop ;-)
Of course, Forth programmers already had this 20-30 years ago...
Scratch + iRobot Create?
I stumbled upon information regarding the mysterious Scratch Extension Protocol. This is very interesting. It addresses a deficiency in Scratch that prevented integration with external things such as robots.
In my opinion, one of the greatest hinderances in getting kids involved with robots is the difficulty in programming them. The root of the difficulty is syntax: So you've got an iRobot Create, want to make it move? Use C, Basic, Python or whatever. Scratch seems like a natural for this.
With the Extension Protocol, I can write a small piece of middleware that would talk to the Create via wireless (Bluetooth maybe?).
I'm not sure where I would put all of the Create protocol parsing and generation. The easy way would be to place it in the middleware, but there is something "just right" about putting it into a microcontroller that is attached to the Create. I think I prefer that way because it offers a future hint of autonomy. Adapting the Scratch Extension Protocol to Create Protocol can be more than a simple protocol translation excercise but evolve into a language of sorts.
Imagine this:
- You develop your ScratchCreate script in Scratch, first controlling an on screen Sprite that represents the iRobot Create.
- You then launch the middleware and continue to debug the script but now control an actual Create wirelessly.
- Once you've got it working the way you want, you download the Scratch script into the microcontroller running the Create.
Voila, you now have an autonomous robot!
This is a powerful concept. I know there are similiar commercial variations on this, but there is something that resonates differently here for me. I'll have to figure out what and write in more detail as to why.
Friday, March 27, 2009
Modular Robotics (Bioloid)
A couple of years ago I dropped big bucks on a Bioloid robotic set. My son has since lost interest in robotics (but I will try to ignite it again in a couple of weeks at RobotFest). I lost interest in the set due to its cumbersome programming interface and (to me) flaky CM-5 processor brick.
This morning I was talking about robots with a co-worker who has done quite a bit himself in the past. I was curious to see if Bioloids were still being sold and... ooh, there are tech manuals now on the smart servos! Protocol documentation too!
I smell a CFT project. In particular, I should be able to pair a Bioloid sensor with an MSP430 or AVR (the CM-5 uses an AVR) and do interesting things. Maybe I could do this with a few servos too.
Imagine: A Bioloid / Roomba (Create) hybrid... oooh, think of the potential!
/todd
Sunday, March 15, 2009
Modular HW
A new idea: Throw a bunch of MSP430F2012s at a problem. I did this recently. Rather than deal with a bigger MCU to handle multiple sensors (which increases software complexity), I have been pairing individual MSP430s with sensors to make them "super sensors".
This allows me to "perfect" a sensor node, define a common I/O facility (bit banged 2400 baud) and then hook them to a single "controller" MSP430 (maybe a fatter chip). An example super sensor would be a motion detector consisting of a F2012 and an accelerometer. All of the algorithmic work of determining true "motion" (vs tilt or vibration) would be handled by the dedicated F2012.
More thoughts on this later...
Monday, March 09, 2009
Back to softer thoughts...
I'm pretty burnt out. So, instead of hacking in my home lab, this past weekend I perused books. I grabbed some (mostly) math and programming books off of the shelf. It was both a reminder of some of the things I miss since I started doing exclusively embedded work and some of the things I don't miss.
What I don't miss is the plethora of general purpose programming languages that vie for my attention. What I do miss is the ability to express math concepts (especially geometry) in a high level manner. My lack of education in domain specific languages (specifically: math) is at fault here.
I think that my "general purpose" language exploration days are truly over. For general purpose programming I don't see what going beyond C and awk (or Tcl) gives me. Domain specific languages (DSLs) are interesting. For example, I use Dot (via Graphviz) for producing directed graphs all of the time. I use Scratch to work out simple animation/graphics oriented ideas (but, curse you Scratch: no parametization or recursion yet!) and I use it to teach kids how to program.
Right now, my son is interested in going beyond Scratch, so we may start playing with GameMaker (a commercial game building tool). That sounds like a DSL to me.
I've also been toying with doing a DSL in awk that will render graphic primitives (to some screen viewer/plotter via pipes) so I can work through Turtle Geometry without having to find/re-learn some Logo variant.
For work I am using awk to do some quick power consumption calculations. Excel is what we normally use, but I'd like to see the math all in one view (not by clicking on cells).
I am considering doing a short DSL in awk to coordinate between Dot/Graphviz state machines and actual code. I'd like to keep the Dot state machine up to date as the code evolves.
For now, I am exploring these softer thoughts...
What I don't miss is the plethora of general purpose programming languages that vie for my attention. What I do miss is the ability to express math concepts (especially geometry) in a high level manner. My lack of education in domain specific languages (specifically: math) is at fault here.
I think that my "general purpose" language exploration days are truly over. For general purpose programming I don't see what going beyond C and awk (or Tcl) gives me. Domain specific languages (DSLs) are interesting. For example, I use Dot (via Graphviz) for producing directed graphs all of the time. I use Scratch to work out simple animation/graphics oriented ideas (but, curse you Scratch: no parametization or recursion yet!) and I use it to teach kids how to program.
Right now, my son is interested in going beyond Scratch, so we may start playing with GameMaker (a commercial game building tool). That sounds like a DSL to me.
I've also been toying with doing a DSL in awk that will render graphic primitives (to some screen viewer/plotter via pipes) so I can work through Turtle Geometry without having to find/re-learn some Logo variant.
For work I am using awk to do some quick power consumption calculations. Excel is what we normally use, but I'd like to see the math all in one view (not by clicking on cells).
I am considering doing a short DSL in awk to coordinate between Dot/Graphviz state machines and actual code. I'd like to keep the Dot state machine up to date as the code evolves.
For now, I am exploring these softer thoughts...
Thursday, February 05, 2009
MSP430 + FC30 (Orientation Sensor)
Recently, I had purchased a few "orientation sensors" (the STMicro FC30 -- basically a dumbed down 3 axis accelerometer) from Sparkfun. Its a very tiny surface mount (LGA-14 3x5x0.9mm
SMD) package and there is no breakout board yet :-(
Hmmm, I thought: I have a small tip (0.016") for my OKi soldering station, so... well, why not?
So, after a few false starts (and a couple of ruined FC30s later), I decided to mount the chip on the bottom of one of my trusty MSP430F2012 EZ430 boards (3 for $10)
So, I used a dab of 5-minute epoxy to hold it in place and began to solder jumpers between the EZ430 and the FC30. Wire-wrap wire (30 AWG) proved to be to thick (and heavy), so I used individual strands of wire from an old test lead cable.
I used a 5 Diopter Luxo magnifier lamp so I could see what I was doing (Oh, those are so nice but pricey. But they are worth it. You position them and they don't move! I have a "low end" KFM1A).
It took a couple of nights (fora total of 2 hours) and I checked for bridges using my son's microscope at 40X. It didn't look pretty, but it held.
Since I was using bare wire strands, I had to be careful not to short them together, so I "layered" epoxy between wires that crossed each other.
I was very careful not to cover the contacts (yet) with epoxy in case I had to rework the solder. When I got all of the pins soldered (I basically ran the interrupt lines to P1.1, P1.3 and P1.4 on the MSP430) I did a quick continuity check to make sure nothing was shorted. Next, I wrote a little app to detect orientation and tested it in the IAR debugger. Things were looking good!
(At this point, I must admit that I have prior experience with this sensor -- with help I managed to kludge a similar wiring job but to a 1 inch protoboard, not directly onto an EZ430. So, I was already familiar with how the FC30 works.)
Once everything looked good, a added a liberal dollop of epoxy to the bottom of the MSP430, and now I have a nice little development board to play around with orientation sensing.
Breakout board? We don't need no stinkin Breakout board. (Yeah, right...)
This was an exercise inspired by the amazing Willard Wigan.
SMD) package and there is no breakout board yet :-(
Hmmm, I thought: I have a small tip (0.016") for my OKi soldering station, so... well, why not?
So, after a few false starts (and a couple of ruined FC30s later), I decided to mount the chip on the bottom of one of my trusty MSP430F2012 EZ430 boards (3 for $10)
So, I used a dab of 5-minute epoxy to hold it in place and began to solder jumpers between the EZ430 and the FC30. Wire-wrap wire (30 AWG) proved to be to thick (and heavy), so I used individual strands of wire from an old test lead cable.
I used a 5 Diopter Luxo magnifier lamp so I could see what I was doing (Oh, those are so nice but pricey. But they are worth it. You position them and they don't move! I have a "low end" KFM1A).
It took a couple of nights (fora total of 2 hours) and I checked for bridges using my son's microscope at 40X. It didn't look pretty, but it held.
Since I was using bare wire strands, I had to be careful not to short them together, so I "layered" epoxy between wires that crossed each other.
I was very careful not to cover the contacts (yet) with epoxy in case I had to rework the solder. When I got all of the pins soldered (I basically ran the interrupt lines to P1.1, P1.3 and P1.4 on the MSP430) I did a quick continuity check to make sure nothing was shorted. Next, I wrote a little app to detect orientation and tested it in the IAR debugger. Things were looking good!
(At this point, I must admit that I have prior experience with this sensor -- with help I managed to kludge a similar wiring job but to a 1 inch protoboard, not directly onto an EZ430. So, I was already familiar with how the FC30 works.)
Once everything looked good, a added a liberal dollop of epoxy to the bottom of the MSP430, and now I have a nice little development board to play around with orientation sensing.
Breakout board? We don't need no stinkin Breakout board. (Yeah, right...)
This was an exercise inspired by the amazing Willard Wigan.
Subscribe to:
Posts (Atom)