High Resolution Digital Weigh-Scale Design Using Z8 Encore! Microcontrollers

Similar documents
An SPI Temperature Sensor Interface with the Z8 Encore! SPI Bus

Getting Started with ESPI Interface Using the Z8 Encore! XP F1680

A Simple Console Application for Z8 Encore! XP MCUs

Objective: Additional project details: Code: PSEMBP 100 Category:STEM Level: High School/Community C.

S3 Flash In-System Programmer

Interfacing Z8 Encore! XP MCUs with an I 2 C-Based Character LCD

Universal Motor Control with Z8 Encore! XP 8-Pin Highly Integrated Microcontroller

Challenge. Hardware Circuit Details. Solution. Result. Features and Functions. Z8 Encore! MC

Z8 Encore! XP F0822 Series

An Automatic Temperature Control System Using RZK

Set Up a PLL Loop Filter on the ez80f91 MCU

Character LCD Interface for ez80acclaim! MCUs

Z8 Encore! XP F0822 Series Development Kit

Zilog Real-Time Kernel

Using the Z8051 MCU s USI Peripheral as an SPI Interface

ZMOTION Detection Module Development Kit

Flash Loader Utility for the Z8 Encore! XP MCU

Z8 Encore! XP/Z8 Encore! Development Kits

Z8 Encore! XP F1680 Series 8-Bit Flash Solution with Extended Peripherals

5x7 LED Matrix Display with Z8 Encore! XP

EEPROM Emulation with the ez80f91 MCU. Discussion

Ethernet Smart Cable

Z8 Encore! XP 4K Series with extended Peripherals

BOOST YOUR SYSTEM PERFORMANCE USING THE ZILOG ESCC CONTROLLER

CDB5532U Evaluation Board and Software

High-Performance 8-Bit Microcontrollers. Up to 8 10-Bit ADC Channels. Two 16-Bit Timers/PWM. Internal Precision Oscillator

ZCRMZNICE01ZEMG Crimzon In-Circuit Emulator

Zatara Series ARM ASSP High-Performance 32-bit Solution for Secure Transactions

Evaluation Board User Guide UG-047

ez80f91 Modular Development Kit

Product Update. Errata to Z8 Encore! 8K Series Silicon. Z8 Encore! 8K Series Silicon with Date Codes 0402 and Later

S3F8S5A Development Kit

Application Note. Interfacing the CS5525/6/9 to the 68HC05. By Keith Coffey MOSI (PD3) SDO MISO (PD2) SCLK. Figure 1. 3-Wire and 4-Wire Interfaces

Serial Communication Controllers (SCC) MULTIPROTOCOL DATA COMMUNICATION SOLUTIONS

Boot Loader for the Z51F6412 MCU

Application Note. Interfacing the CS5521/22/23/24/28 to the 68HC05. Figure 1. 3-Wire and 4-Wire Interfaces

Evaluation Board for CS3308. Description CS Channel. Digitally Controlled Analog Volume Control. PC or External Serial Control Input

± 2g Tri-axis Accelerometer Specifications

Real Time Embedded Systems. Lecture 1 January 17, 2012

PAC5523EVK1. Power Application Controllers. PAC5523EVK1 User s Guide. Copyright 2017 Active-Semi, Inc.

UM0792 User manual. Demonstration firmware for the DMX-512 communication protocol transmitter based on the STM32F103Zx.

AN5181. Building a thermometer using the STM8 Nucleo-64 boards. Application note. Introduction

Z8 Encore! Z8F642 MCU Evaluation Kit

CDB5346. Evaluation Board for CS5346. Features. Description CS5346. Single-ended Analog Inputs. Single-ended Analog Outputs

ZLF645 Crimzon Flash Microcontroller with ZBase Database Industry Leading Universal Infrared Remote Control (UIR) Solution

ZiLOG Real-Time Kernel Version 1.2.0

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

AK5393 to CS5361/81 Conversion

Evaluation Board for Transducer ADC EVAL-AD7730EB

AN3279 Application Note

AC/DC. Adapter. Serial. Adapter. Figure 1. Hardware Setup

Evaluation Board for CS5351

CDB5461AU Evaluation Board & Software

Z8 Encore! XP Family of Microcontrollers Development Kits

ONE PHASE POWER METER (CS5464) SOLUTION

NovalithIC H-Bridge Demo Board

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

Zilog TCP/IP Software Suite

Four-Channel Universal Analog Input Using the MAX11270

SBAT90USB162 Atmel. SBAT90USB162 Development Board User s Manual

AN10428 UART-SPI Gateway for Philips SPI slave bridges

USB-to-I2C. Ultra Hardware User s Manual.

XC2000 Family AP Application Note. Microcontrollers. XC2236N Drive Card Description V1.0,

CDB5529 Evaluation Board and Software

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

USB-to-I2C. Professional Hardware User s Manual.

North American Service Manual

This manual provides information for the final user application developer on how to use SPC57S-Discovery microcontroller evaluation board.

Nuvoton 1T 8051-based Microcontroller NuTiny-SDK-N76E885 User Manual

Atmel ATMXT143E touchscreen controller Capacitive touch ITO 320 x 240 pixel LCD display with SPI interface LED backlight

HYDRA-X23/X23S. Power Application Controllers. PAC HYDRA-X User s Guide. Copyright 2014 Active-Semi, Inc.

C8051F800-DK C8051F800 DEVELOPMENT KIT USER S GUIDE. 1. Relevant Devices. 2. Kit Contents. 3. Hardware Setup

EVAL-ADT7516. SPI -/I 2 C -Compatible, Temperature Sensor, 4-Channel ADC and Quad Voltage Output DAC FEATURES APPLICATIONS

Nuvoton 4T 8051-based Microcontroller NuTiny-SDK-N78E715 User Manual

AK5394A to CS5381 Conversion

Application Note, V1.0, Aug AP08064 XC866/886/888. Safeguarding the Microcontroller under Out-of-Spec Noise Conditions.

< W3150A+ / W5100 Application Note for SPI >

AN3980 Application note

HYDRA-X10. Power Application Controllers TM. PAC HYDRA-X User s Guide. Copyright 2014 Active-Semi, Inc.

USER GUIDE. Atmel maxtouch Xplained Pro. Preface

UM2119 User manual. Graphical user interface (GUI) for EVAL-L9907-H. Introduction

P R E L I M I N A R Y. Programming the QF4A512 EEPROM

HVP-KV10Z32 User s Guide

AN Interfacing Philips Bridge IC with Philips microcontroller. Document information

DSD: Delta Sigma Demodulator. XMC microcontrollers September 2016

LM48555 Evaluation Board

STSW-L9960, STSW-L9960T Graphical User Interface (GUI) for EVAL-L9960 & EVAL-L9960T

PAC5232EVK1. Power Application Controllers. PAC5232EVK1 User s Guide. Copyright 2017 Active-Semi, Inc.

ICP05 IBOARD LITE ICP05. - iboard lite

XE166 Family AP Application Note. Microcontrollers. UConnect XE162N Hardware Description V1.0,

C8051F00x/01x-DK C8051F00X/01X DEVELOPMENT KIT USER S GUIDE. 1. Kit Contents. 2. Hardware Setup using a USB Debug Adapter

PIC Serial Peripheral Interface (SPI) to Digital Pot

XE166 Family AP Application Note. Microcontrollers. X E D r i v e C a r d H a r d w a r e D e s c r i p t i o n Board REV.

ams AG austriamicrosystems AG is now The technical content of this austriamicrosystems document is still valid. Contact information:

AVR42772: Data Logger Demo Application on XMEGA A1U Xplained Pro. Introduction. Features. AVR XMEGA Microcontrollers APPLICATION NOTE

VLSI Design Lab., Konkuk Univ. Yong Beom Cho LSI Design Lab

ECG (EKG) Primer Jingxi Zhang ABSTRACT

AN2673 Application note

AN4241 Application note

Getting started with the digital MEMS microphone expansion board based on MP34DT01-M for STM32 Nucleo

Transcription:

Application te High Resolution Digital Weigh-Scale Design Using Z8 Encore! Microcontrollers AN025404-0608 Abstract This application note describes the development and use of a Digital Weigh-Scale (DWS) using Zilog s Z8 Encore! microcontroller. This reference design offers a ready-to-use DWS solution easily scalable to measure high-capacity loads. A high-resolution Analog-to-Digital Converter (ADC) external to the microcontroller is used to accurately measure the load cell output. The measured weight is displayed on the LCD. are the most commonly employed measuring components. The low voltage output of a load cell which is in the order of few millivolts needs to be amplified and digitized. This requires an ADC with a resolution greater than 16-bit. A high-resolution ADC with a built-in amplifier is used for these type of applications. The ADC output is read by a microcontroller and appropriate algorithms are used to calculate the weight and display them. te: The source code associated with this reference design is available under Z8 Encore! Applications Code Library in Application Sample Libraries on www.zilog.com. Features The main features of DWS are: Measures 10 g to 40 kg (with 10 g resolution) TARE feature to measure net weight Count items with identical weights Calibration of weigh-scale Selectable clock source and reference voltage for ADC Displays weight on single-line 8 character (8 x 1) LCD (see Figure 1) Discussion Digital Weigh-Scale measures weight or change in weight depending on the object for measurement. It displays weight in digital format with appropriate units of weight. Load cells whose output voltage changes proportionally to the weight applied Figure 1. Digital Weigh-Scale Reference Design Board Hardware Architecture This reference design is based on the Z8 Encore! MCU which communicates with the 24-bit ADC CS5550 through Serial Peripheral Interface (SPI). The output voltage of the load cell is passed through a Low-Pass Filter (LPF) to suppress any high frequency noise and applied to ADC. The measured weight is displayed on a 8 x 1 LCD. Copyright 2008 by Zilog, Inc. All rights reserved. www.zilog.com

This design supports the user interface to handle TARE, COUNT, and CALIBRATION modes of weigh-scale operation. The power supply for DWS is derived from a 9 V DC adapter. It is essential that the excitation voltage for the load cell and the ADC reference voltage is derived from the same source to provide ratiometric connection. Hence, any variation in excitation voltage of the load cell does not result in loss of measurement accuracy, since the ADC s voltage resolution changes proportionally. The block diagram in Figure 2 provides an overview of the DWS hardware architecture. For more details on hardware connections, see Appendix A Schematics on page 4. te: The analog input pin, AIN2, is used as the default analog channel for measurements. The AIN1 pin is used to measure much lower load cell voltages as it supports higher gain. Switch Functionalities The functionalities of different switches used in the design are described in following sections. TARE TARE is a term used in weights and measurements which refers to the weight to be subtracted from the gross-weight in order to obtain the net weight. For example, to measure the weight of contents in a container, the weight of container (TARE) is subtracted from the gross weight (weight of container + weight of contents). For more details on usage, see Using TARE Function on page 4 and for software implementation, see Figure 4 on page 5. COUNT The COUNT switch is used to determine counts of a known weight item. For more details on usage, see Using COUNT Function on page 4 and for software implementation, see Figure 8 on page 11. CALIBRATION (External ADC) The CALIBRATION switch allows you to perform gain and offset calibration on external ADC CS5550. 5V 9V Power Supply 3.3V 2.5V 2.5V 5V 3.3V 3.3V 5V Vref VA+ VD+ VDD 8x1 LCD 5V SDO MISO PA4-PA7 Load Cell L P F AIN2- AIN2+ SDI SCLK ~CS MOSI SCLK ~SS PA0 PA1 PA2 TARE COUNT CALIBRATION Switch XIN T1OUT PA3 TEST CS5550 Z8 Encore! Figure 2. Digital Weigh-Scale Hardware Block Diagram AN025404-0608 Page 2 of 14

TEST The TEST switch allows you to exit the TARE and COUNT modes and display the absolute weight placed on the load cell. Software Implementation This reference design makes use of the Z8 Encore! s on-chip SPI, Timer, and GPIO peripheral. The software presented with this application initializes these peripherals and configures the CS5550 ADC. The output of Timer1 is used as system clock source for CS5550. The output of CS5550 is read every 50 ms. Timer0 is configured to generate interrupt every 1 ms. A flag indicating the 50 ms timeout is monitored and initially 10 samples of ADC output are collected and stored into a buffer. The average of these 10 samples is used to calculate the weight. Each new sample collected thereon replaces the oldest sample in the buffer. If the current ADC value differs from its previous value by a predefined threshold, then, it implies that there is a substantial change in weight and 10 new samples are collected. This way, sudden weight changes are taken into account. The threshold ADC value is selectable through THRESHOLD_ WEIGHT_DIFFERENCE macro. All weight, COUNT value, and operating modes of weigh-scale are displayed on LCD. Weight less than 1 kg is displayed in grams. Weight greater than 999 g is displayed in kilograms with 3 decimal places. The software also continuously polls switch press and corresponding functionalities of the switches are performed. See Appendix B Flowcharts on page 5for the software flow. As the ADC count value read from the controller corresponds to the Load cell output, the Load cell characteristic is derived by plotting ADC count values against standard weights. An appropriate equation is obtained from this plot which is used to calculate the weight at run-time. Figure 3 displays the characteristic of the load cell used in this reference design. cadc Count 1500000 1400000 1300000 1200000 1100000 1000000 900000 800000 700000 600000 0 5 10 15 20 25 30 35 40 45 Weight (Kg) Figure 3. Load Cell Characteristics Figure 3 plot results in a linear equation of type y = mx+ c (1) where, x is the weight in kilograms y is the ADC Count corresponding to the applied weight c is the ADC Count when no load is present on load cell m is the slope of the curve Rearranging Equation (1), x = ( y c) m (2) Equation (2) is used to calculate weight at runtime. As the load cell characteristic varies from one to another, you have to derive an appropriate equation as discussed above and calculate the weight. AN025404-0608 Page 3 of 14

Performing Weight Measurements Setup The setup for measuring weight is provided below: 1. Connect the bridge excitation terminals of the load cell to connector J16 on the reference design board. 2. Connect the differential output of the load cell to connector J4. 3. Plug in a 9 V, 10 W DC adapter to J15. 4. Put the SPDT switch SW6 in ON position to power up the board. 5. Build digital_weigh_scale.zdsproj available in the source folder of the Application Library using ZDS II Z8 Encore!. 6. Download the code onto the reference board. Basic Weight Measurement Follow the steps below to measure the basic weight: 1. Execute the code and observe the measured weight on LCD. This value will vary from one load cell to other. You will have to calibrate the weigh-scale against standard weights to get accurate readings. 2. Place some weight on the load cell and the measured weight will be displayed on the LCD screen. Using TARE Function Follow the steps below to use the TARE function: 1. Place the object on the scale whose weight is to be offset for further measurements. 2. Press TARE switch. Character T is displayed on the LCD indicating that the scale is in TARE mode. 3. Place the object whose weight is to be measured on the load cell. 4. To exit the TARE mode and start absolute measurement, press the TEST switch. Using COUNT Function Follow the steps below to use the COUNT function: 1. Place the reference weight on load cell against which the counting is to be done and press COUNT switch. 2. The LCD displays count value 1 and the mode C indicating that the scale is in COUNT mode. 3. Place additional identical weights to view the number of objects kept on the load cell. 4. To exit the COUNT mode and start weight measurement, press the TEST switch. Using CALIBRATION Function Follow the steps below to use the CALIBRATION function: 1. Press the CALIBRATION switch. LCD will display OFFSET. At this point connect the + and - pins of J4 (for AIN2) to ground and press the CALIBRATION switch again. 2. The LCD will display GAIN. Connect the load cell output to J4 (for AIN2) channels and put maximum weight to be measured on the load cell. This maximum weight applies the absolute maximum instantaneous voltage to be measured across the analog inputs. 3. Press the CALIBRATION switch again to complete gain calibration. Optional Design Changes The optional design changes which can be implemented are as follows: 1. To change the system clock source to an external crystal for CS5550, populate crystal Y1 and do not use resistor R5. 2. To use internal reference voltage for CS5550, populate the resistor R6 and do not populate resistor R31. AN025404-0608 Page 4 of 14

te: Summary By default, the reference design uses external reference voltage for CS5550 on-chip modulator and Timer1 output as the system clock source. The reference design based on Z8 Encore! Z8F0812 MCU provides a scalable and ready-touse solution for DWS. The software is modular and easy to customize for any weight measurement application. References The documents associated with Z8 Encore! Z8F0812 MCU available on www.zilog.com are provided below: Z8 Encore! XP F0822 Series Product Specification (PS0225) ez8 TM CPU User Manual (UM0128) Product Specification CS5550 (CS5550_F1) available on www.cirrus.com For lower resolution, the design can be based on Z8F0822, which has 10 bit on-chip ADC. This will necessitate the use of external amplifier to boost the load cell output. The reference design can be easily ported to Z8F1680 for low-cost and low-power solution. AN025404-0608 Page 5 of 14

Appendix A Schematics Appendix A displays the schematics of Digital Weigh-Scale reference board. AN025404-0608 Page 6 of 14

Appendix B Flowcharts This Appendix displays the following flowcharts for the Digital Weigh-Scale application using Z8 Encore! Microcontroller: Main Function (Figure 4) ADC Sample Collection and Change in Weight Detection Routine (Figure 5) Weight Calculation Routine (Figure 6) TARE Switch Handling Function (Figure 7) COUNT Switch Handling Function (Figure 8) CALIBRATION Switch Handling Function (Figure 9) Processing Switch Inputs (Figure 10) AN025404-0608 Page 7 of 14

. Start Initialize GPIO, SPI, Timer of Z8 Encore!. Initialize LCD & Configure ADC CS5550 Start Continuous ADC Conversion Collect 10 ADC samples and put it into an array Monitor switch inputs and call appropriate functions. 50 ms Timeout of the timer? Collect single ADC sample to replace the oldest sample in the array Calculate weight and display it on LCD in appropriate format End Figure 4. Main Function AN025404-0608 Page 8 of 14

Start Replace the oldest sample in the array with a new sample Latest two samples differ by a predefined threshold corresponding to a certain weight? Collect 10 new samples and refresh the array End Figure 5. ADC Sample Collection and Change in Weight Detection Routine Start Average the 10 samples of ADC collected in an array Calculate the weight using appropriate curve fitting equation which relates ADC count to weight End Figure 6. Weight Calculation Routine AN025404-0608 Page 9 of 14

Start Display T on LCD indicating TARE mode Collect 10 ADC samples, average and calculate weight. This weight will be deducted from all future weight measurements, until TEST switch is pressed Change the system mode to NORMAL, to perform actual weight measurements End Figure 7. TARE Switch Handling Function AN025404-0608 Page 10 of 14

Start Display C on LCD indicating COUNT mode Collect 10 ADC samples, average and calculate weight. Measured weight is assigned as the unit weight Any switch other than COUNT Collect 10 ADC samples, average and calculate weight. Divide the measured weight by the unit weight to get the count Display the count End Figure 8. COUNT Switch Handling Function AN025404-0608 Page 11 of 14

Start Display OFFSET on LCD indicating offset calibration follows Connect the appropriate analog input pins of the ADC to ground CALIBRATION switch pressed? Send offset calibration command to ADC Display GAIN on LCD indicating offset calibration follows Connect load cell output to appropriate analog input pins of the ADC and place maximum load to be measured on the load cell CALIBRATION switch pressed? Send gain calibration command to ADC Set system mode to NORMAL to perform actual weight measurements End Figure 9. CALIBRATION Switch Handling Function AN025404-0608 Page 12 of 14

Start TARE switch pressed? Call TARE handling function COUNT switch pressed? Call COUNT handling function CALIBRATION switch pressed? Call CALIBRATION handling function TEST switch pressed? Make the weight offset (as set in TARE function) zero and change system mode to NORMAL End Figure 10. Processing Switch Inputs AN025404-0608 Page 13 of 14

Warning: DO NOT USE IN LIFE SUPPORT LIFE SUPPORT POLICY ZILOG'S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS PRIOR WRITTEN APPROVAL OF THE PRESIDENT AND GENERAL COUNSEL OF ZILOG CORPORATION. As used herein Life support devices or systems are devices which (a) are intended for surgical implant into the body, or (b) support or sustain life and whose failure to perform when properly used in accordance with instructions for use provided in the labeling can be reasonably expected to result in a significant injury to the user. A critical component is any component in a life support device or system whose failure to perform can be reasonably expected to cause the failure of the life support device or system or to affect its safety or effectiveness. Document Disclaimer 2008 by Zilog, Inc. All rights reserved. Information in this publication concerning the devices, applications, or technology described is intended to suggest possible uses and may be superseded. ZILOG, INC. DOES NOT ASSUME LIABILITY FOR OR PROVIDE A REPRESENTATION OF ACCURACY OF THE INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED IN THIS DOCUMENT. ZILOG ALSO DOES NOT ASSUME LIABILITY FOR INTELLECTUAL PROPERTY INFRINGEMENT RELATED IN ANY MANNER TO USE OF INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED HEREIN OR OTHERWISE. The information contained within this document has been verified according to the general principles of electrical and mechanical engineering. Z8, Z8 Encore!, and Z8 Encore! XP are registered trademarks of Zilog, Inc. ez8 is a trademark of Zilog, Inc. All other product or service names are the property of their respective owners. AN025404-0608 Page 14 of 14 14