The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers.    


Datasheet Search Engine   
 
Part # or Description: • 5V RS232 Driver • 2SC5066* • "Real Time Clock" • "USB connector" • "blue led" 5mm • 10 watt zener diode • 2N3055* motorola
 
Search Tip: Try entering the part number only. Include a wildcard (eg. lm317* or 1n4148*)

 

 

Simple Solution Simple Problem Williams Mark Thoren Automobiles, aircr


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



Application Note March 2007 Developments Battery Stack Voltage Measurement
Simple Solution Simple Problem Williams Mark Thoren Automobiles, aircraft, marine vehicles, uninterruptible power supplies telecom hardware represent areas utilizing series connected battery stacks. These stacks individual cells contain many units, reaching potentials hundreds volts. such systems often desirable accurately determine each individual cell's voltage. Obtaining this information presence high "common mode" voltage generated battery stack more difficult than might supposed. Battery Stack Problem "battery stack problem" been around long time. deceptively simple appearance masks stubbornly resistant problem. Various approaches have been tried, with varying degrees success.1 Figure voltmeter measures single cell battery. Beyond obvious, arrangement works because there voltages measurement path other than measurand. ground referred voltmeter only encounters voltage measured. Figure "stack" series connected cells more complex presents problems. voltmeter must switched between cells determine each individual cell's voltage. Additionally, voltmeter, normally composed relatively voltage breakdown components, must withstand input voltage relative ground terminal. This "common mode" voltage reach hundreds
VOLTMETER
volts large series connected battery stack such used automobile. Such high voltage operation beyond voltage breakdown capabilities most practical semiconductor components, particularly accurate measurement required. switches present similar problems. Attempts implementing semiconductor based switches encounter difficulty voltage breakdown
Lare registered trademarks Linear Technology Corporation. other trademarks property their respective owners. 1See Appendix Ears Goghs" detail
commentary some typical approaches.
VOLTMETER
CELLS
BATTERY STACK
SWITCH CONTROL
SINGLE CELL BATTERY
AN112
AN112
Figure Voltmeter Measuring Ground Referred Single Cell Subjected Common Mode Voltage
Figure Voltmeter Measuring Cell Stack Undergoes Increasing Common Mode Voltage Measurement Proceeds Stack. Switches Switch Control Also Encounter High Voltages
an112f
AN112-1
Application Note
leakage limitations. What really needed practical method that accurately extracts individual cell voltages while rejecting common mode voltages. This method cannot draw battery current should simple economically implemented. Transformer Based Sampling Voltmeter Figure concept addresses these issues. Battery voltage (VBATTERY) determined pulse exciting transformer (T1) recording transformer primary clamp voltage after settling occurs. This clamp voltage predominately diode VBATTERY shunting similarly clamping T1's secondary. diode small transformer term constitute predictable errors subtracted out, leaving VBATTERY output. Detailed Circuit Operation Figure detailed version transformer based sampling voltmeter. closely follows Figure with some minor differences which described this section's conclusion. pulse generator produces wide event (Trace Figure 1kHz repetition rate. pulse generator's impedance output drives resistor also triggers delayed pulse generator. T1's primary (Trace responds rising value representing VDIODE VBATTERY along with small fixed error contributed transformer. T1's primary clamps this value. After time (Trace dictated delayed pulse generator pulse (Trace closes allowing charge towards T1's clamped value. After number pulses assumes level identical T1's primary clamp voltage. buffers this potential feeds differential amplifier operating gain near unity, subtracts diode transformer error terms, resulting direct reading VBATTERY output. Accuracy critically dependent transformer clamping fidelity over temperature clamp voltage range. carefully designed transformer specified yields Figure waveforms. Primary (Trace secondary (Trace clamping detail appear highly expanded vertical scale. Clamping flatness within millivolts; trace center aberrations derive from gate feedthrough. Tight transformer clamp coupling promotes good performance. Circuit accuracy 25°C 0.05% over battery range with 120ppm/°C drift, degrading 0.25% VBATTERY
2Battery stack voltage monitor development aided floating, variable potential battery simulator described Appendix
PULSE GENERATOR PULSE GENERATOR CELLS PRIMARY DELAYED PULSE VBATTERY DIODE ERROR
DELAYED PULSE GENERATOR
DIODE
VBATTERY
CELLS
POTENTIAL T1'S CLAMP VALUE ANALOG INPUT SAMPLING VOLTMETER SAMPLE COMMAND
DIODE TRANSFORMER ERROR TERMS SUBTRACTION
AN112
OUTPUT VBATTERY
Figure Transformer-Based Sampling Voltmeter Operates Independently High Common Mode Voltages. Pulse Generator Periodically Activates Delayed Pulse Triggers Sampling Voltmeter, Capturing T1's Clamped Value. Residual Error Terms Corrected Following Stage
an112f
AN112-2
Application Note
LT1761-5 12VIN 74HC04 10s, 1kHz 2N3904 MATCH 200A PULSE GENERATOR VN2222 PULSE ENGINEERING PA2100NL PA2101NL RESISTOR
10k*
DIODE
SAMPLING VOLTMETER (SAMPLE-HOLD)
VBATTERY
CD4016 4.7k 0.001F
LTC1050
6.34M*
LT1789
OUTPUT VBATTERY 1.03
7.5k* 100pF 74HC123 DELAY TIME 270pF
DELAYED PULSE
511*
AN112
ERROR SUBTRACTION
DELAYED PULSE GENERATOR
14.7k*
Figure Transformer Sampling Voltmeter Schematic Closely Follows Figure Concept. Error Subtraction Terms Include Compensating Resistor/Gain Corrections Errors T1's Clamping Action. Q1-Q3 Transistors Replace Diodes More Consistent Matching. Prevents T1's Negative Recovery Excursion from Influencing
5V/DIV 2V/DIV 2mV/DIV 2.2V STEP
5V/DIV 5V/DIV 2mV/DIV 2.2V STEP
2s/DIV
AN112
2s/DIV
AN112
Figure Figure Waveforms Include Pulse Generator Input (Trace Primary (Trace 74HC123 Delay Time Output (Trace Control Input (Trace Timing Ensures Sampling Occurs When Settled Clamped State
Figure Primary (Trace Secondary (Trace Clamping Detail. Highly Expanded Vertical Scale Shows Primary Secondary Clamping Flatness Within Millivolts. Trace Center Aberrations Derive from Gate Feedthrough
an112f
AN112-3
Application Note
Several details circuit operation. Transistor VBE's, substituted diodes, provide more consistent initial matching temperature tracking. capacitor maintains impedance frequency, minimizing cell voltage movement during sampling interval. Finally, synchronously switched prevents T1's negative recovery excursion from deleteriously influencing S1's operation. This approach's advantage that circuitry does encounter high common mode voltages-T1 galvanically isolates circuit from common mode potentials associated with VBATTERY. Thus, conventional voltage techniques semiconductors employed. Multi-Cell Version transformer-based method inherently adaptable multi-cell battery stack measurement problem previously described. Figure conceptual schematic shows multi-cell monitoring version. Each channel monitors cell. individual channel read biasing appropriate enable line turn switch, enabling that particular channel's transformer. hardware required each channel typically limited transformer, diode connected transistor switch.
PULSE GENERATOR
Automatic Control Calibration This scheme suited digitally based techniques automatic calibration. Figure uses PIC16F876A microcontroller, from LTC1867 analog digital converter, control pulse generators channel selection. before, even though cell stack reach hundreds volts, transformer galvanic isolation allows signal path components operate voltage. further benefit processor driven operation elimination Figure diode matching requirement. practice, processor-based board tested room temperature with known voltages applied input terminals. channels then read, furnishing information necessary processor determine each channel's initial gain. These parameters then stored nonvolatile memory, permitting one-time calibration that eliminates both mismatch gain mismatch induced errors. Channels provide zero 1.25V reference voltages representing cell voltage extremes. room-temperature values stored nonvolatile memory. temperature changes occur, readings from channel used calculate change offset change gain that applied measurement channels. calibration maintained temperature varies because each channel's -2mV/°C drift slopes nearly identical. Similarly, gain errors from channel channel nearly identical. Since gain offset continuously calibrated, gain offset LTC1867 drop equation. only points that must accurate measurement (easy, just short channel inputs together) 1.25V reference voltage, provided LT®1790-1.25. LTC1867 internally amplifies internal 2.5V reference 4.096V REFCOMP pin, which sets full scale (4.096V when configured unipolar mode, ±2.048V bipolar mode). Thus absolute maximum cell voltage that measured 3.396V. since offset measurement nominally 0.7V input never danger clamping zero. zero reading will result given LTC1867 negative offset input voltage positive voltage less than equal offset.) Accuracy processor-driven circuit over input range 25°C. Drift drops less than 50ppm/°C-almost lower than Figure
an112f
SAMPLE-HOLD
BATTERY STACK
ENABLE LINES
AN112
SECTIONS
Figure Multiple Channels Facilitated Adding Enable Lines Transistor Switches
AN112-4
Application Note
74HC14 ADC_CH7 RB0/EXCITATION 74HC574 PROCESSOR DATA RB1/LATCH ENABLE LINES 74HC14 OTHER CHANNELS ADC_CH6 RB0/EXCITATION 74HC00 4.7k VN2222 LT1790-1.25 74HC00 4.7k VN2222 OFFSET 2N3904
GAIN 2N3904 VREF
0.1F 2.2F LTC1867 VREF REFCOMP
IDENTICAL CHANNELS 74HC14 2N3904 CHX+ INPUT CHX-
ADC_CH0 ADC_CH1 ADC_CH2 ADC_CH3 ADC_CH4 ADC_CH5 ADC_CH6 ADC_CH7
ADC_CHX 4.7k VN2222
RB5/CS RC3/SCK RC5/MOSI RC4/MISO
PROCESSOR
RB0/EXCITATION 74HC00
AN112 F08a
Figure Pulse Generators, Calibration Channels, Measurement Channels. Calibration Channels Eliminate Matching Requirement Compensate Temperature Dependent Errors
an112f
AN112-5
Application Note
0.1F LTC1799CS5 0.1F 20MHz SUPERVISOR 0.1F 22.1 22.1 OSCIN PIC16LF877A-I/PT 0.1F RA4/ISO SHDN TXE# RXF# CLK# 1.5k RB5/CS RB1/LATCH RB0/EXCITATION RC7/RX RC6/TX RC5/MOSI RC4/RISO RC3/SCK
49.9k IN-CIRCUIT PROGRAMMING PORT
COMMAND
RXF#
0.1F
102k
PGD/RB7 PGC/RB6 OSCOUT INT/RB0 RX/RC7 TX/RC6 MOSI/RC5 MISO/RC4 SCK/RC3 MCLR
INDICATORS
2200pF
VCC25 VCC3 VCCA SYSTEM RST# MMBT3904 LTC1726EMS8-2.5
PROCESSOR DATA
100pF
2N7002 CLK#
74HC74PW RESET
74HC74PW 0.1F 22.1 10MHz NC7SP17P5X
AN112 F08b
Figure Microcontroller Reset
an112f
AN112-6
Application Note
0.1F USB5V
0.1F
0.1F
6.3V USB5V 0.1F
0.1F
PROCESSOR DATA
AVCC VCCIO USBDM USBDP FT245BM RSTOUT# EECS TXE# RXF# 22.1 48MHz USB5V USB5V 0.1F LTC6905CS5-96 XTIN XTOUT SW/WU TEST PWREN# RST# AGND EESK EEDATA
22.1k 22.1k 1.5k 47pF 47pF
USB-B CONNECTOR
USB_RD_CLK# USB_WR_CLK USB_TXE# USB_RXF#
0.1F USB5V
2.21k
3V3VOUT 47pF
93LC46BT-1/OT
AN112F08c
Figure Interface (for Development Only)
Firmware Description complete firmware code listing Appendix code this circuit designed good starting point actual product. Data displayed FTDI FT242B interface FTDI's Virtual Port drivers installed, allowing control through terminal program. Data channels continuously displayed terminal, simple text commands control program operation. timer interrupt called 1000 times second. controls pulse generators ADC, stores readings array that read time. Thus main program reading buffer, most out-ofdate reading will 1ms. Automatic calibration routines also included. functions store zero reading full-scale reading
channels, including calibration voltages applied channels nonvolatile memory. These subsequently used calibrate initial gain offset errors well temperature dependent errors. entire procedure apply zero volts inputs issue command store zero calibration, then apply 1.25V inputs issue command store full-scale calibration. Note that this more complicated than basic functionality test that would part manufacturing process. 1.25V factory calibration source from voltage calibrator, from selected "golden" LT1790-1.25 that kept stable temperature. digital filter also included testing purposes. filter simple exponential (infinite impulse response) filter with constant 0.1. This reduces noise seen readings factor
an112f
AN112-7
Application Note
Measurement Details take reading from given channel, processor must apply excitation transformer, wait voltage signal settle out, take reading with ADC, then remove excitation. This driven interrupt service routine that called once every millisecond. Refer Appendix code listing. Figure shows digital signals, excitation pulse, clamp voltage input along with code that performs these operations.3 Individual channels enabled loading byte with high into 74HC574 latch. Note that excitation applied after bits LTC1867 data read out. This perfectly acceptable, since there conversion taking place data LTC1867 output register static. Depending specific timing processor being used, excitation applied before reading data, middle reading data, after reading data before initiating conversion. serial clock very slow-1MHz instance, applying excitation before reading data would result excitation being applied which long. only constraint that voltage input must have enough time settle properly that excitation left long. Figure shows same signals over entire interrupt service routine. There similar analog signals each transformer other LTC1867 inputs. Adding More Channels There lots ways more channels this circuit. Figure shows channel concept. Figure decodes channels into eight banks eight channels using 74HC138 address decoders. selected bank corresponds LTC1867 input that programmed through interface. additional analog multiplexing done with 74HC4051 analog switches. single 74HC4051 feeding each LTC1867 input gives inputs. LTC1867 still great choice high channel count applications, rather than single channel ADC, because good idea break multiplexer trees into several stages minimize total channel capacitance. LTC1867 takes care last stage. with maximum sample rate 200ksps, digitize channels maximum 1ksps limitation sense transformer. That's batteries.
3Sometimes jack-of-all-trades exactly what need. high speed
AN112
highbyte spi_read (LTC1867CONFIG[j]);
output_d (LATCHWORD [j]);
output_high (LATCH); output_low (LATCH); output_low (CS);
output_high (EXCITATION);
delay_us (delay);
lowbyte spi_read (0);
output_high (CS);
Figure Pulse Generator Sequencing
output_low (EXCITATION);
AN112
digital designer would never dream trading good logic analyzer mixed-signal oscilloscope test signal integrity across complicated backplane. 100MHz analog channels pale comparison good four channel, half-gig scope. testing circuit with microcontroller data converters megasamples second, good mixed signal oscilloscope master trade.
Figure Scanning Channels
an112f
AN112-8
Application Note
74HC4051 74HC14 4.7k VN2222
2N3904
74HC138 LTC1867_CH7 LTC1867 INPUTS
CH63+ CH63-
EXCITATION
74HC14 4.7k VN2222
ADDITIONAL CIRCUITS BANK
2N3904 CH56+ CH56-
LTC1867_CH0 CHANNEL SELECTION WITHIN BANK 74HC138N BANK SELECTION (FOLLOWS SELECTED LTC1867 INPUT) EXCITATION
ADDITIONAL BANKS
74HC4051 74HC14
ADDITIONAL CIRCUITS
2N3904
74HC138 EXCITATION
CH7+ CH7-
4.7k VN2222
74HC14 4.7k VN2222
ADDITIONAL CIRCUITS BANK
2N3904 CH0+1 CH0-1
AN112
Figure 64-Channel Concept
an112f
AN112-9
Application Note
REFERENCES Williams, Jim, "Transformers Optocouplers Implement Isolation Techniques," "Isolated Temperature Measurement," pp.116-117. Magazine (January 1982) Williams, Jim, "Isolated Temperature Sensor," LT198A Data Sheet. Linear Technology Corporation (1983) Dobkin, "Isolated Temperature Sensor," LM135 Data Sheet. National Semiconductor Corporation (1978) Williams, Jim, "Isolation Techniques Signal Conditioning," "Isolated Temperature Measurement," pp.1-2. National Semiconductor Corporation, Application Note (May 1982) Sheingold, "Transducer Interfacing Handbook," "Isolation Amplifiers," 81-85. Analog Devices Inc. (1980) Williams, Jim, "Signal Sources, Conditioners Power Circuitry," "0.02% Accurate Instrumentation Amplifier with 120dB CMRR," 11-13. Linear Technology Corporation, Application Note (November 2004)
an112f
AN112-10
Application Note
APPENDIX Ears Goghs Things That Don't Work "battery stack problem" been around long time. Various approaches have been tried, with varying degrees success. problem appears deceptively simple; technically economically qualified solutions notably elusive. Typical candidates their difficulties presented here. Figure presumably solves problem converting cell potentials current, obviating high common mode voltages. amps feed multiplexed input A/D; decoded output presents individual cell voltages. This approach seriously flawed. Required resistor precision values unrealistic, becoming progressively more unrealistic number cells stack increases. Additionally, resistors drain current from cells, distinct often unallowable disadvantage. isolation amplifier based approach appears Figure Isolation amplifiers feature galvanically floating inputs, fully isolated from their output terminals. Typically, device
CELLS AMPLIFIERS
contains modulation-demodulation circuitry floating supply which powers signal input section4. amplifier inputs monitor cell; isolation barrier prevents battery stack common mode voltage from corrupting output referred measurement results. This approach works quite well but, requiring isolation amplifier cell, complex quite expensive. Some simplification possible; e.g., single power driver servicing many amplifiers, method remains costly involved. Figure employs switched capacitor technique measure individual cell voltage while rejecting common mode voltage. clocked switches alternately connect capacitor across associated cell discharge into output common referred capacitor.5 After number such cycles output capacitor assumes cell voltage. buffer amplifier provides output. This arrangement rejects common mode voltages requires many expensive high voltage switches, high voltage level shift nonoverlapping switch drive. More subtly, switch leakage degrades accuracy, particularly temperature
4See reference details isolation amplifiers. 5Old timers amongst readership will recognize this configuration derivative venerable reed switched "flying capacitor" multiplexer.
AN112 FA01
CELLS, REFERRED
Figure Unworkable Scheme Suppresses High Common Voltages Converting Cell Potentials Current. Circuit Decodes Amplifier Outputs Derive Individual Cell Voltages. Required Resistor Precision Values Unrealistic. Resistors Draw Current from Cells
an112f
MULTIPLEXER DECODE DATA OUTPUT
AMPLIFIERS
AN112-11
Application Note
CELLS ISOLATION AMPLIFIERS
ISOLATION AMPLIFIER
ISOLATION BARRIER
POWER FLOATING POWER SUPPLY FLOATING INPUT BATTERY STACK POWER COMMON POWER DRIVER OUTPUT DEMODULATOR FLOATING COMMON OUTPUT COMMON
MODULATOR
AN112 FA02
ISOLATION AMPLIFIER (DETAIL)
ISOLATION AMPLIFIER
CELLS
ISOLATION AMPLIFIERS
Figure Isolation Amplifier's Galvanically Floating Input Eliminates Common Mode Voltage Effects. Approach Works, Complex Expensive Requiring Isolation Amplifier Cell
an112f
AN112-12
Application Note
SWITCH-CAP SECTIONS CELLS
rises. Optically driven switches, particularly those available conveniently packaged driven MOSFETS, simplify level shift expense, voltage breakdown leakage concerns remain6. Switch related disadvantages eliminated Figure A4's approach. Each cell's potential digitized dedicated converter. output transmitted across isolation barrier data isolator (optical, transformer). most elementary form, each powered separate, isolated power supply. This isolated supply population reducible, cannot eliminated. Constraints include cell voltage A/D's maximum permissible supply input common mode voltages. Within these limitations, several channels serviceable isolated supply. Further refinement possible through employment multiplexed input A/Ds. Even with these improvements, numerous isolated supplies still mandated large battery stacks. Although this scheme technologically sound, complex expensive.
optically coupled variant this approach given Reference
OUTPUT COMMON
BATTERY STACK
SWITCH DRIVE- LEVEL SHIFT
OUTPUT COMMON
AN112 FA03
CELLS SWITCH-CAP SECTIONS
OUTPUT COMMON
Figure Switched Capacitor Scheme Rejects Common Mode Voltage Requires High Voltage Switches, Nonoverlapping Drive Level Shift. Switch Leakage Degrades Accuracy. Optically Driven Switches Simplify Level Shift Breakdown Leakage Issues Remain
ISOLATED SUPPLY DRIVE ISOLATION BARRIER CELLS SECTIONS ISOLATED SUPPLY OUTPUT COMMON REFERRED LOADS DATA ISOLATOR DATA COMMON POWER SUPPLY
ISOLATED SUPPLY BATTERY STACK
DATA ISOLATOR
DATA COMMON
ISOLATED SUPPLY
DATA ISOLATOR ISOLATION BARRIER
DATA COMMON
AN112 FA04
CELLS
SECTIONS
Figure Cell Requires Isolated Supplies Data Isolators. Multiplexed Input A/Ds Minimize Usage. Isolated Supply Population Reducible, Cannot Eliminated
an112f
AN112-13
Application Note
APPENDIX Floating Output, Variable Potential Battery Simulator Battery stack voltage monitor development aided floating, variable potential battery simulator. This capability permits accuracy verification over wide range battery voltage. floating battery simulator substituted cell stack desired voltage directly dialed out. Figure B1's circuit simply battery-powered follower (A1) with current boosted (A2) output. LT1021 reference high resolution potentiometric divider specified permits accurate output settling within 1mV. composite amplifier unloads divider drives 680F capacitor approximate battery. Diodes preclude reverse biasing output capacitor during supply sequencing 1F-150k combination provides stable loop compensation. Figure depicts loop response input step; overshoot untoward dynamics occur despite A2's huge capacitive load. Figure shows battery simulator response (trace trace transformer clamp pulse. Closed-loop control 680F capacitor limit simulator output excursion within 30V. This error small that noise averaging techniques high gain oscilloscope preamplifier required resolve
75k* TRIM LT1021 10.000V TRIM THIS VALUE THIS VOLTAGE
BAT85
100k**
LT1012
LT1010 150k OUTPUT
1N4001
METAL FILM RESISTOR DP-1311 KELVIN-VARLEY DIVIDER
680F
AN112 FB01
Figure Battery Simulator Floating Output Settable Within 1mV. Unloads Kelvin-Varley Divider; Buffers Capacitive Load
an112f
AN112-14
Application Note
5V/DIV 0.5V/DIV 50V/DIV NOISE AVERAGED
20ms/DIV
AN112 FB02
Figure 150k-1F Compensation Network Provides Clean Response Despite 680F Output Capacitor
2s/DIV
AN112 FB03
Figure Battery Simulator Output (Trace Responds Trace Transformer Clamp Pulse. Closed-Loop Control 680F Capacitor Maintain Simulator Output Within 30V. Noise Averaged, 50V/Division Sensitivity Required Resolve Response
APPENDIX Microcontroller Code Listing microcontroller code consists three files: Battery_monitor.c contains main program loop, including calibration temperature correction, support functions. Interrupts.c code timer2 interrupt that drives transformer excitation controls LTC1867 ADC. Battery monitor.h contains various defines, global variable declarations function prototypes.
an112f
AN112-15
Application Note
battery_monitor.c Channel Battery Monitor with continuous gain offset correction. Includes "factory calibration" feature. first power apply zero volts inputs, allow data settle, type `o'. Next apply 1.25V inputs, allow data settle, type `p'. This calibrates circuit, ready run. Offset correction technique: Present offset correction init_offset[7] voltage[7] Hotter less counts voltage[7] correction goes POSITIVE, this voltage[i] voltage[i] voltage[i] init_offset[i] present_offset Slope correction Technique: Initial slope init_fs[6] init_offset[7] counts 1.25V Present slope voltage[6] voltage[7] counts 1.25V Keyboard command summary: `a': increment conversion period (default 1ms) `z': decrement conversion period `s': increment `x': decrement `d': increment pulse-convert delay (default 2us) `c': decrement pulse-convert delay `f': increment pulse-convert delay `v': decrement pulse-convert delay `n': Calculate voltages display `m': Display values `t': Echo text terminal insert comments into data that being captured. Terminate with `k': Disable digital filter `l': Enable digital filter `o': Store offsets nonvolatile memory `p': Store full-scale readings nonvolatile memory Written Compiler Version 3.242 Mark Thoren Linear Technology Corporation January 2007 #include "battery_monitor.h" #include "interrupts.c" void main(void) int8 unsigned int16 adccode; float temp=0.0, offset_correction, slope, slope_correction; initialize(); rx_usb(); print_cal_constants(); Initialize hardware Wait until character received display calibration constants before starting.
while(1) if(usb_hit()) parse(); keyboard command necessary for(i=0; i<=7; ++i) Read data first readflag[i] Tell interrupt that we're reading!!
an112f
AN112-16
Application Note
adccode data[i]; readflag[i] temp (float) adccode; convert floating point if(filter) Simple exponential filter voltage[i] voltage[i]; voltage[i] 0.1* temp; else voltage[i] temp; if(calculate) Display temperature corrected voltages Calculate Corrections. offset correction stored reading minus present reading offset_correction read_offset_cal(7) voltage[7]; Slope correction stored slope based initial readings divided present slope. Units (dimensionless) slope_correction (float) read_fs_cal(6) (float) read_offset_cal(7); Initial counts/1.25V slope_correction slope_correction (voltage[6] voltage[7]); for(i=0; i<=5; ++i) Print Measurement Channels Units slope "volts count" slope 1.25000 ((float) read_fs_cal(i) Inefficient (float) read_offset_cal(i)); limited Correct initial offset temperature dependent offset. units temp "ADC counts" temp voltage[i] (float) read_offset_cal(i) offset_correction; Correct initial slope temp temp slope; Units temp "volts" Correct temperature dependent slope temp temp slope_correction; busbusy printf(tx_usb, "%1.5f, temp); busbusy busbusy Print terminal printf(tx_usb, "%1.6f, %1.1f, slope_correction, offset_correction); busbusy else Display counts for(i=0; i<=7; ++i) busbusy Print terminal printf(tx_usb, "%1.0f, voltage[i]); busbusy busbusy printf(tx_usb, "D:%d, P:%d\r\n", delay, period); print period delay busbusy Delay blink light delay_ms(100); output_high(PIN_C0); delay_ms(100); output_low(PIN_C0); //end loop //end main
an112f
AN112-17
Application Note
Parse keyboard commands arguments: none returns: void void parse(void) char switch(rx_usb()) case `a': period break; increment period case `z': period break; decrement period case `s': period break; increment case `x': period break; decrement case `d': delay break; increment pulse-convert delay case `c': delay break; decrement pulse-convert delay case `f': delay break; case `v': delay break; case `n': calculate break; Calculate voltages case `m': calculate break; Display values case `t': Echoes text terminal insert comments into data that being captured. Terminate with busbusy printf(tx_usb, "enter comment\r\n"); while((ch=rx_usb())!='!') tx_usb(ch); tx_usb(`\r'); tx_usb(`\n'); busbusy break; case `k': filter break; Disable filter case `l': filter break; Enable Filter case `o': write_offset_cal(); break; Store offset nonvolatile mem. case `p': write_fs_cal(); break; Store nonvolatile mem. Update period necessary write offset full-scale calibration constants non-volatile memory arguments: none returns: void void write_offset_cal(void) unsigned int16 intvoltage; for(i=0; i<=7; ++i) intvoltage (unsigned int16) voltage[i]; Cast unsigned int16 write_eeprom (init_offset_base+(2*i), intvoltage Write high byte delay_ms(20); write_eeprom (init_offset_base+(2*i)+1, intvoltage); Write byte delay_ms(20); void write_fs_cal(void) unsigned int16 intvoltage; for(i=0; i<=7; ++i)
an112f
AN112-18
Application Note
intvoltage (unsigned int16) voltage[i]; Cast unsigned int16 write_eeprom (init_fs_base+(2*i), intvoltage Write high byte delay_ms(20); write_eeprom (init_fs_base+(2*i)+1, intvoltage); Write byte delay_ms(20); read offset full-scale calibration constants from non-volatile memory arguments: none returns: void unsigned int16 read_offset_cal(int channel) return unsigned int16 read_fs_cal(int channel) return Print calibration constants (raw counts) arguments: none returns: void void print_cal_constants(void) for(i=0; i<=7; ++i) printf(tx_usb, "ch%d offset: %05Lu, %05Lu\r\n" Interface FT24BM controller usb_hit() arguments: none returns: data ready read, zero otherwise rx_usb() arguments: none returns: character from controller tx_usb() argments: data send returns: void char usb_hit(void) return !input(RXF_); char rx_usb(void) char buf; while(input(RXF_)) when data available, wait around output_low(RD_); delay_cycles(1); buf=input_d(); output_high(RD_); return(buf);
an112f
AN112-19
Application Note
void tx_usb(int8 value) while(input(TXE_)) //Low when FULL, wait around output_d(value); output_high(WR); delay_cycles(1); output_low(WR); input_d(); Hardware initialization arguments: none returns: void void initialize(void) output_high(ISO_PWR_SD_); //turn power setup_adc_ports(NO_ANALOGS); setup_adc(ADC_OFF); setup_psp(PSP_DISABLED); setup_spi(SPI_CONFIG); clock edges clock idles low, data changes falling edges, valid rising edges. output_low(I2C_SPI_); output_low(AUX_MAIN_); only MAIN setup_timer_1(T1_DISABLED); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); output_low(PIN_C0); delay_ms(100); output_high(PIN_C0); Turn LEDs output_high(PIN_C1); output_high(PIN_C2); Initialization input(RXF_); input(TXE_); output_high(RD_); output_low(WR); delay_ms(100); output_low(CS); delay_us(5); output_high(CS); Turn interrupts (only one) enable_interrupts(INT_TIMER2); enable_interrupts(GLOBAL);
an112f
AN112-20
Timer Interrupt This interrupt service routine does work controlling transformer excitation controlling LTC1867. #int_TIMER2 Tell compiler that this Timer TIMER2_isr() static int8 ledstatus; int8 highbyte, lowbyte; if(++ledstatus 0x80) output_low(LED); Blink light every calls if(ledstatus 0x00) output_high(LED);
if(!busbusy) main() using bus, nothing. for(j=0; j<=7; ++j) output_d(LATCHWORD[j]); Place excitation data output_high(LATCH); Latch data output_low(LATCH); output_low(CS); Enable LTC1867 serial interface highbyte spi_read(LTC1867CONFIG[j]); Read high byte. Acquisition begins falling clock edge output_high(EXCITATION); Apply transformer excitation delay_us(delay); Wait analog signal settle lowbyte spi_read(0); Finish reading data. Input also settling During this time. output_high(CS); Start conversion!!! output_low(EXCITATION); Remove excitation. instruction cycle plenty "analog hold time" if(!readflag[j]) data[j] make16(highbyte, lowbyte); Don't write main() reading!! This simple anti-collision technique. worst case latency single reading, 1ms. }//end loop }//end if(!busbusy)
Application Note
AN112-21
an112f
Application Note
battery_monitor.h defines, global variables, function prototypes #include <16F877A.h> Standard header #device adc=8 #use delay(clock=20000000) Clock frequency 20MHz #use #define SPI_CONFIG 5MHz when master 20MHz //#fuses NOWDT,RC, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, LVP, NOCPD, NOWRT This less confusing configuration word with #rom statement Function DEBUG WRT1 WRT0 BOREN PWRTEN# WDTEN FOSC1 FOSC0 #rom 0x2007 {0x3F3A} Battery Monitor Project Defines Global variables int16 data[8]; data from LTC1867 int8 readflag[8]; Tells that main reading data, write int1 busbusy Tells that main talking int1 calculate Send calculated voltages terminal when asserted int1 filter Enables digital filter when asserted unsigned int8 period Period between reads unsigned int8 delay Additional settling time after applying excitation float voltage[8]; Holds floating point calculated voltages Non-volatile memory base addresses calibration constants #define init_offset_base #define init_fs_base First, define words sent LTC1867 Single ended, unipolar, 4.096V range. #define LTC1867CH0 0x84 #define LTC1867CH1 0xC4 #define LTC1867CH2 0x94 #define LTC1867CH3 0xD4 #define LTC1867CH4 0xA4 #define LTC1867CH5 0xE4 #define LTC1867CH6 0xB4 #define LTC1867CH7 0xF4 Excitation enable lines. Write this `574 register before enabling excitation pulse. #define EXC0 0x01 #define EXC1 0x02 #define EXC2 0x04 #define EXC3 0x08 #define EXC4 0x10 #define EXC5 0x20 #define EXC6 0x40 #define EXC7 0x80
an112f
AN112-22
Application Note
define lookup tables such that excitation signal lines with selected LTC1867 input. byte CONST LTC1867CONFIG {LTC1867CH1, LTC1867CH2, LTC1867CH3, LTC1867CH4, LTC1867CH5, LTC1867CH6, LTC1867CH7, LTC1867CH0}; byte CONST LATCHWORD {EXC6, EXC5, EXC4, EXC3, EXC2, EXC1, EXC0, EXC7}; //Pin Definitions #define EXCITATION #define LATCH #define #define #define #define #define #define #define #define RXF_ TXE_ ISO_PWR_SD_ LCD_EN PIN_B0 PIN_B1 PIN_C1 PIN_A0 PIN_A1 PIN_A2 PIN_A3 PIN_A4 PIN_A5 PIN_B5 PIN_E1 PIN_E2 Enables excitation selected channel 74HC573 latch Spare blinky light
#define AUX_MAIN_ #define I2C_SPI_ #byte SSPCON #byte SSPSTAT #bit #bit
0x14 0x94 SSPCON.4 SSPSTAT.6
Function Prototypes void parse(void); void write_offset_cal(void); void write_fs_cal(void); unsigned int16 read_offset_cal(int channel); unsigned int16 read_fs_cal(int channel); void print_cal_constants(void); char usb_hit(void); void initialize(void); void tx_usb(int8 value); char rx_usb(void);
an112f
Information furnished Linear Technology Corporation believed accurate reliable. However, responsibility assumed use. Linear Technology Corporation makes representation that interconnection circuits described herein will infringe existing patent rights.
AN112-23
Application Note
an112f
AN112-24
Linear Technology Corporation
1630 McCarthy Blvd., Milpitas, 95035-7417
(408) 432-1900 FAX: (408) 434-0507
0307 PRINTED
www.linear.com
LINEAR TECHNOLOGY CORPORATION 2007

Other recent searches


ST2305 - ST2305   ST2305 Datasheet
S1F76640 - S1F76640   S1F76640 Datasheet
PD78F0511 - PD78F0511   PD78F0511 Datasheet
78F0512 - 78F0512   78F0512 Datasheet
78F0513 - 78F0513   78F0513 Datasheet
OP1177 - OP1177   OP1177 Datasheet
OP2177 - OP2177   OP2177 Datasheet
OP4177 - OP4177   OP4177 Datasheet
MMFT3055V - MMFT3055V   MMFT3055V Datasheet
M3500-0102 - M3500-0102   M3500-0102 Datasheet
F-1900 - F-1900   F-1900 Datasheet
ECG004 - ECG004   ECG004 Datasheet
BCM5241 - BCM5241   BCM5241 Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive