Monday, June 6, 2011

Open-source tools for ARM microcontrollers

The ARM (Advanced RISC Machine) architecture appears in many 32-bit microcontrollers. I have NXP (Philips) LPC2138 (ARM7TMDI-S) and Luminary Micro LM3S811 (ARM7 Cortex-M3) microcontrollers. Embedded software development is well supported by open-source tools.

My current preferred development environment is Cygwin running under Windows, but Linux works well too. The GNU cross compiler for ARM7 can be built to run with Cygwin. Binutils, GCC, and GDB source code can be configured and compiled under Cygwin. The graphic user interface for gdb is available with insight and ddd. Windows Emacs also works with gdb. The Cortex-M3 support is not available with earlier versions of GCC. A relatively compact C library can be built from newlib.  The flash programming for LPC21xx can be done with the open source program lpc21isp.

The ARM7 microcontrollers have on-chip debugging capability with JTAG interface. Openocd (Open On-Chip Debugger) is the package for flash memory download and debugging interface for gdb. Openocd supports a number of JTAG hardwares, including simply parallel port "wiggler" interface, USB FT2232 interface. It can also be built under Cygwin. The parallel port interface requires the giveio driver (from AVRDUDE). The driver package (including .h and .lib) from FTDI can be used for the FT2232 interface. An open-source driver for FT2232 is also available.

The Luminary Micro's LM3S811 eval board use FTDI's FT2232 chip to drive the JTAG signals. It can also be used as the JTAG interface for external devices. Despite of lacking TRST (Tap Reset) and SRST (System Reset) signals at the external connector, it is able to interface with LPC2138. A small modification to the LM3S811 eval board allows the control of TRST. By lifting the resistor connecting to the USB_RSTn line and soldering a haywire to the connector TRST pad, we have the control of TRST. When we debug the on-board microcontroller, we need to insert a jumper wire between the TRST pin and the external debug pin. Note that the existing openocd software thinks it is toggling SRST, but I found it works quite well with LPC2138.  [Update: The later version of the LM3S811 Eval board has the SRST signal added.]
Modified to debug external device with OpenOCD.

Thus embedded software development is possible with the set of open-source tools. If a real-time operating system is desired, FreeRTOS has been ported to a number of ARM microcontrollers.

However, it is worth noting that the code generated by the GNU compiler seems far less efficient than the commercial compilers.  My single-precision Whetstone benchmark testing has shown it to be 6 times as slow and double-precision to be 3 times as slow with almost 3 times of code size.

Sunday, May 29, 2011

Solid state relay

Solid state relays that carry large current are bulky.  A simply way to have a small optocoupler driving a power MOSFET.

Monday, March 28, 2011

Layout Check List

  • DRC
    • Make sure the rules are complete
    • Resolve all DRC errors
  • Footprint verification
    • Check for footprint orientation, pin assignment, especially  transistors
    • Check for soldermask occlusion
  • Components clearance in 3D
    • Check for components extrusion beyond footprint, especially edge connectors
  • Silkscreen visibility
    • Check for overlap with holes
    • Check for overlap with components extrusion beyond footprint
    • Check for component designators
  • Fiducial marks
    • Three fiducial marks for the board
    • Fiducial marks for high pin count components
  • Polarization marks
    • Mark all polarized components
    • Mark Pin 1 of components/connectors
  • Logo/labels
    • Company logo
    • Board name
    • Fab date
    • Serial number
  • Gerber inspection
    • Inspect Gerber files with possible a different viewer
    • View in skeleton mode
    • View plane layer in positive mode

Tuesday, January 25, 2011

Miniature servo drive

A miniature servo motor may require a voltage of 5V or less and current of 200mA.  An audio amplifier is ideally suitable to drive this type of motors.  It normally uses a bridge tied load (BTL) configuration, which makes H-bridge unnecessary.  It is capably of 1-2W into 4 or 8 Ohm speaker, so it can source and sink the required motor current and the bandwidth is more than adequate for a servo drive.  The National LM4866 2.2W stereo audio amplifier in the small TSSOP-20 package can drive two small motors.  It is likely to result in lower components and smaller footprint than other solutions.

Sunday, December 26, 2010

Capacitors in series

I needed a capacitor that can withstand over 400V. But what I had were 250V capacitors. So I put two identical capacitors in series. I monitored the voltages applied across each of the capacitors. There was surprisingly amount of imbalance, and progressively getting worse. One of the capacitors took up the larger share of the voltage. I placed 150K resistors across each of the capacitors, about 1mA and 0.5W dissipation. That was enough to restore the balance.

Wednesday, November 10, 2010

EE books for a practicing EE

This list also appears here.

Troubleshooting Analog Circuits (EDN Series for Design Engineers)
1. Troubleshooting Analog Circuits (EDN Series for Design Engineers) by Robert A. Pease

"To learn about subtleties of basic components."
Analysis and Design of Analog Integrated Circuits
2. Analysis and Design of Analog Integrated Circuits by Robert G. Meyer

"For analog IC design. It is still unsurpassed as a standard introduction of analog IC design."
The Art of Electronics
3. The Art of Electronics by Paul Horowitz

"Very comprehensive coverage. It is a good reference to start and does not exhaust even as you gain experience."
Noise Reduction Techniques in Electronic Systems, 2nd Edition
4. Noise Reduction Techniques in Electronic Systems, 2nd Edition by Henry W. Ott

"For thorny noise problems. It's done much to demystify noise mitigation methods."
Analog Circuit Design: Art, Science and Personalities (EDN Series for Design Engineers)
5. Analog Circuit Design: Art, Science and Personalities (EDN Series for Design Engineers) by Jim Williams

"To learn about the temperament of an analog circuit designer."
CMOS Circuit Design, Layout, and Simulation
6. CMOS Circuit Design, Layout, and Simulation by R. Jacob Baker

"For CMOS IC design."
The Design of CMOS Radio-Frequency Integrated Circuits
7. The Design of CMOS Radio-Frequency Integrated Circuits by Thomas H. Lee

"For CMOS RF IC design. If it can be done in CMOS, it will be done in CMOS."
High Speed Digital Design: A Handbook of Black Magic
8. High Speed Digital Design: A Handbook of Black Magic by Howard W. Johnson

"For high speed digital design. It deals with the unpleasant non-ideal aspects of digital signals."
The Feynman Lectures on Physics, The Definitive Edition Volume 2 (2nd Edition)
9. The Feynman Lectures on Physics, The Definitive Edition Volume 2 (2nd Edition) by Richard P. Feynman

"For physical foundation of electromagnetism. Even though you do not intend to be a physicist, a solid background of classical EM serves you well for years to come."
Semiconductor Devices: Physics and Technology
10. Semiconductor Devices: Physics and Technology by S. M. Sze

"For device physics. Unless you are involved in device fabrications, it is a sufficient introduction for circuit designers."
Operational Amplifiers: Theory and Practice
11. Operational Amplifiers: Theory and Practice by James K. Roberge

"For feedback theory. It is slightly dated, but still useful. To be an effective circuit designer, you have to know feedback theory."
Solid State Radio Engineering
12. Solid State Radio Engineering by Herbert L. Krauss

"For RF design. You are an incomplete EE if you cannot build a radio."
Principles of CMOS VLSI Design
13. Principles of CMOS VLSI Design by Neil H. E. Weste

"For CMOS digital ASIC design."
Electric Motors and Drives: Fundamentals, Types and Applications (3rd Edition)
14. Electric Motors and Drives: Fundamentals, Types and Applications (3rd Edition) by Austin Hughes

"For operating principles of various motor types."
RF Circuit Design
15. RF Circuit Design by John E. Blyler

"A very good starter book on RF design."
Oliver Heaviside: The Life, Work, and Times of an Electrical Genius of the Victorian Age
16. Oliver Heaviside: The Life, Work, and Times of an Electrical Genius of the Victorian Age by Paul J. Nahin

"To see how our profession begins."
Designing Analog Chips
17. Designing Analog Chips by Hans Camenzind

"A good introductory account from an experienced designer."
The Soul of A New Machine
18. The Soul of A New Machine by Tracy Kidder

"The human aspect of computer design."
Switching Power Supply Design, 3rd Ed.
19. Switching Power Supply Design, 3rd Ed. by Abraham I. Pressman

"An insightful book on switching regulators."



Sunday, November 7, 2010

Enlightenment

In the course of one's life, there are a few moments of enlightenment that significantly alter one's conception. Here are the some of the technical nature.

Origin of Scientific Theory

Studying sciences up to high school gives the impression that a scientific theory is a summary of all the scientific facts and observations which are so painstakingly collected. Then there are modern physics with theory of relativity and quantum theory, which are much hard to deduce from just experimental observations. There was relatively little experimental data to suggest the theory of general relativity. Einstein claimed that scientific theory is the free creation of human mind. Kant already pointed out that the condition of human mind shapes the perception of external world. Science does not simply proceed from experiments to theory.

Evolution of Humans

From my early science classes, it seemed natural that the human species evolved from local apes. So the Peking man might be the ancestor of the Asian people. It was astonishing to learn that all humans evolved from a single group from Africa which migrated to the rest of the world.

Pseudo code

When I first learned about computer programming in high school, the teacher drew the flow diagrams. I never quite got it and programming was very hard for me. Then in the college, the professor showed the pseudo code and stepwise refinement. You start with very high level human language description and refine it to the degree that can be coded in the computer programming language. Suddenly programming became a lot easier. Later I learned that the technique was described in an article "Program Development by Stepwise Refinement" by Niklaus Wirth in 1971.

Circuit Theory

In the high school physics class, I encountered some circuit analysis problems. At that time, no systematic approach was presented. Each problem seemed to require some trick. Finally, in the first course of electrical engineering, the Kirchhoff's circuit laws were introduced, then there was a mechanical way for all linear circuits. But later in the real world engineering, it became clear the loop method and the nodal method were unwieldy for anything but the simplest circuits.

Computer architecture

The first introduction to central processing unit (CPU) was ugly. The accumulator architecture of the early days just did not appeal to me. Then the x86 assembly class was even worse; it is hard to like x86 architecture. Only after I read Hennessy and Patterson's book on RISC architecture, the whole computer design started to make sense to me. But it was a little too late.