Author Archives: R-B

Code optimization tricks for AVR microcontrollers

Using high-level language compilers such as C greatly improves the development efficiency of microcontroller-based products. But when programs are written in C and compiled by a C compiler, the code efficiency is generally lower compared to an Assembly language program. However, good knowledge of microcontroller architecture and C coding helps the developers to optimize the code for reduced size and enhanced performance. For example, if we use a “do { } while ( )” loop, an increment or a decrement loop index generates different code size. Usually we write our loops counting from zero to the maximum value (increment), but it is more efficient to count the loop from the maximum value to zero (decrement). This application note describes various code optimization tips for 8-bit AVR microcontrollers based on avr-gcc (C compiler). However, due to their general nature these tips could be implemented in other compilers or with similar compiler options, and vice versa.

Code Optimization in AVR microcontrollers

Three-Phase Electronic Watt-Hour Meter Using the MSP430F677x

The TI’s MSP430F677x devices belong to the powerful 16-bit MSP430F6xx platform, which brings in many new features and provides flexibility to support robust poly-phase metrology solutions. These devices find their application in energy measurement and have the necessary architecture to support them. This application report describes the implementation of a three-phase electronic electricity meter using the MSP430F677x metering processor. The key parameters calculated during energy measurements are: RMS current and voltage, active and reactive power and energies, power factor, and frequency. A 32-bit x 32-bit hardware multiplier on this chip further accelerates the math intensive operations during the energy computation. The application report has complete metrology source code provided as a zip file.

3-phase watt meter

Understanding ADC parameters for accurate analog-to-digital conversions

Analog-to-digital-conversion (ADC) is required in Embedded Systems to deal with various analog world parameters such as current, pressure, motion, temperature, etc. An ADC is an electronic system or a module that has analog input, reference voltage input and digital outputs. The ADC convert the analog input signal to a digital output value that represents the size of the analog input comparing to the reference voltage. It basically samples the input analog voltage and produces an output digital code for each sample taken. This application note from Atmel describes the fundamental concepts of ADC and the associated parameters that determine the performance and accuracy of the ADC’s output.

Understanding ADC parameters

Making a smart I2C DC motor controller

A full-fledged DC motor controlling application requires a lot of I/O resources and MCU time. This project is about making a dedicated DC motor controllerthat would release the main microcontroller from this duty so that it could do other important tasks more efficiently. The controller uses Atmega168 as a slave I2C device that receives commands from a host MCU through I2C signal lines, and controls two DC motors using the L293D high-current H-driver chip. Separate PWM signals are used for each motor to achieve precise motor steering. The built-in motor steering library routines makes the motor control much easier.

Smart DC motor controller with I2C interface

« Older Entries Recent Entries »