Você está na página 1de 23

RichardHaberkamp

NikolasRoosevelt

APracticalExercisefortheADC

JanuszZalewski,Ph.D
CDA4170,DataAcquisition&Control

Spring2009

TableofContents

1. EquipmentConnectivity

1.1RequiredHardware

1.2HardwareInterfaces

2.1RequiredSoftware

2.2RunningLabVIEW

2.3ConfiguringLabVIEW

3.2ConfiguringADCVI

3.3ADCCommands

2. SystemSoftware

3. Application

3.1OpeningADCVI

4. References

11

5. Appendix

12

1. EquipmentConnectivity
1.1RequiredHardware

Thefollowingcomponentsareneededforthisexercise(SeeFigure1):

SuperLogicsADC1[1]

SomedevicetointerfacewiththeADC1(suchasabatterypack)

Computer,suchasaPCorLaptop,whichmusthaveanavailableserialporttointerface
withtheSuperlogicsADC1andmustalsomeettheminimumrequirementsofLabVIEWas
detailedinTable1.

Table1:LabVIEWSystemRequirements[2]

1.2HardwareInterfaces
Toproperlysetuptheequipmentforthisexercise,theuserisrequiredtoconnectthe
componentsasshowninFigure1:

SuperLogicsADC1

BatteryPack
PowerSupply

ElectricalOutlet

Serial(RS232)
Connection

Computer

Figure1:HardwareSetup
2. SystemSoftware
Toperformthisexercise,theuserisexpectedtohaveNationalInstrumentsLabVIEW8.6
alreadyinstalledontheircomputer.

Step1:LeftclickontheStartmenubutton(seeFigure2).

ToruntheLabVIEWapplication,theusercanfollowthesesteps:


Figure2:StartMenuButton

Step2:NavigatethroughtheStartmenu.ThedefaultStartmenupathoftheapplicationis
Programs>NationalInstruments>LabVIEW8.6>LabVIEW,asshowninFigure3.

Figure3:LocatingLabVIEWintheStartMenu

Step3:Afterthesplashscreen,youwillbepresentedwiththemaindialogofLabVIEW,asshownin
Figure4.

Figure4:MainLabVIEWWindow

ThisexercisewillusethedefaultconfigurationoftheLabVIEWapplication.

3. Application
3.1OpeningADCVI1
AftertheuserhasopenedLabVIEW,theycanthenopentheVIusedtocommunicatewiththe
ADC.ItisassumedthattheuserhasacopyoftheVIavailableontheircomputer.Thefollowing
stepsdetailhowtoopentheVI(assumingitislocatedontheirdesktop):
Step1:FromthemainwindowselectFile>Open(AsshowninFigure5)

Figure5:HowtoOpentheVI
1

LabVIEW programs are commonly called Virtual Instruments, in brief VIs

Step2:AfterbeingpresentedwiththeOpendialog,navigatetothelocationwheretheVIis
savedbyleftclickingtheDesktopbuttonintheleftpane(seeFigure6).

Figure6:LabVIEWOpenDialog
Step3:Leftclickonthenameofthefile,suchADC1RW.viandthenleftclickontheOK
button(SeeFigure7).Asaresult,theapplicationwillopeninawindowasshowninFigure8.

Figure7:SelectingtheFile
3.2ConfiguringADCVI

TheVIiswrittentocommunicatewiththeADCviatheserialportviathedefaultconfiguration.
Theconfigurableparametersareasfollows:VISAresourcename(port),baudrate,databits,
paritybit,stopbits,andflowcontrol.Intheeventthatanerrorisencounteredwhiletryingto
communicatewiththeADC,theusermayneedtotweakthesesettingsfromthedefaults.

Thedefaultconfigurationis:

VISAresourcename:COM1

baudrate:19200

databits:8

parity:None

stopbits:1.0

flowcontrol:None

Figure8:ADC1RW.viFrontPanel
Onceanynecessaryconfigurationchangeshavebeenmade,theusermustleftclicktheRun
Continuouslybutton.

Figure9:LeftclicktheSecondButtonforRunContinuously
WhiletheVIisrunning,theusermaytogglethewriteandreadswitchestotheONposition.This
willallowtheVItowritetheuserspecifiedinputtotheADC,andthenreadanyvaluethatmaybe
returned.Asuccessfulcommunicationofthedefaultstringtowritevalueof*IDN?\r\nwill
provideareadstringofX(asshownbelow).

Figure10:ASuccessfulWritethenRead

3.3ADCCommands

Providedfortheuseristheabilitytousepreprogrammedcommandsinsteadofthosethatare
userspecified.Theusermayselectonepreprogrammedcommandsbyselectingadifferent
optionunderInputSelection.Therearefourpreprogrammedcommandsavailabletotheuser:
FirmwareVersion,DigitalInputPortStatus,PulseCounter,andReceiveErrorCount.

ThereareadditionalcommandsthattheusermayissuewiththeUserInputoptionselected.Each
commandspecifiedinthestringtowritefieldmustbefollowedby\r\n.Thisissuesacarriage
returnandnewlinewithinthewritestring,andisrequiredforsuccessfullyissuingcommands.
Additionalcommandstheusermayspecifyareasfollows:


Table2:ADCCommand/ResponseTable[3]

Note:AnexceptiontothislististheLyxxx(D/Aoutput)command.Thistableisfromthe
equipmentmanualthataccompaniestheSuperLogicsADC1R2,whichisbaseduponfirmware
version3.0.UsedinthisexerciseistheolderADC1modelwhichusesfirmwareversion2.2.Using
theLyxxxcommandwiththeoldfirmwarewillprovidearesponseofX.

3.4ReceivingDataFromTheADC
Usingthefollowingtableinconjunctionwitheitheroftheanalognibblecommands,UorQ,theuser
cantakereadingsfromeachoftheanalogchannels.Theusercanreaddirectlyfromaport,ortake
thedifferentialbetweenchannels.

Table3:AnalogControlNibbles[3]

Table4:ExampleNibbleCommands[3]

4. References

[1]SuperLogics,RS232DataAcquisitionDevice,SuperLogics,Inc.,Waltham,MA,2002,
http://www.superlogics.com/specpage.asp?Items=8000
[2]NationalInstruments,SystemRequirementsforLabVIEWDevelopmentSystemandLabVIEW
Modules,NationalInstrumentsCorporation,Austin,TX,2009,
http://www.ni.com/labview/requirements.htm
[3]SuperLogics,ADC1R2I/OModuleManual,SuperLogics,Inc.,Waltham,MA,December30,
2004,http://www.superlogics.com/manuals/adc1.pdf

5.Appendix:DevelopmentoftheADC1VirtualInstrument
ThefirstthingthatneedstobedoneistodownloadandinstallthemostcurrentNational
InstrumentsDeviceDriversfromni.com.Afterthishasbeencompleted(downloadingand
installingnormallyrequiresonetotwohours)developmentoftheVIinLabVIEWcanbegin.

ThewaytogoaboutdevelopingthisVIistobreakitupintosmallercomponents.First,
establishcommunicationswiththedevice.Then,addtheabilitytoinputcommandsand
receivearesponse.Next,addsomefunctionalitysuchasbuttonsforcommoncommands,
comboboxeswithconfigurationoptions.Finely,addthecomponentstoreadinvoltages
fromtheADCanddisplayitnumericallyandasagraph.

5.1EstablishingCommunicationswiththeSuperlogicsADC1
Tobeginprogramming,openLabVIEWfollowingthestepsoutlinedinsection2ofthis
document,SystemSoftware.Oncethisisdone,doubleclickonBlankVI(showninFigure11)
tocreateanewLabVIEWproject.

Figure11:OpeningablankVI
ThefrontpanelofanewVIwillopen.InordertocommuicatewiththeADC,weneedsome
waytoconfigureourVItocommunicatewithit.Luckelly,LabVIEWcomesprepackagedwith

severalInstrumentI/OVIs.TheVIswewillmostlybeusingaretheVISAslocatedinthe
IntrumentI/Opalletteofthecontrolpanel,asshowninFigure12.

Figure12:ControlPanelshowingexpandedInstrumentI/Opalette.

ToallowcommunicationbetweentheADCandtheapplication,theuserwillhavetobeable
tosettheproperportconfiguration.Todothis,clickanddragtheVISAConfigureSerialPort
formtheInstrumentI/OunderSerial.DragtheVISAanddropitontotheblockdiagram
(Figure13).


Figure13:PlacingtheVistaConfigureSerialPortontheBlockDiagram.

ThisVISAallowstheportsettingstobeestablished,eitherbyconstantssetbythe
programmer,orasinputsfromtheuser.Theusershouldbeabletochoosetheproper
settings,sothenextstepistoaddcontrolsfortheproperportsettings.Toaddeachofthe
controlsrightclickonthefrontpanelanddraganddropaTextControl(Figure14)foreachof
therequiredsettings:PortName,BaudRate,DataBits,Parity,StopBits,FlowControl,and
ReadFrequencyasshowninFigure15.

Figure14:TestControls

Figure15:PortSettings.

WireeachcontroltotheVISAConfigureSerialPortasshowninFigure16.


Figure16:WirecontrolstoVISA.
CommandInput
NowwewanttobeabletoinputcommandstotheADC1.Thiswillrequirecontrolsto
selectdesiredcommands,andaswitchtowritetotheADC.AddaswitchtotheFrontpanel
inthesamemannerasaddingtextcontrolsinsection5.1asshowninfigure17.

Figure17:SwitchControlPalette
ThiswillbetheWritecontrol.AddaCasestructuretothebackpanelfromtheProgramming
PaletteasshowninFigure18andFigure19.ThiscasewillbetruewhentheWriteswitchis

toggledonandfalsewhenitistoggledoff.

Figure18:TheProgrammingPalette.

Figure19:Casestructurewithwritetogglewired.

InsidetheWritecasestructureisanothercasestructure.Thisonehasadifferentcasefor
eachofthecommandoptions.SelectanothercasestructurefromtheProgrammingPalette

andplaceitinsidetheWritecasestructureasshowninFigure19.

SelecttheVISAWriteobjectfromtheI/OpaletteasshownpreviouslyinFigure12anddrop
ininsidetheinnercasestructure.ThiswillallowstringstobewrittentotheADC.Labelthis
caseasUserInput,andmakeitthedefaultcase.Thiswillbeforwhentheuserwhishesto
inputacommandthatisnotincludedwiththisapplicationcommands.AddaTextControlto
theinsideofthiscase,andwireittothecase.Addanothercasetotheinnercasestructure
andfollowtheabovestepforeachcommandyouwishtohaveincludedwiththeapplication.

NowtheVISAConfigureSerialPortneedstobewiredtotheVISAWriteasshowninFigure
20.NowtheapplicationcanwritetotheADC.

Figure20:WiretheConfigureSerialPorttotheVISAWrite.
ReadingFromTheADC1
ThissectioncoversreadingfromtheADC.Youwillneedawayofcontrollingthefrequency
atwhichtheADCispolled.ThiscanbedonewithaStackedSequenceStructurefoundinthe
ProgrammingPaletteasshowninFigure18.AddonetotheBlockDiagram.Insidethis,
placeaNumericalControlwiredtoaWaitcounterfoundintheTimingPaletteunder
Programming(Figure21).

Figure21:TimingPaletteandFrequencyControl.

NowcreatetheCaseStructuretocontrolwhentoreadfromtheADC.PlaceanewCase
StructureontheBlockDiagramandaddaReadToggleSwitchaswasdonefortheWriteCase

Structure.SelecttheVISAReadfromtheI/OPaletteasshowninFigure12.Alsoadda
PropertyNodeinsidethisCase.NowtheVISAWritefromSection5.2iswiredthroughthe
FrequencystructuretothePropertyNode,andthentotheVisaRead(Figure22).

Figure22:Write,ReadandFrequencyControl.
CreateaTextIndicatorandwireittotheVISARead.ThisshowstheoutputoftheADC.

CreatingtheGraph
Tocreatethegraph,selectBuildXYGraphfromtheExpressVIspalette.Placeitontheblock
diagramasshowninFigure22.SincetheVISAReadoutputsastring,thisoutputwillhaveto
beconvertedtoadoubletobereadablebythegraphfunction.TodothisweuseaString
Subsetfunctiontoreadonly3charactersofthestring,thenconvertthatstringintoanumber
usingaHexadecimaltoNumberfunction.BothofthesearefoundintheProgramming
Palette.PlacetheseontotheBlockDiagramandwirethemtogetherasshowninFigure23.


Figure23:TheReadCaseStructure.

TheoutputthenneedstobeconvertedtoadoublewiththeToDoublePrecisionFloat
function.ThesignalisthendividedbyaconversionfactorandwiredtotheYinputofthe
BuildXYGraphVIasshowninFigure23.TheBuildXYGraphisthenwiredtoanXYGraph
indicatorwhichisplacedontheFrontPanelasShowninFigure24.NowtheApplicationis
readytoberun.

Figure24:TheCompletedApplication

Você também pode gostar