You are on page 1of 42

KeyboardEmulationDataLogger

By:
ScottLeonard
MatticsPhi
GregAlesso
NormanTran
FacultyAdvisor:DaleDolan
SeniorProject
ELECTRICALENGINEERINGDEPARTMENT
CaliforniaPolytechnicStateUniversity
SanLuisObispo
2013
1
Table of Contents
Abstract
I.Introduction
II.Background
III.Design
IV.TestResults
V.DevelopmentandConstruction
VI.Conclusion
VII.Bibliography
X.Appendices
A.ABETSeniorProjectAnalysis
B.PartsListandCosts
C.ArduinoSketchCode
D.LiteratureSearch
E.WiringDiagram
F.HardwareLayout
G.ConstructionGuide
2
ListofTables:
CompetingProducts(8)
DetailedSystemRequirements(9)
OPAMPSelection(12)
VoltageAccuracyTestData(19)
CurrentAccuracyTestData(20)
3
ListofFigures:
Figure1:BlockDiagramofSystemComponents(7)
Figure2:Inputvoltagestagecircuitdiagram(13)
Figure3:HallEffectCurrentSensorModule(14)
Figure4:Test3PowerCalculationGraphData(20)
Figure5:Accuracyvs.CalibrationVoltage(21)
Figure6:DevelopmentOverview(23)
Figure7:FallQuarterGanttChart(24)
4
ABSTRACT
Thepurposeofthisprojectistodesignandbuildalowcost,portableUSBdataloggerforelectrical
engineeringlabs.ThisdataloggerconnectstoanycomputerthroughaUSBportandappearsasa
keyboardtothehostsoperatingsystem.Theloggerperformselectricalmeasurementsandrecordsthe
databyemulatingkeyboardstrokesinsideanyspreadsheetprogramoranalysistoolwithouttheneed
forsoftwareorancillaryhardware.Theloggeriscapableofmeasuringvoltageandcurrent.Theend
resultofthisprojectistocreatealowcost,easytousesolutionfordatacollectionthatcanbe
replicatedbyotherstudents.
5
Introduction
ThepurposeofthisseniorprojectistodesignandbuildalowcostUSBkeyboardemulatingdata
loggerforelectricalengineeringlabs.Thisdevicewillmeasurevoltageandcurrentthroughavarietyof
commonrangesusingamicrocontrollercomponentwithanintegratedADC.Thismicrocontrollerwill
thensendmeasurementvaluestoacomputerthroughaUSBportwheretheywillberecordeddirectly
intoaspreadsheetprogram.TheUSBcommunicationcomponentwillbeimplementedusingtheHuman
InterfaceDevice(HID)protocoltoensurecompatibilitywithmostpersonalcomputerswithoutspecial
loggingsoftware.Theendgoalofthiseffortistoproduceanaffordable,potentiallycommercialproduct
thatwillhelpotherstudentsandexperimenterswiththeirelectricalengineeringprojects.
TheideabehindtheUSBdataloggeristoproduceaproductthatcanmeasurevoltageandcurrent
signalsandenterthemdirectlyintoausefulprogramsuchasMicrosoftExcel.Mostdatamanipulationin
undergraduateElectricalEngineeringlabsaredonewiththehelpofaspreadsheetprogram.The
productwillconnectviaaUSBdrivestraightintoaPC.Thedevicewillconsistofaninputstagemade
upofopamps,resistorsandswitchesthatregulatethevoltageandcurrentinputs.Themainideaisnot
tocreateahighpoweredmultimeter,ratheraversatile,usefuldevicethatcangeneratethenecessary
datawithoutsuperfluousprogramsrunning.Thisproductshouldbesmallandshouldworkmuchlikea
keyboardormousewould,beingconnectedsimplythroughaUSBport,usingUSBprotocol.
Anotherimportantperformanceparameterofthedataloggeristhecompatibilityandmobilityit
presents.Thedeviceissmallenoughtotransportaroundfromplacetoplace.Itcanbeusedonlaptops,
MACsandPCswithoutrequiringspecialsoftwareordriverstobeinstalled.
6
Background
TeamOverview:
DaleDolan FacultyAdvisor PowerDepartmentFaculty
MatticsPhi SoftwareandProgramming ElectricalEngineeringStudent
ScottLeonard ProjectLeader ElectricalEngineeringStudent
GregAlesso HardwareandSensing ElectricalEngineeringStudent
NormanTran SoftwareandProgramming ComputerEngineeringStudent
Dataloggingdevicesonthemarketvaryinpricesbasedontheaccuracyandtheutilityofthedevice.
AsseenbelowinTable1,someexistingdevicesarelistedalongwiththeircommonfeatures.The
reasonforthewidepricerangeisbecausesomeofthedevicesaredesignedwithmoreaccuracy,
functionality,andusability.Thehigherpriceddevicesareusedmoreinindustryratherthan
commerciallyandeventhen,thecommercialdevicesareexpensive.Thispreventsstudentsand
hobbyistsfrompurchasingdevicesthatmightbeofusetothem.Bykeepingthepriceofthisdevicelow
andaffordable,thetargetmarketwillbebroadertoincreasetheamountofconsumerswhileproviding
studentsandhobbyistswithdevicesthataremadeforstudents,forstudents,andcreatedbystudents.
Thediagrambelowinfigure1showsthemajorcomponentsoftheproject.
Figure1:BlockDiagramofSystemComponents
7
TableI:SummaryofExistingDataLoggerSystems
ProductName Software
Required
ListedPrice Interface Range Input
Channels
Portable Other
Features
AVRStick NO $9.99 USB Voltage(0to
2.56volts)
1 NO None
ELUSB3
Voltage
Logger
YES $75.25 USB Voltage(0to
30volts)
1 YES None
NIUSB600 YES $279.00 USB Voltage(10
to10volts)
8 YES Labonachip:
digitalIO,
Counters,
PWM
Fluke289
Industrial
Logging
Meter
Yes $558.24 USB Voltage(50
mVto1000V)
1 YES VeryWide
Rangeof
Features
LascarDirect
ConnectData
Recorder
YES $67.00 USB Voltage(0to
30volts)
1 YES None
Bipolar
VoltageDC
Simple
Logger
No $379.00 USB Voltage(850
to850volts)
1 YES Longterm
voltage
reading
MicroII
USBData
Logger
YES $84.00 USB voltage(0to
10volts)
1 YES LCDdisplay
SDVoltage
DataLogger
YES $495.00 SDCard Voltage(0to
1.5volts)
1 YES SDcard
interface
Supco
Current
&Voltage
DataLogger
Yes $411.93 USB Voltage(0to
500V)
1 Yes Current,
alarms,three
phase
SIVoltage
DataLogger
Yes $249.00 USB Voltage(0to
5)
1 Yes None
SITrueRMS
AC
Voltage/Curre
ntDatalog
Yes $309.00 USB Voltage(10to
600V)
2 Yes LCD
8
Requirements and Specifications
GeneralRequirements:
1. Easyandpracticaltooperate
2. Workswithoutexternalsoftware
3. Devicewillhavealowcost
4. Devicewillbedurable
5. Measuresusefulvaluesinlab
6. Compatiblewithcommonspreadsheetprograms
7. Compatiblewithapersonalcomputer
TableII:DetailedSystemRequirements
General
Requirements
Specifications Justification
14,7 Thedeviceishandheldand
portable,weighingnomore
than1poundandnomorethan
12cubicinches.
Sincethedevicewillmostlybeusedin
labenvironments,beinghandheldand
portableallowstheusertomoveitto
variousareaswithoutneededexternal
equipment.
14,6,7 Thedeviceisimplementedwith
widelyavailablecomponents.
Thedevicewillneedtofitthebudgetof
astudentandcanbereplicatedwithout
specialtools.
13,8 Devicecanbeimplementedas
avoltmeterorcurrentmeter.
Thespecificationsofeachofthese
measurementsaredescribedbelow.
5 Thevoltmeterreadsupto25v
withuponedecimalplaceof
accuracy.
Thisallowsstudentsandhobbyiststo
measureandlogvoltagevaluesintothe
computerwithaccuracy.
5 Thecurrentmeterreadsupto
5AwithDCorACcurrent,
providinguptoonedecimal
placesforaccuracy.
Thisallowsstudentsandhobbyiststo
measureandlogcurrentvaluesintothe
computerwithaccuracy.
9
13,58 Deviceisinterfaceablewith
USB2.0,Excel,andMatlab
usingincludedsoftware
package.
Mostlabenvironmentscontain
computerswithExcelandMatlab.
Beingabletointerfacewithcomputers
withtheseprogramsallowstheuserto
logandutilizethedatamoreefficiently.
1,2,5,7 Devicecanbepoweredfrom
USB.
Thisremovestheneedforanexternal
powersource.Sincedevicewill
interfacewithacomputer,thismakes
thedevicemorepractical.
24,7 Devicecostsnomorethan$40. Keepingpriceslowmakesthisdevicea
competitorwithotherdevicescurrently
onthemarketandfitsastudents
budget.
4,5 Deviceisabletooperateunder
normaloperatingconditions
(0Cto70C).
Allowsthedevicetobeusedunder
variousconditionswhilestillbeing
operable.
4,5 Devicewillinclude
overvoltageprotection
featuresatinputs
Byprovidingovervoltageprotection,
theuserwillavoidaccidentaldamageto
thedevice.
10
Design: Hardware
Componentlist:
(2)400PinPrototypingBoard
(3)39kResistors
(1)RailtoRailQuadOpAmpIC
(1)4InputDIPSwitches
(6)BananaJackTerminals
(1)5AmpHallEffectCurrentSensor
(1)14PinICSocket
22AWGAssortedWireSolidCore&Solder
(3)10KOhmBlueTrimPot(15Turn)
(1)LogSpeedTrimPotw/Knob
(16)ICBreakoffMaleHeaders
(1)USBMicroCable
(1)On/OffRecordingSwitch
(1)ArduinoLeonardo
Thehardwaredesignofthisprojectisdividedintoseveraldifferentsections.Theywere
designedseparatelyatdifferentstagesintheprojectandintegratedtogetherinthefinal
quarterofwork.
Thefirstpartofthisdesignprocesswastheinputstagesforthedatalogger.Considering
thatourmicrocontrollercanbeeasilydamagedfrominputvoltagesover5volts,theuseof
anopampwascrucialtobuffertheinputstages.Thisopampwouldbepowereddirectly
fromthe5vsupplyavailablefromArduino,whichisultimatelyprovidedbythehost
computersUSBport.Itneededtohaverailsfrom5Vallthewaydownto0V,which
requiresarailtorailopamp.Knowingthattherewouldbemultipleinputs,quadopamps
wereboughtandtested.Thequadopamppackagewasselectedbecauseofitswide
availability,value,andthroughholepackageoptions.Severaloftheseweresuitable,so
thedecisioncamedowntocost.TheTI86A019Mwasfinallysettledupon.Theinput
voltagerangewaschosentobelargerthan5volts,sotheinputstagewasdesignedasa
resistivedividerflowingintoavoltagefollower.AnindepthlookofisshowninTableIII.
11
TableIII:OPAMPSelection
Name GroundOutput RailOutput DigikeyPrice AbsoluteMaxInput
Voltage
TLV2741 0 5.07 $1.63 vdd+0.2
23741 0 5.09 $2.25 vdd+0.2
MCP6004 0 5.07 $0.48 vdd+0.3
MC33204P 0.04 5.05 $1.61 notstated
TLC2274AIN 0 5.07 $2.48 vdd+0.3
LMC660CN 0 5.06 $2.38 vdd+0.3
LMC6484IN 0.01 5.07 $2.90 vdd+0.3
MCP604 0 5.07 $1.25 vdd+0.3
MCP6024 0.01 5.06 $2.08 (vdd+0.3)
LM324N 1.43 3.799 $2.34 32.0volts
LS404CN 0.54 4.485 $1.24 32.0volts
LM2902N 1.80 3.777 $2.65 32.0volts
TL074CN 1.399 4.472 $3.07 16.0volts
Thevoltagerangewasdecidedtobe025V.Thiswasdonewitha39Kohm/10Kohm
resistivedivider(seeninfigure2.)Threevoltageinputstageswerechosenforaspecific
reason.Generally,inelectricalengineeringlabs,theinputvoltageandtheoutputvoltages
aremeasured.Thethirdinputstageistoallowtheusertomeasureavoltagedifference,
whilemeasuringavoltagewithanuncommonground.
12
Figure2:Inputvoltagestagecircuitdiagram
Thecurrentsensor(Figure3)waschosenbasedonpriceandfunctionality.Itcanonly
handle05A,butthiswasdeterminedtobesufficientforgeneralcircuituse.Thisdevice
waschosennotbecauseitwasahighpowered,highfunctioningsensor,butbecauseit
wasthemostcosteffectivesensorthatgaveanacceptablecurrentrange.Thecurrent
device(shownbelow)isconnectedtothecommongroundandthe5VoutputoftheArduino
Leonardo.TheoutputsignalfromthemoduleisconnecteddirectlytooneoftheADC
ports.
13
Figure3:ACS712LCElectronics05AmpAC/DCHallEffectCurrentSensorModule
TheArduinoLeonardowaschosenforitsusefulcapabilities.Asacrificewasmadewith
thisdecision.Thetwooptionswereeithertousealowfunctioningmicrocontrollerpic,orto
usetheLeonardo.TheLeonardowaschosen,despiteprice,becauseitcamewitha
builtinkeyboardemulator.TheLeonardoisinterconnectedwiththeinputstages.The
opampsgettheir5Vand0Vrailsfromthecontrollers5Voutputandthecommonground
foundonthedevice.ThisallowstheentireprojecttobepoweredbyUSBpowerfromthe
computer.Thedevicegetsthe5VfromitsUSBconnection.
Thedevicetakesinthe05Vinputfromtheopampsandcurrentsensor,convertsthem
intodigitalvaluesthroughabuiltinADC,andthenoutputsamanipulatedversiontogive
accuratevalues.
TheArduinoLeonardoisalsoconnectedtocertainuseroperatedexternalcomponents.
Switchesareconnectedtothedevicesdigitalinputstheseswitchesturnonandoffthe
recordingofthevoltageandcurrentinputs.Themainswitchturnson/offkeyboard
emulation.ThisallowstheusertopreparetheExcelorspreadsheetprogrambeforeturning
onloggingandhavingtheArduinotakeovercontrolofthekeyboard.Theuseralsohasthe
optiontochangetherecordingspeed.Thisneedstobeavailableduetothevarying
speedsofdifferentcomputers.Thisisdesignedwithapotentiometerconnectedtoan
analoginput.Thisvariedvaluewillincreaseordecreasetheloggingspeed,sotheuser
canseerealtimechangeofthemeasurecircuit.
14
Design: Software
ThesoftwareforthedataloggeriswrittenusingArduinosketch.Thesoftwareisconfigured
toworkbestwithMicrosoftExcel,howeveritfunctionsfineinNotepad,Wordpad,orother
texteditors.Themajorfunctionsofthesoftwarearebrokendownintoseveralpartsbelow.
Setup
First,inthesetup()function,digitalpins9through13aresetasinputswiththeirinternal
pullupresistorsactivated.ThissetstheonswitchasLOWandoffasHIGH.Pins9
through11actasswitchestoturnon/offdataloggingforthevoltageinputs,pin12actsas
aswitchtoturnon/offdataloggingforthecurrentinput,andpin13actsasaswitchtoturn
on/offkeyboardentry.Thisswitchisintendedtopreventunintendedkeyboardentries
becausetheArduinotakesoverthekeyboardonceitisswitchedon.Thesetup()functionis
onlyrunonce.
voidsetup()
{
Serial.begin(9600)//Setupserial
//Inputpullupresistorsusedinsteadofexternalpulldowns
//HIGH=OFF,LOW=ON
pinMode(9,INPUT_PULLUP)//Switchforanalogpin2(Voltage1)
pinMode(10,INPUT_PULLUP)//Switchforanalogpin3(Voltage2)
pinMode(11,INPUT_PULLUP)//Switchforanalogpin4(Voltage3)
pinMode(12,INPUT_PULLUP)//Switchforanalogpin5(Current)
pinMode(13,INPUT_PULLUP)//Switchforanalogpin0(Potentiometer)
Keyboard.begin()//Setupkeyboardentry
}
Loop
Theloopfunctionactslikethemainfunction,butrunscontinuously.First,digitalpin13is
checkedtoseeifitisonoroff.ItisonwhenitisLOW.Theflagvariabledetermines
whetherornottoprinttheheader.Itisonlyprintedonceattheverytop.Then,the
adjustDelay()functioniscalledtodeterminetheloggingspeed.Digitalpins9to12are
readtodetermineiftheirswitchesareturnedon.Iftheyare,thevoltagesarereadusingthe
logVoltage()function.Thevaluereadfromthecurrentpinisadjustedandscaledfor
accuracybeforeitisprintedtothescreen.Likewise,thevoltagevaluesreturnedfrom
logVoltage()arescaledbyafactorof5.1inordertoproduceaccurateresults.Atab
15
keystrokeisenteredtomovetothenextcelltotherightinExcelinbetweendatareadings.
Lastly,thedelayinmillisecondsisprintedoutandanenterkeyisenteredtomovedownto
thenextline.ThelogVoltage()andadjustDelay()functionswillbeexplainedindepthbelow.
voidloop()
{
if(digitalRead(13)==LOW)//Pin13mustbegroundedtostartwriting
{
if(flag==0)//Printoutheaderatthetop
{
flag=initializeHeader()
}
adjustDelay()//Setloggingspeedbyadjustingdelay
for(i=5i>=2i)
{
if(digitalRead(i+7)==LOW)
{
//Logvoltagesfromanalogpins24,currentfromanalogpin5
if(i==5)//Currentpin
{
voltVal=readVoltage(i)//Readvoltage
curVal=(voltVal2.56)*5.555//Scalevalueforcurrent
Keyboard.print(curVal)
}
else//Voltagepin
{
voltVal=readVoltage(i)*5.1//Readandscalevoltage
Keyboard.print(voltVal)
}
}
if(i==2)//Reachedendofline
{
insertTab()
//Printloggingspeedinms(0to200)
Keyboard.print(logDelay)
insertEnter()
}
else
{
insertTab()
}
}
}
}
16
Functions
ThereadVcc()functionisusedtoimprovetheaccuracyoftheADCintheArduino.Ituses
theinternal1.1VreferencetocalculatetheVcc.ThisisdonebecausetheUSBvoltageof
differentcomputerswillvaryandwillnotbeexactly5V.Theresultisreturnedinmillivoltsfor
moreaccuracy.Thisfunctionwastakenfrom
http://provideyourown.com/2012/secretarduinovoltmetermeasurebatteryvoltage/
longreadVcc(){
//Read1.1VreferenceagainstAVcc
//setthereferencetoVccandthemeasurementtotheinternal1.1V
reference
#ifdefined(__AVR_ATmega32U4__)||defined(__AVR_ATmega1280__)||
defined(__AVR_ATmega2560__)
ADMUX=_BV(REFS0)|_BV(MUX4)|_BV(MUX3)|_BV(MUX2)|_BV(MUX1)
#elifdefined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)||
defined(__AVR_ATtiny84__)
ADMUX=_BV(MUX5)|_BV(MUX0)
#elifdefined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)||
defined(__AVR_ATtiny85__)
ADMUX=_BV(MUX3)|_BV(MUX2)
#else
ADMUX=_BV(REFS0)|_BV(MUX3)|_BV(MUX2)|_BV(MUX1)
#endif
delay(2)//WaitforVreftosettle
ADCSRA|=_BV(ADSC)//Startconversion
while(bit_is_set(ADCSRA,ADSC))//measuring
uint8_tlow=ADCL//mustreadADCLfirstitthenlocksADCH
uint8_thigh=ADCH//unlocksboth
result=(high<<8)|low
result=1125300L/result//CalculateVcc(inmV)1125300=
1.1*1023*1000
returnresult//Vccinmillivolts
}
ThelogVoltage()functiontakesintheanalogpinnumberasaparameterandreturnsthe
voltagereadingasadouble.ItcallsthereadVcc()functiontodeterminetheVccandthen
dividesby1000togetthereadinginvolts.Then,theanalogpinisread,returninga10bit
17
ADCvaluefrom0to1023.Thisvalueisdividedby1023andmultipliedbyVcctogetan
accuratevoltagemeasurement.
doublereadVoltage(intanPin)
{
vcc=readVcc()/1000.0//ReadVcc
digRead=analogRead(anPin)//Readanalogpin
delay(10)
voltage=((digRead/1023.0)*vcc)//Calculatevoltage
returnvoltage
}
TheadjustDelay()functionreadsthepintiedtothepotentiometer,whichisdesignatedas
analogpin0.Therangeforthisvaluewasmeasuredtobefrom0to892.Thedelay()
functionisthencalledusingthepotentiometervaluedividedby4.46.Thisproducesadelay
between0msto200ms.
voidadjustDelay()
{
potVal=analogRead(potPin)//Readthepotentiometervalue
//Potentiometerreadingshouldbebetween0and1023
logDelay=potVal/5.115//Givesadelaybetween0and200ms
delay(logDelay)
}
18
TESTING
TestObjective:Thepurposeofthesetestsistodeterminetheaccuracyofthe
device,aswellastoshowthedevicescapabilitiesinrecordingvaluesofactuallytest
circuits.
Procedure:
Test1
A.Insertpowersupplystraightintoterminals1,2,and3.
B.Connectaseparatevoltmeteracrossthepowersupplyterminals.
C.Increasethevoltageupto26Vinincrementsof1V.
D.Runthedeviceandcomparethevalues.
Test2
A.Connectthecurrentsourcethroughanelectricloadandapowersupply.
B.Setthecurrentat0Aandthenincreaseto3A.
C.Letthedevicerecordthecurrentvalues.
D.Comparetotheelectricloadvalues.
Test3
A.Setupcircuit:connectpowersupplythroughanelectricload.
B.Connectthecurrentthroughthecurrentsensorterminals.
C.PutthefromthepowersupplythroughVoltageinput1.
D.Setthecurrenttoanarbitraryvalue,1A.
E.RecordthecurrentandVoltagevalues.
F.Increasethevoltagetogetanacceptablerangeofdata.
F.Usingtheexcelfunctiongraphthepowervs.loadvoltage.
DataandGraphs
TableIV:Voltageaccuracytestdata
v1
v2 v3 Avg. Calibration Difference
0.05 0.05 0.05 0.05 0.1 0.05
1.05 1.05 1.05 1.05 1.099 0.05
1.95 1.95 1.94 1.95 1.979 0.03
3.02 3.02 3.02 3.02 3.056 0.04
4.05 4.05 4.07 4.06 4.087 0.03
5.05 5.05 5.05 5.05 5.078 0.03
5.99 5.97 5.97 5.98 5.99 0.01
7.07 7.07 7.07 7.07 7.084 0.01
19
8.22 8.2 8.22 8.21 8.222 0.01
9.22 9.22 9.22 9.22 9.222 0
10.22 10.19 10.19 10.2 10.207 0.01
10.99 10.99 10.94 10.97 10.99 0.02
12.09 12.09 12.06 12.08 12.091 0.01
13.06 13.04 13.06 13.05 13.06 0.01
14.11 14.11 14.14 14.12 14.111 0.01
15.24 15.24 15.24 15.24 15.226 0.01
16.11 16.11 16.11 16.11 16.091 0.02
17.06 17.03 17.06 17.05 17.034 0.02
18.08 18.08 18.08 18.08 18.072 0.01
19.24 19.24 19.26 19.25 19.224 0.03
20.26 20.24 20.24 20.25 20.23 0.02
21.18 21.16 21.18 21.17 21.16 0.01
22.21 22.18 22.13 22.17 22.174 0
23.23 23.21 23.23 23.22 23.2 0.02
24.26 24.23 24.23 24.24 24.234 0.01
25.13 25.1 25.24 25.16 25.1 0.06
26.2 26.2 26.2 26.2 26.159 0.04
TableV:Currentaccuracytestdata
Lowcurrent
recorded(A)
LargestCurrent
recorded(A)
ActualCurrent(A) BiggestDifference
0.13 0.04 0 0.13
0.02 0.21 0.1 0.11
0.31 0.46 0.4 0.09
0.64 0.79 0.7 0.09
0.94 1.07 1 0.07
1.27 1.4 1.3 0.1
1.52 1.76 1.6 0.16
1.82 2.01 1.9 0.11
2.04 2.26 2.1 0.16
2.35 2.56 2.4 0.16
2.65 2.89 2.7 0.19
2.98 3.14 3 0.14
20
Figure4:Test3PowerCalculationGraphData
Figure5:Accuracyvs.CalibrationVoltage
21
ResultsandAnalysis
Testonewasperformedtogiveanaccuracyvalueofthedevice.Accuracywasgenerally
determinedusingabenchtopmultimeter,recordedaboveascalibrationvoltage.Thethree
terminals,whichwereallcalibratedindividually,producedroughlythesamevalues.The
differencebetweentheloggedvaluesandthevaluesbeingrecordedmanuallywasnever
morethan.05V(seeTableIV.Thisletsussaywithconfidencethattheaccuracyofthe
deviceis+/50mV.Thisisanacceptablevalueandmeetsthedesignrequirementswe
setouttomatch.Figure5aboveshowsthedifferencebetweentheloggers
measurementsandthecalibrationvoltage.
Testtwowasdesignedtotesttheaccuracyofthecurrentsensorandthedevice.Thiswas
doneusinganelectricload.Thecurrentwaswasvariedforarangeofdata03A.
Thedevicehadahardtimegettingaconstantcurrent,eventhoughthecurrentinputedwas
constant.ThedatainTableVshowsalargerangeofdifference.Thelargestdifference
was.19Vfromtheactualamperage.Thisletsussaythatourdevicehasanaccuracyof+/
200mA.
Test3providesanexamplefunctionofthedatalogger.Thepurposewastorecordthe
currentandthevoltageacrossaspecificload.Thedatawasthengraphedagainstthe
increasingvoltage,whilekeepcurrentconstant.TheresultcanbeseeninFigure4.This
testoffersoneofthemainappealsoftheproject.Becausethedatawasalreadyin
MicrosoftExcel,itwasasimpletaskmultiplyingthecurrentandthevoltagetoobtain
power.Selectingandgraphingthetwoaxeswasalsoverysimpleandfast.Itcanbe
observedfromthegraphabovethatthedevicedoesitsjobadequately.
22
DevelopmentandConstruction
Thisprojectwasdevelopedastwomajorsystems:hardwareinvolvedwiththedataloggershield
andsoftwarefortheArduinomicrocontroller.Asummaryofthemajordevelopmentstepsis
shownbelowinfigure5:
Figure6:DevelopmentOverview
23
Thisdataloggerwasimplementedwithcommonlyavailablecomponentswiththehopethatit
couldbeassembledbytheaveragehobbyistorstudentwithminimalexperience.Thecomplete
constructionprocessisdetailedintheappendix.
Themostdifficultstepsinthedevicesconstructioninvolvesolderconnectionsincloseproximity
tooneanother.Theconstructionprocessforthisdevicecouldbegreatlysimplifiedbyetchinga
printedcircuitboardwithcoppertracesbetweentheconnections.Thisextrastepin
constructionwouldbewellworththeeffortfromthegaininreliabilityandeaseofassembly.
Figure7:FallQuarterGanttChart
ThegoalofFallQuarterwastodecidewhatcorecomponentswillbeneededfortheproject,as
shownaboveinfigure6.Fromthere,wecreatedandtestedthemostbasicsubassemblesof
thesystem:thevoltagedivider,currentsensorandtheADCinputintothemicrocontroller.By
theendofWinterQuarter,thedevicewastestedforbasicfunctionalitywhichincludedreading
voltageandcurrentvalues.Thedeviceshouldalsobetestedfordataloggingand
communicationtothecomputerthroughUSBinordertooperatewiththedataloggingsoftware.
Throughoutthequarters,therewillbealotofdesign/implement/testingcyclesthatboththe
hardwareandsoftwareteamswillgothrough.Thisallowstheteamtofocusonothergoalsat
thebeginningofWinterQuarterwiththeknowledgethatthedeviceisabletooperatewithbasic
functionality.Springquarterwasdedicatedtodocumentingthedeviceandfinetuningits
performance.
24
Conclusion
Thisdevicemeetstherequirementsandgoalssetatthestartoftheproject.Thefirst
requirementswereeaseofuseandportability.Thedeviceissmallenoughtotransportfrom
placetoplace,lightweight,andisstableenoughnottobreakorfallapart.Thedevicealso
requiresnospecialsoftwareuploadedbytheuser.Oncethecodeiswrittenontothe
microprocessor,itwillfunctiononanycomputer.Thedataloggeralsoutilizesjustonecommon
microUSBtoUSBmaletomalecabletoconnecttoacomputerandonceconnected,itisable
tologdataattheflipofaswitch.Thedeviceitselfiseasytounderstand.Ithasclearterminalsfor
voltageandcurrentinputsaswellasaneasytoseeswitchsystemtocontrolwhenthedevice
recordsanddoesntrecord.
Anothercriteriawasprice(seeappendixB.)Thetotalpriceofthehardwareandsoftware
neededtobuildthisproductwas$34.37,thisisaslightlyhigherpricethantheinitialestimate.
Wefirstenvisionedapriceofaround$20.Thisbecameaenlargedwhenwechangedthedesign
toincludeanArduinoLeonardo.ThismicroprocessorisasignificantupgradefromthePIC
originallychosenintermsofeasyusability.TheLeonardoofferedmorefeaturestohelpwiththe
keyboardemulation,andthereforetheincreaseinpricewasdeemedacceptable.Afinalpriceof
$34.37stillmeetsourrequirements.Themarketforthistypeofdeviceissubstantiallyaboveour
componentprice.Whenconsideringthecustomerforthisdevice,acollegestudentwithlimited
funds,itwasimportanttomakethisanaffordablealternative.Thispricewasmetandthiswas
donewhilestillmeetingacceptableaccuracynumbers.
Asmallsacrificewasmadetokeepthecostlow.Althoughtheaccuracyofthedevice
isntashighpoweredassomeoftheotheralternatives,itisabletoproduceaccuratedatafor
whatitismeanttomeasure.Bydoingseveralcalibrationandtestingsteps,thevoltageand
currentaccuracyreadingswereobtainedtobe+/50mVand+/200mArespectively.By
choosingavoltagerangefrom026Vandhaving3inputstages,itallowstheusertodoseveral
differentthings.Thewiderrangewasdeemedtobethemostusefulrangeforanelectrical
engineeringstudentinanelectronicslab.Voltagesdontcommonlyexceed26Vandusually
hoveraroundthe812Vrange.Havingmultipleinputstagesallowsformeasuringinputand
outputvoltagessimultaneouslythisallowsuserstographthetwocolumnsversusoneanother.
Similarly,theabilitytorecordcurrentaswellasvoltagemeansthatpowergraphscanbe
graphedandanalyzed.
Anotherlargerequirementthatwasmetwastheabilitytorecordsomethingstraightinto
MicrosoftExcelorasimilarprogram.Thedeviceactsasakeyboard,printingvaluesone
keystrokeatatime.Thisispracticalintheworldofelectronicslabs.Almostalldatamanipulation
isdonewithinExcel.Asmentionedabove,theeaseofmultiplyingtwocolumnsandthen
graphingitrightawayisinvaluable.Manydataloggingproductsusetheirowninterfaceand
softwaretoprintvalues.ButtheideaisthatthosevalueswilljustbepostedintoExcelanyway,
sothisfeaturecutsoutthemiddlestep.
Overallthisdevicecanbedefinedanaffordable,portableandpracticalvoltageand
amperagedatalogger.Thatiswhatwesetouttodesignandcreate.Thefinishedproductis
abovesatisfactorywhencomparedtowhatweenvisionedatthestart.
25
Appendices
A.SeniorProjectAnalysis
SummaryofFunctionalRequirements
Thegoalofthisprojectistocreateadataloggingdeviceforelectricalengineeringthatissmall,portable,
andeasytouseforstudentsandhobbyists.Tomeetthisgoal,thisloggerwillbeimplementedonalow
costmicrocontrollerplatformwithUSBcompatibility.Thisdevicewillmeasurevoltageandcurrent
throughavarietyofcommonrangesusingamicrocontrollercomponentwithanintegratedADC.This
microcontrollerwillthensendmeasurementvaluestoacomputerthroughaUSBport,wheretheywill
berecordeddirectlyintoaspreadsheetprogram.TheUSBcommunicationcomponentwillbe
implementedusingtheHumanInterfaceDevice(HID)protocoltoensurecompatibilitywithmost
personalcomputerswithoutspecialloggingsoftware.
PrimaryConstraints
Threemainperformanceparametersconstrainourdesign:
1.Inputrangevs.inputaccuracy
2.Numberofinputsvs.samplingrate
3.Costvs.functionality
Inputrangeandinputaccuracyformatradeoffthatmustbeaddressedforeachoftheinputsonthe
microcontroller.OursystemreliesonADCstoapproximateadigitalvaluegivenananaloginput.This
meansthatforanygivenrangeofvoltages,thereisafixednumberofbitsthatcanbeapproximated
fromthevalue.Inourcase,thismeasurementislimitedto10bits,soforanygivenmeasurementrange,
thepossiblevoltagesaredividedinto2^10possiblevalues.Astheinputrangeincreases,thesestates
becomefurtherapart,decreasingaccuracy.
Anotherconstraintisthetradeoffbetweeninputnumberandsamplingrate.Ourdataloggingdevice
mustsamplefrommultipleinputs,providingareadingforeach.Asaresult,someinputvaluesmay
changeasthedeviceiswaitingtoreadthem,causingalossofinformation.Thiscreatesinaccuraciesin
measurementsthatneedtobeaddressed,especiallywhenmeasuringaudioandcontrolsignals.Asthe
numberofinputdevicesincreases,themaxsamplingratefortheinputsisreduced.Thisproblemcanbe
overcomebyallowingtheusertospecifywhichinputsourcesaretobemeasuredandwhichareto
remaininactive.
26
Finally,themostimportanttradeoffforourdeviceisthecostvs.itsfunctionality.Theendpriceofthe
devicedetermineshowmanypeoplecanaffordtouseit,butthefunctionalityiswhatsetsitapartfrom
otherproducts.Thereasonforkeepingthecostlowistokeepthisproductcompetitivewhen
comparedtothecurrentmarketinordertodothis,theproductioncostofthedevicemustbelowas
wellwhichiswhythedevicewillbesoldasakittosaveonlaborcosts.
Sizeisanothermajorfactorthatlimitsthecomponentsofthedevice.Inordertokeepitsmall,the
microcontrollermustbesmallaswellastheenclosureandthecomponentswithinthemicrocontroller.
Economic
Thetargetcustomerbaseforthisdeviceiselectricalengineeringstudentsandhobbyistsofallages.The
maincostscomefromthemicroprocessorplatform,theArduinoLeonardo.Theoriginalestimatedcost
ofallthecomponentswasunder$20.Thiswasthegoalsetinthebeginningoftheproject.However,
uponfurtherresearch,theArduinoLeonardowasdeterminedtobethebestchoiceastheplatformfor
theprojectduetoitsbuiltinkeyboardemulationandhardwaresafetyfeatures.Thefinalcomponent
costsfortheprojectis$34.37.
Ifthedeviceissuccessful,thereareseveralcostbenefitsthatwilloccuroverthelifetimeoftheproductif
itwascommercialized.Asmoredevicesaresoldandproductionincreases,morecomponentscanbe
orderedinlargebulkpurchases,whichtranslatestoaloweroverallcost.Asmorepeopleuseand
experimentwiththedevice,salesmayincreaseordecreaseoverthelifespanoftheproductdepending
onhowwellitissupportedandupdatedasproblemsarise.
Ifmanufacturedonacommercialbasis
Theamountofdevicessoldeachyeariscurrentlyunknown.Sincetheproductmainlytargetsstudents,
alargerangeofunitscouldbesold.
Themanufacturingcostofthisdevicecurrentamounttoabout$35.Thisincludespurchasingallthe
partsandtheirshippingcosts.Sincemostofthecomponentswillbeboughtinbulk,thepriceswill
decreaseasmorecomponentsarepurchased.
Thesalespricecostofthisdevicewillbebetween$50and$60.Thisincludesthepriceonpurchasing
andbaggingthecomponents.Shippingpriceswillbebasedonlocation.Themaingoalofthisdeviceis
notprofitbutmoreofalearningexperienceandhelpingotherstudentswiththeirlabs.Ifusedcorrectly
27
andnotrecklessly,thedeviceshouldnotrequireanyadditionalcoststomaintainandoperate.
Environmental
Thisdevicemayusepotentiallyenvironmentallyharmfulmicroelectroniccomponentssothebyproducts
ofmanufacturingthosecomponentswillhaveanimpactontheenvironment.
Sincethisdeviceusesapersonalcomputerasapowersupply,thebyproductofgeneratingthatpower
wouldbetheemissionsfromthevariouselectricgeneratorsincluding,butnotlimitedto,naturalgas,
nuclear,coal,petroleum,andotherrenewableresources.Fortunately,thepowerdrawnfromthe
deviceislessthan1watt,makingaverysmallloadontheelectricalgrid.
Assumingthattherearedefectivepartswithinthedevice,theusercanrecyclethedefectivepartsat
electronicrecyclingcenters,whichhelpstheenvironmentandkeepsunwantedwasteoutofthe
ecosystem.
Manufacturability
Thereshouldbenospecialissueswithmanufacturingthisdeviceonceadesignisvalidated.Ituses
partsthatcanbeboughtonlinefromanywhere.Sincethisdevicewillnotbesoldprebuilt,therewillnot
beanymanufacturingissuesfromtheselleraswell.
Thecomponentsusedforthisdevicearelowincostandverycommon.Purchasinginbulksavesonthe
costofshippingandpriceperpart.Thisallowsustokeepthepriceofthedevicelowertokeepitmore
competitive.
Sustainability
Most,ifnot,allofthecomponentsofthedevicearerecyclable,sointhecasewherethedeviceisfaulty
orthecomponentsorfaulty,thedeviceitselforthecomponentscanberecycledatanelectronics
recyclingcenterorrepurposedforotherprojects.
Ethical
Thedevicewillhavetoperformtotheclaimsthatarewrittenbyusregardingtheabilitytomeasureup
tocertainvoltagesandcurrents.Inaddition,theaccuracyofthedevicemustbelistedcorrectlyfor
eachmeasurementrange.Theproductwillbesafetouseunderthespecifiedenvironmentswithoutany
reasonableriskofharmingtheuser.Awarningsheetwillbeincludedwiththeproducttospecifyany
hazardsordangerousoperatingconditions.
28
HealthandSafety
Animportantsafetyissuethatneedstobeaddressedisafailsafefeaturewhichprotectstheuserfrom
misuseinthecaseofmeasuringhighvoltagesorcurrents.Thesedangerscanbeavoidedbyusingthe
protectioncircuitryandlimitingexposedhighvoltagecontacts.Thedeviceisintendedforuseby
peopleovertheageof10andisnotintendedasatoy.Appropriatemarkingswillbeaddedtothe
devicespackagingtoreflectthis.
SocialandPolitical
Thedirectstakeholdersarethestudentsandhobbyiststhatpurchasethisdevice,ourgroup,andthe
manufacturersthatmakethecomponentsofthisdevice.Indirectstakeholdersincludethecompanies
thehobbyistsworkforthatmaketheproductsandtheteacherswhothestudentslearnfrom.
Development
Thisprojectrequireddomainknowledgefrommanydifferentareasofelectricalengineering.
Developingthisprogramontimewiththerequiredfunctionscalledforateamwithawiderangeofskill
sets.Thisprogramimprovedourknowledgeofdatacollectiontoolsandthesoftwareassociatedwith
USBkeyboardinterfaces.
29
B.CostTables
OriginalCostEstimate:
FinalSpendingTable:
30
C. Arduino Sketch Code
/*
USBDataLogger
Students:MatticsPhi,ScottLeonard,GregAlesso,NormanTran
Advisor:DaleDolan
CaliforniaPolytechnicStateUniversity
SeniorProject
Spring2013
*/
inti
staticintflag=0//Flagtoprintoutheader
longresult//Vccinmillivolts
unsignedintdigRead//Digitalvalueofvoltagereadfrominput
doublevoltage//Voltagereadfromanaloginput
doublevcc//Vccinvolts
doublevoltVal//Voltagevaluetoprint
doublecurVal//Currentvaluetoprint
doublepotVal//Digitalpotentiometervalue
intpotPin=0//Analogpinforpotentiometer
doublelogDelay//Loggingspeeddelayinms
voidsetup()
{
Serial.begin(9600)//Setupserial
//Inputpullupresistorsusedinsteadofexternalpulldowns
//HIGH=OFF,LOW=ON
pinMode(9,INPUT_PULLUP)//Switchforanalogpin2(Voltage1)
pinMode(10,INPUT_PULLUP)//Switchforanalogpin3(Voltage2)
pinMode(11,INPUT_PULLUP)//Switchforanalogpin4(Voltage3)
pinMode(12,INPUT_PULLUP)//Switchforanalogpin5(Current)
pinMode(13,INPUT_PULLUP)//Switchforanalogpin0(Potentiometer)
Keyboard.begin()//Setupkeyboardentry
}
voidloop()
{
if(digitalRead(13)==LOW)//Pin13mustbegroundedtostartwriting
{
if(flag==0)//Printoutheaderatthetop
{
flag=initializeHeader()
31
}
adjustDelay()//Setloggingspeedbyadjustingdelay
for(i=5i>=2i)
{
if(digitalRead(i+7)==LOW)
{
//Logvoltagesfromanalogpins24,currentfromanalogpin5
if(i==5)//Currentpin
{
voltVal=readVoltage(i)//Readvoltage
curVal=(voltVal2.56)*5.555//Scalevalueforcurrent
Keyboard.print(curVal)
}
else//Voltagepin
{
voltVal=readVoltage(i)*5.1//Readandscalevoltage
Keyboard.print(voltVal)
}
}
if(i==2)//Reachedendofline
{
insertTab()
//Printloggingspeedinms(0to200)
Keyboard.print(logDelay)
insertEnter()
}
else
{
insertTab()
}
}
}
}
intinitializeHeader()
{
Keyboard.print("Current")
insertTab()
Keyboard.print("Voltage1")
insertTab()
Keyboard.print("Voltage2")
insertTab()
Keyboard.print("Voltage3")
insertTab()
Keyboard.print("LoggingDelay(ms)")
insertEnter()
32
return1
}
voidinsertTab()
{
Keyboard.write(KEY_TAB)
}
voidinsertEnter()
{
Keyboard.write(KEY_RETURN)
}
longreadVcc(){
//Read1.1VreferenceagainstAVcc
//setthereferencetoVccandthemeasurementtotheinternal1.1V
reference
#ifdefined(__AVR_ATmega32U4__)||defined(__AVR_ATmega1280__)||
defined(__AVR_ATmega2560__)
ADMUX=_BV(REFS0)|_BV(MUX4)|_BV(MUX3)|_BV(MUX2)|_BV(MUX1)
#elifdefined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)||
defined(__AVR_ATtiny84__)
ADMUX=_BV(MUX5)|_BV(MUX0)
#elifdefined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)||
defined(__AVR_ATtiny85__)
ADMUX=_BV(MUX3)|_BV(MUX2)
#else
ADMUX=_BV(REFS0)|_BV(MUX3)|_BV(MUX2)|_BV(MUX1)
#endif
delay(2)//WaitforVreftosettle
ADCSRA|=_BV(ADSC)//Startconversion
while(bit_is_set(ADCSRA,ADSC))//measuring
uint8_tlow=ADCL//mustreadADCLfirstitthenlocksADCH
uint8_thigh=ADCH//unlocksboth
result=(high<<8)|low
result=1125300L/result//CalculateVcc(inmV)1125300=
1.1*1023*1000
returnresult//Vccinmillivolts
}
doublereadVoltage(intanPin)
{
vcc=readVcc()/1000.0//ReadVcc
33
digRead=analogRead(anPin)//Readanalogpin
delay(10)
voltage=((digRead/1023.0)*vcc)//Calculatevoltage
returnvoltage
}
voidadjustDelay()
{
potVal=analogRead(potPin)//Readthepotentiometervalue
//Potentiometerreadingshouldbebetween0and1023
logDelay=potVal/5.115//Givesadelaybetween0and200ms
delay(logDelay)
}
34
D. Literature Search
[1]NationalInstruments,LowCost,BusPoweredMultifunctionDAQforUSB218
Datasheet[RevisedSept.2012]
Thesourcehasauthoritytoprovidereliableinformationbecauseitisfromawellknown
companynamedNationalInstruments.
[2]WimClaesetal.,DesignofWirelessAutonomousDataloggerICs(TheSpringer
InternationalSeriesinEngineeringandComputerScience,1
st
ed.NewYork:
SpringerVerlag,2005.
Thissourcehasauthoritybecausetheauthorshavewrittenotherbooksonlowpowered
dataloggers,transistordesign,andmanyotherbooksaboutbiomedicalsystemsandtheory.
[3]Engelberg,S.etal.,InstrumentationnotesAUSBEnabled,FLASHDiskBasedData
Logger,Instrumentation&MeasurementMagazine,IEEE,vol.10,iss.2,p.6366,April
2007.
ShlomoEngelberghasalsowritten8booksonelectricalandcomputerengineeringincluding
digitalsignalprocessing,microcontrollerdesign,andcontroltheory.
[4]GabrielIbarra,etal.,DataStorageDeviceCompatiblewithMultipleInterconnect
Standards,U.S.Patent8239581,May10,2010.
GabrielIbarraandhisteamatSeagateTechnologyLLCfiledanotherpatentthatdealtwithdata
storagedevicesmethodsforpoweroninitialization.
[5]GabrielIbarra,etal.,DataStorageDeviceandMethodsforPoweronInitialization,
U.S.Patent8055942,November8,2011.
GabrielIbarraandhisteamatSeagateTechnologyLLCfiledanotheranotherpatentthatdealthwith
datastoragedevicecompatiblewithmultipleinterconnectstandards.
35
[6]ExtechInstruments,HumidityandTemperatureUSBDataloggerRTH10Datasheet
[Revised2009]
Thesourcehasauthoritytoprovidereliableinformationbecauseitisfromatechnological
companynamedExtech.
[7]GeminiDataLoggers,TinytagUltra2TemperatureLoggerTGU4017Datasheet
[RevisedApril2011]
GeminiDataLoggersisacompanythatfocusessolelyondataloggingdevicesbecauseofthis,
wedecidedthatifweweretolookatdataloggers,itmightaswellcomefromGemini.
[8]AgilentTechnologies,InfiniiVision7000ASeriesOscilloscopesDatasheet[Revised
Feb.2010]
AgilentTechnologiesisawellknowncompanythatcreatesmeasurementtoolsandequipment.
Theysellequipmentworldwideandarewellknownwithinourlabsaswell.
[9]ThurlbyThandarInstruments,Lowcost20MHzFunctionGeneratorTG120Datasheet
ThurlbyThanderisaEuropeancompanybutnevertheless,thebrandiswellknownonthatside
oftheworld.
36
E. Master Wiring Diagram
37
F. Hardware Layout
38
Appendix G: Construction Guide

1. Insert Headers

Break off four groups
of male headers to
form the connection
between the board
and the shield. All
pins receive a header
except for SCL, SDA,
and AREF.


2. Align Proto-Board

The shield is made
from two proto-boards
with copper pads
facing out from both
sides. Stack two
boards over the
heads so that they are
centered over the
Arduino.


3. Solder Headers

Solder the headers to
the proto-boards while
they are aligned over
the Arduino.


4. Check Board

Using a multimeter,
check each of the
solder points for
unwanted shorts to its
neighboring pads.
Repeat this process
for each new
component added.




5. Mark for Drilling

Six holes need to be
added for the voltage
inputs and recording
on/off switch. Use the
outermost pre-drilled
holes as a center for
three equally spaced
marks on each side of
the the board


6. Drill Terminal
Holes

Using a 1/4 drill bit,
drill out holes for the
bannana terminals.


7. Optional Terminal

If you are including the
current sensor, drill an
extra hole for an
additional terminal.


8. Mount Terminals

Mount the banana
terminals to the board,
making sure that each
post is insulated from
the board by a plastic
spacer.




9. Mount On/Off
Switch

In the remaining hole,
mount the on/off
recording switch. The
switch pictured here is
pre-wired.


10. Mount Current
Sensor Module

Mount the current
sensor on the bottom
of the board as
shown. Test fit the
shield to the board
with the sensor to
avoid collisions before
soldering.


11. Mount DIP
Switches

Mount and solder the
DIP switches to the
board. Pins 12
through 9 will be
connected to ground
through the switch.


12. Mount IC Socket

Mount and solder the
IC socket to the board.
To form the voltage
followers, solder the
negative input and
output of each op-amp
together for each of
the four stages.



13. Connect Current
Sensor to Terminals

Connect the current
sensor to the current
terminals.


14. Mount
Potentiometers

Mount and solder the
log speed adjustment
potentiometer, along
with the voltage
divider pots.


15. Add Resistors to
Voltage Inputs

Solder resistors
directly to the voltage
input terminals. This
fixed resistor forms
the top half of each
voltage divider.


16. Connect
Components

Using segments of 22
AWG wire, connect
each of the
components as shown
in the complete wiring
diagram.