Computer Science LabIn my July column I suggested a few projects that kids can undertake to learn more about the exciting field of embedded systems.1
A lot of you responded. One engineer wrote: "Apart from the outsourcing issue, I hope my children can avoid the bitter disappointment, frustration, and stress that I have experienced working for insecure, technically clueless managers. I suppose all fields have their share of managers who are &%$*# artists with hidden agendas. I just hope my children find careers that are more tolerable than what mine has become. To answer your opening question, 'So why not get the next generation interested in embedded systems design?' I don't want to see my kids get their passion, joy, and self-esteem kicked out of them."
In over 30 years in this field I have never met so many engineers disgusted with their career choice, nor so many un- or under-employed developers. It's a very different world than just a few years ago. But other correspondents still have their engineering joie de vivre and are anxious to pass their passion on to the next generation.
John Kopplin sent me a course he's developed called Computer Science Lab, which he wrote to educate kids of any age (including those middle-aged ones who still like to learn).2 The name is a misnomer as a third of it is specifically aimed at teaching embedded development on an 8051.
It's very cool.
A single $19 (less for educators) CD for Windows contains three separate courses that take the newbie from no real understanding of programming to a working knowledge of assembly, C, and C++. I dug into it and want to share my experience.
Pop the disk into the computer and listen to an annoying bit of music as the program installs itself - oddly, into c:\Computer Science Lab, not c:\Program Files as is standard for modern versions of Windows. There's no uninstall, which may or may not frustrate you; as one who puts lots of programs on my computer for short-term evaluation, this lack always elicits a groan. The collection of materials is big, 135MB, which reflects its depth, not some bloatware factor.
I said there are three different courses; there's actually a fourth, the extra one being a waltz through the history of computers. I almost skipped this as it has no bearing on learning to program. In a way the history is even more interesting than the programming. Did you know Leibniz, co-inventor of calculus was first to advocate the use of binary? Or that Blaise Pascal, aged 19, built a mechanical adding machine and mass produced 50 of them? Today's pre-digital odometer uses principles he invented for that machine four hundred years ago. Babbage figures highly in popular accounts of ancient computing, but there's more. From the disk:
"By 1822 the English mathematician Charles Babbage was proposing a steam driven calculating machine the size of a room, which he called the Difference Engine. This machine would be able to compute tables of numbers, such as logarithm tables. He obtained government funding for this project due to the importance of numeric tables in ocean navigation. By promoting their commercial and military navies, the British government had managed to become the earth's greatest empire. But in that time frame the British government was publishing a seven volume set of navigation tables which came with a companion volume of corrections which showed that the set had over 1,000 numerical errors. It was hoped that Babbage's machine could eliminate errors in these types of tables. But construction of Babbage's Difference Engine proved exceedingly difficult and the project soon became the most expensive government funded project up to that point in English history. Ten years later the device was still nowhere near complete, acrimony abounded between all involved, and funding dried up. The device was never finished."
Sounds a lot like big government projects today.
Kopplin gives German engineer Konrad Zuse appropriate credit for his pioneering work on computers. Zuse is almost unknown in the USA, yet may have been the Bill Gates of his age had not World War II intervened. Munich's Deutsches Museum exhibits two of his amazing machines and is worth a visit just to learn the history of this astonishing visionary.3
I was fascinated to learn that when J. Presper Eckert designed Eniac no one believed 18,000 tubes could function reliably. In fact, the RCA company refused to join the project, but was induced to sell tubes in the interest of "wartime cooperation." Yet his circuit design was so conservative the machine worked. Eckert even used starving rats to test wire cables. He then designed the rats' least favorite wire into the Eniac.
One female "computer" who calculated ballistics tables by hand remarked "I was astounded that it took all this equipment to multiply 5 by 1,000."
We all know John von Neumann invented the stored program computer, right? Turns out we're wrong. This major breakthrough can be found in Eckert's notes long before he ever started working with von Neumann.
Kopplin's 7,500 word history of computers bursts with pictures, illustrations, and surprises.
The real meat of the class begins with a pretty on-screen RPN calculator that looks just like the HP-29C. The buttons depress when clicked and the display updates appropriately. I might just start using this instead of the Windows calculator.
Kopplin uses the calculator to introduce very basic programming concepts like variables, loops, addressing, conditionals, and the use of memory. Though it's a little quirky to learn programming in RPN (reverse Polish notation) instead of BASIC (shudder) or C, the limited scope of the device's language means students can focus on the concepts and not on learning a big language.
An 8051 simulator
The Lab comes with an 8051 simulation environment and IDE for assembly language.
It discusses the 8051 as if there really were such a processor. Today I'd be surprised to find a real, physical 8051. Instead, hundreds of derivatives exist, sporting wide ranges of memory configurations, peripherals, and even tuned instruction sets. Yet the 8051 is, in a sense, the mother of all microcontrollers and it's reasonable to learn the intricacies of the root processor, as those details scale well to all of its children and grandchildren.
The 8051 instruction set reference is worth the price of the course by itself. Do be aware, though, that the clock counts may vary for real-world derivatives. A hyperlinked lesson plan implemented in Microsoft Help files instructs the student in both the use of the simulator and in the nature of the 8051. A page or two of very basic electronics sets the stage, followed by a very high level tour of machine and assembly, addressing modes and hexadecimal. The detail is just enough to give a nontechnical manager a sense of our world.
From there the course dives into the processor's architecture and a basic assembly language. Each lesson is short and revolves around an example program. Each introduces a few more instructions and programming concepts. Students use the simulator to run the supplied examples and to extend these small programs.
Figure 1 shows the simulator's IDE. A user can step into, step over, set and remove breakpoints, right click to change a register or data item. It's quite conventional and reasonably complete.
The first program is a simple infinite loop. Then a counter, then another that computes factorials. In many cases the programs mirror those implemented with the RPN calculator, showing clearly the difference between building code in different languages.
But Kopplin quickly gets to fun, more engaging programs, such as one that uses PIO (parallel I/O) bits to "draw" a moving train on the output window (bottom window of Figure 1). Fun is important to keep interest levels high, especially in attention-deficient adolescents.
The course goes deep and doesn't neglect uniquely embedded systems issues like working with the 8051's internal peripherals. Simulated timers, UARTs and the like interact with the programs just as they would on a real chip. It even covers interrupts; the simulator provides periodic interrupts that the code can capture and process.
While the RPN calculator section ends with a nice summary, the 8051 segment does not. That's a shame. We learn best when you tell them what you're going to tell them, tell them, and then summarize what you just told them. Instead this part ends somewhat abruptly after describing the final interrupt program.
Onward to C/C++
From there we leave the truly embedded systems world behind and move to another IDE, one running C/C++ under Windows. Though this IDE looks something like that offered by Microsoft's Visual Studio it's really a shell around GNU C++ compiler and GDB. The interface prettifies the raw GNU tools, but doesn't completely isolate you from the powerful but maddeningly complex command set. Buttons control most common functions like single stepping, but for many other operations (like viewing a variable) you must issue a GDB command in the scrolling text window.
John's approach to teaching C and C++ is much like that for 8051 assembly language. A series of graduated lessons with examples, all of which run on the IDE, takes the student from no C/C++ knowledge at all to that of an apprentice programmer. Mastery will take more practice, more trial programs, and a bit more depth than provided. But you will be writing real, useful programs by the end of the course.
This section has two parts: basic C/C++ working in a DOS command window and the elements of writing Windows code. I tried--I really tried--some time ago to write a Windows program. Visual Studio even created a complete, working "Hello World" program. But where was the printf? A search found it sitting in a puzzling resource file. I guess I'll stick to embedded systems.
This course cleared up the mysteries. It's not easy as even the simplest bit of Windows code uses an awful lot of cryptic API calls. But this course will get you building simple apps in Microsoftland, ironically while working with GNU tools.
Windows' richer API leads to examples that are a lot more fun than those possible on the 8051. Games and programs that explore the physics of collisions are provided.
A good start for beginners
I get a tremendous amount of e-mail from people wanting to learn about embedded systems. From now on I'll recommend this course. Any determined individual will gain a lot of proficiency working through the materials.
John writes conversationally and engagingly. He doesn't resist the chance to editorialize, bashing Microsoft, Sun, Apple, and Java slightly to the course's detriment. He detests iostreams, operator overloading, and exceptions. Don't expect to learn about these concepts. You won't deal with RTOSes, reentrancy, and other advanced concepts, but will master a lot using examples that are much more appealing to engineers than the contrived ones always found in C/C++ books.
If you're a C programmer wanting to plumb the depths--or at least the shallows--of C++, or an embedded developer aching to learn Windows programming, get this program. If you know someone who wants to learn the mysteries of the embedded world, put this disk under his or her Christmas tree.
1. Ganssle, Jack. "Turn a Kid on to Engineering," Embedded Systems Programming, July 2005, p.41.
2. Kopplin, John. Computer Science Lab, training course on CD; www.computersciencelab.com.
3. Munich's Deutsches Museum. www.deutsches-museum.de/ausstell/dauer/inform/e_infor3.htm.
We purchased this product for use in our home school with one of my kids who recently said, "Dad, I want to do what you do." He's going thru the course at his own pace and loving every minute of it.
Thanks, Jack, for letting us know about it.
- Andy Kunz
Sr. Firmware Engineer
New Jersey, U.S.A.
Actually, Alan Turing invented almost all the technology used in modern software --"programs as data," the "assembler," the linking loader, and the reusable subroutine library, among them. if the Brits had ponied up the resources, Turing would have very likely completed the design for his general-purpose computer, far ahead of von Neumnan. There are several papers published on all this history which are just astonishing reading.
- Mike O'Dell
New Enterprise Associates
"It discusses the 8051 as if there really were such a processor. Today I'd be surprised to find a real, physical 8051."
I guess I've been in this business to long. My old Boss went to one of the first Intel seminars on the 8051 to many decades ago now. He brought back a 8031 that was so new that it is labeled with a label-maker in Scotch Tape. I can't make up my mind if I should throw it out or put it on E-Bay, so here it sets collecting dust.
- Bob Paddock
The Designer-III Company
Thanks for reviewing my Computer Science Lab curriculum. It's been tough reaching the right audience and kids of professional engineers will definitely enjoy working through this self-paced course. The only comments I feel like offering on the review are that the 15 seconds of "annoying" music during the install is Jimi Hendrix and there is an uninstall offered: it's just on the CD-ROM rather than on the Windows Start menu.
- John Kopplin
Senior Systems Engineer