Download - ADC1 Manual Final

Transcript
  • 7/29/2019 ADC1 Manual Final

    1/23

    RichardHaberkamp

    NikolasRoosevelt

    APracticalExercisefortheADC

    JanuszZalewski,Ph.D

    CDA4170,DataAcquisition&Control

    Spring2009

  • 7/29/2019 ADC1 Manual Final

    2/23

    TableofContents

    1. EquipmentConnectivity 31.1RequiredHardware 3

    1.2Hardware

    Interfaces

    3

    2. SystemSoftware 42.1RequiredSoftware 4

    2.2RunningLabVIEW 4

    2.3ConfiguringLabVIEW 6

    3. Application 63.1OpeningADCVI 6

    3.2Configuring

    ADC

    VI

    7

    3.3ADCCommands 9

    4. References 115. Appendix 12

  • 7/29/2019 ADC1 Manual Final

    3/23

    1. EquipmentConnectivity1.1RequiredHardware

    Thefollowingcomponentsareneededforthisexercise(SeeFigure1):

    SuperLogicsADC1[1] SomedevicetointerfacewiththeADC1(suchasabatterypack) Computer,suchasaPCorLaptop,whichmusthaveanavailableserialporttointerface

    withtheSuperlogicsADC1andmustalsomeettheminimumrequirementsofLabVIEWas

    detailedinTable1.

    Table1:LabVIEWSystemRequirements[2]

  • 7/29/2019 ADC1 Manual Final

    4/23

    1.2HardwareInterfaces

    Toproperlysetuptheequipmentforthisexercise,theuserisrequiredtoconnectthe

    componentsas

    shown

    in

    Figure1:

    Figure1:HardwareSetup

    2. SystemSoftwareToperformthisexercise,theuserisexpectedtohaveNationalInstrumentsLabVIEW8.6

    alreadyinstalledontheircomputer.

    ToruntheLabVIEWapplication,theusercanfollowthesesteps:

    Step1:LeftclickontheStartmenubutton(seeFigure2).

    BatteryPack

    Computer

    SuperLogicsADC1

    ElectricalOutlet

    PowerSupply

    Serial(RS232)

    Connection

  • 7/29/2019 ADC1 Manual Final

    5/23

    Figure2:StartMenuButton

    Step2:NavigatethroughtheStartmenu.ThedefaultStartmenupathoftheapplicationis

    Programs >NationalInstruments >LabVIEW8.6 >LabVIEW,asshowninFigure3.

    Figure3:LocatingLabVIEWintheStartMenu

  • 7/29/2019 ADC1 Manual Final

    6/23

    Step3:Afterthesplashscreen,youwillbepresentedwiththemaindialogofLabVIEW,asshownin

    Figure4.

    Figure4:MainLabVIEWWindow

    ThisexercisewillusethedefaultconfigurationoftheLabVIEWapplication.

    3. Application3.1OpeningADCVI

    1

    AftertheuserhasopenedLabVIEW,theycanthenopentheVIusedtocommunicatewiththe

    ADC.ItisassumedthattheuserhasacopyoftheVIavailableontheircomputer.Thefollowing

    stepsdetailhowtoopentheVI(assumingitislocatedontheirdesktop):

    Step1:FromthemainwindowselectFile >Open(AsshowninFigure5)

    Figure5:HowtoOpentheVI

    1 LabVIEW programs are commonly called Virtual Instruments, in brief VIs

  • 7/29/2019 ADC1 Manual Final

    7/23

    Step2:AfterbeingpresentedwiththeOpendialog,navigatetothelocationwheretheVIis

    savedbyleftclickingtheDesktopbuttonintheleftpane(seeFigure6).

    Figure6:LabVIEWOpenDialog

    Step3:Leftclickonthenameofthefile,such ADC1RW.viandthenleftclickontheOK

    button(SeeFigure7). Asaresult,theapplicationwillopeninawindowasshowninFigure8.

    Figure7:SelectingtheFile

    3.2ConfiguringADCVI

  • 7/29/2019 ADC1 Manual Final

    8/23

    TheVIiswrittentocommunicatewiththeADCviatheserialportviathedefaultconfiguration.

    Theconfigurableparametersareasfollows:VISAresourcename(port),baudrate,databits,

    paritybit,stopbits,andflowcontrol.Intheeventthatanerrorisencounteredwhiletryingto

    communicatewiththeADC,theusermayneedtotweakthesesettingsfromthedefaults.

    Thedefault

    configuration

    is:

    VISAresourcename:COM1 baudrate:19200 databits:8 parity:None stopbits:1.0 flowcontrol:None

    Figure8:ADC1RW.viFrontPanel

    Onceanynecessaryconfigurationchangeshavebeenmade,theusermustleftclicktheRun

    Continuouslybutton.

  • 7/29/2019 ADC1 Manual Final

    9/23

    Figure9:LeftclicktheSecondButtonforRunContinuously

    WhiletheVIisrunning,theusermaytogglethewriteandreadswitchestotheONposition.This

    willallowtheVItowritetheuserspecifiedinputtotheADC,andthenreadanyvaluethatmaybe

    returned.Asuccessfulcommunicationofthedefaultstringtowritevalueof*IDN?\r\nwillprovide

    aread

    string

    of

    X

    (as

    shown

    below).

    Figure10:ASuccessfulWritethenRead

    3.3ADCCommands

    Providedfortheuseristheabilitytousepreprogrammedcommandsinsteadofthosethatare

    userspecified.Theusermayselectonepreprogrammedcommandsbyselectingadifferent

    optionunderInputSelection.Therearefourpreprogrammedcommandsavailabletotheuser:FirmwareVersion,DigitalInputPortStatus,PulseCounter,andReceiveErrorCount.ThereareadditionalcommandsthattheusermayissuewiththeUserInputoptionselected.Eachcommandspecifiedinthestringtowritefieldmustbefollowedby\r\n.Thisissuesacarriagereturnandnewlinewithinthewritestring,andisrequiredforsuccessfullyissuingcommands.

    Additionalcommandstheusermayspecifyareasfollows:

  • 7/29/2019 ADC1 Manual Final

    10/23

    Table2:ADCCommand/Response Table[3]

    Note:AnexceptiontothislististheLyxxx(D/Aoutput)command.Thistableisfromthe

    equipmentmanualthataccompaniestheSuperLogicsADC1R2,whichisbaseduponfirmware

    version3.0.UsedinthisexerciseistheolderADC1modelwhichusesfirmwareversion2.2.Using

    theLyxxxcommandwiththeoldfirmwarewillprovidearesponseofX.

  • 7/29/2019 ADC1 Manual Final

    11/23

    3.4ReceivingDataFromTheADC

    Usingthefollowingtableinconjunctionwitheitheroftheanalognibblecommands,UorQ,theuser

    cantakereadingsfromeachoftheanalogchannels. Theusercanreaddirectlyfromaport,ortake

    thedifferentialbetweenchannels.

    Table3:AnalogControlNibbles[3]

    Table4:ExampleNibbleCommands[3]

  • 7/29/2019 ADC1 Manual Final

    12/23

  • 7/29/2019 ADC1 Manual Final

    13/23

    [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

  • 7/29/2019 ADC1 Manual Final

    14/23

    5.Appendix:DevelopmentoftheADC1VirtualInstrument

    ThefirstthingthatneedstobedoneistodownloadandinstallthemostcurrentNational

    InstrumentsDeviceDriversfromni.com. Afterthishasbeencompleted(downloadingand

    installingnormallyrequiresonetotwohours)developmentoftheVIinLabVIEWcanbegin.

    ThewaytogoaboutdevelopingthisVIistobreakitupintosmallercomponents. First,

    establishcommunicationswiththedevice. Then,addtheabilitytoinputcommandsand

    receivearesponse. Next,addsomefunctionalitysuchasbuttonsforcommoncommands,

    comboboxeswithconfigurationoptions. Finely,addthecomponentstoreadinvoltages

    fromtheADCanddisplayitnumericallyandasagraph.

    5.1Establishing

    Communications

    with

    the

    Superlogics

    ADC

    1

    Tobeginprogramming,openLabVIEWfollowingthestepsoutlinedinsection2ofthis

    document,SystemSoftware. Oncethisisdone,doubleclickonBlankVI(showninFigure11)

    tocreateanewLabVIEWproject.

    Figure11:OpeningablankVI

    ThefrontpanelofanewVIwillopen. InordertocommuicatewiththeADC,weneedsome

    waytoconfigureourVItocommunicatewithit. Luckelly,LabVIEWcomesprepackagedwith

  • 7/29/2019 ADC1 Manual Final

    15/23

    severalInstrumentI/OVIs. TheVIswewillmostlybeusingaretheVISAs locatedinthe

    IntrumentI/Opalletteofthecontrolpanel,asshowninFigure12.

    Figure12:ControlPanelshowingexpandedInstrumentI/Opalette.

    Toallow

    communication

    between

    the

    ADC

    and

    the

    application,

    the

    user

    will

    have

    to

    be

    able

    tosettheproperportconfiguration. Todothis,clickanddragtheVISAConfigureSerialPort

    formtheInstrumentI/OunderSerial. DragtheVISAanddropitontotheblockdiagram

    (Figure13).

  • 7/29/2019 ADC1 Manual Final

    16/23

    Figure13:PlacingtheVistaConfigureSerialPortontheBlockDiagram.

    ThisVISAallowstheportsettingstobeestablished,eitherbyconstantssetbythe

    programmer,orasinputsfromtheuser. Theusershouldbeabletochoosetheproper

    settings,so

    the

    next

    step

    is

    to

    add

    controls

    for

    the

    proper

    port

    settings.

    To

    add

    each

    of

    the

    controlsrightclickonthefrontpanelanddraganddropaTextControl(Figure14)foreachof

    therequiredsettings:PortName,BaudRate,DataBits,Parity,StopBits,FlowControl,and

    ReadFrequencyasshowninFigure15.

  • 7/29/2019 ADC1 Manual Final

    17/23

    Figure14:TestControls

    Figure15:PortSettings.

    WireeachcontroltotheVISAConfigureSerialPortasshowninFigure16.

  • 7/29/2019 ADC1 Manual Final

    18/23

    Figure16:WirecontrolstoVISA.

    CommandInput

    NowwewanttobeabletoinputcommandstotheADC1. Thiswillrequirecontrolsto

    selectdesiredcommands,andaswitchtowritetotheADC. AddaswitchtotheFrontpanel

    inthesamemannerasaddingtextcontrolsinsection5.1asshowninfigure17.

    Figure17:SwitchControlPalette

    ThiswillbetheWritecontrol. AddaCasestructuretothebackpanelfromtheProgramming

    PaletteasshowninFigure18andFigure19. ThiscasewillbetruewhentheWriteswitchis

  • 7/29/2019 ADC1 Manual Final

    19/23

    toggledonandfalsewhenitistoggledoff.

    Figure18: TheProgrammingPalette.

    Figure19: Casestructurewithwritetogglewired.

    InsidetheWritecasestructureisanothercasestructure. Thisonehasadifferentcasefor

    eachofthecommandoptions. SelectanothercasestructurefromtheProgrammingPalette

  • 7/29/2019 ADC1 Manual Final

    20/23

    andplaceitinsidetheWritecasestructureasshowninFigure19.

    SelecttheVISAWriteobjectfromtheI/OpaletteasshownpreviouslyinFigure12anddrop

    ininsidetheinnercasestructure. ThiswillallowstringstobewrittentotheADC. Labelthis

    caseas

    User

    Input,

    and

    make

    it

    the

    default

    case.

    This

    will

    be

    for

    when

    the

    user

    whishes

    to

    inputacommandthatisnotincludedwiththisapplicationcommands. AddaTextControlto

    theinsideofthiscase,andwireittothecase. Addanothercasetotheinnercasestructure

    andfollowtheabovestepforeachcommandyouwishtohaveincludedwiththeapplication.

    NowtheVISAConfigureSerialPortneedstobewiredtotheVISAWriteasshowninFigure

    20. NowtheapplicationcanwritetotheADC.

    Figure20: WiretheConfigureSerialPorttotheVISAWrite.

    ReadingFromTheADC1

    ThissectioncoversreadingfromtheADC. Youwillneedawayofcontrollingthefrequency

    atwhichtheADCispolled. ThiscanbedonewithaStackedSequenceStructurefoundinthe

    ProgrammingPaletteasshowninFigure18. AddonetotheBlockDiagram. Insidethis,

    placeaNumericalControlwiredtoaWaitcounterfoundintheTimingPaletteunder

    Programming(Figure21).

  • 7/29/2019 ADC1 Manual Final

    21/23

    Figure21:TimingPaletteandFrequencyControl.

    NowcreatetheCaseStructuretocontrolwhentoreadfromtheADC. PlaceanewCase

    StructureontheBlockDiagramandaddaReadToggleSwitchaswasdonefortheWriteCase

  • 7/29/2019 ADC1 Manual Final

    22/23

    Structure. SelecttheVISAReadfromtheI/OPaletteasshowninFigure12. Alsoadda

    PropertyNodeinsidethisCase. NowtheVISAWritefromSection5.2iswiredthroughthe

    FrequencystructuretothePropertyNode,andthentotheVisaRead(Figure22).

    Figure22:Write,ReadandFrequencyControl.

    CreateaText

    Indicator

    and

    wire

    it

    to

    the

    VISA

    Read.

    This

    shows

    the

    output

    of

    the

    ADC.

    CreatingtheGraph

    Tocreatethegraph,selectBuildXYGraphfromtheExpressVIspalette. Placeitontheblock

    diagramasshowninFigure22. SincetheVISAReadoutputsastring,thisoutputwillhaveto

    beconvertedtoadoubletobereadablebythegraphfunction. TodothisweuseaString

    Subsetfunctiontoreadonly3charactersofthestring,thenconvertthatstringintoanumber

    usingaHexadecimaltoNumberfunction. BothofthesearefoundintheProgramming

    Palette. PlacetheseontotheBlockDiagramandwirethemtogetherasshowninFigure23.

  • 7/29/2019 ADC1 Manual Final

    23/23

    Figure23:TheReadCaseStructure.

    TheoutputthenneedstobeconvertedtoadoublewiththeToDoublePrecisionFloat

    function. ThesignalisthendividedbyaconversionfactorandwiredtotheYinputofthe

    BuildXYGraphVIasshowninFigure23. TheBuildXYGraphisthenwiredtoanXYGraph

    indicatorwhichisplacedontheFrontPanelasShowninFigure24. NowtheApplicationis

    readytoberun.

    Figure24:TheCompletedApplication