Top Banner
12 Issue 143 June 2002 CIRCUIT CELLAR ® www.circuitcellar.com hate to see folks suffer with old-fashioned reme- dies. After three decades of such anguish, I decided that enough is enough. So what am I talking about? Well, my focus for today’s pain relief is related to monitoring the battery packs used in RC models. The cure comes as BatMon, the sophisticated battery mon- itoring accessory shown in Photo 1. I started flying RC model aircraft in the late 1960s. Back then, I was a young lad with an expensive hobby support- ed by neighborhood lawn mowing jobs. Because of my limited budget, I used inexpensive Rayovac carbon zinc cells in my RC transmitters and receivers. My radio gear was simple and this was a suitable solution. But, affordable digital proportional radios eventually came along and the battery needs changed dramatically. Rechargeable NiCd battery packs became the power source of choice. The common configuration for air- borne electronics was a four-cell pack that provided 4.8 VDC. Battery capaci- ties were typically 500 to 600 mAh. Checking the battery was something of a witch hunt. You would measure the pack with a voltmeter modified to expand the reading near the nominal 4.8-V range. A flashlight bulb was used as a moderate resistive load. A meas- urement that was under 4.7 V would indicate that it was time to end the day, because the pack was unsafe to fly. A higher voltage was assumed to be good to go. It was a reliable method if you observed its limitations, but at best it only offered a pass/fail status. Other than by gut-felt experience, you never really knew the true dis- charge state of the pack. But given the needs of the day and the available tech- nology, I was happy with the voltmeter test. Sure, new folks to the hobby would occasionally misuse the method (or ignore the test) and fly on a near empty pack. Even the pros did this from time to time. As you can guess, an airborne RC model with a dead bat- tery is not a pretty sight. Fortunately, balsa wood was cheap back then. Because a battery’s storage capacity is analogous to a car’s fuel tank, I want- ed to be able to see the charge level in the same way a gas gauge works in a car. That would be much better than the voltage method, because a peek at the remaining capacity would offer advanced warning if I were flying on fumes, so to speak. The underlying problem is that the discharge voltage curves for NiCd bat- teries are not linear. In fact, they spend nearly all of their useful dis- charge time at 1.2 V per cell. To com- plicate matters, the voltage is affected by the load (servo movement) and out- side temperature. The voltage charac- teristics also change as the battery ages. Predicting the remaining battery capacity with any accuracy was out of the question for the average modeler. Fast forward about 30 years. I now fly RC model helicopters. These high- tech aircraft are notorious for consum- ing battery current because the servos are quite active and under a heavy load. But, no matter what type of model is flown (or driven), I still use NiCd bat- tery packs. Following them in populari- ty are the nickel metal hydride (NiMh) type. Both chemistries provide 1.2 V per cell and are rechargeable. Their nonlinear discharge curves have not changed much. There are other battery technologies that are in use, but these two are used by most RC hobbyists. BatMon to the Rescue i For years, hobbyists have relied on volt- meters and guesswork to monitor the storage capacity of battery packs for RC models. Now, Thomas intro- duces a more precise high-tech battery moni- tor that is small enough to be mounted in the cockpit of an RC model helicopter. Thomas Black FEATURE ARTICLE A Battery Monitor for RC Applications
8

BatMon to the Rescue - Circuit Cellarcircuitcellar.com/wp-content/uploads/2012/07/CC-Issue143-Black.pdf · borne electronics was a four-cell pack that ... needs of the day and the

Apr 15, 2018

Download

Documents

phungdat
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: BatMon to the Rescue - Circuit Cellarcircuitcellar.com/wp-content/uploads/2012/07/CC-Issue143-Black.pdf · borne electronics was a four-cell pack that ... needs of the day and the

12 Issue 143 June 2002 CIRCUIT CELLAR® www.circuitcellar.com

hate to seefolks suffer with

old-fashioned reme-dies. After three decades

of such anguish, I decided that enoughis enough. So what am I talking about?Well, my focus for today’s pain relief isrelated to monitoring the battery packsused in RC models. The cure comes asBatMon, the sophisticated battery mon-itoring accessory shown in Photo 1.

I started flying RC model aircraft inthe late 1960s. Back then, I was a younglad with an expensive hobby support-ed by neighborhood lawn mowingjobs. Because of my limited budget, Iused inexpensive Rayovac carbon zinccells in my RC transmitters andreceivers. My radio gear was simpleand this was a suitable solution.

But, affordable digital proportionalradios eventually came along and thebattery needs changed dramatically.Rechargeable NiCd battery packsbecame the power source of choice.The common configuration for air-borne electronics was a four-cell packthat provided 4.8 VDC. Battery capaci-ties were typically 500 to 600 mAh.

Checking the battery was somethingof a witch hunt. You would measurethe pack with a voltmeter modified toexpand the reading near the nominal

4.8-V range. A flashlight bulb was usedas a moderate resistive load. A meas-urement that was under 4.7 V wouldindicate that it was time to end theday, because the pack was unsafe tofly. A higher voltage was assumed tobe good to go. It was a reliable methodif you observed its limitations, but atbest it only offered a pass/fail status.

Other than by gut-felt experience,you never really knew the true dis-charge state of the pack. But given theneeds of the day and the available tech-nology, I was happy with the voltmetertest. Sure, new folks to the hobbywould occasionally misuse the method(or ignore the test) and fly on a nearempty pack. Even the pros did thisfrom time to time. As you can guess,an airborne RC model with a dead bat-tery is not a pretty sight. Fortunately,balsa wood was cheap back then.

Because a battery’s storage capacityis analogous to a car’s fuel tank, I want-ed to be able to see the charge level inthe same way a gas gauge works in acar. That would be much better thanthe voltage method, because a peek atthe remaining capacity would offeradvanced warning if I were flying onfumes, so to speak.

The underlying problem is that thedischarge voltage curves for NiCd bat-teries are not linear. In fact, theyspend nearly all of their useful dis-charge time at 1.2 V per cell. To com-plicate matters, the voltage is affectedby the load (servo movement) and out-side temperature. The voltage charac-teristics also change as the batteryages. Predicting the remaining batterycapacity with any accuracy was out ofthe question for the average modeler.

Fast forward about 30 years. I nowfly RC model helicopters. These high-tech aircraft are notorious for consum-ing battery current because the servosare quite active and under a heavy load.But, no matter what type of model isflown (or driven), I still use NiCd bat-tery packs. Following them in populari-ty are the nickel metal hydride (NiMh)type. Both chemistries provide 1.2 Vper cell and are rechargeable. Theirnonlinear discharge curves have notchanged much. There are other batterytechnologies that are in use, but thesetwo are used by most RC hobbyists.

BatMon to the Rescue

iFor years, hobbyistshave relied on volt-meters and guessworkto monitor the storagecapacity of batterypacks for RC models.Now, Thomas intro-duces a more precisehigh-tech battery moni-tor that is smallenough to be mountedin the cockpit of an RCmodel helicopter.

Thomas Black

FEATUREARTICLE

A Battery Monitor for RC Applications

cabate
Text Box
Copyright Circuit Cellar, Inc. This article cannot be reprinted without permission: [email protected]. To subscribe: http://circuitcellar.com/subscription/
Page 2: BatMon to the Rescue - Circuit Cellarcircuitcellar.com/wp-content/uploads/2012/07/CC-Issue143-Black.pdf · borne electronics was a four-cell pack that ... needs of the day and the

www.circuitcellar.com CIRCUIT CELLAR® Issue 143 June 2002 13

mount in each model aircraft (seeFigure 1). This is not your typical larg-er-than-life Gotham City solution. It’sonly 1.3″ × 2.8″ and weighs one ounce.But the BatMon does have the typicaldual persona expected of a super hero.

For user simplicity, it reports batterycapacity as a zero to nine (0% to 90%)level value. This is my favorite modebecause it works just like a car’s gasgauge. However, for those of you whomust see hard numbers, it also reportsthe actual remaining capacity—up to2500 mAH—with 5% accuracy.

In addition, it reports problems asso-ciated with battery pack failures, badon/off switches, and defective servos.A super-bright LED indicator flashes ifany trouble is detected. Even in mod-erate sunlight this visual indicator canbe seen from a couple hundred feetaway, which is perfect for fly-by checks.

The BatMon is compatible with allof the popular battery sizes. Packcapacities from 100 mAH to 2500 mAHcan be used. They can be either four-cell or five-cell of either NiCD orNiMH chemistries. The battery param-eters are programmed by using a pushbutton and simple menu interface.

The device has three connections.Two of the RC-style connectors areinserted in series with the battery pack.Because you are making current meas-urements, this sort of intimate connec-tion is necessary. There is a third con-nector that plugs into a spare channelof the RC receiver (or you can use aY adapter on any servo). This connectorenables the display when the RCreceiver’s power switch is turned on.

The thought of losing control of aflying model, due to a defect in theBatMon, was not something that Iwanted to encourage. My main concernwas that the BatMon circuitry wasdirectly in the path of the RC equip-ment’s battery. Fortunately, only threepassive components are in this criticalarea, and two of them are RC type con-nectors. The third is a shunt resistorthat was carefully selected to ensurereliable operation. If you assemble theBatMon correctly, it will not pose arisk to your equipment’s reliability.

Perhaps the most important ele-ment of the project was the display. Isearched for a suitable two-line LCD,

We still use four cells to power ourreceivers and servos. Some folks haveimplemented five-cell power sourcesto turbo charge their servo speeds. Overthe years, the packs’ milliamp-hourscapacities have dramatically increasedand the size and weights have tumbled.I am happy to report that cell reliabilityis extraordinary. Battery troubles nowa-days are nearly always self-inflicted.

But, the same inaccurate voltagetest is used to determine the dischargestate of battery packs. Oh sure, themeasuring devices have transformedinto cute bar graph indicators, brightLEDs that blink morse code warnings,and audio beepers. Of course theexpanded scale voltmeters that we usedin the old days are still popular, too.But all of these methods rely on thesame brainless go/no-go voltage test.

So, what gives? The battery gaugingtechnology required to report the trueremaining cell capacity (milliamphours) has been around for years. Thisis common practice in portable com-puters and other consumer devices.Patiently, I waited for an RC batterygauge to show up at the hobby store.

Sadly, a little on-board gadget thatwould work with my RC receiver nevermaterialized on the store shelf. Severalyears ago there was a rumor that onewas available, but it quickly disap-peared long before I could get my handson one. Today, electric model hobbyistsuse the digital watt-meter devices, butthey are designed to monitor the heavycurrents consumed by electric motors.I wanted finer resolution so I coulduse it with my RC receiver and servos.

With that in mind, a couple of yearsago, I convinced my firm that weshould tackle this challenge. Althoughwe were not in the RC equipment busi-ness, there was some interest. It wasdecided that I would develop a proto-type that would act as a proof-of-con-cept. The premise was that if I couldstir up some interest among local RCpilots, then a more advanced designwould follow before we attempted topitch it to the hobby industry. Withluck, this was to become a low-costRC accessory at the local hobby store.

As you will soon see, the project wascompleted and has served me well forover two flying seasons. Sadly, it did

not become a commercial offering.I’m happy to report, however, that Ifinally have what I always wanted andI’m pleased to share it with all of myRC comrades. The project is well suit-ed for monitoring the battery in near-ly any electronic device, so its use isnot limited to RC applications.

At the start of the project, I assumedthat the most logical design centeredon installing the tiny battery gaugingIC inside the battery pack. A specialhand-held LCD readout would pluginto the model’s charge jack (a handyplace to do so). It would extract theremaining capacity via the unused con-nector pin found on all RC receiver bat-teries. The nice thing about having thedata stored inside the battery is that itallows you to swap the pack and thedata remains with it. It also appearedto be a cost-effective arrangement.

But this solution was soon deemedunacceptable for several reasons. First,existing battery packs would need tobe outfitted with the special IC. Thisis a low-cost effort at the time of packassembly, but a retrofit connector-basedsolution would be more costly. Also, itwas not common to swap packs in thefield, so this assumed advantage reallydid not add much value. But mostimportantly, this concept did not haveany visual warning features that wouldalert you of pack trouble while flying.

My solution evolved into theBatMon, a standalone device that can

4.8- or 6-Vbattery

8

BAT RX AUX

BatMon

RadioControlRCVR

BATCH1CH2CH3CH4

Connect to any channel

Chargeplug

On/off

Figure 1—Installation in an RC model is as simple asplugging in three cables. Multiple point measurementsallow the system to detect battery-related trouble.Voltage detection at the RC receiver even helps detectstalled servos and electrical issues.

cabate
Text Box
Copyright Circuit Cellar, Inc. This article cannot be reprinted without permission: [email protected]. To subscribe: http://circuitcellar.com/subscription/
Page 3: BatMon to the Rescue - Circuit Cellarcircuitcellar.com/wp-content/uploads/2012/07/CC-Issue143-Black.pdf · borne electronics was a four-cell pack that ... needs of the day and the

components required to use theDS2438. RSENSE is a fractional ohmcurrent sense resistor. RF and CF areconfigured as an input filter. Don’t letthis simplicity fool you, this fellowhas a lot going on under the hood.

The DS2438 is a register-baseddevice. The registers are accessed bythe host through a clever bidirectionalcommunication scheme. If you haveever used a low-pin-count Dallas ICbefore, then you are no doubtacquainted with the company’s one-wire bus protocol. The chip is self suf-ficient and can operate by itself afterthe host has configured it. A niftyone-wire trick is that the registers canbe accessed even if the battery sourceis completely dead. This feature is notneeded in the BatMon design.

In the BatMon, the one-wire busbegins at pin 6 (port RA4) of thePIC16C63 microcontroller and termi-nates at the DS2438’s DQ I/O line (pin8). Using bit-banging I/O, the PIC canread and write the necessary registers.The timing is critical, but the PIC iscapable of handling the chore. Full

14 Issue 143 June 2002 CIRCUIT CELLAR® www.circuitcellar.com

but I didn’t find any decent offerings. Idecided to use a seven-segment LEDdisplay for the initial design. I reck-oned that a custom LCD would needto wait for a production version of theBatMon. In retrospect, the LED dis-play works surprisingly well.

The seven-segment display willaccommodate one character at a time.This works nicely with the zero tonine battery level values, but sometrickery is used to show the four-digitcapacity and two character errorcodes. These values are merely“spelled out” in a flash card sort ofway. For example, 575 mAH wouldrepeatedly flash as “5,” “7,” or “5.”

An issue with the LED readout isthat it consumes almost 60 mA of cur-rent. Because it does not need to be onwhile the aircraft is flying, it can beset to display only when you press thepush-button switch. Upon release itwill shut off after a few seconds. As aconvenience, the level value flashesevery 5 s when the display is off. But, ifyou want the display active at all times,you can set the BatMon to do so.

The battery gauging IC that I usedis from Dallas Semiconductor. Thereare other firms that have similar parts(Unitrode, TI, etc.), but the DallasDS2438 Smart Battery Monitor was aperfect choice for my RC application(see Figure 2). This eight-pin coulomb-counting chip contains an A/D-basedcurrent accumulator, A/D voltageconvertor, and a slew of other featuresthat are needed to get the job done.The famous Dallas one-wire I/Omethod provides an efficient interfaceto a PIC16C63 microcontroller.

There’s a lot I could say about theDS2438, but the Dallas folks have donea fine job of explaining its operation inthe 30-page datasheet. But, I will gladlytake you for a quick stroll just to helpacquaint you with some areas of inter-est. You will quickly realize that thechip has significant smarts built into it.

Looking at the block diagram inFigure 3, you can see that there arefew connections to the outside world.Communication to the host requiresonly one pin. Besides a host microcon-troller, there are only three external

Figure 2—A battery fuel gauging ICand a microcontroller are combined toaccurately measure the current con-sumption of an RC system. The single-character LCD is used to display bat-tery data and status messages.

cabate
Text Box
Copyright Circuit Cellar, Inc. This article cannot be reprinted without permission: [email protected]. To subscribe: http://circuitcellar.com/subscription/
Page 4: BatMon to the Rescue - Circuit Cellarcircuitcellar.com/wp-content/uploads/2012/07/CC-Issue143-Black.pdf · borne electronics was a four-cell pack that ... needs of the day and the

MBasic Software

Whether your just learning or a professional, Programming PICmicro®MCUs has never been easier ! MBasic is much simpler than C orAssembly. MBasic creates a one click solution that allows you toexperiment and test code changes on-the-fly! Bring your projects to lifequicker and easier with MBasic for PICmicro® MCUs !

ICD - In Circuit Debugger

Stop wasting time strategically planting debug statements throughoutyour entire program. MBasic includes a built-in ICD (In CircuitDebugger ) FREE. Watch variables, SFRs and RAM values as eachline executes. MBasic’s ICD is so easy to use, even the first time usercan have it up and running in minutes !

MBasic and Assembly Language

Seasoned Assembly programmer or just learning ? MBasic allows aneasy mix of BASIC and Assembly. Instead of spending weeks writingyour program, have it done in days !

Syntax

A complete set of easy to use commands ! Serin, Serout,If..Then..Elseif..Else..Endif, Do..While, While..Wend, OWin, OWout,ADin, Pulsin, Pulsout, PWM, Xin, Xout and more! Plus easy acces toall PICmicro built-in hardware peripherals.

Math

MBasic is the only BASIC compiler that supports 32 bit floating pointand integer math. This includes 32 x 32 bit divides and multiplies.

MBasic Pro Only $229.95

Includes Printed Manual and CD-ROM with MBasic.

ISP-PRO Programmer

- Uses PC Serial port (USB w/ adapter)- Very Simple to use- Free Software updates- Complete with Windows IDE!- Easy in-circuit programming- Supports PIC, Scenix, I2C and more!- Firmware upgrades Free!- RJ-11 / 10 Pin Header- Includes RJ-11 Cable

Solderless Development

- Completely Assembled Board- In Circuit Programmable (ISP)- Solderless Bread Board- Built in RS232 (w/ Max232)- Built in Power Connector- Removable Oscillator- Documentation- Auto Disconnect for RB3, RB6, & RB7- Available in several models

Development Kit

Includes: - MBasic Pro Compiler - 2840 Development Board - ISP-PRO Programmer - PIC16F876-20 - 10Mhz Resonator - Serial Cable - Power Supply - CD-ROM and Manual

Download MBasic

Lite FREE !

Starting At $159.95Starting At $59.95Only $59.95

Learn to Program PIC Microcontrollers in easy to use BASIC

Optional ISP-PRO

Items Available

- Plastic Enclosure- 40 Pin Zif Adapter- Universal Adapter

Try before you buy !

PIC

MIC

RO

MC

U® TO

OLS

www.basicmicro.com

!"

#"$%&'M i crocont ro l l e rs M ad e Easy™

MBASIC is a registered trademark of Basic Micro Inc.

PICmicro is a registered trademark of Microchip Inc.

Join our on-line PIC forums, information and help FREE!!!

Page 5: BatMon to the Rescue - Circuit Cellarcircuitcellar.com/wp-content/uploads/2012/07/CC-Issue143-Black.pdf · borne electronics was a four-cell pack that ... needs of the day and the

16 Issue 143 June 2002 CIRCUIT CELLAR® www.circuitcellar.com

details of the I/O protocol are outlinedin the DS2438 datasheet, so I won’trepeat them here.

The integrated current accumulator(ICA) register is the main workhorseinside this petite part. It records currentconsumption using a coulomb-countingscheme. An internal oscillator sam-ples the voltage across the RSENSEresistor (R12) at a rate of 36.4 timesper second. The RC filter (R2 and C2)has a cutoff of about 16 Hz, whichtames noise but allows the neededcurrent spikes to be captured.

Because small current ADC offseterrors can severely affect the long-termaccuracy of the ICA, the DS2438 has aregister that cancels the offset currents.The offset register makes the correction.The BatMon is designed to use thisclever nonvolatile R/W register. Thereis a special user-invoked mode thatinitializes the correction value. This isdone using the push-button switchafter the board is assembled. For fulldetails to the offset calibration, readthe user guide, which can be down-loaded from the Circuit Cellar ftp site.

The DS2438 has registers that reportinstantaneous current, battery voltage,and external voltage. These featureswere a blessing to the project. But notall of the goodies were needed. Thetemperature, elapsed time meter (ETM),disconnect time stamp (DT), chargecurrent accumulator (CCA), dischargecurrent accumulator (DCA), and end-of-charge (EOC) registers are all ignored.These features are available if you wishto expand the functionality of theBatMon. For example, cold battery tem-peratures will reduce effective capacity,so the temperature register could beused to adjust the reported values.

After the PIC has initialized theDS2438, battery consumption is auto-matically tallied by the ICA register. Ithas eight scaled bits of resolution, sothe sense resistor (R12) determines thebit weights. With the selected 0.050-Ωvalue, each count is 9.765 mAH, whichresults in a max count of 2500 mAH.

The ICA can sense the direction ofcurrent flow, so the accumulator countsdown during battery discharge andcounts up during recharge. The ICAregister is read by the PIC16C63 every100 ms and the value is scaled into

milliamp-hours and a zero to nine level.You decide what to display on theseven-segment LED. You can toggle thetwo measurements (level versus capaci-ty) by pressing the push-button switch.

I also wanted to accommodate someof the oddities that are associated withNiCd and NiMh batteries. For onething, they are not 100% efficient dur-ing the charge cycle. They also tend toself-discharge when they are resting. Topartially mask these issues, the PICcompensates the values held in the ICAregister. During a charge cycle, thePIC reduces the ICA’s value by about20%. This mimics an 80% charge effi-ciency. During idle periods, the ICA isreduced by 2% every 24 h.

Both of these corrections are practicalvalues and work well. Zealots mayargue that the values are too general-ized, but hey, these are often the sameguys who use a voltmeter to checktheir packs. Besides, the BatMon doesnot change the way you maintain yourbatteries, so a fresh charge is alwaysexpected before using them. Thisrequirement makes the correctionprocess unnecessary, but I added it tothe software anyway.

Limiting the BatMon’s job to merefuel gauging would have been short-sighted. After all, there are all sorts ofthings that can go wrong but can easi-ly be detected by monitoring thepack’s voltage under load. The DS2438can measure two voltages, so it waselected to lend a helping hand.

Photo 1—The BatMon is small enough to fit in mostRC models. The three cables plug into the model’sRC system. A bright LED remotely warns the pilot ofbattery trouble. The single character display reportsthe remaining capacity of the battery.

cabate
Text Box
Copyright Circuit Cellar, Inc. This article cannot be reprinted without permission: [email protected]. To subscribe: http://circuitcellar.com/subscription/
Page 6: BatMon to the Rescue - Circuit Cellarcircuitcellar.com/wp-content/uploads/2012/07/CC-Issue143-Black.pdf · borne electronics was a four-cell pack that ... needs of the day and the

!"#$% &"''(

$) * + , $ -+ .+ +$%

/0'*("0" 12 " "" ( (' 3"!#

/0'*(""" /2 " "" ( (' 3""

/0'*((0" 12 " (/ 4 (' 3"/1

/0'*(("" /2 " (/ 4 (' 3""/

!"#!$% &'#!

(!)!&

* +&)!* +,-#!

!

"#$%&'(#)*($

!"#$"!%&'

&#,&,./%%0)())(*)++

/0'*("0"

&% ,,,**#-

+ , - + , . / ! 0 , # + / 0 !1

Page 7: BatMon to the Rescue - Circuit Cellarcircuitcellar.com/wp-content/uploads/2012/07/CC-Issue143-Black.pdf · borne electronics was a four-cell pack that ... needs of the day and the

even if the aircraft is flying. It willflash a single wink if the batterycapacity is low (under 30%). A double-wink indicates a more serious issuethat needs immediate attention.

One of the issues that needed to beaddressed was that the end user’s bat-tery pack ratings can vary. To workeffectively, the BatMon needs to knowthe pack’s rated voltage and milliamp-

hours capacity. After all, the modelcould be equipped with nearly any packcapacity. To complicate matters, fourcells (4.8 VDC) or five cells (6 VDC)might be installed. The solutioninvolves the push-button switch andsome fancy footwork.

There is a special programming menuthat can be activated by following acertain power-on sequence. First, turnon the model’s power using its on/offswitch. Wait for the display to appear.Second, turn off the power. Immediatelypress and hold the push-button switch(SW1). Third, within 2 s, turn on thepower and confirm that the displayshows a flashing “P.”

From this point you can traverse thedifferent menu settings by quicklycycling the on/off switch. Items in amenu are selected by pressing the pushbutton. You can choose cell capacity(100 to 2500 mAH), cell count (four orfive), and other features. Full detailsare contained in the user guide.

The PIC16C63 firmware was writ-ten in C using CCS’s PIC C Compiler.It uses all but about a dozen bytes of

18 Issue 143 June 2002 CIRCUIT CELLAR® www.circuitcellar.com

The PIC reads the two independentvoltage measurements and determinesif they are within safe limits. The bat-tery voltage is measured at theDS2438’s V+ and V– pins. The batterypack is a low-impedance currentsource, so the voltage drop is smallunder the expected loads. However, ifthe voltage is too low, the display willreport a U1 error (battery voltage low).This can trap charge issues, cell fail-ures, or serious current draw problemsfrom the servos.

The other measured voltage is on theswitched side of the RC system’s on/offswitch, complements of the DS2438’sVAD input (pin 4). Because this meas-urement is made on the RC receiver’sload side, it will see a higher nominalvoltage drop. If it is excessive, a U2(bad switch, weak battery, stalledservo) or U3 (low battery voltage,binding servo) error will be reported.

If any trouble is detected, the LEDstatus indicator will flash. This LEDcan be installed on the PCB orremotely mounted on the aircraft. It isbright, so you should be able to see it

Photo 2—Here's how the battery monitor looksinstalled in the RC model helicopter’s cockpit. You canuse the BatMon on RC airplanes, cars, and boats too.Or, you could adapt the design for battery monitoringapplications that aren’t RC-related.

cabate
Text Box
Copyright Circuit Cellar, Inc. This article cannot be reprinted without permission: [email protected]. To subscribe: http://circuitcellar.com/subscription/
Page 8: BatMon to the Rescue - Circuit Cellarcircuitcellar.com/wp-content/uploads/2012/07/CC-Issue143-Black.pdf · borne electronics was a four-cell pack that ... needs of the day and the

the 40-KB code space. If youwish to add features, youshould plan on upgrading toa different MCU.

All of the important tasksare performed by the real-time kernel, which is doneby the serv_jiffy() func-tion (a simple task schedulerthat’s synchronized toTimer 1). It has 50-ms resolu-tion and can launch sequen-tial tasks at periods up toonce per minute. It is calledfrom the main function inorder for the PIC’s sleep cycleto easily utilize it.

Speaking of the sleepcycle, when the equipment isturned off, the PIC is shutdown after a few seconds ofbeing idle. The operating cur-rents are reduced to ~180 µAwhile in Sleep mode. To achieve thislow current, you must disable thebrownout fuse during chip burning.

During Sleep mode, the PIC wakesup periodically to calculate the self-discharge and charge correction values.It is also during this period that itchecks to see if the RC power switchhas been turned on. If so, the PIC fullywakes up, enables the display, and per-forms all of the monitoring features.

The software is fully documented. Itwill not be easy to dissect my code,however, all of the information to doso is in the source text. Given the sizeof the program and some of its com-plexities, I’m sorry to say that I willnot be able to answer specific questionsconcerning the software’s C functions.Besides, there’s no fun in being spoon-fed all of the answers. So, just roll upyour sleeves and study the code.

The BatMon is not a good candidatefor perfboard construction. A big issueis that RC models present a harshoperating environment. Vibration andless than pleasant landings demandthat you use rugged electronic assem-bly techniques. My vote is that youdesign a circuit board for it. It is not acomplicated circuit, so with the helpof a freeware PCB program you shouldbe on your way. My latest version usednearly all through-hole parts. I couldhave accomplished drastic size reduc-

www.circuitcellar.com CIRCUIT CELLAR® Issue 143 June 2002 19

SOFTWARETo download the software and usersguide, go to ftp.circuitcellar.com/pub/Circuit_Cellar/2002/143/.

SOURCESPIC C CompilerCustom Computer Services, Inc.(262) 797-0455 www.ccsinfo.com

DS2438 Battery MonitorDallas Semiconductor, Inc.(972) 371-4000 www.dalsemi.com

PIC16C63 MicrocontrollerMicrochip Technology, Inc.(480) 786-7200www.microchip.com

tions if I used the SMT components. Please be aware that sloppy PCB

layouts may allow the 3.58-MHzoscillator to radiate unwanted har-monics. This could cause interferencewith RC receivers. Lastly, the currentsense resistors’ accuracy can be com-promised if you are not careful how itis connected to the DS2438. You canexpect inaccurate capacity values ifthe sense line traces are in the cur-rent carrying path.

The connections to the battery packand receiver are made with standardRC hobby servo connectors. They areavailable at most RC hobby shops. Youwill need a 22-AWG, two-conductorfemale cable for the battery (J1), a 22-AWG, two-conductor male for the RCswitch (J2), and a three-conductor (anyAWG) for the Aux In (J3) connector.Please note that the battery cables areheavy-gauge to minimize voltagedrops. Keep them short (less than 6″)and strain relief all cables at the PCB.

I found that large heat shrink tub-ing makes a robust enclosure for thefinished unit. The tubing I used is thetype that is designed for RC batterypacks. It is low cost and is sold by thefoot at most hobby shops that special-ize in RC cars. You can also use theheat shrink tubing that is sold as cov-ering material for the main blades onRC model helicopters.

Thomas Black designs and supportshigh-tech devices for the consumerand industrial markets. He is currentlyinvolved in telecom test products.During his free time, he can be foundflying his RC models. Sometimes heattempts to improve his models bycreating odd electronic designs, mostof which are greeted by puzzledamusement from his flying pals.

All you have to do is cutsmall holes for the threecables, slide it on, shrinkit, and then trim someopenings for the LED’s andswitch. With some addi-tional trimming, I can cre-ate flaps on the open endsthat are easily bent downand glued in place. The fin-ished unit is protectedfrom field dust and it’s alsomoderately fuel proof (glowfuel is very conductive).The finished unit ismounted in the model’scockpit using double-sidedtape or held with rubberbands (see Photo 2).

As you can see, there is ahigh-tech solution to moni-toring your RC batterypacks. If you’re still sold on

the old-fashioned voltage method, bemy guest to continue the practice.But, holy cow! With the BatMon,there is a better way. I

64-bit S/Nand 1-Wire

control

Disconnectsense

Temperaturesensor

To hostDQ

1-WireVDD

V?

Oscillator

VoltageA/D converter

CurrentA/D converter

)

RSENS

CF+

VSENS-RF

GND

VSENS+

VDD

VAD

VREG

8-byteSP (00h)

8-bit CRC

8-byteSP (01h)

8-bit CRC

8-byteSP (02h)

8-bit CRC

8-byteSP (03h–07h)

8–bit CRC

Temperatureregister

Battery/generalvoltage registerBattery current

register

Thresholdregister

RTCregister

Offset register

(DIS) Connectregister

40-byte non-volatile memory

Current accumulators

Control logic

DS2438

Figure 3—The Dallas DS2438 was designed for battery fuel gauging of low-cost con-sumer products. It records current consumption and has an assortment of other fea-tures to support battery-powered applications. The data stored in registers isaccessed via the Dallas one-wire bus.

cabate
Text Box
Copyright Circuit Cellar, Inc. This article cannot be reprinted without permission: [email protected]. To subscribe: http://circuitcellar.com/subscription/