Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file...

116

Transcript of Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file...

Page 1: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,
Page 2: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

ModbusLabVIEWLibraryHelpFebruary2009,372767A-01ThishelpfiledescribestheModbusLabVIEWVIlibrary.Formoreinformationaboutthishelpfile,refertothefollowingtopics:UsingHelpImportantInformationTechnicalSupportandProfessionalServicesTocommentonNationalInstrumentsdocumentation,refertotheNationalInstrumentsWebsite.©2009NationalInstrumentsCorporation.Allrightsreserved.

Page 3: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

UsingHelpConventionsNavigatingHelpSearchingHelpPrintingHelpFileTopics

Page 4: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

ConventionsThishelpfileusesthefollowingformattingandtypographicalconventions:

Thisicondenotesanote,whichalertsyoutoimportantinformation.Thisicondenotesatip,whichalertsyoutoadvisoryinformation.

bold Boldtextdenotesitemsthatyoumustselectorclickinthesoftware,suchasmenuitemsanddialogboxoptions.Boldtextalsodenotesparameternames.

green Underlinedtextinthiscolordenotesalinktoahelptopic,helpfile,orWebaddress.

purple Underlinedtextinthiscolordenotesavisitedlinktoahelptopic,helpfile,orWebaddress.

italic Italictextdenotesvariables,emphasis,cross-references,oranintroductiontoakeyconcept.Italictextalsodenotestextthatisaplaceholderforawordorvaluethatyoumustsupply.

monospace Textinthisfontdenotestextorcharactersthatyoushouldenterfromthekeyboard,sectionsofcode,programmingexamples,andsyntaxexamples.Thisfontisalsousedforthepropernamesofdiskdrives,paths,directories,programs,subprograms,subroutines,devicenames,functions,operations,variables,filenames,andextensions.

Page 5: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

NavigatingHelp(WindowsOnly)Tonavigatethishelpfile,usetheContents,Index,andSearchtabstotheleftofthiswindoworusethefollowingtoolbarbuttonslocatedabovethetabs:

NoteTheinformationinthistopiconlyappliestothehelpfileinstalledwiththeWindowsversionofthesoftware.Hide—Hidesthenavigationpanefromview.Locate—LocatesthecurrentlydisplayedtopicintheContentstab,allowingyoutoviewrelatedtopics.Back—Displaysthepreviouslyviewedtopic.Forward—DisplaysthetopicyouviewedbeforeclickingtheBackbutton.Options—Displaysalistofcommandsandviewingoptionsforthehelpfile.

Page 6: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

SearchingHelp(WindowsOnly)UsetheSearchtabtotheleftofthiswindowtolocatecontentinthishelpfile.

NoteTheinformationinthistopiconlyappliestothehelpfileinstalledwiththeWindowsversionofthesoftware.

Ifyouwanttosearchforwordsinacertainorder,suchas"relateddocumentation,"addquotationmarksaroundthesearchwordsasshownintheexample.SearchingfortermsontheSearchtaballowsyoutoquicklylocatespecificinformationandinformationintopicsthatarenotincludedontheContentstab.

TipYoucantemporarilydisablethesearchhighlightingfeaturebyselectingOptions»SearchHighlightOfffromthetoolbar.

Page 7: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

WildcardsYoualsocansearchusingasterisk(*)orquestionmark(?)wildcards.Usetheasteriskwildcardtoreturntopicsthatcontainacertainstring.Forexample,asearchfor"prog*"liststopicsthatcontainthewords"program,""programmatically,""progress,"andsoon.Usethequestionmarkwildcardasasubstituteforasinglecharacterinasearchterm.Forexample,"?ext"liststopicsthatcontainthewords"next,""text,"andsoon.

NoteWildcardsearchingwillnotworkonSimplifiedChinese,TraditionalChinese,Japanese,andKoreansystems.

Page 8: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

NestedExpressionsUsenestedexpressionstocombinesearchestofurtherrefineasearch.YoucanuseBooleanexpressionsandwildcardsinanestedexpression.Forexample,"exampleAND(programORVI)"liststopicsthatcontain"exampleprogram"or"exampleVI."Youcannotnestexpressionsmorethanfivelevels.

Page 9: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

BooleanExpressionsClickthe buttontoaddBooleanexpressionstoasearch.ThefollowingBooleanoperatorsareavailable:

AND(default)—Returnstopicsthatcontainbothsearchterms.Youdonotneedtospecifythisoperatorunlessyouareusingnestedexpressions.OR—Returnstopicsthatcontaineitherthefirstorsecondterm.NOT—Returnstopicsthatcontainthefirsttermwithoutthesecondterm.NEAR—Returnstopicsthatcontainbothtermswithineightwordsofeachother.

Page 10: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

SearchOptions

UsethefollowingcheckboxesontheSearchtabtocustomizeasearch:Searchpreviousresults—Narrowstheresultsfromasearchthatreturnedtoomanytopics.Youmustremovethecheckmarkfromthischeckboxtosearchalltopics.Matchsimilarwords—Broadensasearchtoreturntopicsthatcontainwordssimilartothesearchterms.Forexample,asearchfor"program"liststopicsthatincludethewords"programs,""programming,"andsoon.Searchtitlesonly—Searchesonlyinthetitlesoftopics.

Page 11: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

PrintingHelpFileTopics(WindowsOnly)CompletethefollowingstepstoprintanentirebookfromtheContentstab:

NoteTheinformationinthistopiconlyappliestothehelpfileinstalledwiththeWindowsversionofthesoftware.

1. Right-clickthebook.2. SelectPrintfromtheshortcutmenutodisplaythePrintTopics

dialogbox.3. SelectthePrinttheselectedheadingandallsubtopicsoption.

NoteSelectPrinttheselectedtopicifyouwanttoprintthesingletopicyouhaveselectedintheContentstab.

4. ClicktheOKbutton.

Page 12: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

PrintingPDFDocumentsThishelpfilemaycontainlinkstoPDFdocuments.ToprintPDFdocuments,clicktheprintbuttonlocatedontheAdobeAcrobatViewertoolbar.

Page 13: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetMasterQueryReadCoils(poly).viThemasterusesthisVIreadtheslaves'coils.Thiscorrespondstoapublicfunctioncodeof1intheMODBUSprotocol.

MBAPHeaderisaclustercontainingthetransactionIDandUnitID.ThisisadditionalinformationnotusuallyrequiredforaMODBUStransaction.

TransactionIdentifier—Thisidentifierisfortransactionpairing;theMODBUSservercopiestherequesttransactionidentifierintheresponse.UnitIdentifier—Thisfieldisforintra-systemroutingpurposes.IttypicallycommunicatestoaMODBUSseriallineslavethroughagatewaybetweenanEthernetTCP-IPnetworkandaMODBUSserialline.TheMODBUSclientsetsthisfieldintherequest,andtheserverresponsemustreturnthisfieldwiththesamevalue.

TCPConnectionRefnuminisanetworkconnectionrefnumthatuniquelyidentifiestheTCPconnection.UseTCPOpenConnection.vitoopenaTCPconnection.StartingAddressisthefirstaddresslocationofthecoiltoread.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindthecoiladdressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdevice

Page 14: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

configurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Quantityrepresentshowmanycoilstoreadfromtheslave.TheVIreturnsthecoilatStartingAddressandeachfollowingcoiluptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadscoilsfromtheslaveataddress0,1,2,and3.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

TCPConnectionRefnum(dup)canbeaninputtoanotherMODBUSVI,oryoucancloseitusingTCPCloseConnection.vi.

Coilsrepresentsthedatareadfromtheslave.

Page 15: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 16: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetMasterQueryReadDiscreteInputs(poly).viThemasterusesthisVItoreadtheslaves'discreteinputs.Thiscorrespondstoapublicfunctioncodeof2intheMODBUSprotocol.

MBAPHeaderisaclustercontainingthetransactionIDandUnitID.ThisisadditionalinformationnotusuallyrequiredforaMODBUStransaction.

TransactionIdentifier—Thisidentifierisfortransactionpairing;theMODBUSservercopiestherequesttransactionidentifierintheresponse.UnitIdentifier—Thisfieldisforintra-systemroutingpurposes.IttypicallycommunicatestoaMODBUSseriallineslavethroughagatewaybetweenanEthernetTCP-IPnetworkandaMODBUSserialline.TheMODBUSclientsetsthisfieldintherequest,andtheserverresponsemustreturnthisfieldwiththesamevalue.

TCPConnectionRefnuminisanetworkconnectionrefnumthatuniquelyidentifiestheTCPconnection.UseTCPOpenConnection.vitoopenaTCPconnection.StartingAddressisthefirstaddresslocationofthediscreteinputstoread.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindthediscreteinputaddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibrary

Page 17: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

expectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Quantityrepresentshowmanydiscreteinputstoreadfromtheslave.TheVIreturnsthediscreteinputatStartingAddressandeachfollowingdiscreteinputuptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadsdiscreteinputsfromtheslaveataddress0,1,2,and3.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

Page 18: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

TCPConnectionRefnum(dup)canbeaninputtoanotherMODBUSVI,oryoucancloseitusingTCPCloseConnection.vi.DiscreteInputsrepresentsthedatareadfromtheslave.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 19: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetMasterQueryReadExceptionStatus(poly).viThemasterusesthisVItoreadtheexceptionstatusfromtheslave.Thiscorrespondstoapublicfunctioncodeof7intheMODBUSprotocol.

MBAPHeaderisaclustercontainingthetransactionIDandUnitID.ThisisadditionalinformationnotusuallyrequiredforaMODBUStransaction.

TransactionIdentifier—Thisidentifierisfortransactionpairing;theMODBUSservercopiestherequesttransactionidentifierintheresponse.UnitIdentifier—Thisfieldisforintra-systemroutingpurposes.IttypicallycommunicatestoaMODBUSseriallineslavethroughagatewaybetweenanEthernetTCP-IPnetworkandaMODBUSserialline.TheMODBUSclientsetsthisfieldintherequest,andtheserverresponsemustreturnthisfieldwiththesamevalue.

TCPConnectionRefnuminisanetworkconnectionrefnumthatuniquelyidentifiestheTCPconnection.UseTCPOpenConnection.vitoopenaTCPconnection.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIor

Page 20: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

functionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

TCPConnectionRefnum(dup)canbeaninputtoanotherMODBUSVI,oryoucancloseitusingTCPCloseConnection.vi.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0ora

Page 21: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

warningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 22: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetMasterQueryReadHoldingRegisters(poly).viThemasterusesthisVItoreadtheslaves'holdingregisters.Thiscorrespondstoapublicfunctioncodeof3intheMODBUSprotocol.

MBAPHeaderisaclustercontainingthetransactionIDandUnitID.ThisisadditionalinformationnotusuallyrequiredforaMODBUStransaction.

TransactionIdentifier—Thisidentifierisfortransactionpairing;theMODBUSservercopiestherequesttransactionidentifierintheresponse.UnitIdentifier—Thisfieldisforintra-systemroutingpurposes.IttypicallycommunicatestoaMODBUSseriallineslavethroughagatewaybetweenanEthernetTCP-IPnetworkandaMODBUSserialline.TheMODBUSclientsetsthisfieldintherequest,andtheserverresponsemustreturnthisfieldwiththesamevalue.

TCPConnectionRefnuminisanetworkconnectionrefnumthatuniquelyidentifiestheTCPconnection.UseTCPOpenConnection.vitoopenaTCPconnection.StartingAddressisthefirstaddresslocationoftheholdingregistertoread.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindtheholdingregisteraddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibrary

Page 23: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

expectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Quantityrepresentshowmanyholdingregisterstoreadfromtheslave.TheVIreturnstheholdingregisteratStartingAddressandeachfollowingholdingregisteruptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadsholdingregistersfromtheslaveataddress0,1,2,and3.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

Page 24: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

TCPConnectionRefnum(dup)canbeaninputtoanotherMODBUSVI,oryoucancloseitusingTCPCloseConnection.vi.HoldingRegistersrepresentsthedatareadfromtheslave.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 25: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetMasterQueryReadInputRegisters(poly).viThemasterusesthisVItoreadtheslaves'inputregisters.Thiscorrespondstoapublicfunctioncodeof4intheMODBUSprotocol.

MBAPHeaderisaclustercontainingthetransactionIDandUnitID.ThisisadditionalinformationnotusuallyrequiredforaMODBUStransaction.

TransactionIdentifier—Thisidentifierisfortransactionpairing;theMODBUSservercopiestherequesttransactionidentifierintheresponse.UnitIdentifier—Thisfieldisforintra-systemroutingpurposes.IttypicallycommunicatestoaMODBUSseriallineslavethroughagatewaybetweenanEthernetTCP-IPnetworkandaMODBUSserialline.TheMODBUSclientsetsthisfieldintherequest,andtheserverresponsemustreturnthisfieldwiththesamevalue.

TCPConnectionRefnuminisanetworkconnectionrefnumthatuniquelyidentifiestheTCPconnection.UseTCPOpenConnection.vitoopenaTCPconnection.StartingAddressisthefirstaddresslocationoftheinputregistertoread.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindtheinputregisteraddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibrary

Page 26: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

expectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Quantityrepresentshowmanyinputregisterstoreadfromtheslave.TheVIreturnstheinputregisteratStartingAddressandeachfollowinginputregisteruptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadsinputregistersfromtheslaveataddress0,1,2,and3.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

Page 27: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

TCPConnectionRefnum(dup)canbeaninputtoanotherMODBUSVI,oryoucancloseitusingTCPCloseConnection.vi.InputRegistersrepresentsthedatareadfromtheslave.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 28: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetMasterQueryWriteMultipleCoils(poly).viThemasterusesthisVItowritemultiplecoilstotheslave.Thiscorrespondstoapublicfunctioncodeof15intheMODBUSprotocol.

MBAPHeaderisaclustercontainingthetransactionIDandUnitID.ThisisadditionalinformationnotusuallyrequiredforaMODBUStransaction.

TransactionIdentifier—Thisidentifierisfortransactionpairing;theMODBUSservercopiestherequesttransactionidentifierintheresponse.UnitIdentifier—Thisfieldisforintra-systemroutingpurposes.IttypicallycommunicatestoaMODBUSseriallineslavethroughagatewaybetweenanEthernetTCP-IPnetworkandaMODBUSserialline.TheMODBUSclientsetsthisfieldintherequest,andtheserverresponsemustreturnthisfieldwiththesamevalue.

TCPConnectionRefnuminisanetworkconnectionrefnumthatuniquelyidentifiestheTCPconnection.UseTCPOpenConnection.vitoopenaTCPconnection.StartingAddressistheaddresslocationofthefirstcoiltowrite.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindthecoiladdressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneed

Page 29: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

tosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Coilsisthecoilstowrite.Thearraylengthrepresentsthenumberofcoilsthatwillbewritten.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

TCPConnectionRefnum(dup)canbeaninputtoanotherMODBUSVI,oryoucancloseitusingTCPCloseConnection.vi.

ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.The

Page 30: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

exceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 31: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetMasterQueryWriteMultipleRegisters(poly).viThemasterusesthisVItowritemultipleregisterstotheslave.Thiscorrespondstoapublicfunctioncodeof16intheMODBUSprotocol.

MBAPHeaderisaclustercontainingthetransactionIDandUnitID.ThisisadditionalinformationnotusuallyrequiredforaMODBUStransaction.

TransactionIdentifier—Thisidentifierisfortransactionpairing;theMODBUSservercopiestherequesttransactionidentifierintheresponse.UnitIdentifier—Thisfieldisforintra-systemroutingpurposes.IttypicallycommunicatestoaMODBUSseriallineslavethroughagatewaybetweenanEthernetTCP-IPnetworkandaMODBUSserialline.TheMODBUSclientsetsthisfieldintherequest,andtheserverresponsemustreturnthisfieldwiththesamevalue.

TCPConnectionRefnuminisanetworkconnectionrefnumthatuniquelyidentifiestheTCPconnection.UseTCPOpenConnection.vitoopenaTCPconnection.StartingAddressistheaddresslocationofthefirstregistertowrite.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindtheregisteraddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneed

Page 32: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

tosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Registersaretheregisterstowrite.Thearraylengthrepresentshowmanyregisterswillbewritten.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

TCPConnectionRefnum(dup)canbeaninputtoanotherMODBUSVI,oryoucancloseitusingTCPCloseConnection.vi.

ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.The

Page 33: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

exceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 34: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetMasterQueryWriteSingleCoil(poly).viThemasterusesthisVItowriteasinglecoiltotheslave.Thiscorrespondstoapublicfunctioncodeof5intheMODBUSprotocol.

MBAPHeaderisaclustercontainingthetransactionIDandUnitID.ThisisadditionalinformationnotusuallyrequiredforaMODBUStransaction.

TransactionIdentifier—Thisidentifierisfortransactionpairing;theMODBUSservercopiestherequesttransactionidentifierintheresponse.UnitIdentifier—Thisfieldisforintra-systemroutingpurposes.IttypicallycommunicatestoaMODBUSseriallineslavethroughagatewaybetweenanEthernetTCP-IPnetworkandaMODBUSserialline.TheMODBUSclientsetsthisfieldintherequest,andtheserverresponsemustreturnthisfieldwiththesamevalue.

TCPConnectionRefnuminisanetworkconnectionrefnumthatuniquelyidentifiestheTCPconnection.UseTCPOpenConnection.vitoopenaTCPconnection.Addressisthefirstaddresslocationofthecoiltowrite.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindthecoiladdressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneed

Page 35: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

tosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Coilisthecoiltowrite.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

TCPConnectionRefnum(dup)canbeaninputtoanotherMODBUSVI,oryoucancloseitusingTCPCloseConnection.vi.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror

Page 36: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.

erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 37: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetMasterQueryWriteSingleRegister(poly).viThemasterusesthisVItowriteasingleregistertotheslave.Thiscorrespondstoapublicfunctioncodeof6intheMODBUSprotocol.

MBAPHeaderisaclustercontainingthetransactionIDandUnitID.ThisisadditionalinformationnotusuallyrequiredforaMODBUStransaction.

TransactionIdentifier—Thisidentifierisfortransactionpairing;theMODBUSservercopiestherequesttransactionidentifierintheresponse.UnitIdentifier—Thisfieldisforintra-systemroutingpurposes.IttypicallycommunicatestoaMODBUSseriallineslavethroughagatewaybetweenanEthernetTCP-IPnetworkandaMODBUSserialline.TheMODBUSclientsetsthisfieldintherequest,andtheserverresponsemustreturnthisfieldwiththesamevalue.

TCPConnectionRefnuminisanetworkconnectionrefnumthatuniquelyidentifiestheTCPconnection.UseTCPOpenConnection.vitoopenaTCPconnection.Addressistheaddresslocationoftheregistertowrite.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindtheregisteraddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneed

Page 38: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

tosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Registeristheregistertowrite.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

TCPConnectionRefnum(dup)canbeaninputtoanotherMODBUSVI,oryoucancloseitusingTCPCloseConnection.vi.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror

Page 39: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.

erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 40: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialMasterQueryReadCoils(poly).viThemasterusesthisVItoreadtheslaves'coils.Thiscorrespondstoapublicfunctioncodeof1intheMODBUSprotocol.

SerialParametersareparametersthatmodifythewaytheMODBUSframeisstructured.RefertotheMODBUSspecificationformoreinformationabouttheMODBUSFrame.TheSerialParametersinLabVIEWisaclustercontaininganenum(Mode)andaninteger(SlaveAddress).ModeRTUDataisrepresentedinbinaryformat.ASCIIDataisrepresentedinASCII,soitishumanreadable.

SlaveAddressThisistheaddressoftheslaveyouarecommunicatingwith.ThispropertyisusuallyvalidforRS-485networks,whichcanhavemultipleMODBUSdevicesconnectedtothesamenetwork.

Note:Consultyourdevicedocumentationtofindouthowtovalidate/changetheaddressofyourdevice.

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.StartingAddressisthefirstaddresslocationofthecoiltoread.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindthecoiladdressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,

Page 41: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Quantityrepresentshowmanycoilstoreadfromtheslave.TheVIreturnsthecoilatStartingAddressandeachfollowingcoiluptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadscoilsfromtheslaveataddress0,1,2,and3.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.

sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,

Page 42: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

whatinputsareinerror,andhowtoeliminatetheerror.

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.Coilsrepresentsthedatareadfromtheslave.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.

sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 43: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialMasterQueryReadDiscreteInputs(poly).viThemasterusesthisVItoreadtheslaves'discreteinputs.Thiscorrespondstoapublicfunctioncodeof2intheMODBUSprotocol.

SerialParametersareparametersthatmodifythewaytheMODBUSframeisstructured.RefertotheMODBUSspecificationformoreinformationabouttheMODBUSFrame.TheSerialParametersinLabVIEWisaclustercontaininganenum(Mode)andaninteger(SlaveAddress).ModeRTUDataisrepresentedinbinaryformat.ASCIIDataisrepresentedinASCII,soitishumanreadable.

SlaveAddressThisistheaddressoftheslaveyouarecommunicatingwith.ThispropertyisusuallyvalidforRS-485networks,whichcanhavemultipleMODBUSdevicesconnectedtothesamenetwork.

Note:Consultyourdevicedocumentationtofindouthowtovalidate/changetheaddressofyourdevice.

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.StartingAddressisthefirstaddresslocationofthediscreteinputstoread.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindthediscreteinputaddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.

Page 44: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Quantityrepresentshowmanydiscreteinputstoreadfromtheslave.TheVIreturnsthediscreteinputatStartingAddressandeachfollowingdiscreteinputuptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadsdiscreteinputsfromtheslaveataddress0,1,2,and3.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,

Page 45: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.DiscreteInputsrepresentsthedatareadfromtheslave.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.

Page 46: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 47: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialMasterQueryReadExceptionStatus(poly).viThemasterusesthisVItoreadtheexceptionstatusfromtheslave.Thiscorrespondstoapublicfunctioncodeof7intheMODBUSprotocol.

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

SerialParametersareparametersthatmodifythewaytheMODBUSframeisstructured.RefertotheMODBUSspecificationformoreinformationabouttheMODBUSFrame.TheSerial

Page 48: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

ParametersinLabVIEWisaclustercontaininganenum(Mode)andaninteger(SlaveAddress).ModeRTUDataisrepresentedinbinaryformat.ASCIIDataisrepresentedinASCII,soitishumanreadable.

SlaveAddressThisistheaddressoftheslaveyouarecommunicatingwith.ThispropertyisusuallyvalidforRS-485networks,whichcanhavemultipleMODBUSdevicesconnectedtothesamenetwork.

Note:Consultyourdevicedocumentationtofindouthowtovalidate/changetheaddressofyourdevice.

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfront

Page 49: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

panelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 50: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialMasterQueryReadHoldingRegisters(poly).viThemasterusesthisVItoreadtheslaves'holdingregisters.Thiscorrespondstoapublicfunctioncodeof3intheMODBUSprotocol.

SerialParametersareparametersthatmodifythewaytheMODBUSframeisstructured.RefertotheMODBUSspecificationformoreinformationabouttheMODBUSFrame.TheSerialParametersinLabVIEWisaclustercontaininganenum(Mode)andaninteger(SlaveAddress).ModeRTUDataisrepresentedinbinaryformat.ASCIIDataisrepresentedinASCII,soitishumanreadable.

SlaveAddressThisistheaddressoftheslaveyouarecommunicatingwith.ThispropertyisusuallyvalidforRS-485networks,whichcanhavemultipleMODBUSdevicesconnectedtothesamenetwork.

Note:Consultyourdevicedocumentationtofindouthowtovalidate/changetheaddressofyourdevice.

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.StartingAddressisthefirstaddresslocationoftheholdingregistertoread.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindtheholdingregisteraddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.

Page 51: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Quantityrepresentshowmanyholdingregisterstoreadfromtheslave.TheVIreturnstheholdingregisteratStartingAddressandeachfollowingholdingregisteruptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadsholdingregistersfromtheslaveataddress0,1,2,and3.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,

Page 52: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.HoldingRegistersrepresentsthedatareadfromtheslave(arrayofU16).ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.

Page 53: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 54: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialMasterQueryReadInputRegisters(poly).viThemasterusesthisVItoreadtheslavesinputregisters.Thiscorrespondstoapublicfunctioncodeof4intheMODBUSprotocol.

SerialParametersareparametersthatmodifythewaytheMODBUSframeisstructured.RefertotheMODBUSspecificationformoreinformationabouttheMODBUSFrame.TheSerialParametersinLabVIEWisaclustercontaininganenum(Mode)andaninteger(SlaveAddress).ModeRTUDataisrepresentedinbinaryformat.ASCIIDataisrepresentedinASCII,soitishumanreadable.

SlaveAddressThisistheaddressoftheslaveyouarecommunicatingwith.ThispropertyisusuallyvalidforRS-485networks,whichcanhavemultipleMODBUSdevicesconnectedtothesamenetwork.

Note:Consultyourdevicedocumentationtofindouthowtovalidate/changetheaddressofyourdevice.

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.StartingAddressisthefirstaddresslocationoftheinputregistertoread.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindtheinputregisteraddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.

Page 55: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Quantityrepresentshowmanyinputregisterstoreadfromtheslave.TheVIreturnstheinputregisteratStartingAddressandeachfollowinginputregisteruptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadsinputregistersfromtheslaveataddress0,1,2,and3.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,

Page 56: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.InputRegistersrepresentsthedatareadfromtheslave(arrayofU16).ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.

Page 57: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 58: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialMasterQueryWriteMultipleCoils(poly).viThemasterusesthisVItowritemultiplecoilstotheslave.Thiscorrespondstoapublicfunctioncodeof15intheMODBUSprotocol.

SerialParametersareparametersthatmodifythewaytheMODBUSframeisstructured.RefertotheMODBUSspecificationformoreinformationabouttheMODBUSFrame.TheSerialParametersinLabVIEWisaclustercontaininganenum(Mode)andaninteger(SlaveAddress).ModeRTUDataisrepresentedinbinaryformat.ASCIIDataisrepresentedinASCII,soitishumanreadable.

SlaveAddressThisistheaddressoftheslaveyouarecommunicatingwith.ThispropertyisusuallyvalidforRS-485networks,whichcanhavemultipleMODBUSdevicesconnectedtothesamenetwork.

Note:Consultyourdevicedocumentationtofindouthowtovalidate/changetheaddressofyourdevice.

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.StartingAddressistheaddresslocationofthefirstcoiltowrite.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindthecoiladdressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustentera

Page 59: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

namefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Coilsisthecoilstowrite.Thearraylengthrepresentsthenumberofcoilsthatwillbewritten.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

Page 60: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 61: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialMasterQueryWriteMultipleRegisters(poly).viThemasterusesthisVItowritemultipleregisterstotheslave.Thiscorrespondstoapublicfunctioncodeof16intheMODBUSprotocol.

SerialParametersareparametersthatmodifythewaytheMODBUSframeisstructured.RefertotheMODBUSspecificationformoreinformationabouttheMODBUSFrame.TheSerialParametersinLabVIEWisaclustercontaininganenum(Mode)andaninteger(SlaveAddress).ModeRTUDataisrepresentedinbinaryformat.ASCIIDataisrepresentedinASCII,soitishumanreadable.

SlaveAddressThisistheaddressoftheslaveyouarecommunicatingwith.ThispropertyisusuallyvalidforRS-485networks,whichcanhavemultipleMODBUSdevicesconnectedtothesamenetwork.

Note:Consultyourdevicedocumentationtofindouthowtovalidate/changetheaddressofyourdevice.

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.StartingAddressistheaddresslocationofthefirstregistertowrite.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindtheregisteraddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustentera

Page 62: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

namefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Registersaretheregisterstowrite.Thearraylengthrepresentshowmanyregisterswillbewritten.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.

sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,

Page 63: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

whatinputsareinerror,andhowtoeliminatetheerror.

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 64: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialMasterQueryWriteSingleCoil(poly).viThemasterusesthisVItowriteasinglecoiltotheslave.Thiscorrespondstoapublicfunctioncodeof5intheMODBUSprotocol.

SerialParametersareparametersthatmodifythewaytheMODBUSframeisstructured.RefertotheMODBUSspecificationformoreinformationabouttheMODBUSFrame.TheSerialParametersinLabVIEWisaclustercontaininganenum(Mode)andaninteger(SlaveAddress).ModeRTUDataisrepresentedinbinaryformat.ASCIIDataisrepresentedinASCII,soitishumanreadable.

SlaveAddressThisistheaddressoftheslaveyouarecommunicatingwith.ThispropertyisusuallyvalidforRS-485networks,whichcanhavemultipleMODBUSdevicesconnectedtothesamenetwork.

Note:Consultyourdevicedocumentationtofindouthowtovalidate/changetheaddressofyourdevice.

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.Addressistheaddresslocationofthecoiltowrite.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindthecoiladdressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.

Page 65: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

InmostMODBUSdeviceconfigurationsoftware,youmustenteranamefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

Coilisthecoiltowrite.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

Page 66: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 67: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialMasterQueryWriteSingleRegister(poly).viThemasterusesthisVItowriteasingleregistertotheslave.Thiscorrespondstoapublicfunctioncodeof6intheMODBUSprotocol.

SerialParametersareparametersthatmodifythewaytheMODBUSframeisstructured.RefertotheMODBUSspecificationformoreinformationabouttheMODBUSFrame.TheSerialParametersinLabVIEWisaclustercontaininganenum(Mode)andaninteger(SlaveAddress).ModeRTUDataisrepresentedinbinaryformat.ASCIIDataisrepresentedinASCII,soitishumanreadable.

SlaveAddressThisistheaddressoftheslaveyouarecommunicatingwith.ThispropertyisusuallyvalidforRS-485networks,whichcanhavemultipleMODBUSdevicesconnectedtothesamenetwork.

Note:Consultyourdevicedocumentationtofindouthowtovalidate/changetheaddressofyourdevice.

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.Addressistheaddresslocationoftheregistertowrite.Thisaddressissometimesreferredtoasoffset.Refertoyourdevice'sdocumentationtofindtheregisteraddressmapping.

BesuretospecifythecorrectaddressintheMODBUSdeviceconfigurationsoftwarefortheregisteryouwanttouseinLabVIEW.InmostMODBUSdeviceconfigurationsoftware,youmustentera

Page 68: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

namefortheregisteryouwanttouse.PerMODBUSconvention,theregisteraddressoftheslavedeviceiscalculatedbysubtracting1fromtheregisternamethatyouspecifyinthemasterdeviceconfigurationsoftware.TheMODBUSLabVIEWlibraryexpectsregisteraddresses,notregisternames,soyoumayneedtosubtract1fromtheaddressyoudefinedintheMODBUSdeviceconfigurationsoftware.Forexample,aregisternamedefinedas2inaMODBUSconfigurationdevicetranslatestoregisteraddress1intheHoldingRegisterstableoftheLabVIEWMODBUSlibrary,asshownbelow.MODBUSDevice

HoldingRegisterName=2

LabVIEW HoldingRegisterAddress=1

HoldingRegisteristheholdingregistertowrite.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

Page 69: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.ExceptionCodeisnonzeroifaMODBUSerrorhasoccurred.Theexceptioncodemappingisasfollows:0 Noerror1 Illegalfunction2 Illegaldataaddress3 Illegaldatavalue4 Failureinassociateddevice5 Acknowledge6 Busy,rejectedmessage7 NAK—NegativeacknowledgeFormoreinformationabouttheseerrorcodes,refertoyourdevice'sdocumentation.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 70: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

IntroductiontotheSlaveVIsYoucanusetheMODBUSLibraryVIsasmastersorslaves.Whenusedasamaster,themachinethattheVIsarerunningonsendscommandsorqueriestotheslave(s).Themasterreads/writestheslave'scoils/discreteinputs/registers.Asaslave,themachinemuststorethisdatasomewhere.TheslaveVIsmakeuseofarraystostoreandaccessthisdata.ThefirstVIyoumustuseisMBSlaveInit(poly).vi,whichinitializestwo65536U16arrays(forregisters)andtwo65536Booleanarrays(forcoilsanddiscreteinputs).AllotherslaveVIsaccessthismemorylocationindifferentways.Thefollowingtabledescribestheprimarytableobjecttypesandread/writetypes.

PrimaryTables ObjectType TypeDiscreteinputs Singlebit ReadonlyCoils Singlebit Read/writeInputregisters 16-bitword ReadonlyHoldingregisters 16-bitword Read/write

Page 71: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveInit(poly).viYoumustusethisVItoinitializetwo65536U16arrays(forregisters)andtwo65536Booleanarrays(forcoilsanddiscreteinputs).

errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

HoldingRegistersrepresentsanemptyarrayforstoringtheholdingregisters.Coilsrepresentsanemptyarrayforstoringthecoils.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE

Page 72: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 73: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveReadAllCoils(poly).viReadsallcoilsfromtheslave'smemorytable.

errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

Coilsrepresentstheentiretableusedforstoringthecoils.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0ora

Page 74: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

warningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 75: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveReadAllDiscreteInputs(poly).viReadsalldiscreteinputsfromtheslave'smemorytable.

errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

DiscreteInputsrepresentstheentiretableusedforstoringthediscreteinputs.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,code

Page 76: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

isanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 77: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveReadAllHoldingRegisters(poly).viReadsallholdingregistersfromtheslave'smemorytable.

errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

HoldingRegistersrepresentstheentiretableusedforstoringtheholdingregisters.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,code

Page 78: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

isanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 79: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveReadAllInputRegisters(poly).viReadsallinputregistersfromtheslave'smemorytable.

errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

InputRegistersrepresentstheentiretableusedforstoringtheinputregisters.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,code

Page 80: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

isanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 81: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveReadCoils(poly).viReturnstheslavecoilsfromStartingAddresstoStartingAddress+Quantity.

StartingAddressisthefirstaddresslocationofthecoilstoread.Thisaddressissometimesreferredtoasoffset.Quantityrepresentshowmanycoilstoread.TheVIreturnsthecoilsatStartingAddressandeachfollowingcoiluptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadscoilsfromaddresses0,1,2,and3.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

Coilsrepresentsthedatastoredinthecoilstable.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatus

Page 82: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

thatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 83: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveReadDiscreteInputs(poly).viReturnstheslave'sdiscreteinputsfromStartingAddresstoStartingAddress+Quantity.

StartingAddressisthefirstaddresslocationofthediscreteinputstoread.Thisaddressissometimesreferredtoasoffset.Quantityrepresentshowmanydiscreteinputstoread.TheVIreturnsthediscreteinputsatStartingAddressandeachfollowingdiscreteinputuptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadsdiscreteinputsfromaddresses0,1,2,and3.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

DiscreteInputsrepresentsthedatastoredinthediscreteinputstable.erroroutcontainserrorinformation.Iferrorinindicatesthatan

Page 84: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

erroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 85: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveReadHoldingRegisters(poly).viReturnstheslaveholdingregistersfromStartingAddresstoStartingAddress+Quantity.

StartingAddressisthefirstaddresslocationoftheholdingregistertoread.Thisaddressissometimesreferredtoasoffset.Quantityrepresentshowmanyholdingregisterstoread.TheVIreturnstheholdingregistersatStartingAddressandeachfollowingholdingregisteruptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadsholdingregistersfromaddresses0,1,2,and3.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

HoldingRegistersrepresentsthedatareadfromtheslave.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthe

Page 86: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

sameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 87: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveReadInputRegisters(poly).viReturnstheslave'sinputregistersfromStartingAddresstoStartingAddress+Quantity.

StartingAddressisthefirstaddresslocationoftheinputregistertoread.Thisaddressissometimesreferredtoasoffset.Quantityrepresentshowmanyinputregisterstoread.TheVIreturnstheinputregistersatStartingAddressandeachfollowinginputregisteruptoQuantity.Forexample,ifStartingAddressis0andQuantityis4,theVIreadsinputregistersfromaddresses0,1,2,and3.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

InputRegistersrepresentsthedatareadfromtheslave.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthe

Page 88: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

sameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 89: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveWriteCoils(poly).viWritesmultiplecoilstotheslavememorytables.

StartingAddressistheaddresslocationofthefirstcoiltowrite.Thisaddressissometimesreferredtoasoffset.Coilstowrite.Thearraylengthrepresentsthequantity.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.

Page 90: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 91: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveWriteDiscreteInputs(poly).viWritesmultiplediscreteinputstotheslavememorytables.

StartingAddressistheaddresslocationofthefirstdiscreteinputtowrite.Thisaddressissometimesreferredtoasoffset.DiscreteInputstowrite.Thearraylengthrepresentsthequantity.

Note:Onlytheslavecanwritediscreteinputs.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

Page 92: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 93: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveWriteHoldingRegisters(poly).viWritesmultipleholdingregisterstotheslavememorytables.

StartingAddressistheaddresslocationofthefirstholdingregistertowrite.Thisaddressissometimesreferredtoasoffset.HoldingRegisterstowrite.Thearraylengthrepresentsthequantity.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE

Page 94: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 95: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSlaveWriteInputRegisters(poly).viWritesmultipleinputregisterstotheslavememorytables.

StartingAddressistheaddresslocationofthefirstinputregistertowrite.Thisaddressissometimesreferredtoasoffset.InputRegisterstowrite.Thearraylengthrepresentsthequantity.

Note:Onlytheslavecanwriteinputregisters.errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

Page 96: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 97: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBEthernetSlaveDemon.viTheEthernetslavedemonwaitsandestablishesconnectiontoEthernetmasters.ItthenconstantlyscanstheTCPbufferforcommandsfromthemaster.Whenitdetectsacommandfromthemaster,itupdatesthememorytableswithdataandalsorespondstothemaster'squeryfordata.YoumustusetheSlaveAPItoaccessthedatainthetables.

Portistheportnumberonwhichyouwanttolistenforaconnection.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheslavewaitsforthemaster'sresponsebeforethrowinganerror.PeriodrepresentsthedurationofaMODBUScycle,orhowoftentheslavescanstheTCPbufferforcommandsfromthemasters.#ofconnectionsisthenumberofconnectionstoTCPmasters.DemonRunningistrueifthedemonisrunning(listeningforconnectionsandcommunicationwithmasters).

Page 98: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialInit.viInitializestheserialportspecifiedbyVISAresourcenametothespecifiedsettings.WiredatatotheVISAresourcenameinputtodeterminethepolymorphicinstancetouseormanuallyselecttheinstance.

ModeisusedtoselectwhichtypeofMODBUSframetouse.ForMBSerialInit.vi,thisaffectsthenumberofdatabitstheserialportuses.RTUDataisrepresentedinbinaryformat(8databits).ASCIIDataisrepresentedinASCII,soitishumanreadable(7databits).

VISAresourcenamespecifiestheresourcetobeopened.Thiscontrolalsospecifiesthesessionandclass.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.BaudRateistherateoftransmission.Thedefaultis9600.Parityspecifiestheparityusedforeveryframetobetransmittedorreceived.Thisinputacceptsthefollowingvalues:0 Noparity(default)1 Oddparity2 Evenparity3 Markparity4 Spaceparity

errorindescribeserrorconditionsthatoccurbeforethisVIorfunctionruns.Thedefaultisnoerror.IfanerroroccurredbeforethisVIorfunctionruns,theVIorfunctionpassestheerrorinvaluetoerrorout.IfanerroroccurswhilethisVIorfunctionruns,theVIorfunctionrunsnormallyandsetsitsownerrorstatusinerrorout.

Page 99: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

UsetheSimpleErrorHandlerorGeneralErrorHandlerVIstodisplaythedescriptionoftheerrorcode.Useerrorinanderrorouttocheckerrorsandtospecifyexecutionorderbywiringerroroutfromonenodetoerrorinofthenextnode.

statusisTRUE(X)ifanerroroccurredbeforethisVIorfunctionranorFALSE(checkmark)toindicateawarningorthatnoerroroccurredbeforethisVIorfunctionran.ThedefaultisFALSE.codeistheerrororwarningcode.Thedefaultis0.IfstatusisTRUE,codeisanegativeerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourceidentifieswhereanerroroccurred.ThesourcestringincludesthenameoftheVIthatproducedtheerror,whatinputsareinerror,andhowtoeliminatetheerror.

FlowControlsetsthetypeofcontrolthetransfermechanismuses.Thisinputacceptsthefollowingvalues:0 None(default)—Thetransfermechanismdoesnotuseflow

control.Buffersonbothsidesoftheconnectionareassumedtobelargeenoughtoholdalldatatransferred.

1 XON/XOFF—ThetransfermechanismusestheXONandXOFFcharacterstoperformflowcontrol.ThetransfermechanismcontrolsinputflowbysendingXOFFwhenthereceivebufferisnearlyfull,anditcontrolstheoutputflowbysuspendingtransmissionwhenXOFFisreceived.

2 RTS/CTS—ThetransfermechanismusestheRTSoutputsignalandtheCTSinputsignaltoperformflowcontrol.ThetransfermechanismcontrolsinputflowbyunassertingtheRTSsignalwhenthereceivebufferisnearlyfull,anditcontrolsoutputflowbysuspendingthetransmissionwhentheCTSsignalisunasserted.

3 XON/XOFFandRTS/CTS—ThetransfermechanismusestheXONandXOFFcharactersandtheRTSoutputsignalandCTSinputsignaltoperformflowcontrol.ThetransfermechanismcontrolsinputflowbysendingXOFFandunassertingtheRTSsignalwhenthereceivebufferisnearlyfull,anditcontrolstheoutputflowbysuspendingtransmission

Page 100: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

whenXOFFisreceivedandtheCTSisunasserted.

4 DTR/DSR—ThetransfermechanismusestheDTRoutputsignalandtheDSRinputsignaltoperformflowcontrol.ThetransfermechanismcontrolsinputflowbyunassertingtheDTRsignalwhenthereceivebufferisnearlyfull,anditcontrolsoutputflowbysuspendingthetransmissionwhentheDSRsignalisunasserted.

5 XON/XOFFandDTR/DSR—ThetransfermechanismusestheXONandXOFFcharactersandtheDTRoutputsignalandDSRinputsignaltoperformflowcontrol.ThetransfermechanismcontrolsinputflowbysendingXOFFandunassertingtheDTRsignalwhenthereceivebufferisnearlyfull,anditcontrolstheoutputflowbysuspendingtransmissionwhenXOFFisreceivedandtheDSRsignalisunasserted.

Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.erroroutcontainserrorinformation.IferrorinindicatesthatanerroroccurredbeforethisVIorfunctionran,erroroutcontainsthesameerrorinformation.Otherwise,itdescribestheerrorstatusthatthisVIorfunctionproduces.Right-clicktheerroroutfrontpanelindicatorandselectExplainErrorfromtheshortcutmenuformoreinformationabouttheerror.

statusisTRUE(X)ifanerroroccurredorFALSE(checkmark)toindicateawarningorthatnoerroroccurred.codeistheerrororwarningcode.IfstatusisTRUE,codeisanonzeroerrorcode.IfstatusisFALSE,codeis0orawarningcode.sourcedescribestheoriginoftheerrororwarningandis,inmostcases,thenameoftheVIorfunctionthatproducedtheerrororwarning.

Page 101: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

MBSerialSlaveDemon.viTheserialslavedemonconstantlyscanstheserialportforcommandsfromthemaster.Whenitdetectsacommandfromthemaster,itupdatesthememorytableswithdataandalsorespondstothemaster'squeryfordata.YoumustusetheslaveAPItoaccessthedatainthetables.

SerialPortSetup(RTOnly)isrequiredtoconfiguretheserialportontheRTsystem(ifrunningPharlapRTOS).

VISAresourcenameoutistheresourcetowhichaVISAsessionisopenedanditsclass.TheclassmatchesthatoftheVISAresourcenameinput.FormoreinformationaboutVISAresourcenames,refertotheNI-VISAHelp.BaudRateistherateoftransmission.Thedefaultis9600.DataBitsisthenumberofbitsintheincomingdata.Thevalueofdatabitsisbetween5and8.Thedefaultvalueis8.Parityspecifiestheparityusedforeveryframetobetransmittedorreceived.Thisinputacceptsthefollowingvalues:0 Noparity(default)

1 Oddparity

Page 102: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

2 Evenparity3 Markparity4 Spaceparity

StopBitsspecifiesthenumberofstopbitsusedtoindicatetheendofaframe.Thisinputacceptsthefollowingvalues:10 1stopbit15 1.5stopbits20 2stopbits

FlowControlsetsthetypeofcontrolusedbythetransfermechanism.Thisinputacceptsthefollowingvalues:0 None(default)—Thetransfermechanismdoesnotuse

flowcontrol.Buffersonbothsidesoftheconnectionareassumedtobelargeenoughtoholdalldatatransferred.

1 XON/XOFF—ThetransfermechanismusestheXONandXOFFcharacterstoperformflowcontrol.ThetransfermechanismcontrolsinputflowbysendingXOFFwhenthereceivebufferisnearlyfull,anditcontrolstheoutputflowbysuspendingtransmissionwhenXOFFisreceived.

2 RTS/CTS—ThetransfermechanismusestheRTSoutputsignalandtheCTSinputsignaltoperformflowcontrol.ThetransfermechanismcontrolsinputflowbyunassertingtheRTSsignalwhenthereceivebufferisnearlyfull,anditcontrolsoutputflowbysuspendingthetransmissionwhentheCTSsignalisunasserted.

3 XON/XOFFandRTS/CTS—ThetransfermechanismusestheXONandXOFFcharactersandtheRTSoutputsignalandCTSinputsignaltoperformflowcontrol.ThetransfermechanismcontrolsinputflowbysendingXOFFandunassertingtheRTSsignalwhenthereceivebufferisnearlyfull,anditcontrolstheoutputflowbysuspendingtransmissionwhenXOFFisreceivedandtheCTSisunasserted.

Page 103: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

4 DTR/DSR—ThetransfermechanismusestheDTRoutputsignalandtheDSRinputsignaltoperformflowcontrol.ThetransfermechanismcontrolsinputflowbyunassertingtheDTRsignalwhenthereceivebufferisnearlyfull,anditcontrolsoutputflowbysuspendingthetransmissionwhentheDSRsignalisunasserted.

5 XON/XOFFandDTR/DSR—ThetransfermechanismusestheXONandXOFFcharactersandtheDTRoutputsignalandDSRinputsignaltoperformflowcontrol.ThetransfermechanismcontrolsinputflowbysendingXOFFandunassertingtheDTRsignalwhenthereceivebufferisnearlyfull,anditcontrolstheoutputflowbysuspendingtransmissionwhenXOFFisreceivedandtheDSRsignalisunasserted.

TerminationCharcallsforterminationofthereadoperation.ThereadoperationterminateswhentheTerminationCharisreadfromtheserialdevice.0xAisthehexequivalentofalinefeedcharacter(\n).Changetheterminationcharto0xDformessagestringsthatterminatewithacarriagereturn(\r).EnableTerminationCharpreparestheserialdevicetorecognizeterminationchar.IfTRUE(default),theportissettorecognizetheterminationcharacter.IfFALSE,theserialdevicedoesnotrecognizetheterminationchar.Timeoutspecifiesthemaximumtimeperiod,inmilliseconds,thattheVIwaitsfortheslave'sresponsebeforethrowinganerror.

SlaveAddressrepresentstheaddressoftheslaveontheMODBUSnetwork.Themastersusethisaddresstocommunicatewiththecorrectslave.VISAresourcenamesspecifiesaarrayofalltheresourcestobeopenedandusedtoconnecttomasters.Forexample,youcanusetwoserialportstoconnectaslavetomultiplemasters.Becausethisisanarrayofstrings,youcanuseaVISApropertynodetoextracttheVISAresourcenamefromaVISASessioncontrol.RefertoMBSerialSlaveExample.viforanexample.

Page 104: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

ModesselectswhichtypeofMODBUSframetouse.Thisisanarrayofclusters.EacharraylocationcorrespondstothemodesettingforthecorrespondingVISAsessionintheVISAresourcenamesarray.RTUDataisrepresentedinbinaryformat(8databits).

ASCIIDataisrepresentedinASCII,soitishumanreadable(7databits).

Timeoutsspecifiesthemaximumtimeperiod,inmilliseconds,thattheslavewaitsforthemaster'sresponsebeforethrowinganerror.EachlocationinthearrayrepresentsthesettingforthecorrespondingVISAresourcefromtheVISAresourcenamesarray.PeriodrepresentsthedurationofaMODBUScycle,orhowoftentheslavescanstheserialports.

Page 105: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

ImportantInformationWarrantyCopyrightTrademarksPatentsWarningRegardingUseofNIProducts

Page 106: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

WarrantyThemediaonwhichyoureceiveNationalInstrumentssoftwarearewarrantednottofailtoexecuteprogramminginstructions,duetodefectsinmaterialsandworkmanship,foraperiodof90daysfromdateofshipment,asevidencedbyreceiptsorotherdocumentation.NationalInstrumentswill,atitsoption,repairorreplacesoftwaremediathatdonotexecuteprogramminginstructionsifNationalInstrumentsreceivesnoticeofsuchdefectsduringthewarrantyperiod.NationalInstrumentsdoesnotwarrantthattheoperationofthesoftwareshallbeuninterruptedorerrorfree.AReturnMaterialAuthorization(RMA)numbermustbeobtainedfromthefactoryandclearlymarkedontheoutsideofthepackagebeforeanyequipmentwillbeacceptedforwarrantywork.NationalInstrumentswillpaytheshippingcostsofreturningtotheownerpartswhicharecoveredbywarranty.NationalInstrumentsbelievesthattheinformationinthisdocumentisaccurate.Thedocumenthasbeencarefullyreviewedfortechnicalaccuracy.Intheeventthattechnicalortypographicalerrorsexist,NationalInstrumentsreservestherighttomakechangestosubsequenteditionsofthisdocumentwithoutpriornoticetoholdersofthisedition.ThereadershouldconsultNationalInstrumentsiferrorsaresuspected.InnoeventshallNationalInstrumentsbeliableforanydamagesarisingoutoforrelatedtothisdocumentortheinformationcontainedinit.EXCEPTASSPECIFIEDHEREIN,NATIONALINSTRUMENTSMAKESNOWARRANTIES,EXPRESSORIMPLIED,ANDSPECIFICALLYDISCLAIMSANYWARRANTYOFMERCHANTABILITYORFITNESSFORAPARTICULARPURPOSE.CUSTOMER'SRIGHTTORECOVERDAMAGESCAUSEDBYFAULTORNEGLIGENCEONTHEPARTOFNATIONALINSTRUMENTSSHALLBELIMITEDTOTHEAMOUNTTHERETOFOREPAIDBYTHECUSTOMER.NATIONALINSTRUMENTSWILLNOTBELIABLEFORDAMAGESRESULTINGFROMLOSSOFDATA,PROFITS,USEOFPRODUCTS,ORINCIDENTALORCONSEQUENTIALDAMAGES,EVENIFADVISEDOFTHEPOSSIBILITYTHEREOF.ThislimitationoftheliabilityofNationalInstrumentswillapplyregardlessoftheformofaction,whetherincontractortort,includingnegligence.AnyactionagainstNationalInstrumentsmustbebroughtwithinoneyearafterthecauseofaction

Page 107: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

accrues.NationalInstrumentsshallnotbeliableforanydelayinperformanceduetocausesbeyonditsreasonablecontrol.Thewarrantyprovidedhereindoesnotcoverdamages,defects,malfunctions,orservicefailurescausedbyowner'sfailuretofollowtheNationalInstrumentsinstallation,operation,ormaintenanceinstructions;owner'smodificationoftheproduct;owner'sabuse,misuse,ornegligentacts;andpowerfailureorsurges,fire,flood,accident,actionsofthirdparties,orothereventsoutsidereasonablecontrol.

Page 108: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

CopyrightUnderthecopyrightlaws,thispublicationmaynotbereproducedortransmittedinanyform,electronicormechanical,includingphotocopying,recording,storinginaninformationretrievalsystem,ortranslating,inwholeorinpart,withoutthepriorwrittenconsentofNationalInstrumentsCorporation.NationalInstrumentsrespectstheintellectualpropertyofothers,andweaskouruserstodothesame.NIsoftwareisprotectedbycopyrightandotherintellectualpropertylaws.WhereNIsoftwaremaybeusedtoreproducesoftwareorothermaterialsbelongingtoothers,youmayuseNIsoftwareonlytoreproducematerialsthatyoumayreproduceinaccordancewiththetermsofanyapplicablelicenseorotherlegalrestriction.

Page 109: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

TrademarksNationalInstruments,NI,ni.com,andLabVIEWaretrademarksofNationalInstrumentsCorporation.RefertotheTermsofUsesectiononni.com/legalformoreinformationaboutNationalInstrumentstrademarks.FireWire®istheregisteredtrademarkofAppleInc.HandleGraphics®,MATLAB®,Real-TimeWorkshop®,Simulink®,Stateflow®,andxPCTargetBox®areregisteredtrademarks,andTargetBox™andTargetLanguageCompiler™aretrademarksofTheMathWorks,Inc.Tektronix®andTekareregisteredtrademarksofTektronix,Inc.TheBluetooth®wordmarkisaregisteredtrademarkownedbytheBluetoothSIG,Inc.Otherproductandcompanynamesmentionedhereinaretrademarksortradenamesoftheirrespectivecompanies.MembersoftheNationalInstrumentsAlliancePartnerProgramarebusinessentitiesindependentfromNationalInstrumentsandhavenoagency,partnership,orjoint-venturerelationshipwithNationalInstruments.

Page 110: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

PatentsForpatentscoveringtheNationalInstrumentsproducts/technology,refertotheappropriatelocation:Help»Patentsinyoursoftware,thepatents.txtfileonyourmedia,ortheNationalInstrumentsPatentNoticeatni.com/patents.

Page 111: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

WARNINGREGARDINGUSEOFNATIONALINSTRUMENTSPRODUCTS(1)NATIONALINSTRUMENTSPRODUCTSARENOTDESIGNEDWITHCOMPONENTSANDTESTINGFORALEVELOFRELIABILITYSUITABLEFORUSEINORINCONNECTIONWITHSURGICALIMPLANTSORASCRITICALCOMPONENTSINANYLIFESUPPORTSYSTEMSWHOSEFAILURETOPERFORMCANREASONABLYBEEXPECTEDTOCAUSESIGNIFICANTINJURYTOAHUMAN.(2)INANYAPPLICATION,INCLUDINGTHEABOVE,RELIABILITYOFOPERATIONOFTHESOFTWAREPRODUCTSCANBEIMPAIREDBYADVERSEFACTORS,INCLUDINGBUTNOTLIMITEDTOFLUCTUATIONSINELECTRICALPOWERSUPPLY,COMPUTERHARDWAREMALFUNCTIONS,COMPUTEROPERATINGSYSTEMSOFTWAREFITNESS,FITNESSOFCOMPILERSANDDEVELOPMENTSOFTWAREUSEDTODEVELOPANAPPLICATION,INSTALLATIONERRORS,SOFTWAREANDHARDWARECOMPATIBILITYPROBLEMS,MALFUNCTIONSORFAILURESOFELECTRONICMONITORINGORCONTROLDEVICES,TRANSIENTFAILURESOFELECTRONICSYSTEMS(HARDWAREAND/ORSOFTWARE),UNANTICIPATEDUSESORMISUSES,ORERRORSONTHEPARTOFTHEUSERORAPPLICATIONSDESIGNER(ADVERSEFACTORSSUCHASTHESEAREHEREAFTERCOLLECTIVELYTERMED"SYSTEMFAILURES").ANYAPPLICATIONWHEREASYSTEMFAILUREWOULDCREATEARISKOFHARMTOPROPERTYORPERSONS(INCLUDINGTHERISKOFBODILYINJURYANDDEATH)SHOULDNOTBERELIANTSOLELYUPONONEFORMOFELECTRONICSYSTEMDUETOTHERISKOFSYSTEMFAILURE.TOAVOIDDAMAGE,INJURY,ORDEATH,THEUSERORAPPLICATIONDESIGNERMUSTTAKEREASONABLYPRUDENTSTEPSTOPROTECTAGAINSTSYSTEMFAILURES,INCLUDINGBUTNOTLIMITEDTOBACK-UPORSHUTDOWNMECHANISMS.BECAUSEEACHEND-USERSYSTEMISCUSTOMIZEDANDDIFFERSFROMNATIONALINSTRUMENTS'TESTINGPLATFORMSANDBECAUSEAUSERORAPPLICATIONDESIGNERMAYUSENATIONALINSTRUMENTSPRODUCTSINCOMBINATIONWITHOTHERPRODUCTSINAMANNERNOTEVALUATEDORCONTEMPLATEDBYNATIONALINSTRUMENTS,THEUSEROR

Page 112: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

APPLICATIONDESIGNERISULTIMATELYRESPONSIBLEFORVERIFYINGANDVALIDATINGTHESUITABILITYOFNATIONALINSTRUMENTSPRODUCTSWHENEVERNATIONALINSTRUMENTSPRODUCTSAREINCORPORATEDINASYSTEMORAPPLICATION,INCLUDING,WITHOUTLIMITATION,THEAPPROPRIATEDESIGN,PROCESSANDSAFETYLEVELOFSUCHSYSTEMORAPPLICATION.

Page 113: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

TechnicalSupportandProfessionalServicesVisitthefollowingsectionsoftheaward-winningNationalInstrumentsWebsiteatni.comfortechnicalsupportandprofessionalservices:

Support—Technicalsupportatni.com/supportincludesthefollowingresources:

Self-HelpResources—Foranswersandsolutions,visitni.com/supportforsoftwaredriversandupdates,asearchableKnowledgeBase,productmanuals,step-by-steptroubleshootingwizards,thousandsofexampleprograms,tutorials,applicationnotes,instrumentdrivers,andsoon.RegisteredusersalsoreceiveaccesstotheNIDiscussionForumsatni.com/forums.NIApplicationsEngineersmakesureeveryquestionsubmittedonlinereceivesananswer.StandardServiceProgramMembership—ThisprogramentitlesmemberstodirectaccesstoNIApplicationsEngineersviaphoneandemailforone-to-onetechnicalsupport,aswellasexclusiveaccesstoondemandtrainingmodulesviatheServicesResourceCenter.NIofferscomplementarymembershipforafullyearafterpurchase,afterwhichyoumayrenewtocontinueyourbenefits.Forinformationaboutothertechnicalsupportoptionsinyourarea,visitni.com/servicesorcontactyourlocalofficeatni.com/contact.

TrainingandCertification—Visitni.com/trainingforself-pacedtraining,eLearningvirtualclassrooms,interactiveCDs,andCertificationprograminformation.Youalsocanregisterforinstructor-led,hands-oncoursesatlocationsaroundtheworld.SystemIntegration—Ifyouhavetimeconstraints,limitedin-housetechnicalresources,orotherprojectchallenges,NationalInstrumentsAlliancePartnermemberscanhelp.Tolearnmore,callyourlocalNIofficeorvisitni.com/alliance.

Ifyousearchedni.comandcouldnotfindtheanswersyouneed,contactyourlocalofficeorNIcorporateheadquarters.YoualsocanvisittheWorldwideOfficessectionofni.com/niglobaltoaccessthebranchoffice

Page 114: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

Websites,whichprovideup-to-datecontactinformation,supportphonenumbers,emailaddresses,andcurrentevents.

NoteModbusLabVIEWlibrarysupportisbye-mailonly;phonesupportisnotavailable.

Page 115: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

BranchOfficesOffice TelephoneNumberAustralia 1800300800Austria 43662457990-0Belgium 32(0)27570020Brazil 551132623599Canada 8004333488China 862150509800CzechRepublic 420224235774Denmark 4545762600Finland 358(0)972572511France 33(0)157662424Germany 49897413130India 918041190000Israel 972036393737Italy 390241309277Japan 0120-527196/81354722970Korea 820234513400Lebanon 961(0)1332828Malaysia 1800887710Mexico 018000100793Netherlands 31(0)348433466NewZealand 0800553322Norway 47(0)66907660Poland 48223289010Portugal 351210311210Russia 74957836851Singapore 18002265886Slovenia 38634254200

Page 116: Modbus LabVIEW Library Help · Modbus LabVIEW Library Help February 2009, 372767A-01 This help file describes the Modbus LabVIEW VI library. For more information about this help file,

SouthAfrica 270118058197Spain 34916400085Sweden 46(0)858789500Switzerland 41562005151Taiwan 8860223772222Thailand 6622786777Turkey 902122793031UnitedKingdom 44(0)1635523545UnitedStates(Corporate) 5126830100