CURRENT ISSUE
Contests
FEATURE ARTICLE
|
|
Issue #214 May 2008
Where Analog And Digital Collide
An Easy-To-Use LCR Meter
Third Place Microchip 2007 Design Contest
by Miguel Rusch
Start | LCR Meter | Back to Basics | The Big Picture | Creating a Wave | Analog Stages | Signal Conditioning | User Interface | Firmware | Take a Measurement | System Performance | Further Development | What's Next? | Sources & PDF
FIRMWARE
I wrote the system’s code in C and compiled it with the contest version of Microchip’s C30 compiler. Code was developed as many individual functions, which could be tested in isolation. Developing the code in small pieces was necessary because the programming tool I used (PICkit 2) did not support the debugging of dsPIC devices.
Coefficients for the DSP filters were designed using Momentum Data Systems’s dsPIC FD Lite. The resulting assembly files from this program have to be slightly modified to suit versions of MPLAB C30 v1.30 and higher because the standard declarations used are no longer allowed by the compiler.
Before using a digital filter on a small data sample, its delay line has to be set appropriately. Because the initial value of the acquired dataset could lie anywhere within the sinusoid, there is a chance the data could appear to the filter as a step input, which would cause ringing throughout the dataset. The process of setting the delay line involves running a set of data whose length is an exact multiple of the period many times through the filter and ignoring the resulting output data.
Setting the delay line for IIR filters in this way doesn’t present problems; however, the actual frequency of the “100-Hz” test was adjusted to 100.80635 Hz to present an exact sinusoid period with an integer-sized data set. The FIR filters used for down-sampling cannot use recorded data because there is a strict requirement on the cycles between ADC buffer flags. Instead, the initial 50 cycles of the filter use fresh data to set up the delay line and then only the last few frames are stored for further analysis.
I used FastAVR’s FastLCD V1.2.0 to create the graphics displayed on the LCD (see Photo 2). The free program enables you to quickly create and preview graphics before exporting them as a text file in a number of formats, including one suitable for the Toshiba chipset. Graphics were stored in program memory as constants, representing a sizable amount of data.
![]() |
| Photo 2 — Test results are displayed on the graphic LCD. Graphics were created with FastAVR’s free program FastLCD V1.2.0. The data was exported in a format to suit the Toshiba T6963C chipset and stored as constants in program memory. |
Previous | Next *| Subscription Deals |*
|
