|
|
||||||
You may redistribute this newsletter for noncommercial purposes. For commercial use contact jack@ganssle.com. |
||||||
Contents | ||||||
Editor's Notes | ||||||
The good news is that embedded code is much better than any in the rest of the computer industry. Did you know that, on average, 95% of all of the bugs in firmware are removed pre-shipment, compared to 85% for the rest of the computer business? But 95% means too many bugs are getting out the door. We've got to do better. Did you know the average firmware project spends half the schedule in defect removal? That's far too high. Join me to learn how to greatly reduce bug rates while slashing the schedule! Over 5000 engineers have taken this class on six continents. This is a very-fast-paced full day seminar. It's fun, it's informative, and it only covers practical ideas you can use today. The seminar covers these subjects: Languages: C, C++ or Java? What about code reuse - is it a myth? How can you benefit? How to control stacks and heaps. Structuring Embedded Systems: Manage features... or miss the schedule! Using multiple CPUs. Architectures for faster development. Overcoming Deadline Madness: Negotiate realistic deadlines... or deliver late. Scheduling, the science versus the art. Overcoming the biggest productivity busters. Stamp Out Bugs: How to manage bugs to get great code fast. Quick code inspections that keep the schedule on-track. Cool ways to find hardware/software glitches. Managing Real-Time Code: How to design predictable real-time code. Managing reentrancy. Troubleshooting and eliminating erratic crashes. Building better interrupt handlers. Interfacing to Hardware: Understanding high-speed signal problems. Building peripheral drivers faster. Inexpensive performance analysis. How to Learn from Failures... and Successes: Embedded disasters, and what we must learn. Characteristics of a healthy firmware team. A seven step plan to firmware success. There's more information on all three public seminars here. Or, I can deliver the seminar on-site, at your facility, just to your engineers. |
||||||
Quotes and Thoughts | ||||||
Programs do not acquire bugs as people do germs - just by hanging around other buggy programs. They acquire bugs only from their authors. - Harlan Mills |
||||||
Tools and Tips | ||||||
Please submit clever ideas or thoughts about tools, techniques and resources you love or hate. Here are the tool reviews submitted in the past. A reader who wishes to remain anonymous poses a question to Muse readers. How do you deal with geographically-disbursed teams, especially in the embedded world where hardware and software skills may be 8 or 10 time zones apart? Test equipment might be in one location, digital or analog expertise in another, and firmware somewhere else. How do you manage these projects? |
||||||
Freebies and Discounts | ||||||
Nicholas Graumann is the lucky winner of last month's contest; he got a Real-Time Current Monitor that was donated by ee-quipment.com.. In the next article in this issue I review The Art of Electronics, third edition. This month I'll give away my copy of the second edition. It's a little tattered, but is packed full of wisdom about designing analog and digital circuits. Plus, a little mystery insert I've always stored between its pages is included. The contest will close at the end of October, 2015. It's just a matter of filling out your email address. As always, that will be used only for the giveaway, and nothing else. Enter via this link. |
||||||
The Art of Electronics, 3rd Edition | ||||||
Embedded systems are a unique mix of firmware and hardware, the latter comprising electronics, mechanics and all sorts of disciplines. Electronics lives at the heart of the embedded world. The best book ever written about the subject is Horowitz and Hill's The Art of Electronics, second edition. Until now. There's now a third edition of the book, which at 1192 pages is an expanded and updated version of the tome which has been in print now for some 35 years. If you're not familiar with The Art of Electronics, it's a practical guide to the field written for students, but equally valuable - no, necessary - for engineers designing circuits. While incredibly accessible and written with a bit of whimsy with clear, non-academic prose, readers will get most out of the book if they're willing to tackle the math, which never goes beyond first-year calculus. If you took circuit theory in college you remember the mind-bending analysis that challenged third-year students; Horowitz and Hill leave all of that out. It isn't always an easy read, but is always worth your while to work to understand the material. An appendix does go over the math needed, but to really get the material one does need a decent grounding in trig, a little complex math, and some calculus. If you are familiar with the second edition, the new version includes more on logic design, expanded discussion about switchers and power conversion as well as low-noise and precision circuits. Completely new topics are too numerous to list, but include much more on FETs of various kinds, transimpedance amplifiers, delta-sigma and precision multi-slope converters, serial buses and more. Despite the 1192 pages there's more to the field of electronics than the authors can cover. RF, with the exception of transmission lines, is pretty much left out, as is power transmission. I know little about the latter, but RF is important to many of us, so figure on supplementing this book with the ARRL Handbook. The authors note that there's more they would have liked to have added, so will release The Art of Electronics: The x-Chapters at some point. I can't wait. The book starts out with the very basics but by the second chapter goes into designing with transistors and op-amps. Yes, the theory is there; by page 90 they're into the Ebers-Moll model, but that is complemented by discussions of SMT part markings, connectors, and other matters necessary to actually build circuits, in addition to designing them. I won't list the material covered as the table of contents is here. Suffice to say that for a couple of decades The Art of Electronics has been always within reach in my office, and this new edition is worth every penny. Unless and until a fourth edition comes out, you can pry my copy from my cold, dead hands. Elektor is offering a 10% discount on the book to Muse readers here. |
||||||
Debouncing Switches and Encoders | ||||||
John Youngquist wrote the following essay about debouncing switches and encoders, and generously offered to share it with Muse readers: Some of the worst code I have ever seen is that written to de-bounce switches and handle rotary encoders. I've seen screen loads and Kbytes spent when only a few instructions are required. I guess it is simple when you know how, but apparently it's not widely known or obvious. I developed this de-bouncing method decades ago trying to force fit applications into the 1Kbyte code space of an 8048 processor. I have used variants of this simple technique ever since. The 8048 was Intel's first embedded processor to have 1K of on board program space in erasable EEPROM. I used it in many designs. The code shown here for the rotary encoder is far more recent. Over the years I have written several convoluted quadrature decoding schemes but an elegant solution always eluded me. Finally this one is clean and simple. It's intended for polled rotary switches where speed isn't critical. For high speed motor encoders an interrupt driven method is required. De-bouncing simple switches: Logical edge detector and de-bouncer in 8051 code: READ THE SWITCH INPUT PORT As written this code fragment puts a logic one in each bit position where the switch is closed. It returns zeros everywhere else. The bits change state only after two identical sequential states. It responds to a zero to one transition as shown. If you want the other polarity complement the input byte first. Sensing both states: Quadrature Rotary Encoders: Quadrature encoding plays a critical role in both linear and rotary position encoders because it can convey direction of motion or rotation. Of course knob encoders need direction too. Most quaddecoding methods are clumsy and convoluted but this one is not. In fact it is a surprisingly simple 3 step process. 1) Edge detect and de-bounce both polarities of both encoder phases. For a rotary encoder connected to P1.6, P1.7 the following sequence is the setup for dual polarity de-bouncing. It duplicates bits 6,7 in bits 4,5 and compliments them with an XOR instruction. MOV A,P1 ;READ THE ENCODER Now the ACC has the original bits read from the encoder in bits 6,7 and the complement of those bits in bits 4,5. Now the de-bounce edge detector logic previously described identifies both rising edges in ACC bits 6,7 and falling edges in ACC bits 4,5. XCH A,STATUS ;EXCHANGE A, STATUS If the result is non-zero rotational motion has occurred, we need only determine the direction. While direction information is not available in the ACC it is easy enough to derive. First we do a 4 bit circular rotate of the ACC to the left. This means after the rotation we wrap the carry bit around to ACC.4 (accumulator bit 4). RLC A ;ROTATE LEFTNow we extract the direction with a simple logical AND of the ACC and the STATUS byte used in the edge detector code: ANL A,STATUS ;ZERO IS CCW DIRECTION The zero/non-zero status of the ACC tells the direction. You might increment or decrement your count accordingly. It's hard to believe but that is all it takes. On an 8051 the entire process consumes about 25 cycles. |
||||||
The Final Say on Prototyping With SMT Devices | ||||||
Muses 290 and 291 had a lot of excellent suggestions from readers about prototyping with often-tiny SMT components. A few more have dribbled in. Erik Beall wrote:
Dave Harper suggested:
John Johnson added this:
|
||||||
Jobs! | ||||||
Let me know if you’re hiring embedded engineers. No recruiters please, and I reserve the right to edit ads to fit the format and intents of this newsletter. Please keep it to 100 words. There is no charge for a job ad. |
||||||
Joke For The Week | ||||||
Note: These jokes are archived at www.ganssle.com/jokes.htm. From Harold Kraus: We follow the irRational Unified Process for our development life cycle. It never terminates. |
||||||
Advertise With Us | ||||||
Advertise in The Embedded Muse! Over 23,000 embedded developers get this twice-monthly publication. . |
||||||
About The Embedded Muse | ||||||
The Embedded Muse is Jack Ganssle's newsletter. Send complaints, comments, and contributions to me at jack@ganssle.com. The Embedded Muse is supported by The Ganssle Group, whose mission is to help embedded folks get better products to market faster. |