ni-motion™ help · help you develop ni-motion applications. this help file is intended for...
TRANSCRIPT
![Page 1: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/1.jpg)
![Page 2: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/2.jpg)
NI-Motion™HelpJuly2007,372134B-01ThishelpfileprovidesinformationabouttheNI-Motiondriversoftware,includingbackground,configuration,andprogramminginformation.ThepurposeofthishelpfileistoprovideabasicunderstandingoftheNI-Motiondriversoftware,andprovideprogrammingstepsandexamplestohelpyoudevelopNI-Motionapplications.ThishelpfileisintendedforexperiencedLabVIEW,C/C++,orotherdevelopers.Codeinstructionsandexamplesassumeaworkingknowledgeofthegivenprogramminglanguage.Thishelpfilealsoassumesageneralknowledgeofmotioncontrolterminologyanddevelopmentrequirements.ThishelpfilepertainstoallNImotioncontrollersthatusetheNI-Motiondriversoftware.Formoreinformationaboutthishelpfile,refertothefollowingtopics:UsingHelpRelatedDocumentationGlossaryImportantInformationTechnicalSupportandProfessionalServicesTocommentonNationalInstrumentsdocumentation,refertotheNationalInstrumentsWebsite.©2007NationalInstrumentsCorporation.Allrightsreserved.
![Page 3: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/3.jpg)
RelatedDocumentationMostmotioncontrolmanualsalsoareavailableasPDFs.YoumusthaveAdobeReaderwithSearchandAccessibility5.0.5orlaterinstalledtoviewthePDFs.RefertotheAdobeSystemsIncorporatedWebsiteatwww.adobe.comtodownloadAdobeReader.RefertotheNationalInstrumentsProductManualsLibraryatni.com/manualsforupdateddocumentationresources.Thefollowingdocumentscontaininformationthatyoumayfindhelpfulasyouusethishelpfile:
GettingStartedwithNI-MotionforNI73xxMotionControllers—ProvidesinstallationinstructionsandgeneralinformationabouttheNI-Motionproduct.GettingStarted:NISoftMotionControllerforCopleyControlsCANopenDrives—ContainsinformationaboutgettingstartedwiththeNISoftMotionControllerforCANopen.NI-MotionVIHelp—ContainsLabVIEWVIreferencefilesandprovidesdetailsabouteachVI,includingVIdescriptions,listsofcontrolandinputterminals,usage,illustrations,anderrorcodes.NI-MotionFunctionHelp—ContainsfunctionreferencefilesforCandVisualBasicandprovidesdetailsabouteachfunction,includingadescriptionofthefunction,alistofthefunctionparameters,illustrations,anderrorcodes.Measurement&AutomationExplorerHelpforMotion—ProvidesinformationaboutusingMAXtoconfiguretheNI73xxmotioncontrolleraswellassomeadvancedconceptualinformationabouttopicssuchasBodeanalysisandcontrolloopparameters.NI73xxusermanuals—DescribestheelectricalandmechanicalaspectsoftheNI73xxmotioncontroller,andcontainsinformationaboutinstallingandoperatingthedevice.NI-MotionReadme—Containssystemrequirements,installationinstructions,descriptionsofanychangesmadetothesoftware,informationaboutnewfeaturesintherelease,andinformationaboutlate-breakingknownissuesthatarenotdocumentedinotherNI-Motiondocuments.NIDeveloperZone(NIDZ)—VisittheNIDeveloperZone,atni.com/zone,forexampleprograms,tutorials,technical
![Page 4: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/4.jpg)
presentations,theInstrumentDriverNetwork,productadvisors,applicationnotes,andadiscussionforumwhereyoucanshareideas,questions,andsourcecodewithmotiondevelopersaroundtheworld.MotionHardwareAdvisor—VisittheNationalInstrumentsMotionHardwareAdvisoratni.com/devzone/advisors/motion/toselectmotorsandstagesappropriatetothemotioncontrolapplication.
InadditiontotheNIDeveloperZone,youcanfindNI-MotionC/C++andVisualBasicprogrammingexamplesintheNI-Motion\FlexMotion\ExamplesfolderwhereyouinstalledNI-Motion.ThedefaultdirectoryisProgramFiles\NationalInstruments\NI-MotionforWindowsXP/2000andthe32-bitversionofWindowsVistaandProgramFiles(x86)\NationalInstruments\NI-Motionforthe64-bitversionofWindowsVista.YoucanfindLabVIEWexampleprogramsunderexamples\MotioninthedirectorywhereyouinstalledLabVIEW.YoucanfindLabWindows™/CVI™examplesundersamples\MotioninthedirectorywhereyouinstalledLabWindows/CVI.YoucanfindtheNI-MotionC/C++andLabVIEWexamplecodereferencedinthismanualintheNI-Motion\Documentation\Examples\NI-MotionUserManualfolderwhereyouinstalledNI-Motion.
![Page 5: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/5.jpg)
UsingHelpConventionsNavigatingHelpSearchingHelpPrintingHelpFileTopics
![Page 6: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/6.jpg)
ConventionsThishelpfileusesthefollowingformattingandtypographicalconventions:
<> Anglebracketsthatcontainnumbersseparatedbyanellipsisrepresentarangeofvaluesassociatedwithabitorsignalname—forexample,AO<0..3>.
[] Squarebracketsencloseoptionalitems—forexample,[response].
» The»symbolleadsyouthroughnestedmenuitemsanddialogboxoptionstoafinalaction.ThesequenceFile»PageSetup»OptionsdirectsyoutopulldowntheFilemenu,selectthePageSetupitem,andselectOptionsfromthelastdialogbox.Thisicondenotesatip,whichalertsyoutoadvisoryinformation.Thisicondenotesanote,whichalertsyoutoimportantinformation.Thisicondenotesacaution,whichadvisesyouofprecautionstotaketoavoidinjury,dataloss,orasystemcrash.
bold Boldtextdenotesitemsthatyoumustselectorclickinthesoftware,suchasmenuitemsanddialogboxoptions.Boldtextalsodenotesparameternames.
darkred Textinthiscolordenotesacaution.green Underlinedtextinthiscolordenotesalinktoahelptopic,
helpfile,orWebaddress.italic Italictextdenotesvariables,emphasis,cross–references,or
anintroductiontoakeyconcept.Italictextalsodenotestextthatisaplaceholderforawordorvaluethatyoumustsupply.
monospace Textinthisfontdenotestextorcharactersthatyoushouldenterfromthekeyboard,sectionsofcode,programmingexamples,andsyntaxexamples.Thisfontisalsousedforthepropernamesofdiskdrives,paths,directories,
![Page 7: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/7.jpg)
programs,subprograms,subroutines,devicenames,functions,operations,variables,filenames,andextensions.
monospacebold
Boldtextinthisfontdenotesthemessagesandresponsesthatthecomputerautomaticallyprintstothescreen.Thisfontalsoemphasizeslinesofcodethataredifferentfromtheotherexamples.
monospaceitalic
Italictextinthisfontdenotestextthatisaplaceholderforawordorvaluethatyoumustsupply.
![Page 8: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/8.jpg)
NavigatingHelp(WindowsOnly)Tonavigatethishelpfile,usetheContents,Index,andSearchtabstotheleftofthiswindoworusethefollowingtoolbarbuttonslocatedabovethetabs:
Hide—Hidesthenavigationpanefromview.Locate—LocatesthecurrentlydisplayedtopicintheContentstab,allowingyoutoviewrelatedtopics.Back—Displaysthepreviouslyviewedtopic.Forward—DisplaysthetopicyouviewedbeforeclickingtheBackbutton.Options—Displaysalistofcommandsandviewingoptionsforthehelpfile.
![Page 9: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/9.jpg)
SearchingHelp(WindowsOnly)UsetheSearchtabtotheleftofthiswindowtolocatecontentinthishelpfile.Ifyouwanttosearchforwordsinacertainorder,suchas"relateddocumentation,"addquotationmarksaroundthesearchwordsasshownintheexample.SearchingfortermsontheSearchtaballowsyoutoquicklylocatespecificinformationandinformationintopicsthatarenotincludedontheContentstab.
![Page 10: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/10.jpg)
WildcardsYoualsocansearchusingasterisk(*)orquestionmark(?)wildcards.Usetheasteriskwildcardtoreturntopicsthatcontainacertainstring.Forexample,asearchfor"prog*"liststopicsthatcontainthewords"program,""programmatically,""progress,"andsoon.Usethequestionmarkwildcardasasubstituteforasinglecharacterinasearchterm.Forexample,"?ext"liststopicsthatcontainthewords"next,""text,"andsoon.
NoteWildcardsearchingwillnotworkonSimplifiedChinese,TraditionalChinese,Japanese,andKoreansystems.
![Page 11: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/11.jpg)
NestedExpressionsUsenestedexpressionstocombinesearchestofurtherrefineasearch.YoucanuseBooleanexpressionsandwildcardsinanestedexpression.Forexample,"exampleAND(programORVI)"liststopicsthatcontain"exampleprogram"or"exampleVI."Youcannotnestexpressionsmorethanfivelevels.
![Page 12: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/12.jpg)
BooleanExpressionsClickthe buttontoaddBooleanexpressionstoasearch.ThefollowingBooleanoperatorsareavailable:
AND(default)—Returnstopicsthatcontainbothsearchterms.Youdonotneedtospecifythisoperatorunlessyouareusingnestedexpressions.OR—Returnstopicsthatcontaineitherthefirstorsecondterm.NOT—Returnstopicsthatcontainthefirsttermwithoutthesecondterm.NEAR—Returnstopicsthatcontainbothtermswithineightwordsofeachother.
![Page 13: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/13.jpg)
SearchOptions
UsethefollowingcheckboxesontheSearchtabtocustomizeasearch:Searchpreviousresults—Narrowstheresultsfromasearchthatreturnedtoomanytopics.Youmustremovethecheckmarkfromthischeckboxtosearchalltopics.Matchsimilarwords—Broadensasearchtoreturntopicsthatcontainwordssimilartothesearchterms.Forexample,asearchfor"program"liststopicsthatincludethewords"programs,""programming,"andsoon.Searchtitlesonly—Searchesonlyinthetitlesoftopics.
![Page 14: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/14.jpg)
PrintingHelpFileTopics(WindowsOnly)CompletethefollowingstepstoprintanentirebookfromtheContentstab:
1. Right-clickthebook.2. SelectPrintfromtheshortcutmenutodisplaythePrintTopics
dialogbox.3. SelectthePrinttheselectedheadingandallsubtopicsoption.
NoteSelectPrinttheselectedtopicifyouwanttoprintthesingletopicyouhaveselectedintheContentstab.
4. ClicktheOKbutton.
![Page 15: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/15.jpg)
PrintingPDFDocumentsThishelpfilemaycontainlinkstoPDFdocuments.ToprintPDFdocuments,clicktheprintbuttonlocatedontheAdobeAcrobatViewertoolbar.
![Page 16: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/16.jpg)
IntroductionThissectionprovidesbasicinformationabouttheNI-Motiondriversoftware,motioncontrolsetup,andspecifictask-basedinstructionsforcreatingmotioncontrolapplicationsusingtheLabVIEWandC/C++applicationdevelopmentenvironments.
![Page 17: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/17.jpg)
AboutNI-MotionNI-MotionisthedriversoftwareforNationalInstruments73xxmotioncontrollersandtheNISoftMotionController.YoucanuseNI-MotiontocreatemotioncontrolapplicationsusingtheincludedlibraryofLabVIEWVIsandC/C++functions.NationalInstrumentsalsoofferstheNIMotionAssistantandNI-MotiondevelopmenttoolsforVisualBasic.
![Page 18: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/18.jpg)
NI-MotionArchitectureTheNI-MotiondriversoftwarearchitectureisbasedontheinteractionbetweentheNImotioncontrollersandahostcomputer.ThisinteractionincludesthehardwareandsoftwareinterfaceandthephysicalandfunctionalarchitectureoftheNImotioncontrollers.ThefollowingblockdiagramdemonstratestheNImotioncontrolhardwareandsoftwareinteraction.
NoteTheNIMotionControllerblockisnotapplicabletotheNISoftMotionController.
![Page 19: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/19.jpg)
NIMotionControllerArchitectureFunctionally,thearchitectureoftheNI73xxmotioncontrollersandtheNISoftMotionControllerisgenerallydividedintofourcomponents:supervisorycontrol,trajectorygenerator,controlloop,andmotionI/O.FortheNISoftMotionController,themotionI/Ocomponentisseparatefromthecontroller.Thefollowingfiguresdemonstratehowthecomponentsofthe73xxandNISoftMotionControllerinteract.TypicalNI73xxMotionControllerFunctionalArchitecture
NISoftMotionControllerFunctionalArchitecture
![Page 20: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/20.jpg)
NIMotionControllerFunctionalComponentsThefollowinglistdescribeshoweachcomponentofthe73xxcontrollersandtheNISoftMotionControllerfunctions:
Supervisorycontrol—Performsallthecommandsequencingandcoordinationrequiredtocarryoutthespecifiedoperation
Systeminitialization,whichincludeshomingtoazeropositionEventhandling,whichincludeselectronicgearing,triggeringoutputsbasedonposition,updatingprofilesbasedonuserdefinedevents,andsoonFaultDetection,whichincludesstoppingmovesonalimitswitchencounter,safesystemreactiontoemergencystopordrivefaults,watchdog,andsoon
Trajectorygenerator—ProvidespathplanningbasedontheprofilespecifiedbytheuserControlloop—Performsfast,closed-loopcontrolwithsimultaneousposition,velocity,andtrajectorymaintenanceononeormoreaxesThecontrolloophandlesclosingtheposition/velocityloopbasedonfeedback,anditdefinestheresponseandstabilityofthesystem.Forsteppersystems,thecontrolloopisreplacedwithastepgenerationcomponent.Toenablethecontrollooptoexecutefasterthanthetrajectorygeneration,aninterpolationcomponent,orsplineengine,thecontrolloopinterpolatesbetweensetpointscalculatedbythetrajectorygenerator.ThefollowingfigureillustratesthefunctionalarchitectureofNImotioncontrollers.
![Page 21: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/21.jpg)
MotionI/O—AnaloganddigitalI/Othatsendsandreceivessignalsfromtherestofthemotioncontrolsystem.Typically,theanalogoutputisusedasacommandsignalforthedrive,andthedigitalI/Oisusedforquadratureencodersignalsasfeedbackfromthemotor.ThemotionI/Operformspositionbreakpointandhighspeedcapture.Also,thesupervisorycontrolusesthemotionI/Otoachievecertainrequiredfunctionality,suchasreactingtolimitswitchesandcreatingthemovementmodesneededtoinitializethesystem.
![Page 22: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/22.jpg)
NI73xxControllerArchitectureNI73xxcontrollersuseadual-processorarchitecture.Thetwoprocessors,acentralprocessingunit(CPU)andadigitalsignalprocessor(DSP),formthebackboneoftheNImotioncontroller.ThecontrollerCPUisa32-bitmicro-controllerrunninganembeddedrealtime,multitaskingoperatingsystem.ThisCPUofferstheperformanceanddeterminismneededtosolvemostcomplexmotionapplications.TheCPUperformscommandexecution,hostsynchronization,I/Oreaction,andsystemsupervision.TheDSPhastheprimaryresponsibilityoffastclosed-loopcontrolwithsimultaneousposition,velocity,andtrajectorymaintenanceonmultipleaxes.TheDSPalsoclosesthepositionandvelocityloops,anddirectlycommandsthetorquetothedriveoramplifier.MotionI/OoccursinhardwareonanFPGAandconsistsoflimit/homeswitchdetection,positionbreakpoint,andhigh-speedcapture.Thisensuresverylowlatenciesintherangeofhundredsofnanosecondsforbreakpointsandhigh-speedcaptures.RefertotheSynchronizationsectionforinformationaboutbreakpointsandhigh-speedcapture.Themotioncontrollerprocessorismonitoredbyawatchdogtimer,whichishardwarethatcanbeusedtoautomaticallydetectsoftwareanomaliesandresettheprocessorifanyoccur.Thewatchdogtimerchecksforproperprocessoroperation.Ifthefirmwareonthemotioncontrollerisunabletoprocessfunctionswithin62ms,thewatchdogtimerresetsthemotioncontrolleranddisallowsfurthercommunicationsuntilyouexplicitlyresetthemotioncontroller.Thisensuresthereal-timeoperationofthemotioncontrolsystem.Thefollowingfunctionsmaytakelongerthan62mstoprocess:
SaveDefaultsResetDefaultsEnableAutoStartObjectMemoryManagementClearBufferEndStorage
Thesefunctionsaremarkedasnon-real-timefunctions.RefertotheNI-MotionFunctionHelportheNI-MotionVIHelpformoreinformation.
![Page 23: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/23.jpg)
ThefollowingblockdiagramillustratesthephysicalarchitectureoftheNImotioncontrollerhardware.
TipBecausetheNISoftMotionControllerisnotahardwaredevice,informationaboutitsarchitectureisnotcoveredinthistopic.RefertoNISoftMotionControllerArchitectureforinformationaboutthefunctionalarchitecturespecifictotheNISoftMotionController.
![Page 24: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/24.jpg)
NISoftMotionControllerArchitectureTheNI-MotionarchitecturefortheNISoftMotionControllerusesstandardPC-basedplatformsandopenstandardstoconnectintelligentdrivestoareal-timehost.Inthisarchitecture,thesoftwarecomponentsofthemotioncontrollerrunonareal-timehostandallI/Oisimplementedinthedrives.ThisseparationofI/Ofromthemotioncontrollersoftwarecomponentshelpstolowersystemcostandimprovereliabilitybyimprovingconnectivity.TheCANopenstandardisusedtoconnectthesecomponents.WhenyouusetheNISoftMotionControllerwithaCANopendevice,youcandaisychainupto15drivestogetherandconnectthemtothereal-timehost.Thereal-timeProcessDataObjects(PDOs)definedbytheCANopenprotocolareusedtotransferdatabetweenthedrivesandhost.AllI/OrequiredbythemotioncontrollerisimplementedbyCANopendrivesthatsupporttheDeviceProfile402forMotionControl.Currently,theNISoftMotionControllersupportsonlyCANopendrivesfromCopleyControlsCorp.WhenusedwithCANopendevices,theSupervisoryControlandTrajectoryGenerationcomponentsoftheNISoftMotionControllerexecuteinareal-timeenvironmentthatisrunningLabVIEWReal-TimeModule(ETS).Ifyourmotioncontrolsystemuses8axesorfewer,thesupervisorycontrolandtrajectorygenerationloopsexecuteevery10milliseconds.Ifyourmotioncontrolsystemusesmorethan8axes,thesupervisorycontrolandtrajectorygenerationloopsexecuteevery20milliseconds.WhenyouusetheNISoftMotionControllerwithaCANopendrive,thedriveimplementsthecontrolloopandinterpolation,asshowninthefollowingfigure.
Inthisconfiguration,theI/Oandthecontrolloopexecuteonthe
![Page 25: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/25.jpg)
CANopendrive.TheNISoftMotionControllerusesanNI-CANdevicetocommunicatetotheCANbus.
![Page 26: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/26.jpg)
NISoftMotionControllerCommunicationWatchdogThesupervisorycontrolintheNISoftMotionControllercontinuouslymonitorsallcommunicationwiththedrivesconnectedtothehost.Ifanydrivefailstoupdateitsdatainthehostloopupdateperiod,theaxiscorrespondingtothatdriveisdisabledandthecommunicationwatchdogstatusbit,whichisreturnedbytheReadPerAxisStatusVIorfunction,issettoTRUE.Similarly,alldrivesconnectedtotheNISoftMotionControllerareconfiguredtogointoafaultstateifthedatafromtheNISoftMotionControllerisnotupdatedeveryhostloopupdateperiodonthedrives.ThecommunicationwatchdogfunctionalityensuresthattheNISoftMotionControlleroperatesinrealtime.
TipTogetanaxisoraxesoutofthecommunicationwatchdogstate,resettheNISoftMotionController.
![Page 27: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/27.jpg)
CreatingNI-MotionApplicationsThefollowingfiguredescribesthestepsforcreatinganapplicationwithNI-Motion,anddescribesthegenericstepsrequiredtodesignamotionapplication.
ForinformationaboutinteractionwithotherI/O,suchasaNationalInstrumentsdataand/orimageacquisitiondevices,refertoSynchronization.
![Page 28: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/28.jpg)
ProgrammingwithNI-MotionYoucanusetheC/C++functionsandLabVIEWVIs,includedwithNI-Motion,toconfigureandexecutemotioncontrolapplications.ThissectioncoverstheNI-MotionalgorithmsyouneedtouseallthefeaturesofNI-Motion.Eachtaskdiscussionusesthesamestructure.First,agenericalgorithmflowchartshowshowthecomponentpiecesrelatetoeachother.Then,thetaskdiscussiondetailsanyaspectsofcreatingthetaskthatarespecifictoLabVIEWorC/C++programming,completewithdiagramsandcodeexamples.
NoteTheLabVIEWblockdiagramsandC/C++codeexamplesaredesignedtoillustrateconcepts,anddonotcontainallthelogicorsafetyfeaturesnecessaryformostfunctionalapplications.
RefertotheNI-MotionFunctionHelportheNI-MotionVIHelpfordetailedinformationaboutspecificfunctionsorVIs.
![Page 29: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/29.jpg)
WhatYouNeedtoKnowaboutMovesThissectiondiscussestheconceptsnecessaryforprogrammingmotioncontrolincludingmoveprofiles,movetypes,velocityandaccelerationvalues,andtimingloops.
![Page 30: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/30.jpg)
MoveProfilesThebasicfunctionofamotioncontrolleristomakemoves.Thetrajectorygeneratortakesinthetypeofmoveandthemoveconstraintsandgeneratespoints,orinstantaneouspositions,inrealtime.Then,thetrajectorygeneratorfeedsthepointstothecontrolloop.Thecontrolloopconvertseachinstantaneouspositiontoavoltageortostep-and-directionsignals,dependingonthetypeofmotoryouareusing.Moveconstraintsarethemaximumvelocity,acceleration,deceleration,andjerkthatthesystemcanhandle.Thetrajectorygeneratorcreatesavelocityprofilebasedonthesemoveconstraintvalues.Therearetwotypesofprofilesthatcanbegeneratedwhilemakingthemove:trapezoidalands-curve.
![Page 31: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/31.jpg)
TrapezoidalWhenyouuseatrapezoidalprofile,theaxesaccelerateattheaccelerationvalueyouspecify,andthencruiseatthemaximumvelocityyouload.Basedonthetypeofmoveandthedistancebeingcovered,itmaybeimpossibletoreachthemaximumvelocityyouset.Thevelocityoftheaxis,oraxes,inacoordinatespaceneverexceedsthemaximumvelocityloaded.Theaxesdeceleratetoastopattheirfinalposition,asshown.
![Page 32: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/32.jpg)
S-CurveTheaccelerationanddecelerationportionsofans-curvemotionprofilearesmooth,resultinginlessabrupttransitions,asshowninthefollowingfigure.Thislimitsthejerkinthemotioncontrolsystem,butincreasescycletime.Thevaluebywhichtheprofileissmoothediscalledthemaximumjerkors-curvevalue.
![Page 33: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/33.jpg)
BasicMovesTherearefourbasicmovetypes:
ReferenceMove—InitializestheaxestoaknownphysicalreferencesuchasahomeswitchorencoderindexStraight–LineMove—MovesfrompointAtopointBinastraightline.ThemovecanbebasedonpositionorvelocityArcMove—MovesfrompointAtopointBinanarcorhelixContouredMove—Auser-definedmove;yougeneratethetrajectory,andthepointsloadedintothemotioncontrolleraresplinedtocreateasmoothprofile
Themotioncontrollerusesthespecifiedmoveconstraints,alongwiththemovedata,suchasendpositionorradiusandtravelangle,tocreateamotionprofileinallthemovesexceptthecontouredmoves.Contouredmovesignorethemoveconstraintsandfollowthepointsyouhavedefined.
![Page 34: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/34.jpg)
CoordinateSpaceWiththeexceptionofthearcmove,youcanexecuteallbasicmovesoneitherasingleaxisoronacoordinatespace.Acoordinatespaceisalogicalgroupingofaxes.Ifyouareperformingamovethatusesmorethanoneaxis,youmustspecifyacoordinatespacemadeupoftheaxesthemovewilluse,asshowninthefollowingfigure.
NoteArcmovesalwaysexecuteonacoordinatespace.
UsetheConfigureVectorSpaceVIorfunctiontoconfigureacoordinatespace.Thisfunctioncreatesalogicalmappingofaxesandtreatstheaxesaspartofacoordinatespace.Thefunctionthenexecutesthemovegeneratedbythetrajectorygeneratoronthevector,andtreatsallthemoveconstraintsasvectorvalues.
![Page 35: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/35.jpg)
Multi-StartsversusCoordinateSpacesCoordinatespacesalwaysstartandendthemotionofallaxessimultaneously.Youcanusemulti-startstocreateasimilareffectwithoutgroupingaxesintocoordinatespaces.Usingamulti-startautomaticallystartsallaxesvirtuallysimultaneously.Tosimultaneouslyendthemoves,youmustcalculatethemoveconstraintstoendtravelatthesametime.Incoordinatespaces,thesevaluesarecalculatedautomatically.
![Page 36: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/36.jpg)
TrajectoryParametersUsetrajectoryparameterstocontrolthemovesyouprograminNI-Motion.Alltrajectoryparametersforservoaxesareexpressedintermsofquadratureencodercounts.Parametersforopen-loopandclosed-loopstepperaxesareexpressedinsteps.Forservoaxes,theencoderresolution,whichisexpressedincountsperrevolution,determinestheultimatepositionalresolutionoftheaxis.Forstepperaxes,thenumberofstepsperrevolutiondependsuponthetypeofstepperdriveandmotoryouareusing.Forexample,asteppermotorwith1.8°/step(200steps/revolution)usedinconjunctionwitha10Xmicrostepdrivehasaneffectiveresolutionof2,000stepsperrevolution.Resolutiononclosed-loopstepperaxesislimitedtothestepsperrevolutionorencodercountsperrevolution,whichevervalueismorecoarse.Floating-pointversusfixed-pointparameterrepresentationandtimebasearetwoadditionalfactorsthataffectthewaytrajectoryparametersareloadedtotheNImotioncontrollerascomparedtohowtheyareusedbythetrajectorygenerators.
![Page 37: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/37.jpg)
Floating-PointversusFixed-PointParametersOnNI73xxmotioncontrollers,youcanloadsometrajectoryparametersaseitherfloating-pointorfixed-pointvalues,buttheinternalrepresentationontheNImotioncontrollerisalwaysfixed-point.Youmustconsiderthisfunctionalitywhenworkingwithonboardvariables,inputs,andreturnvectors.Thisfunctionalityalsohasasmalleffectonparameterrangeandresolution.TheNISoftMotionControllerusesa64-bitfloatingpointtrajectorygenerator.Therangesforallmoveconstraintsarethefull64-bitrange,whichincludesmaximumvelocity,maximumacceleration,maximumdeceleration,maximumaccelerationjerk,maximumdecelerationjerk,andvelocityoverridepercentage.Allarcparametersthatusefloatingpointalsosupportthefull64-bitfloatingpointrange.
![Page 38: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/38.jpg)
NI73xxMoveConstraintValuesThefollowingsectionsdefinetheminimumandmaximumvaluesformoveconstraintsaswellasadditionalinformationabouttheresolutionofthevelocityoverridevalueandarcangle.Velocityandaccelerationvaluesareloadedincounts/s,RPM,RPS/s,steps/s,andsoon,whichareallfunctionsofsecondsorminutes.However,thetrajectorygeneratorupdatestargetpositionattheTrajectoryUpdateRate,whichisprogrammablewiththeEnableAxesVIorfunction.Thismeansthattherangefortheseparametersdependsontheupdaterateselected.NI73xxVelocityinRPMNI73xxVelocityinCounts/sorSteps/s
NI73xxAccelerationinCounts/s2
NI73xxAccelerationinRPS/sNI73xxVelocityOverrideinPercentNI73xxArcAnglesinDegrees
![Page 39: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/39.jpg)
NI73xxVelocityinRPMVelocityvaluesinRPMareconvertedtoaninternal16.16fixed-pointformatinunitsofcounts(steps)persampleperiod(updateperiod)beforebeingusedbythetrajectorygenerator.NI-Motioncancontrolvelocityto1/65,536ofacountorsteppersample.Thefollowingtableshowstheminimumandmaximumvelocityincounts/min.UsetheformulashownintheCalculationBasedonUnitscolumntodeterminethecounts/minvaluetoRPM.
UpdateRate MIN MAX Calculation
BasedonUnits62.5µs 14.648438
counts/minForservomotors,themaximumcounts/minis1.2billionindependentoftheupdaterate.
±RPMmax=MAX×1/rwherer=counts/revolution
125µs 7.324219counts/min
187.5µs
4.882813counts/min
250µs 3.662109counts/min
312.5µs
2.929688counts/min
Forsteppermotors,themaximumcounts/minvalueisdependentonthecontroller:
480millioncounts/minforNI7350240millioncounts/minforNI7330/7340/7390
±RPMmin=MIN×1/rwherer=counts/revolution
375µs 2.441406counts/min
437.5µs
2.092634counts/min
500µs 1.831055counts/min
![Page 40: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/40.jpg)
YoucancalculatethisminimumvelocityincrementinRPMwiththefollowingformula:minimumRPM=Vmin×( )×60×( )
whereVmin=1/65,536counts/sampleorsteps/sampleTs=sampleperiodinsecondspersample60=numberofsecondsinaminuteR=countsorstepsperrevolution
orminimumRPM=MIN×
YoualsocancalculatetheminimumvelocityusingtheformulashownintheCalculationBasedonUnitscolumn.Foratypicalservoaxiswith2,000countsperrevolutionoperatingata250µsupdaterate,theminimumRPMincrementis
× ×60× =0.00183105RPMor
3.662109× =0.00183105RPMYoucancalculatethemaximumvelocityinRPMwiththefollowingequation:maximumRPM=Vmax×60×
whereVmax=20MHzforservos8MHzforsteppersonaNI7350controller4MHzforsteppersonaNI7330,NI7340,orNI7390motioncontrollerR=counts/stepsperrevolution
andisconstrainedbyacceleration/decelerationaccordingtothefollowingequation:velocity (65,536×deceleration)acceleration
wherevelocityisincounts/sampleandaccelerationanddecelerationareincounts/sample2.
![Page 41: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/41.jpg)
Fromtheexample,themaximumRPMis
(20×106)×60× =600,000RPMRPMvaluesstoredinonboardvariablesareindouble-precisionIEEEformat(f64).
![Page 42: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/42.jpg)
NI73xxVelocityinCounts/sorSteps/sVelocityvaluesincounts/sorsteps/sarealsoconvertedtotheinternal16.16fixed-pointformatinunitsofcountsorstepspersample(update)periodbeforebeingusedbythetrajectorygenerator.Althoughthemotioncontrollercancontrolvelocityto1/65,536ofacountorsteppersample,itisimpossibletoloadavaluethatsmallwiththeLoadVelocityVIorfunction,asshowninthefollowingformula:Velocityincountsorstep/s=Vmin×
where:Vminis1/65,536counts/sampleorsteps/sampleandTsisthesampleperiodinsecondspersample.
Evenatthefastestupdaterate,Ts=62.5×106
LoadVelocitytakesanintegerinputwithaminimumvalueof1count/sorstep/s.Youcannotloadfractionalvalues.Ifyouneedtoloadavelocityslowerthanonecountorsteppersecond,usetheLoadVelocityinRPMVIorfunction.Youcancalculatethemaximumvelocitywiththefollowingequation:maximumvelocity=Vmax
whereVmax=20MHzforservos8MHzforsteppersonaNI7350controller4MHzforsteppersonaNI7330,NI7340,orNI7390motioncontroller
andisconstrainedbyacceleration/decelerationaccordingtothefollowingequation:velocity (65,536×deceleration)acceleration
wherevelocityisincounts/sampleandaccelerationanddecelerationareincounts/sample2.
![Page 43: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/43.jpg)
NI73xxAccelerationinCounts/s2Accelerationanddecelerationvaluesareconvertedtoaninternal16.16fixed-pointformatinunitsofcounts/s2beforebeingusedbythetrajectorygenerator.Thefollowingtableshowstheminimumandmaximumaccelerationupdateratesincounts/sec2.
UpdateRate MAX MIN
CalculationBasedonUnits
62.5µs 2,048,000,000counts/sec2 3906counts/sec2 Accelmax=MAX
125µs 2,048,000,000counts/sec2 977counts/sec2
187.5µs 910,222,222counts/sec2 434counts/sec2
250µs 512,000,000counts/sec2 244counts/sec2
312.5µs 327,680,000counts/sec2 156counts/sec2 Accelmin=MIN
375µs 227,555,556counts/sec2 109counts/sec2
437.5µs 167,183,673counts/sec2 80counts/sec2
500µs 128,000,000counts/sec2 61counts/sec2
Youcancalculatetheminimumaccelerationincrementwiththefollowingformula:
minimumacceleration/deceleration=Amin×( )2
where
Amin=1/65,536counts/sample2orsteps/sample2
Ts=sampleperiodinsecondspersampleForatypicalservoaxiswith2,000countsperrevolutionoperatingatthe250µsupdaterate,calculatetheminimumacceleration/decelerationincrementusingthefollowingequation:
( )×( )2=244counts/second2
![Page 44: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/44.jpg)
Youcancalculatethemaximumacceleration/decelerationusingthefollowingequation:
maximumacceleration/deceleration=Amax×( )2
where
Amax=32counts/sample2
Ts=sampleperiodinsecondspersampleandisconstrainedaccordingtothefollowingequations:acceleration256 decelerationdeceleration65536 acceleration
![Page 45: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/45.jpg)
NI73xxAccelerationinRPS/sAccelerationanddecelerationvaluesinRPS/sareconvertedtoaninternal16.16fixed-pointformatinunitsofcounts/sample2orsteps/sample2beforebeingusedbythetrajectorygenerator.Thefollowingtableshowstheminimumandmaximumaccelerationupdateratesincounts/sec2.
UpdateRate MAX MIN CalculationBasedon
Units62.5µs 2,048,000,000
counts/sec23906counts/sec2
±RPS/smax=MAX×1/rwherer=counts/revolution
125µs 2,048,000,000counts/sec2
977counts/sec2
187.5µs 910,222,222counts/sec2
434counts/sec2
250µs 512,000,000counts/sec2
244counts/sec2
312.5µs 327,680,000counts/sec2
156counts/sec2
±RPS/smin=MIN×1/rwherer=counts/revolution
375µs 227,555,556counts/sec2
109counts/sec2
437.5µs 167,183,673counts/sec2
80counts/sec2
500µs 128,000,000counts/sec2
61counts/sec2
YoucancalculatetheminimumaccelerationincrementinRPS/swiththefollowingformula:
RPS/sec=Amin×( )2×where
Amin=1/65,536counts/sample2orsteps/sample2
![Page 46: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/46.jpg)
Ts=sampleperiodinsecondspersampleR=countsorstepsperrevolution
orRPM/s=MIN×
Foratypicalservoaxiswith2,000countsorstepsperrevolutionoperatingatthe250µsupdaterate,calculatetheminimumRPS/sincrementusingthefollowingequation:
( )×( )2× =0.122070RPS/sor
244× =0.122YoucancalculatethemaximumRPS/susingthefollowingequation:
maximumRPS/s=Amax×( )2×( )
where
Amax=32counts/sample2
Ts=sampleperiodinsecondspersampleR=countsorstepsperrevolution
andisconstrainedaccordingtothefollowingequations:acceleration 256×decelerationdeceleration 65536×acceleration
or
Foratypicalservoaxiswith2,000countsorstepsperrevolutionoperatingatthe250µsupdaterate,calculatethemaximumRPS/sincrementusingthefollowingequation:
32×( )2× =256,000RPS/sRPS/svaluesstoredinonboardvariablesareindouble-precisionIEEEformat(f64).
![Page 47: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/47.jpg)
NI73xxVelocityOverrideinPercentTheLoadVelocityOverrideVIorfunctiontakesasingle-precisionfloating-point(f32)datavaluefrom0to150%,butvelocityoverrideisinternallyimplementedasavelocityscalefactorof0to384withanimplicitfixeddenominatorof256.NI-Motionusesthevelocityoverridetoincreasethespeedofthecalculationforthesakeofcalculationspeed—thedivisionisashiftrightbyeightbits.Theresolutionforvelocityoverrideisthereforelimitedto1/256,orabout0.39%.
NoteTheconversionfromfloating-pointtofixed-pointisperformedonthehostcomputer,notonthemotioncontroller.Toloadvelocityoverridefromanonboardvariable,youmustusetheintegerrepresentationof0to384,where384correspondsto150%.
NoteIfthedistanceofthemoveistoosmall,itmaynotbepossibletoreachthecommandedmaximummoveconstraints.Insuchinstances,NI-Motionadjuststhemoveconstraintslowertoreachthecommandedposition.
![Page 48: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/48.jpg)
NI73xxArcAnglesinDegreesTheLoadCircularArc,LoadHelicalArc,andLoadSphericalArcVIs/functionstakeangleparametersindegreesasdouble-precisionfloating-pointvalues.Thesevaluesareconvertedtoaninternal16.16fixed-pointrepresentationwheretheintegerpartcorrespondstomultiplesof45°(forexample,360°isrepresentedas0x00080000).Usethefollowingformulatoconvertfromfloating-pointtofixedpoint:
where:Qisthequotient,theintegermultipleof45°Ristheremainder.
Forexample,94.7°isrepresentedin16.16formatasfollows:
Theminimumangularincrementistherefore
×45º=0.000687º
NoteTheconversionfromfloating-pointtofixed-pointisperformedonthehostcomputer,notontheNImotioncontroller.ToloadarcVIsfromonboardvariables,youmustusethe16.16fixed-pointrepresentationforallangles.
![Page 49: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/49.jpg)
NI73xxArcMoveLimitationsThefollowingarelimitationstothevelocityandaccelerationofarcmoves.
NoteRoundtheresultoftheseequationstothenearestinteger.
ArcmovesmustmeettherequirementsofthefollowingequationsoranNIMC_invalidVelocityErrorisgenerated:V×P×4<R
and
whereV=Velocityincounts/sP=PIDsamplerateinsecondsI=CoarseArcPointsIntervalPeriod(10msor20ms)inseconds,configuredinMAXR=Radiusincounts
ArcmovesmustmeettherequirementsofthefollowingequationsoranNIMC_invalidAccelerationErrorisgenerated:A×P×4<R
and
where
A=Acceleration/decelerationincounts/s2
P=PIDsamplerateinsecondsI=CoarseArcPointsIntervalPeriod(10msor20ms)inseconds,configuredinMAXR=Radiusincounts
![Page 50: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/50.jpg)
TimingLoopsNationalInstrumentsrecommendsthatyouusethelooptimingsdiscussedinthefollowingsections.
![Page 51: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/51.jpg)
StatusDisplayWhenyouaredisplayingstatusinformationtotheuser,suchasposition,movestatus,orvelocity,anupdateratefasterthan60mshasnovalue.Infact,thereisnoneedtoupdateadisplayanyfasterthan22Hzbecausethehumaneyecandetectflickeronlyatrefreshratesslowerthan22Hz.However,youmightseeflickerinmonitorsataround60Hz,becauseofinterferencewithartificiallightfromlightbulbsthatrunona60HzACsignal.Therecommendedstandardis60msbecauseonemightneedmultiplefunctioncallswithinonelooptoacquireallthenecessarydata.
![Page 52: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/52.jpg)
GraphingDataWhenacquiringdataforgraphingortrackingpurposes,a10msupdatetimesuitsmostapplications.MAX,forexample,updatesitsmotiongraphsevery10ms.Thisupdatetimeequatesto100sampleseverysecondandprovidesenoughresolutionfortypicalapplications.Considerhowaccuratethegraphdisplayiswhenchoosingthetimingfortheloop.
![Page 53: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/53.jpg)
EventPollingUseapollingintervalof5mswhenpollingforatime-criticaleventthatmustoccurbeforetheprogramcontinues.Thisintervalisfastenoughtosatisfymosttime-criticalpollingneeds,althoughcertainhigh-speedapplicationsmayrequireafasterinterval.Considertheallowableresponsetimewhenchoosingapollinginterval.Forexample,tosynchronizethemotionwiththeacquisitioninanapplicationwhereauserplacesanobjectunderthescanareaandclicksaScanbutton,youcreateperiodicbreakpointsevery10countstotriggeradataacquisitionoverRTSI.Inthisexample,theloopneedsonlytoreadthepositionandwaitforthemovetocompletebeforeendingthescan.Althoughtheprogrampollsforanevent(movecomplete),noactionisbeingtriggeredbythemovecomplete.Becausethereisnoneedforinstantaneousaction,thereisnoneedtoupdatethepositionanyfasterthan60ms,and60msisacceptableformonitoringthemovecompletestatusaswell.
![Page 54: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/54.jpg)
Straight-LineMovesAstraight-linemoveexecutestheshortestmovebetweentwopointsandcanuseone,two,orthreeaxes.Straight-linemovesareeitherposition-basedorvelocity-based.
![Page 55: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/55.jpg)
Position-BasedStraight-LineMovesPosition-basedstraight-linemovesusethespecifiedtargetpositiontogeneratethemovetrajectory.Forexample,ifthemotoriscurrentlyatpositionzero,andthetargetpositionis100,aposition-basedmovecreatesatrajectorythatmoves100counts(steps).Thecontrollerrequiresthefollowinginformationtomovetoanotherpositioninastraightline:
Startposition—Currentposition,normallyheldoverfromapreviousmoveorinitializedtozeroEndposition—Alsoknownasthetargetposition,orwhereyouwanttomovetoMoveconstraints—Maximumvelocity,maximumacceleration,maximumdeceleration,andmaximumjerkTipWhenyouareusingtheNISoftMotionController,youcanloadseparateaccelerationanddecelerationjerkvalues.
Themotioncontrollerusesthegiveninformationtocreateatrajectorythatneverexceedsthemoveconstraintsandthatmovesanaxisoraxestotheendpositionyouspecify.Thecontrollergeneratesthetrajectoryinrealtime,soyoucanchangeanyoftheparameterswhiletheaxesaremoving.
![Page 56: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/56.jpg)
Straight-LineMoveAlgorithmThestraight-linemovealgorithmincludesthefollowingprocedures:
Loadtargetposition—SpecifiestheendpositionLoadthemoveconstraints—Loadsthevelocity,acceleration,deceleration,andjerkvaluesStartmotion—Startsthemove
Thestartpositionisalwaysthecurrentpositionoftheaxisoraxes.Youcanloadtheendpositionaseitheranabsolutepositiontomovetoorasapositionrelativetothestartingposition.Althoughyoucanupdateanyparameterwhilethemoveisinprogress,thenewparameterisusedonlyafterasubsequentStartorBlendMove.
TipYoumustloadthemoveconstraintsonlyiftheyaredifferentfromwhatwaspreviouslyloaded.
![Page 57: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/57.jpg)
Straight-LineMoveLabVIEWDiagramThefollowingblockdiagramsdemonstrateusingNI-Motiontocompletea1Dand2Dstraight-linemove,respectively.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
![Page 58: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/58.jpg)
1DStraight-LineMoveBlockDiagram
1LoadVelocity 4LoadS-CurveTime
7StartMotion
2LoadAcceleration/Deceleration
5SetOperationMode
8ReadperAxisStatus
3LoadAcceleration/Deceleration
6LoadTargetPosition
9MotionErrorHandler
![Page 59: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/59.jpg)
2DStraight-LineMoveBlockDiagram
1ConfigureVectorSpace
5LoadS-CurveTime
9CheckMoveCompleteStatus
2LoadVelocity 6SetOperationMode
10ReadperAxisStatus
3LoadAcceleration/Deceleration
7LoadTargetPosition
11ReadperAxisStatus
4LoadAcceleration/Deceleration
8StartMotion 12MotionErrorHandler
![Page 60: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/60.jpg)
Straight-LineMoveC/C++CodeTipThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\forfilesthatarecompleteandcompileasis.
![Page 61: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/61.jpg)
1DStraight-LineMoveCode
![Page 62: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/62.jpg)
2DStraight-LineMoveCode
![Page 63: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/63.jpg)
Velocity-BasedStraight-LineMovesSomemotionapplicationsrequiremovesthattravelinastraightlineforaspecificamountoftimeatagivenspeed.Thistypeofmoveisknownasvelocityprofilingorjogging.Youcanuseamotioncontrolapplicationtomoveamotoratagivenspeedforaspecifictime,andthenchangethespeedwithoutstoppingtheaxis.Thesignoftheloadedvelocityspecifiesthedirectionofmotion.Positivevelocityimpliesforwardmotionandnegativevelocityimpliesreversemotion.
TipYoucanchangethemoveconstraintsduringavelocitymove.
![Page 64: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/64.jpg)
Velocity-BasedStraight-LineMoveAlgorithmThefollowingfigureshowsagenericvelocity-basedstraight-linemovealgorithmapplicabletobothC/C++andLabVIEWcode.
LoadingasecondvelocityandexecutingtheStartMotionVIorfunctioncausesthemotioncontrollertoaccelerateordeceleratetothenewlyloadedvelocityusingtheaccelerationordecelerationparameterslastloaded.TheaxisdeceleratestoastopusingtheStopMotionVIorfunction.Thevelocityprofilecreatedintheexamplecodeisshowninthefollowingfigure.
![Page 65: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/65.jpg)
Velocity-BasedStraight-LineMoveLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontocompleteavelocity-basedstraight-linemove.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1LoadVelocity 5SetOperationMode
9StartMotion
2LoadAcceleration/Deceleration
6StartMotion 10ReadperAxisStatus
3LoadAcceleration/Deceleration
7ReadperAxisStatus
11StopMotion
4LoadS-CurveTime 8LoadVelocity 12MotionErrorHandler
![Page 66: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/66.jpg)
Velocity-BasedStraight-LineMoveC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
i32moveTime1;//Timeforthe1stsegment
i32moveTime2;//Timeforthe2ndsegment
i32initialTime;
i32currentTime;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=3;
//Settheaxisnumber
axis=1;
//Movetimeforthefirstsegment
moveTime1=5000;//milliseconds
//Movetimeforthesecondsegment
moveTime2=10000;//milliseconds
////////////////////////////////
//------------------------------------------------------------
//Firstsegment
//------------------------------------------------------------
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,axis,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,axis,NIMC_ACCELERATION,100000,0xFF);
CheckError;
//Setthedecelerationforthemove(incounts/sec^2)
![Page 67: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/67.jpg)
err=flex_load_acceleration(boardID,axis,NIMC_DECELERATION,100000,0xFF);
CheckError;
//Setthejerk(s-curvevalue)forthemove(insampleperiods)
err=flex_load_scurve_time(boardID,axis,100,0xFF);
CheckError;
//Settheoperationmodetovelocity
err=flex_set_op_mode(boardID,axis,NIMC_VELOCITY);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
//Waitforthetimeforfirstsegment
initialTime=timeGetTime();
do
//Checkthemovecompletestatus/followingerror/axisoffstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
//Getthecurrenttimeandcheckiftimeisoverforthefirstsegment
currentTime=timeGetTime();
if((currentTime-initialTime)>=moveTime1)break;
Sleep(50);//Checkevery50ms
while(!(axisStatus&NIMC_MOVE_COMPLETE_BIT)&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
//------------------------------------------------------------
//Secondsegment
//------------------------------------------------------------
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,axis,6568,0xFF);
CheckError;
//Startthemove-toupdatethevelocity
![Page 68: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/68.jpg)
err=flex_start(boardID,axis,0);
CheckError;
//Waitforthetimeforsecondsegment
initialTime=timeGetTime();
do
//Checkthemovecompletestatus/followingerror/axisoffstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
//Getthecurrenttimeandcheckiftimeisoverforthesecondsegment
currentTime=timeGetTime();
if((currentTime-initialTime)>=moveTime2)break;
Sleep(50);//Checkevery50ms
while(!(axisStatus&NIMC_MOVE_COMPLETE_BIT)&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
//Deceleratetheaxistoastop
err=flex_stop_motion(boardID,axis,NIMC_DECEL_STOP,0);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
![Page 69: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/69.jpg)
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 70: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/70.jpg)
VelocityProfilingUsingVelocityOverrideYoualsocanusetheLoadVelocityOverrideVIorfunctiontoshiftfromonevelocitytoanotherwhileexecutingmoves.Whenyouusethisfunction,youindicatethenewvelocityintermsofapercentageoftheoriginallyloadedvelocityinsteadofexplicitlystatingthevelocityyouwanttochangeto.Forexample,120percentofanoriginalvelocityof10,000changesthevelocityto12,000.Thetransitionbetweenvelocitiesfollowsallothermoveconstraints.
![Page 71: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/71.jpg)
VelocityProfilingUsingVelocityOverrideAlgorithmThefollowingfigureshowsavelocity-basedstraight-linemovealgorithmshowingtheuseofvelocityoverrideapplicabletobothC/C++andLabVIEWcode.
![Page 72: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/72.jpg)
VelocityProfilingUsingVelocityOverrideLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-MotiontodovelocityprofilingusingVelocityOverride.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1LoadVelocity 5SetOperationMode
9ReadperAxisStatus
2LoadAcceleration/Deceleration
6StartMotion 10StopMotion
3LoadAcceleration/Deceleration
7ReadperAxisStatus
11MotionErrorHandler
4LoadS-CurveTime 8LoadVelocityOverride
![Page 73: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/73.jpg)
VelocityProfilingUsingVelocityOverrideC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
i32moveTime1;//Timeforthe1stsegment
i32moveTime2;//Timeforthe2ndsegment
i32initialTime;
i32currentTime;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=3;
//Settheaxisnumber
axis=1;
//Movetimeforthefirstsegment
moveTime1=5000;//milliseconds
//Movetimeforthesecondsegment
moveTime2=10000;//milliseconds
////////////////////////////////
//------------------------------------------------------------
//Firstsegment
//------------------------------------------------------------
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,axis,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,axis,NIMC_ACCELERATION,100000,0xFF);
![Page 74: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/74.jpg)
CheckError;
//Setthedecelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,axis,NIMC_DECELERATION,100000,0xFF);
CheckError;
//Setthejerk(s-curvevalue)forthemove(insampleperiods)
err=flex_load_scurve_time(boardID,axis,100,0xFF);
CheckError;
//Settheoperationmodetovelocity
err=flex_set_op_mode(boardID,axis,NIMC_VELOCITY);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
//Waitforthetimeforfirstsegment
initialTime=timeGetTime();
do
//Checkthemovecompletestatus/followingerror/axisoffstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
//Getthecurrenttimeandcheckiftimeisoverforthefirstsegment
currentTime=timeGetTime();
if((currentTime-initialTime)>=moveTime1)break;
Sleep(50);//Checkevery50ms
while(!(axisStatus&NIMC_MOVE_COMPLETE_BIT)&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
//------------------------------------------------------------
//Secondsegment
//------------------------------------------------------------
//Changethevelocityto80%oftheinitiallyloadedvalue
err=flex_load_velocity_override(boardID,axis,80,0xFF);
![Page 75: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/75.jpg)
CheckError;
//Waitforthetimeforsecondsegment
initialTime=timeGetTime();
do
//Checkthemovecompletestatus/followingerror/axisoffstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
//Getthecurrenttimeandcheckiftimeisoverforthesecondsegment
currentTime=timeGetTime();
if((currentTime-initialTime)>=moveTime2)break;
Sleep(50);//Checkevery50ms
while(!(axisStatus&NIMC_MOVE_COMPLETE_BIT)&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
//Deceleratetheaxistoastop
err=flex_stop_motion(boardID,axis,NIMC_DECEL_STOP,0);
CheckError;
//Resetvelocityoverridebackto100%
err=flex_load_velocity_override(boardID,axis,100,0xFF);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
![Page 76: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/76.jpg)
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 77: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/77.jpg)
ArcMovesAnarcmovecausesacoordinatespaceofaxestomoveonacircular,spherical,orhelicalpath.Youcanmovetwo-dimensionalvectorspacesinacircleonlyona2Dplane.Youcanmovea3Dvectorspaceonasphericalorhelicalpath.Eacharcgeneratedbythemotioncontrollerpassesthroughacubicsplinealgorithmthatensuresthesmoothestarc.Thisalsoensuresnegligiblechordalerror,whichiserrorcausedwhentwopointsonthesurfaceofthearcjoinwitheachotherusingastraightline.Acubicsplinealgorithmgeneratesmultiplepointsbetweeneverytwopointsofthearc,ensuringsmoothmotion,minimumjerk,andmaximumaccuracyatalltimes.Thedatapathisshowninthefollowingfigure.
NoteArcmovesmustmeettherequirementsoftheequationsinNI73xxArcMoveLimitationsoranNIMC_invalidVelocityErrorisgenerated.
![Page 78: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/78.jpg)
CircularArcsAcirculararcdefinesanarcintheXYplaneofa2Dor3Dcoordinatespace.Thearcisspecifiedbyaradius,startingangle,andtravelangle.Also,likeallcoordinatespacemoves,thearcusesthevaluesofmoveconstraints—maximumvelocity,maximumacceleration,andmaximumdeceleration.
TipFortheNISoftMotionController,thearcgenerationalsousesaccelerationjerkanddecelerationjerkwhilecalculatingthearcmove.
NoteWhenyouuseanNI73xxmotioncontrollertomoveamotorinanarc,youcanuseonlytrapezoidalprofiles.Youdonotusejerktocalculatetheprofileforarcmoves.
Tomoveaxesinacirculararc,themotioncontrollerneedsthefollowinginformation:
Radius—SpecifiesthedistancefromthecenterofthearctoitsedgeStartAngle—Orientsthearconitsplaneusingthestartingpointasanaxistospinaround.Becausethestartingpointforanewarcisfixedbasedonthecurrentposition,movingitscenteraroundthestartingpointalterstheorientationofanewarc.Forexample,thefollowingfigureshowstheeffectofchangingthestartanglefrom0°to180°.
1OriginalArc 2Arcwith180°StartAngleTravelAngle—Indicateshowfarthearctravelsina360°circle.
![Page 79: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/79.jpg)
Forexample,atravelangleof90°executesaquarter-circle,atravelangleof360°createsafullcircle,andatravelangleof720°createstwofullcircles.Apositivetravelanglealwayscreatescounterclockwisecircularmotion.Anegativetravelanglereversesthedirectiontocreateclockwisecircularmotion,asshowninthefollowingfigure.
1PositiveTravelAngle 2NegativeTravelAngle
![Page 80: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/80.jpg)
CircularArcMoveAlgorithmThefollowingfigureshowsagenericcirculararcmovealgorithmapplicabletobothC/C++andLabVIEWcode.
![Page 81: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/81.jpg)
CircularArcMoveLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontocompleteacirculararcmove.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureVectorSpace
5LoadCircularArc 8ReadperAxisStatus
2LoadVelocity 6StartMotion 9ReadperAxisStatus
3LoadAcceleration/Deceleration
7CheckMoveCompleteStatus
10MotionErrorHandler
4LoadAcceleration/Deceleration
![Page 82: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/82.jpg)
CircularArcMoveC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8vectorSpace;//Vectorspacenumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
u16status;
u16moveComplete;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
vectorSpace=NIMC_VECTOR_SPACE1;
////////////////////////////////
//Configurea2DVectorSpacecomprisingofaxes1and2
err=flex_config_vect_spc(boardID,vectorSpace,1,2,0);
CheckError;
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,vectorSpace,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_ACCELERATION,100000,0xFF);
CheckError;
//Setthedecelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_DECELERATION,100000,0xFF);
CheckError;
![Page 83: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/83.jpg)
//LoadSphericalArc
err=flex_load_circular_arc(boardID,vectorSpace,5000/*radius*/,0.0/*startAngle*/,180.0/*travelAngle*/,0xFF);
CheckError;
//Startthemove
err=flex_start(boardID,vectorSpace,0);
CheckError;
do
axisStatus=0;
//Checkthemovecompletestatus
err=flex_check_move_complete_status(boardID,vectorSpace,0,&moveComplete);
CheckError;
//Checkthefollowingerror/axisoffstatusforaxis1
err=flex_read_axis_status_rtn(boardID,1,&status);
CheckError;
axisStatus|=status;
//Checkthefollowingerror/axisoffstatusforaxis2
err=flex_read_axis_status_rtn(boardID,2,&status);
CheckError;
axisStatus|=status;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
while(!moveComplete&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
![Page 84: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/84.jpg)
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 85: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/85.jpg)
SphericalArcsA3Dsphericalarcdefinesa2DcirculararcintheX'Y'planeofacoordinatesystemthatistransformedbyrotationinpitch,asshowninthefirstfigure,andyaw,asshowninthesecondfigure,fromthenormal3Dcoordinatespace(XYZ).
InthetransformedX'Y'Z'space,the3Darcisreducedtoasimpler2Darc.The3Darcisdefinedasa2DcirculararcintheX'Y'planeofatransformedvectorspaceX'Y'Z'.Thistransformedvectorspace,X'Y'Z',isdefinedinorientationonly,withnoabsolutepositionoffset.ItsorientationisrelativetotheXYZvectorspace,andisdefinedintermsofpitchandyawangles.Whenrotatingthroughthepitchangle,theYandY'axesstayalignedwitheachotherwhiletheX'Z'planerotatesaroundthem.Whenrotatingthroughtheyawangle,theY'axisneverleavestheoriginalXYplane,asthenewly-definedX'Y'Z'vectorspacerotatesaroundtheoriginalZ-axis.Theradius,startangle,andtravelangleparametersalsoapplytoasphericalarcthatdefinesthearcintwodimensions.
![Page 86: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/86.jpg)
SphericalArcMoveAlgorithmThefollowingfigureshowsagenericsphericalarcmovealgorithmapplicabletobothC/C++andLabVIEWcode.
![Page 87: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/87.jpg)
SphericalArcMoveLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontocompleteasphericalarcmove.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureVectorSpace
5LoadSphericalArc 9ReadperAxisStatus
2LoadVelocity 6StartMotion 10ReadperAxisStatus
3LoadAcceleration/Deceleration
7CheckMoveCompleteStatus
11MotionErrorHandler
4LoadAcceleration/Deceleration
8ReadperAxisStatus
![Page 88: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/88.jpg)
SphericalArcMoveC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8vectorSpace;//Vectorspacenumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
u16status;
u16moveComplete;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
vectorSpace=NIMC_VECTOR_SPACE1;
////////////////////////////////
//Configurea3DVectorSpacecomprisingofaxes1,2and3
err=flex_config_vect_spc(boardID,vectorSpace,1,2,3);
CheckError;
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,vectorSpace,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_ACCELERATION,100000,0xFF);
CheckError;
//Setthedecelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_DECELERATION,100000,0xFF);
CheckError;
![Page 89: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/89.jpg)
//LoadSphericalArc
err=flex_load_spherical_arc(boardID,vectorSpace,5000/*radius*/,45.0/*planePitch*/,
45.0/*planeYaw*/,0.0/*startAngle*/,180.0/*travelAngle*/,0xFF);
CheckError;
//Startthemove
err=flex_start(boardID,vectorSpace,0);
CheckError;
do
axisStatus=0;
//Checkthemovecompletestatus
err=flex_check_move_complete_status(boardID,vectorSpace,0,&moveComplete);
CheckError;
//Checkthefollowingerror/axisoffstatusforaxis1
err=flex_read_axis_status_rtn(boardID,1,&status);
CheckError;
axisStatus|=status;
//Checkthefollowingerror/axisoffstatusforaxis2
err=flex_read_axis_status_rtn(boardID,2,&status);
CheckError;
axisStatus|=status;
//Checkthefollowingerror/axisoffstatusforaxis3
err=flex_read_axis_status_rtn(boardID,3,&status);
CheckError;
axisStatus|=status;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
while(!moveComplete&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
![Page 90: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/90.jpg)
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 91: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/91.jpg)
HelicalArcsAhelicalarcdefinesanarcina3DcoordinatespacethatconsistsofacircleintheXYplaneandsynchronizedlineartravelintheZ-axis.Thearcisspecifiedbyaradius,startangle,travelangle,andZ-axislineartravel.LineartravelisthelineardistancetraversedbythehelicalarcontheZ-axis,asshowninthefollowingfigure.
1SideViewofHelix 3IsometricViewofHelix2TopViewofHelix 4LinearTravel
![Page 92: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/92.jpg)
HelicalArcMoveAlgorithmThefollowingfigureshowsagenerichelicalarcmovealgorithmapplicabletobothC/C++andLabVIEWcode.
![Page 93: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/93.jpg)
HelicalArcMoveLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontocompleteahelicalarcmove.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureVectorSpace
5LoadHelicalArc 9ReadperAxisStatus
2LoadVelocity 6StartMotion 10ReadperAxisStatus
3LoadAcceleration/Deceleration
7CheckMoveCompleteStatus
11MotionErrorHandler
4LoadAcceleration/Deceleration
8ReadperAxisStatus
![Page 94: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/94.jpg)
HelicalArcMoveC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8vectorSpace;//Vectorspacenumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
u16status;
u16moveComplete;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
vectorSpace=NIMC_VECTOR_SPACE1;
////////////////////////////////
//Configurea3DVectorSpacecomprisingofaxes1,2and3
err=flex_config_vect_spc(boardID,vectorSpace,1,2,3);
CheckError;
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,vectorSpace,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_ACCELERATION,100000,0xFF);
CheckError;
//Setthedecelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_DECELERATION,100000,0xFF);
CheckError;
//LoadHelicalArc
err=flex_load_helical_arc(boardID,vectorSpace,5000/*radius*/,0.0/*startAngle*/,
![Page 95: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/95.jpg)
720.0/*travelAngle*/,5000/*lineartravel*/,0xFF);
CheckError;
//Startthemove
err=flex_start(boardID,vectorSpace,0);
CheckError;
do
axisStatus=0;
//Checkthemovecompletestatus
err=flex_check_move_complete_status(boardID,vectorSpace,0,&moveComplete);
CheckError;
//Checkthefollowingerror/axisoffstatusforaxis1
err=flex_read_axis_status_rtn(boardID,1,&status);
CheckError;
axisStatus|=status;
//Checkthefollowingerror/axisoffstatusforaxis2
err=flex_read_axis_status_rtn(boardID,2,&status);
CheckError;
axisStatus|=status;
//Checkthefollowingerror/axisoffstatusforaxis3
err=flex_read_axis_status_rtn(boardID,3,&status);
CheckError;
axisStatus|=status;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
while(!moveComplete&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
![Page 96: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/96.jpg)
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 97: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/97.jpg)
ContouredMovesAcontouredmovemovesanaxisoracoordinatespaceofaxesinapatternthatyoudefine.Thetrajectorygeneratoronthemotioncontrollerisnotusedduringacontouredmove.Thecontrollertakespositiondataintheformofanarray,andsplinesthedatabeforeoutputtingittotheDACsorstepperoutputs,asshowninthefollowingfigure.
Contouredmovesareusefulwhenyouwanttogenerateatrajectorythatcannotbeconstructedfromstraightlinesandarcs.Toensurethatthemotionissmoothwithminimumjerk,themotioncontrollercreatesintermediatepointsusingacubicsplinealgorithm.Themoveconstraintscommonlyusedtolimitothertypesofmoves,suchasmaximumvelocity,maximumacceleration,maximumdeceleration,andmaximumjerk,havenoeffectoncontouredmoves.However,theNIMotionAssistantprototypingtoolcanremapauser-definedtrajectorybasedonspecifiedmoveconstraints,preservingmovecharacteristicsandmovegeometry.
![Page 98: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/98.jpg)
ContouredMoveAlgorithmThefollowingfigureshowsagenericcontouredmovealgorithmapplicabletobothC/C++andLabVIEWcode.
Allcontouredmovesarerelative,meaningmotionstartsfromthepositionoftheaxisoraxesatthetimethecontouringmovestarts.Thisbehaviorissimilartothewayarcmoveswork.Dependingontheoperationmodeyouuse,youcanloadabsolutepositionsinthearrayorrelativepositions,whichimplyincrementalpositiondifferencesbetweencontouringpoints.
![Page 99: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/99.jpg)
AbsoluteversusRelativeContouringAllpositionsinacontouringbufferarerelativetothecurrentpositionwhenstarting.Thereisanassumed0pointthatthefirmwareaddstothefrontofthebufferofpoints.Forexample,ifthecontourbufferis[10,20,30,40],thepositionsare[0,10,20,30,40]inthefirmware.Whenacontourmovestartsittakesasnapshotofthecurrentpositionaccordingtothefollowingequation:StartPosition=currentPosition.
Thestartpositionisaddedtoeachpointinthebuffertogettheactualpositiontomovethroughaccordingtothefollowingequation:Point=StartPosition+bufferPosition[n].
Ifthecurrentpositionis100,andthebufferis[10,20,30,40],thecontourmovefollowsthesepoints:[100,110,120,130,140].Thedifferencebetweenabsolutecontouringandrelativecontouringishowthepointsinthebufferaretreated.Thepreviousexamplewasofanabsolutecontourmove.Arelativecontourmovetreatsthepointsasdeltasaccordingtothefollowingformula:Point[n]=Point[n-1]+bufferPosition[n]
Forarelativecontourmovethatstartsatposition100andincludesabufferwiththefollowingvalues:[10,20,30,40],thepointsthecontourmovefollowsare[100,110,130,160,200].Forcontouredmoves,notwoconsecutivepointscandifferbymorethan2151.Forabsolutepositionmode,thefirstpositioninthearraypassedtothecontrollermustbelessthan2151,andanytwoconsecutivepointsmustbelessthan2151.Forrelativepositionmode,nopointpassedtothecontrollercanbegreaterthan2151.AbsoluteversusRelativeContouringExampleIfanaxisstartsatposition0anduseseitherofthefollowingsetsofcontouringpoints,theaxisendsupatposition28.Iftheaxisstartsatposition10,itendsupatposition38inbothcases.
1 3 6 10 14 18 22 25 27 28
![Page 100: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/100.jpg)
1 2 3 4 4 4 4 3 2 1
![Page 101: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/101.jpg)
ContouredMoveLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontocompleteacontouredmove.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureVectorSpace
5StartMotion 9ClearBuffer
2SetOperationMode
6ReadperAxisStatus 10SetOperationMode
3ConfigureBuffer 7ReadperAxisStatus 11MotionErrorHandler
4WriteBuffer 8CheckMoveCompleteStatus
ThefollowingfiguredemonstratestheTRUEcaseoftheexample.
![Page 102: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/102.jpg)
1CheckBuffer 2WriteBuffer
![Page 103: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/103.jpg)
ContouredMoveC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8vectorSpace;//Vectorspacenumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
u16status;//Temporarycopyofstatus
u16moveComplete;//Movecompletestatus
i32i;
i32points[1994]=NIMC_SPIRAL_ARRAY;//Arrayof2Dpointstomove
u32numPoints=1994;//Totalnumberofpointstocontourthrough
i32bufferSize=1000;//Thesizeofthebuffertoallocateonthemotioncontroller
f64actualInterval;//Theintervalthecontrollercanreallycontourat
i32*downloadData=NULL;//Thetemporaryarraythatiscreatedtodownloadthepointstothecontroller
u32currentDataPoint=0;//Indicatesthenextpointinthepointsarraythatistobedownloaded
i32backlog;//Indicatestheavailablespacetodownloadmorepoints
u16bufferState;//Indicatesthestateoftheonboardbuffer
u32pointsDone;//Indicatesthenumberofpointsthathavebeenconsumed
u32dataCopied=0;//Keepstackofthepointscopied
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
vectorSpace=NIMC_VECTOR_SPACE1;
////////////////////////////////
//Configurea2DVectorSpacecomprisingofaxes1and2
err=flex_config_vect_spc(boardID,vectorSpace,1,2,0);
CheckError;
//Settheoperationmodetoabsoluteposition
err=flex_set_op_mode(boardID,vectorSpace,NIMC_ABSOLUTE_CONTOURING);
CheckError;
![Page 104: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/104.jpg)
//Configurebufferonmotioncontrollermemory(RAM)
//Noterequestedtimeintervalishardcodedto10milliseconds
err=flex_configure_buffer(boardID,1/*buffernumber*/,vectorSpace,NIMC_POSITION_DATA,bufferSize,numPoints,NIMC_TRUE,10,&actualInterval);
CheckError;
//Sendthefirst1000pointsofthedata
downloadData=malloc(sizeof(i32)*bufferSize);
for(i=0;i<bufferSize;i++)
downloadData[i]=points[i];
currentDataPoint++;
err=flex_write_buffer(boardID,1/*buffernumber*/,bufferSize,0,downloadData,0xFF);
free(downloadData);
downloadData=NULL;
CheckError;
//StartMotion
err=flex_start(boardID,vectorSpace,0);
CheckError;
for(;;)
axisStatus=0;
//Checkforavailablespaceanddownloadremainingpointsevery50milliseconds
Sleep(50);
//Checktoseeifwehavemorepointstodownload
if(currentDataPoint<numPoints)
err=flex_check_buffer_rtn(boardID,1/*buffernumber*/,&backlog,&bufferState,&pointsDone);
CheckError;
if(backlog>=300)
downloadData=malloc(sizeof(i32)*backlog);
dataCopied=0;
for(i=0;i<backlog;i++)
if(currentDataPoint>numPoints)break;
downloadData[i]=points[currentDataPoint];
currentDataPoint++;
dataCopied++;
err=flex_write_buffer(boardID,1/*buffernumber*/,dataCopied,0,downloadData,0xFF);
free(downloadData);
downloadData=NULL;
CheckError;
![Page 105: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/105.jpg)
//Checkthemovecompletestatus
err=flex_check_move_complete_status(boardID,vectorSpace,0,&moveComplete);
CheckError;
if(moveComplete)break;
//Checkforaxisoffstatus/followingerrororanymodalerrors
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
//Checkthemotoroffstatusonalltheaxesoraxis
err=flex_read_axis_status_rtn(boardID,1,&status);
CheckError;
axisStatus|=status;
err=flex_read_axis_status_rtn(boardID,2,&status);
CheckError;
axisStatus|=status;
if((axisStatus&NIMC_FOLLOWING_ERROR_BIT)||(axisStatus&NIMC_AXIS_OFF_BIT))
break;//Breakoutoftheforloopasanaxiswaskilled
//Setthemodebacktoabsolutemodetogetthecontrolleroutofcontouring
//mode
err=flex_set_op_mode(boardID,vectorSpace,NIMC_ABSOLUTE_POSITION);
CheckError;
//Freethebufferallocatedonthecontrollermemory
err=flex_clear_buffer(boardID,1/*buffernumber*/);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
![Page 106: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/106.jpg)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 107: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/107.jpg)
ReferenceMovesUsereferencemovestomovetheaxestoaknownstartinglocationandorientation.ReferencefunctionsincludetheFindReferenceVIorfunction,theCheckReferenceVIorfunction,theWaitReferenceVIorfunction,theReadReferenceStatusVIorfunction,theLoadReferenceParametersVIorfunction,andtheGetReferenceParametersVIorfunction.UseCheckReferencetodetermineiftheFindReferenceoperationiscomplete.ThisfunctionisoftenplacedinaloopthatcontinuesuntilthestatusfortheFindReferenceoperationisshowntobecomplete.YoucanuseWaitReferenceifthereisnoneedtomonitorthestatusoftheFindReference.UseaFindReferencemovetoinitiateasearchoperationtofindareferenceposition.Availablesearchoperationsincludehomeswitch,indexpulse,forwardlimitswitch,reverselimitswitch,center,orrunsequence.RefertotheNI-MotionVIHelportheNI-MotionFunctionHelpforinformationaboutreferencemoveoptions.
![Page 108: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/108.jpg)
ReferenceMoveAlgorithmThefollowingfigureshowsagenericreferencemovealgorithmapplicabletobothC/C++andLabVIEWcode.
![Page 109: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/109.jpg)
FindHomeSettingtheFindReferencesearchtypetoHomeinitiatesasearchsequenceforahomeinputorothersensorhookeduptothehomeinput.Attributesyoucanspecifyincludetheinitialsearchdirection,theedge(forwardorreverse)ofthehomesignaltostopon,andthedesiredtraveldirectionwhenyouapproachthespecifiedhomeedge.ThesearchisperformedatthemaximumfindvelocityspecifiedbyMaxFindVelocityorMaxFindRPM.Thevelocityoftheaxisissettothisvalueduringthefindoperation.Thevelocityisthenrestoredtoitspreviousvalueafterthesearchcompletes.Whentheinitialsearchdirectionisforward,theaxisstartsmovingintheforwarddirection.Ifthespecifiedhomesignaltransitionisdetected,thefindhomesequencecontinuesbasedontheothercontrolbits.Iftheforwardlimitswitchisencounteredbeforethehomeinput,theaxisautomaticallyreversesdirectionandcontinuessearchingforthehomeinput.Then,ifthereverselimitisencounteredbeforethehomeinput,thesequencestopsandtheHomeFoundstatusisFalse.Ifahomeinputexists,findingitisguaranteed.Asimilarsearchsequenceisfollowedwhentheinitialsearchdirectionisreverse,exceptthesearchstartsinthereversedirection.Youcanconfigurethefindhomesequencetodetecteithertherisingorfallingedgeofthehomesignal,asshowninthefollowingfigures.YoualsocansettheactivestateofthelimitandhomeinputswiththeSetLimitInputPolarityVIorfunctionandSetHomeInputPolarityVIorfunction,respectively.Afterthehomeinputisfound,motionapproachesthehomeedgefromthespecifieddirection.Ifnecessary,theaxistravelspastthehomeedgeandreversesdirectiontoapproachitfromtheprogrammeddirection.Tosmoothlyapproachtheedge,thisportionofthesequenceisexecutedataslowervelocityusingtheApproachVelocityPercentvaluesetwithLoadReferenceParameterVIorfunctionorinMAX.Thisapproachdirectionfeatureisusedtominimizetheeffectsofmotionsystemwindup,backlash,and/orhomesensorhysteresis.
![Page 110: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/110.jpg)
Theforwardedgeistheedgeofthehomeswitchthathasapositionhigherthanthatofthereverseedge.TheWaitReferenceVIorfunctionreportsthesuccessofaFindHome.WaitReferencealsocanbeusedtoqueryifthefindoperationiscompletebyusingatimeoutof0.YoualsocanmonitorthisstatuswiththeReadReferenceStatusVIorfunctionandReadperAxisStatusVIorfunction.Whenthehomeinputisfound,theHomeFoundstatusissettoTrue.Ifthehomesequencefailstolocatethespecifiededgeofthehomesignal,theHomeFoundstatusisFalse.
NoteNationalInstrumentsrecommendsnotconnectingthehomeinputtoeithertheforwardorreverselimits.Thismightcauseinappropriatebehavior.InsteaduseFindForwardorFindReverse.ConsiderusingFindCenterforstagesifyourgoalistocenterthesystemtothecenteroftravel.
IfyouexecuteaFindHomeonsystemswithoutahomeinput,thesequencealwaysterminatesatthelimitswitchoppositetotheinitialsearchdirection.TheHomeFoundstatusisfalseandtheedgeandapproachdirectionfeaturesarenotapplicable.ConsiderusingFindForwardandReverseLimitsinstead.IfSmartEnableisdisabledyoumustenablebothlimitsandthehomeinputpriortoexecutingtheFindHome.Ifanyofthelimitorhomeinputs
![Page 111: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/111.jpg)
aredisabledontheaxis,theFindHomedoesnotstartandamodalerrorisgenerated.Also,afteraFindHomesequencecompletes,thehomeinputmustbedisabledbecauseitisnolongerrequired,assumingyoudonotwanttostoponitthenexttimethesystemmovespastit.WiththeSmartEnablefeatureenabledbothlimitsandthehomeinputareautomaticallyenabledpriortoinitiatingthesearch.Afterthesearchcompletes,thelimitsandthehomeinputarereturnedtotheirpreviousstates.IfyouuseSmartEnable,NationalInstrumentsrecommendssettingthedefaultinMAXtoenabletheforwardandreverselimitsanddisablethehomeinput.Afterthehomeinputisfound,anoffsetmoveisperformed,ifspecified.OffsetMovespecifiestheamountanddirectionoftheoffset.ThisoffsetmoveisperformedatthemaximumfindvelocityspecifiedbyMaxFindVelocityorMaxFindRPM.BydefaultOffsetMoveis0,resultinginnooffsetmove.
NoteIfyouaredoinganoffsetmoveafteraFindHome,verifythatyousetthecorrectEdgetoStopOnusingtheLoadReferenceParameterVIorfunctionsothattheoffsetmovedoesnotcrossthehomeswitch.
Aftertheoffsetmoveisperformed,thepositionisresetifResetPosition?istrue.ThepositionissettothevaluesindicatedbyResetPrimaryPositionandResetSecondaryPosition.Thisprocedureestablishesarepeatablereferencepositionthatisasaccurateasthehomeedgelocation.Inclosed-loopencoderbasedsystems,youcanperformaFindIndexafteraFindHometoovercomeanyerrorsinthehomeedgelocation.TheFindIndexoperationallowsyoutogetafixedencoderpositionrelativetoyourhomeinput.Example1Youwanttofindtheforwardedgeofthehomeinputonaxis2andapproachitfromthereversedirection.Youalsowanttoperformanoffsetof500countsintheforwarddirectionandthenresetthepositionto0.Inaddition,youwanttobeginsearchinginthereversedirection.First,thesettingsinMAXmustcorrespondtothefollowing:
Final Search Edge Smart Reset Offset Reset Reset
![Page 112: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/112.jpg)
Direction Direction Enable Position? PrimaryPosition
SecondaryPosition
True(Reverse)
True(Reverse)
False(Forward)
True True 500 0 0
Then,tostartthesearch,callFindReferencewiththefollowingparameters:
axisOrVectorSpace=Axis2(usingLabVIEW)/NIMC_AXIS2(usingC)searchType=FindHome(0)axisOrVSMap=Unused
Asshowninthefollowingfigure,thisFindHomesequencesearchesforthehomeinputattheMaxFindVelocityfromthereversedirection(1).Whenthehomeinputisfound,theaxisdeceleratesandrepositionstothedesiredapproachdirection(2).Then,theforwardedgeisapproachedattheApproachVelocityinthereversedirection(3).
Example2Youwanttofindtheforwardedgeofthehomeinputonaxis2andapproachitfromtheforwarddirection.Youalsowanttoperformanoffsetof500countsinthereversedirectionandthenresetthepositionto0.Inaddition,youwanttobeginsearchinginthereversedirection.First,thesettingsinMAXmustcorrespondtothefollowing:
FinalDirection
SearchDirection
Edge SmartEnable
ResetPosition?
Offset ResetPrimaryPosition
ResetSecondaryPosition
![Page 113: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/113.jpg)
False(Forward)
True(Reverse)
False(Forward)
True True –500 0 0
Then,tostartthesearch,callFindReferencewiththefollowingparameters:
axisOrVectorSpace=Axis2(usingLabVIEW)/NIMC_AXIS2(usingC)searchType=Home(0)axisOrVSMap=Unused
Asshowninthefollowingfigure,thisFindHomesequencesearchesforthehomeinputfromthereversedirection(1).Whenthehomeinputisfound,theaxisdecelerates(2).ThentheforwardedgeisapproachedattheApproachVelocityintheforwarddirection(3).
Example3Youwanttofindthereverseedgeofthehomeinputonaxis2andapproachitfromthereversedirection.Inaddition,youwanttobeginsearchinginthereversedirection.First,thesettingsinMAXmustcorrespondtothefollowing:
FinalDirection
SearchDirection
Edge SmartEnable
ResetPosition?
Offset ResetPrimaryPosition
ResetSecondaryPosition
True(Reverse)
True(Reverse)
True(Reverse)
True False 0 0 0
Then,tostartthesearch,callFindReferencewiththefollowing
![Page 114: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/114.jpg)
parameters:axisOrVectorSpace=Axis2(usingLabVIEW)/NIMC_AXIS2(usingC)searchType=Home(0)axisOrVSMap=Unused
Asshowninthefollowingfigure,thisFindHomesequencesearchesforthehomeinputfromthereversedirection(1).Whentheforwardedgeofthehomeinputisfound,theaxisdeceleratestotheApproachVelocity(2).ThenthereverseedgeisapproachedattheApproachVelocityinthereversedirection(3).
Example4Youwanttofindthereverseedgeofthehomeinputonaxis2andapproachitfromtheforwarddirection.Inaddition,youwanttobeginsearchinginthereversedirection.First,thesettingsinMAXmustcorrespondtothefollowing:
FinalDirection
SearchDirection
Edge SmartEnable
ResetPosition?
Offset ResetPrimaryPosition
ResetSecondaryPosition
False(Forward)
True(Reverse)
True(Reverse)
True False 0 0 0
Then,tostartthesearch,callFindReferencewiththefollowingparameters:
axisOrVectorSpace=Axis2(usingLabVIEW)/NIMC_AXIS2
![Page 115: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/115.jpg)
(usingC)searchType=Home(0)axisOrVSMap=Unused
Asshowninthefollowingfigure,thisFindHomesequencesearchesforthehomeinputfromthereversedirection(1).Whenthereverseedgeofthehomeinputisfound,theaxisdecelerates(2).ThenthereverseedgeisapproachedattheApproachVelocityintheforwarddirection(3).
NoteWhentheinitialsearchdirectionisforward,theFindHomebehavioristhereverseoftheexamplesshown.
![Page 116: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/116.jpg)
FindIndexSettingtheFindReferencesearchtypetoIndexinitiatesasearchsequencetofindtheindex(marker)signalofthefeedbackencoder.Attributesyoucanspecifyincludetheinitialsearchdirection,approachvelocitypercent,andsearchdistance.Theencoderindexsignalisaccuratetoonequadraturecountandprovidesamuchmorerepeatablereferencethanusingjustalimitorhomeinputedge.FindIndexistypicallyexecutedafteraFindHome,FindCenter,orFindLimitoperation.Withthisprocedure,thehomeinputneedonlybeaccurateenoughtorepeatedlylocatetheaxiswithinthesameencoderrevolutionorindexperiod.ThenyoucanuseFindIndextofindauniqueinstanceoftheindex.
NoteFindIndexisonlyavailableonaxeswithincrementalencoderfeedback.
WhenperformingaFindIndexoperationafteranotherfind,youmightnoticeinconsistentoperationiftheindex(marker)signalisneartotheedgeofthehomeinputorlimit.Inthiscase,aFindIndexoperationcansometimesbeoffbyonerevolution.Tosolvethis,NationalInstrumentsrecommendsperforminganoffsetmoveonthepreviousfindtomoveawayfromtheindex(marker)signal,andthenperformtheFindIndexoperation.Thesearchsequenceisperformedinthespecifieddirectionatafixedlowvelocityof¼RPSunlessthemaximumfindvelocityisslower.Toguaranteefindingtheindex(ifoneexists),thelengthofthemoveisautomaticallysettoslightlygreaterthanoneencoderrevolution.IfyoupreviouslyperformedaFindForwardLimitoraFindReverseLimitNationalInstrumentsrecommendsyousetthesearchdirectionoftheFindIndextoadirectionoppositetothedirectionoftravelintothelimit.FindIndexusestheApproachVelocityPercentvaluesetwiththeLoadReferenceParameterVIorfunctionorinMAXthroughouttheentiresearchsequence.
NoteIfthevelocityoftheFindIndexoperationisveryhigh,itispossiblethesearchdistanceisreportedcompletebeforeindexfoundreportedcomplete.ThisresultsinIndexFoundstatusreportedasfalse.Toavoidthisyoucaneitherincreasethesearch
![Page 117: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/117.jpg)
distancetoallowmoretimetoreporttheindexfoundand/ordecreasethesearchspeedtoslowdownthesearch.
Innormaloperation,FindIndexuseshigh-speedcapturecircuitrytodetecttheindex.Theaxistypicallyovershootsbyanamountthatvariesdependingonthevelocity,thencomesbacktotheindex.Inmostcasesthisisnotnoticeable.
NoteIfyouareusingalinearencoderorifyourcounts/stepsperrevolutionissettoavalueotherthantheactualcounts/stepsperrevolution,usetheSearchDistanceparametersetwithLoadReferenceParameterorinMAXtoloadacustomsearchdistanceforaFindIndexmove.
TheWaitReferenceVIorfunctionreportsthesuccessofaFindIndex.WaitReferencealsocanbeusedtoqueryifthefindoperationiscompleteusingatimeoutof0.YoualsocanmonitorthisstatuswiththeReadperAxisStatusVIorfunction.WhentheindexisfoundtheIndexFoundstatusissettoTrue.Iftheindexisnotfoundduringthesearchrevolution,theaxiscomestoastopandindicatesthefailurebysettingtheIndexFoundstatustoFalse.Missingtheindexispossibleforanumberofreasonsincludinganincorrectlyconnectedencoderoranincorrectvalueforcountsperrevolution.Refertothemotioncontrollerdocumentationformoreinformationaboutencoderconnectionsandindexphasing.YoucanonlyexecuteaFindIndexonproperlyconfiguredaxesthatarepresentlystoppedorkilled.AttemptingtoexecuteaFindIndexwhiletheaxisisinmotiongeneratesamodalerror.RefertotheErrorsandErrorHandlingsectionoftheNI-MotionVIHelporNI-MotionFunctionHelpformoreinformationabouterrors.IfSmartEnableisdisabledNationalInstrumentsrecommendsyoudisablethehomeinputbeforeperformingaFindIndex.IfyoupreviouslyperformedaFindHome,dependingonthesettings,youmightencounterthehomeinputduringaFindIndex.WiththeSmartEnablefeatureenabledbothlimitsareenabledandthehomeinputisdisabledpriortoinitiatingthesearch.Afterthesearchcompletesthelimitsarereturnedtotheirpreviousstates.IfyouuseSmartEnable,NationalInstrumentsrecommendssettingthedefaultinMAXtoenabletheforwardandreverselimitsanddisablethehomeinput.
![Page 118: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/118.jpg)
Aftertheindex(marker)signalisfound,anoffsetmoveisperformed.OffsetMovespecifiestheamountanddirectionoftheoffset.ThisoffsetmoveisperformedatthemaximumfindvelocityspecifiedbyMaxFindVelocityorMaxFindRPM.BydefaultOffsetMoveis0,resultinginnooffsetmove.Aftertheoffsetmoveisperformed,thepositionisresetifEnableResetPositionistrue.ThepositionissettothevaluesindicatedbyPrimaryResetPositionandSecondaryResetPosition.
![Page 119: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/119.jpg)
FindForwardandReverseLimitsSettingtheFindReferencesearchtypetoForwardLimitinitiatesasearchsequencetofindtheforwardlimit.SettingthesearchtypetoReverseLimitinitiatesasearchsequencetofindthereverselimit.AttributesyoucanspecifyincludetheInitialSearchDirectionandtheFinalApproachDirection(forwhenthesearchencounterseachofthelimits).ThesearchisperformedatthemaximumfindvelocityspecifiedbyMaxFindVelocityorMaxFindRPM.Thevelocityoftheaxisissettothisvalueduringthefindoperation.Thevelocityisthenrestoredtoitspreviousvalueafterthesearchcompletes.Whenthesearchoperationinitiatestheaxisstartsmovinginthedirectionofthelimit.WhentheaxisencountersthelimitinthatdirectionthesearchcompletesandtheWaitReferenceVIorfunctionreturnsatruevalue.
Afine-tuningoperationisperformedwhenthelimitisreached.Thisprovidesforamoreaccuratesearch.Tosmoothlyapproachtheedge,thisportionofthesequenceisexecutedatafixedlowvelocityof1/4RPSunlessthemaximumfindvelocityisslower.Thisapproachdirectionfeatureisusedtominimizetheeffectsofmotionsystemwindup,backlash,and/orhomesensorhysteresis.Ifthefinalapproachdirectionistheoppositetothedirectionoftravelintothelimit(true),theaxisthenslowlybacksoffthelimituntilthelimitbecomesinactiveagain.Ifthefinalapproachdirectionisthesameasthedirectionoftravelintolimit(false),thentheaxisslowlybacksoffthelimitandre-approachesit.YoualsocansettheactivestateofthelimitwiththeSetLimitInputPolarityVIorfunction.IfSmartEnableisdisabledNationalInstrumentsrecommendsyoudisablethehomeinputbeforeperformingaFindForwardLimitorFindReverseLimit.IfthehomeinputisenabledandencounteredduringaFindCenter,thesearchstopsatthehomeinputandgeneratesamodalerror.WiththeSmartEnablefeatureenabledthelimityouaresearchingforisenabled,theoppositelimitisleftas-is,andhomeinputisdisabledpriortoinitiatingthesearch.Afterthesearchcompletes,thelimitsarereturnedtotheirpreviousstates.IfyouuseSmartEnable,NationalInstruments
![Page 120: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/120.jpg)
recommendssettingthedefaultinMAXtoenabletheforwardandreverselimitsanddisablethehomeinput.Afterthelimitislocated,anoffsetmoveisperformed.OffsetMovespecifiestheamountanddirectionoftheoffset.ThisoffsetmoveisperformedatthemaximumfindvelocityspecifiedbyMaxFindVelocityorMaxFindRPM.UsuallytheOffsetMoveisnegativeforaFindForwardLimitandpositiveforaFindReverseLimit.BydefaultOffsetMoveis0,resultinginnooffsetmove.Aftertheoffsetmoveisperformed,thepositionisresetifResetPosition?istrue.ThepositionissettothevaluesindicatedbyResetPrimaryPositionandResetSecondaryPosition.
![Page 121: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/121.jpg)
FindCenterSettingtheFindReferencesearchtypetoCenterinitiatesasearchsequencepositioningtheaxisinthemiddleoftheforwardandreverselimits.AttributesyoucanspecifyincludetheInitialSearchDirectionandtheFinalApproachDirection(forwhenthesearchencounterseachofthelimits).ThesearchisperformedatthemaximumfindvelocityspecifiedbyMaxFindVelocityorMaxFindRPM.Thevelocityoftheaxisissettothisvalueduringthefindoperation.Thevelocityisthenrestoredtoitspreviousvalueafterthesearchcompletes.Whenthesearchdirectionisforward,theaxisstartsmovingintheforwarddirection.Whenthelimitinthatdirectionisencountered,thedirectionisreversedtofindthereverselimit.Afterbothlimitsarereachedacenterpositioncanbecalculatedfromtherecordedpositions.Theaxisthenproceedstothecalculatedcenter.WhenthecenterisfoundtheWaitReferenceVIorfunctionreturnsatruevalue.Asimilarsearchsequencestartinginthereversedirectionisfollowedwhentheinitialsearchdirectionisreverse.Attheendofeachlimitoftravel,afine-tuningoperationisperformed.Thisprovidesforamoreaccuratesearch.Tosmoothlyapproachtheedge,thisportionofthesequenceisexecutedatafixedlowvelocityof1/4RPSunlessthemaximumfindvelocityisslower.Thisapproachdirectionfeatureisusedtominimizetheeffectsofmotionsystemwindup,backlash,and/orhomesensorhysteresis.Ifthefinalapproachdirectionisoppositetothedirectionoftravelintothelimit(true),theaxisslowlybacksoffthelimituntilthelimitbecomesinactiveagain.Ifthefinalapproachdirectionisthesameasthedirectionoftravelintolimit(false),theaxisslowlybacksoffthelimitandre-approachesit.YoualsocansettheactivestateofthelimitsinMAXorwiththeSetLimitInputPolarityVIorfunction.
IfSmartEnableisdisabledNationalInstrumentsrecommendsyoudisablethehomeinputbeforeperformingaFindCenter.IfthehomeinputisenabledandencounteredduringaFindCenter,thesearchstopsatthehomeinputandgeneratesamodalerror.
![Page 122: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/122.jpg)
WiththeSmartEnablefeatureenabledbothlimitsareenabledandthehomeinputisdisabledpriortoinitiatingthesearch.Afterthesearchcompletesthelimitsarereturnedtotheirpreviousstates.IfyouuseSmartEnable,NationalInstrumentsrecommendssettingthedefaultinMAXtoenabletheforwardandreverselimitsanddisablethehomeinput.Afterthecenterislocated,anoffsetmoveisperformed.OffsetMovespecifiestheamountanddirectionoftheoffset.ThisoffsetmoveisperformedatthemaximumfindvelocityspecifiedbyMaxFindVelocityorMaxFindRPM.BydefaultOffsetMoveis0,resultinginnooffsetmove.Aftertheoffsetmoveisperformed,thepositionisresetifResetPosition?istrue.ThepositionissettothevaluesindicatedbyResetPrimaryPositionandResetSecondaryPosition.
![Page 123: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/123.jpg)
RunSequenceSettingtheFindReferencesearchtypetoRunSequenceinitiatesapredefinedsearchacrossmultipleaxesandmultiplefindtypes.ThesequencerunisspecifiedinMAX.YoualsocanusetheLoadReferenceParameterVIorfunctiontoprogrammaticallysettheSequenceOrderforagivenaxisandsearchtype.TheRunSequenceoptionallowsyoutopre-configureasearchsequence.Thatsequencecanthenberunwithasinglefunction.ThesequencegetssavedwhenyousaveuserdefaultstoFlash(ROM).Tospecifyarunsequenceprogrammatically,youcanuseLoadReferenceParametertosettheSequenceOrderforagivenaxisandsearchtype.TheSequenceOrderreferstothephaseaparticularsearchisin.ThedefaultSequenceOrder0indicatesthataparticularsearchtypeisnotincludedinthesequence.
NoteOnlyonesearchtypeonagivenaxiscanhavethesameSequenceOrdernumber.IfyousettheFindHomeSequenceOrderof2,thensettheFindIndexSequenceOrderto2,FindHomeSequenceOrderresetsto0andFindIndexSequenceOrderis2.Noerrorisreportedifthisisthecase.
WhenspecifyingSequenceOrdersyoumustbesurenottoskipoveranumber,allphasesmustbecontiguous.Anyfindsspecifiedafterthegapisnotexecuted.Forexample,ifyouspecifyaFindCenterSequenceOrderof1andaFindIndexSequenceOrderof3,onlytheFindCenterisexecuted.
ExampleSupposeyouhaveastageconfiguredwithitsx-axistiedtoaxis2,itsy-axistiedtoaxis3,andanotherdeviceattachedtothestagetiedtoaxis1.Ifyouwanttomakesureyoucenterthedeviceattachedtothestagebeforeyoucenteredthestageyoumightsetuparunsequencesimilartothefollowing:
Phase1 Wait Phase2 Wait Phase3Axis1 FindCenter FindIndexAxis2 FindCenter FindIndex
![Page 124: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/124.jpg)
Axis3 FindCenter FindIndex
Thesequenceisspecifiedasdifferentphases.Thenextphasedoesnotstartuntilallfindoperationsinagivenphasearecomplete.Inthisexample,Phase1isthecenteringofaxis1;Phase2consistsoffindingtheindexofaxis1,andcenteringaxes2and3;Phase3consistsoffindingtheindexofaxes2and3.ForthisexampleyouwouldsetFindCenterSequenceOrderonAxis1to1,FindIndexSequenceOrderonAxis1to2,FindCenterSequenceOrderonAxes2and3to2,andFindIndexSequenceOrderonAxes2and3to3.
![Page 125: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/125.jpg)
ReferenceMoveLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontocompleteareferencemove.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1LoadVelocity 4LoadS-CurveTime
7ReadperAxisStatus
2LoadAcceleration/Deceleration
5FindReference 8CheckReference
3LoadAcceleration/Deceleration
6CheckReference
9MotionErrorHandler
![Page 126: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/126.jpg)
ReferenceMoveC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
f64acceleration=100;//AccelerationvalueinRPS/S
f64velocity=200;//VelocityvalueinRPM
u16found,finding;//CheckReferenceStatuses
u16axisStatus;//Axisstatus
u16csr=0;//CommunicationstatusRegister
i32position;//Currentpositionofaxis
i32scanVar;//Scanvariabletoreadinvaluesnotsupported
//bythescanffunction
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
//GettheboardID
printf("EntertheBoardID:");
scanf("%d",&scanVar);
boardID=(u8)scanVar;
//Checkiftheboardisatpowerupresetcondition
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
if(csr&NIMC_POWER_UP_RESET)
printf("\nTheFlexMotionboardisintheresetcondition.Pleaseinitializetheboardbefore");
printf("runningthisexample.The\"flex_initialize_controller\"functionwillinitializethe");
printf("boardwithsettingsselectedthroughMeasurementandAutomationExplorer\n");
return;
//Gettheaxisnumber
printf("Entertheaxis:");
scanf("%d",&scanVar);
axis=(u8)scanVar;
//FlushtheStdin
![Page 127: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/127.jpg)
fflush(stdin);
//Loadaccelerationanddecelerationtotheaxisselected
err=flex_load_rpsps(boardID,axis,NIMC_BOTH,acceleration,0xFF);
CheckError;
//Loadvelocitytotheaxisselected
err=flex_load_rpm(boardID,axis,velocity,0xFF);
CheckError;
//StarttheFindReferencemove
err=flex_find_reference(boardID,axis,0,NIMC_FIND_HOME_REFERENCE);
CheckError;
//WaitforfindreferencetocompleteontheaxisAND
//alsocheckformodalerrorsatthesametime
do
//Readthecurrentpositionofaxis
err=flex_read_pos_rtn(boardID,axis,&position);
CheckError;
//Displaythecurrentpositionofaxis
printf("\rAxis%dposition:%10d",axis,position);
//Checkiftheaxishasstoppedb/cofaxisofforfollowingerror
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
//Checkifthereferencehasfinishedfinding
err=flex_check_reference(boardID,axis,0,&found,&finding);
CheckError;
//ReadtheCommunicationStatusRegister-checkthe
//modalerrorbit
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
if(csr&NIMC_MODAL_ERROR_MSG)
flex_stop_motion(boardID,NIMC_AXIS1,NIMC_DECEL_STOP,0);//StoptheMotion
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
//testforfindreferencecomplete,followingerror,oraxisoffstatus
while(!(axisStatus&(NIMC_FOLLOWING_ERROR_BIT|NIMC_AXIS_OFF_BIT))&&finding);
printf("\nAxis%dposition:%10d",axis,position);
if(found)
printf("\rAxisfoundreference");
else
printf("\rAxisdidnotfindreference");
![Page 128: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/128.jpg)
printf("\n\nFinished.\n");
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 129: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/129.jpg)
BlendingBlending,alsocalledvelocityblending,superimposesthevelocityprofilesoftwomovestomaintaincontinuousmotion.Blendingisusefulwhencontinuousmotionbetweenconcatenatedmovesegmentsisimportant.Examplesofsomeapplicationsthatcanuseblendingarescanning,welding,inspection,andfluiddispensing.Blendingmustoccuronvelocityprofilesoftwomovesegments,sotheendpositionsofeachmovesegmentmayormaynotbereached.Forexample,ifyouareblendingtwostraight-linemovesthatforma90ºangle,theblendedmovemustroundthecornertomakethemovecontinuous.Inthiscase,themoveneverreachestheexactpositionwherethetwostraightlinesmeet,butinsteadfollowstheroundedcorner,asshowninthefollowingfigure.
1StartingPosition 3CornerRoundedbyBlending2EndPoint
Motioncontrollerscanperformblendingbetweentwostraight-linemoves,betweentwoarcmoves,orbetweenstraight-lineandarcmoves.Blendingdoesnotworkforreferenceandcontouredmoves.Becauseblendingoccursonvelocityprofiles,theeffectofreachingtheendpositionsofthemovesegmentsandthemaximumvelocitydependsonthevelocity,acceleration,deceleration,andjerkloadedforthetwomovesegments.Becausetwomovesegmentsarealwaysusedwhileblending,itisveryimportantthatyouwaitfortheblendtocompletebeforeloadingthenextmovesegmentyouwanttoblend.
![Page 130: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/130.jpg)
BlendingAlgorithmThefollowingfigureshowsagenericblendingalgorithmapplicabletobothC/C++andLabVIEWcode.
![Page 131: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/131.jpg)
BlendFactorsTherearethreewaysyoucanstartthesecondmoveinablend:
SuperimposethetwomovesbystartingthesecondmoveasthefirstmovestartstodecelerateStartthesecondmoveafterthefirstprofileiscompleteStartthesecondmoveafterthefirstprofileiscompleteandtheaddeddelaytimehaselapsed
RefertoMoveProfilesformoreinformationaboutmoveprofiles.
![Page 132: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/132.jpg)
SuperimposeTwoMovesSuperimposingtwomovesisthemostcommonuseofblending.Inthiscase,themotioncontrollertriestomaintaincontinuousmotionbysuperimposingthetwomovesegmentssuchthatthesecondmovesegmentstartsitsprofilewhilethefirstmoveisdecelerating,asshowninthefollowingfigure.
1BlendingStarts 3ActualVelocity2BlendisComplete
Thevelocityduringthesuperimpositiondependsonthecruisingvelocity,deceleration,andjerkofthefirstmovesegment,andthejerk,acceleration,andcruisingvelocityofthesecondmovesegment.
![Page 133: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/133.jpg)
BlendafterFirstMoveIsCompleteBlendingmovesafterthefirstmoveiscompletecausesthefirstmovesegmenttocometoacompletestopbeforestartingtheprofileofthesecondsegment,asshowninthefollowingfigure.
1BlendingStarts 2BlendisComplete
Thistypeofblendingisusefulifyouwanttostarttwomovesegments,oneaftertheother,withnodelaybetweenthem.
![Page 134: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/134.jpg)
BlendafterDelayYoucanblendtwomovesafteradelayattheendofthefirstmove,asshowninthefollowingfigure.
1BlendingStarts 3User-DefinedDelay2BlendisComplete
Blendinginthismannerisusefulifyouwanttostarttwomovesegmentsafteradeterministicdelay.Thetwomovesegmentscanbeeitherstraight-linemovesorarcmoves.
![Page 135: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/135.jpg)
BlendedMoveLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontocompleteablendedmove.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureVectorSpace
8StartMotion 15LoadVectorSpacePosition
2LoadVelocity 9LoadBlendFactor 16BlendMotion3LoadAcceleration/Deceleration
10LoadCircularArc 17CheckMoveCompleteStatus
4LoadAcceleration/Deceleration
11BlendMotion 18ReadperAxisStatus
5LoadS-CurveTime 12CheckBlendCompleteStatus
19ReadperAxisStatus
6SetOperationMode 13ReadperAxisStatus
20MotionErrorHandler
7LoadVectorSpacePosition
14ReadperAxisStatus
![Page 136: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/136.jpg)
BlendedMoveC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//MainFunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8vectorSpace;//Vectorspacenumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
u16status;
u16complete;//Moveorblendcompletestatus
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
vectorSpace=NIMC_VECTOR_SPACE1;
////////////////////////////////
//Configurea2DVectorSpacecomprisingofaxes1,and2
err=flex_config_vect_spc(boardID,vectorSpace,1,2,0);
CheckError;
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,vectorSpace,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_ACCELERATION,100000,0xFF);
CheckError;
//Setthedecelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_DECELERATION,100000,0xFF);
CheckError;
//Setthejerkorscurveinsampleperiods
err=flex_load_scurve_time(boardID,vectorSpace,1,0xFF);
CheckError;
![Page 137: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/137.jpg)
//Settheoperationmodetoabsoluteposition
err=flex_set_op_mode(boardID,vectorSpace,NIMC_ABSOLUTE_POSITION);
CheckError;
//Loadthefirststraightlinesegmentstoposition5000,5000
err=flex_load_vs_pos(boardID,vectorSpace,5000,5000,0,0xFF);
CheckError;
//Startthemove
err=flex_start(boardID,vectorSpace,0);
CheckError;
//LoadCircularArc-makingasemicircleinthecounterclockwisedirection
err=flex_load_circular_arc(boardID,vectorSpace,5000/*radius*/,0.0/*startAngle*/,180.0/*travelAngle*/,0xFF);
CheckError;
//Blendthemove
err=flex_blend(boardID,vectorSpace,0);
CheckError;
//Waitforblendtocompletebeforeloadingthenextsegment
do
axisStatus=0;
//Checktheblendcompletestatus
err=flex_check_blend_complete_status(boardID,vectorSpace,0,&complete);
CheckError;
//Checkthefollowingerror/axisoffstatusforaxis1
err=flex_read_axis_status_rtn(boardID,1,&status);
CheckError;
axisStatus|=status;
//Checkthefollowingerror/axisoffstatusforaxis2
err=flex_read_axis_status_rtn(boardID,2,&status);
CheckError;
axisStatus|=status;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
![Page 138: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/138.jpg)
Sleep(50);//Checkevery50ms
while(!complete&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
//Loadthefinalstraightlinesegmentstoposition0,0
err=flex_load_vs_pos(boardID,vectorSpace,0,0,0,0xFF);
CheckError;
//Waitformovetocompleteasthisisthefinalsegment
do
axisStatus=0;
//Checkthemovecompletestatus
err=flex_check_move_complete_status(boardID,vectorSpace,0,&complete);
CheckError
//Checkthefollowingerror/axisoffstatusforaxis1
err=flex_read_axis_status_rtn(boardID,1,&status);
CheckError;
axisStatus|=status;
//Checkthefollowingerror/axisoffstatusforaxis2
err=flex_read_axis_status_rtn(boardID,2,&status);
CheckError;
axisStatus|=status;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(50);//Checkevery50ms
while(!complete&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
![Page 139: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/139.jpg)
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 140: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/140.jpg)
ElectronicGearingandCammingUseelectronicgearingorcammingtosynchronizethemovementofoneormoreslaveaxestothemovementofamasterdevice,whichcanbeanencoder,ADC,orthetrajectoryofanotheraxis.Themovementoftheslaveaxesmaybeatahigherorlowergearratiothanthemaster.Forexample,everyturnofthemasteraxismaycauseaslaveaxistoturntwice.
![Page 141: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/141.jpg)
GearingElectronicgearingallowsoneslavemotortobedriveninproportiontoamastermotororfeedbacksensor,suchasanencoderortorque(analog)sensor.Astheslavefollowsthemasterpositionataconstantratio,theeffectissimilartothatoftwoaxesmechanicallygeared.Electronicgearinghasseveraladvantagesovermechanicalgears.Themostnotableisflexibilitybecauseyoucanchangegearratioson-the-fly.Theothermajoradvantagetoelectronicgearingisthatyoucansuperimposeamoveoveragearedaxis.Thesuperimposedmoveisaddedtothegearedprofileoftheslaveaxis,whichallowstheslaveaxistobesynchronizedon-the-fly.Anaxiscanbegearedtoanotheraxis,ortoanencoderorADC.Whenyougearanaxistoanotheraxis,theslaveaxisfollowsthetrajectorygenerationofthemasteraxis.Forexample,ifyoumanuallymovethemasteraxis,theslaveaxisdoesnotmovebecausethetrajectorygeneratorofthemasteraxisisnotactive.Whenyougearanaxistoanencoder,orfeedbackdevice,theslaveaxisfollowsthefeedbackgeneratedbytheencoder.Iftheencoderdetectsmovement,theslavemovesproportionallytoinformationreturnedbytheencoder.Forexample,ifyoutwistthemasteraxisconnectedtotheencoder,theslaveaxisalsoturnsbecauseitisusingthepositioninformationgatheredbytheencoder.WhenanaxisisgearedtoanADC,theslaveaxisfollowsthebinaryvalueoftheADCasifitwereaposition.Forexample,ifthebinarycodefor2Vis6553,theslaveaxistrackstothisposition.
![Page 142: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/142.jpg)
ElectronicGearingAlgorithmThefollowingfigureshowsagenericelectronicgearingalgorithmapplicabletobothC/C++andLabVIEWcode.
![Page 143: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/143.jpg)
AbsoluteversusRelativeGearingThegearratioisusedtodeterminehowfartheslaveaxismustmoveinproportiontothemasterwhengearingisenabled.Thegearratiocanbeabsoluteorrelative.Slaveaxismove=Masteraxisposition×Gearratio
RelativeGearingRelativegearingallowsyoutochangethegearratioon-the-fly.Themastermoveiscalculatedbasedonthemasterreferenceposition,whichisupdatedwhengearingisenabledandisupdatedeachtimeanewgearratioisloaded.Forexample,ifyouhaveagearingratioof2:1(slave:master),theslavemoves20countswhenthemasterdevicemoves10counts.
AbsoluteGearingAbsolutegearingbehavessimilarlytorelativegearinginthatwhengearingisenabled,theslaveaxisfollowsthemasteraxismovementasitisdefinedbythegearratio.Thedifferencebetweenrelativeandabsolutegearingisthatthereferencepositioncalculatedforthemasteraxisisupdatedonlywhengearingisenabled.Thisdifferenceisapparentwhenthegearratioisupdatedon-the-fly.Forexample,ifthegearratiois2:1,thecurrentmasterpositionis1010,thecurrentslavepositionis3020,andthegearratioischangedto3:1,theslaveaxisjumpsfrom3020to3030butthemasterpositionremainsthesame.
![Page 144: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/144.jpg)
Changingagearratioon-the-flyduringabsolutegearingallowsyoutoquicklysynchronizetheslaveaxiswiththemasteraxis.
NoteWhenthegearratioischangedon-the-fly,theslaveaxismovesatfulltorquetothenewposition.
![Page 145: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/145.jpg)
ElectronicGearingLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoperformelectronicgearingusinganencoderasthegearmaster.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureGearMaster
5LoadVelocity 9StartMotion
2LoadGearRatio 6LoadAcceleration/Deceleration
10WaitforMoveComplete
3EnableGearingSingleAxis
7SetOperationMode 11EnableGearingSingleAxis
4Wait 8LoadTargetPosition 12MotionErrorHandler
![Page 146: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/146.jpg)
ElectronicGearingC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8slaveAxis;//Slaveaxisnumber
u8master;//Gearmaster
u16csr=0;//Communicationstatusregister
u16moveComplete;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
slaveAxis=1;
//Masterisencoder4
master=NIMC_ENCODER4;
////////////////////////////////
//--------------------------------------------------------
//Setupthegearingconfigurationfortheslaveaxis
//--------------------------------------------------------
//ConfigureGearMaster
err=flex_config_gear_master(boardID,slaveAxis,master);
CheckError;
//LoadGearRatio3:2
err=flex_load_gear_ratio(boardID,slaveAxis,NIMC_RELATIVE_GEARING,
3/*ratioNumerator*/,2/*ratioDenominator*/,0xFF);
CheckError;
//--------------------------------------------------------
//EnableGearingonslaveaxis
//--------------------------------------------------------
err=flex_enable_gearing_single_axis(boardID,slaveAxis,NIMC_TRUE);
CheckError;
![Page 147: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/147.jpg)
//Waitfor5seconds
Sleep(5000);
//--------------------------------------------------------
//Setupthemoveparametersforthesuperimposedmove
//--------------------------------------------------------
//Settheoperationmodetorelative
err=flex_set_op_mode(boardID,slaveAxis,NIMC_RELATIVE_TO_CAPTURE);
CheckError;
//LoadVelocityincounts/s
err=flex_load_velocity(boardID,slaveAxis,10000,0xFF);
CheckError;
//LoadAccelerationandDecelerationincounts.sec^2
err=flex_load_acceleration(boardID,slaveAxis,NIMC_BOTH,100000,0xFF);
CheckError;
//Loadthetargetpositionfortheregistration(superimposed)move
err=flex_load_target_pos(boardID,slaveAxis,5000,0xFF);
CheckError;
//Startregistrationmoveontheslave
err=flex_start(boardID,slaveAxis,0);
CheckError;
err=flex_wait_for_move_complete(boardID,slaveAxis,0,
1000/*mstimeout*/,20/*mspollInterval*/,&moveComplete);
CheckError;
//--------------------------------------------------------
//DisableGearingonslaveaxis
//--------------------------------------------------------
err=flex_enable_gearing_single_axis(boardID,slaveAxis,NIMC_FALSE);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
![Page 148: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/148.jpg)
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 149: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/149.jpg)
CammingElectroniccammingoperatessimilarlytoelectronicgearinginthatthemovedistanceofanaxisisproportionaltothemovedistanceofitsmasterdevice.Cammingdiffersfromgearinginhowthemaster/slaveratioishandledbythemotioncontroller.Gearingisusedinapplicationswhereaconstantgearvaluecreatesalinearslavepositionprofile,asshown.
Cammingcreatesamoreflexibleprofilebyusingmoremaster/slaveratios.Theseratiosarehandledautomaticallybythemotioncontroller,allowingpreciseswitchingofthegearratios,asshowninthefollowingfigure.Cammingisusedinapplicationswheretheslaveaxisfollowsanon-linearprofilefromamasterdevice.
![Page 150: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/150.jpg)
ElectronicCammingAlgorithmThefollowingfigureshowsagenericelectronicgearingalgorithmapplicabletobothC/C++andLabVIEWcode.Similartogearing,inacammingapplication,aslaveaxiscanperformanymovewhencammingisenabled.Themoveprofileissuperimposedoverthecammingprofile.
![Page 151: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/151.jpg)
CammingApplicationExampleAnexampleofamotioncontrolsystemthatcanbenefitfromtheflexibilityofelectroniccammingisweldingpartsastheytravelonaconveyorbelt.Thefollowingfigureshowsthattheweldingpointmovestothefirstposition,andthenweldsthematerialforacoupleofseconds.Becausetheconveyorbeltkeepsmovingataconstantrate,theweldingpointmustfollowthematerialatthesamespeedastheconveyorbeltduringtheweldprocess.Whentheweldingprocessisfinishedforoneitem,theweldingpointmustquicklyreturntoitsinitialpositionandtheprocessrepeats.
1Conveyorbelt2Movementofthewelderasitfollowstheobject,andthenreturnstotheinitialposition3Weldingpoint
Inthisapplication,themasterdeviceisthepositionencoderattachedtotheconveyorbelt,andtheslaveaxisistheactuatorthatmovestheweldingpoint.Theslaveaxisrepeatedlyperformsatwo-segmentmovement:
1. First,itfollowsthematerialwiththesamespeedastheconveyorbelt.
2. Next,itreturnstotheinitialpositionasthenextmaterialapproaches.
Eachsegmentofthemoveisrepresentedwithagearratiothatdictates
![Page 152: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/152.jpg)
howfastandinwhichdirectiontheweldingpointismovingrelativetotheconveyorbelt.Thisapplicationrequirestheslaveaxistoswitchfromoneratiototheotheratthecorrectmasterposition,otherwisetheweldingprocessisnotrepeatable.Ifthisapplicationusedgearinginsteadofcamming,thelatency,ordelay,ofloadinganewgearratiomightcauseanaccumulationofpositionerrors.Whenacammingoperationisactive,theslaveaxisfollowsaprofilethatisestablishedusingalistofmasterandslavepositionspairs,calledthecammingtableandisloadedintoabufferforuseduringacammingoperation.Anexampleofacammingtableisshownbelow.Thefollowingfigureshowsthat,intheweldingexampledefinedpreviously,theconveyorbeltismovingat1,000counts/sandthepartstobeweldedare6,000countsapart.Toweldthepart,theweldingpointmustfollowthepartdowntheconveyorbeltfor2seconds.
Inthisweldingapplication,theslaveaxismustfollowthepartwiththesamevelocityastheconveyorbeltwhileweldingisinprogress.Becauseittakestwosecondstoweldeachpart,theweldingpointandconveyorbelthavebothmoved2,000countsbythetimetheweldingiscomplete.Thispartoftheweldingapplicationcreatesthefirstmovesegment.Forthesecondmovesegment,theweldingpointmustreturntoitsoriginalpositionsothatitcanweldthenextpartontheconveyorbelt.Tomovetheweldingpointtoitsoriginalpositionatthesametimethatthenextpartisinthecorrectpositionontheconveyorbelt,theweldingpointmusttravel2,000countsintheoppositedirectionoftheconveyorbeltat
![Page 153: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/153.jpg)
halfthespeedthattheconveyorbeltistravelingat.Thefollowingfigureshowsthemoveprofileofthefirstandsecondmovesegments.
Thefollowingtableshowsthecammingtablethatcorrespondstothemoveprofileusedinthisexample.
Time(seconds)
MasterPosition(counts)
SlavePosition(counts) Ratio*
0 0 0 2 2000 2000 14 4000 1000 0.56 6000 0 0.5*Ratio=ΔSlaveDistance/ΔMasterDistance
Thecammingcycleis6,000countsandisdividedintoequallengthsegments.
TipBecausethecammingcycleis6,000counts,themastercyclemustalsobe6,000counts.
Eachrowofdatadefinesagearratio.Thecammingprofileisrepeatedafteracammingcycleiscompleted.Themasterpositionisalwaysinterpretedinsidethemodulusdefinedbythecammingcycle.
Forexample,initially,themasteraxismovesfrom0to1000.Thegearratiousedforthismoveis1:1becausethemasterpositionisinthe0to2000interval.Withagearratioof1:1,theslaveaxismovesatthesamespeedasthemasterdevicetoposition1000.
![Page 154: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/154.jpg)
Asshown,themasterpositioninthisintervalisinsidethemodulus.
Ifthemasteraxismovestoposition2000,thegearratiodoesnotchangebecausethecurrentmasterpositionisstillinsidethe0to2000interval.
Whenthemasteraxismovestoposition4,000,thegearratiochangesto0.5.Theslaveaxistravelshalfthedistancethatthemasteraxistravels,andittravelsintheoppositedirection.Whenthemasterreachesposition6000,theslaveaxismovesbacktheoriginalposition,andthecammingcyclebeginsagain.
![Page 155: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/155.jpg)
SlaveOffsetInsomecammingapplications,theslaveaxismightbeginandendthecammingcycleatdifferentpositions,asshowninthefollowingtable.
MasterPosition(counts) SlavePosition(counts)0 02000 20004000 10006000 500
Thefollowingfigureshowsthat,afterthreecammingcycles,theslaveaxisendpositionis500countsawayfromthestartingposition(0)withtheslaveoffset,andthatwithouttheslaveoffset,theslaveaxisendpositionis1500countsawayfromthestartingposition(0).Withaslaveoffsetof500,theslaveaxistraversesthepositionsspecifiedinthecammingtable,butitdoesnotmaintainthecammingratio.
![Page 156: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/156.jpg)
MasterOffsetIfthematerialandweldingpointarenotinitiallyaligned,asshown,themasteroffsetmustbeappliedtoconsiderthepositiondifference.
Withoutthemasteroffset,themasterdevicepositionisalreadyinsidethefirstintervalassoonasthefirstmaterialpassestheweldingpoint.Thefollowingfigureshowsthatthemastercycleintervalsareoffsetby50counts.Themasterintervalisshiftedfrom0,2,000,4,000,and6,000to50,2,050,4,050,and6,050.
Thefollowingfigureshowsthecammingprofileusedfortheapplicationportrayedinthepreviousfigures.
![Page 157: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/157.jpg)
![Page 158: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/158.jpg)
ElectronicCammingLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoperformelectroniccamming.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureCammingMaster
6SetOperationMode
11EnableCammingSingleAxis
2ConfigureBuffer 7LoadMoveConstraint
12ClearBuffer
3WriteBuffer 8LoadTargetPosition
13MotionErrorHandler
4EnableCammingSingleAxis
9StartMotion
5WaitinaSequenceStructure
10WaitforMoveComplete
![Page 159: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/159.jpg)
ElectronicCammingC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//////////////////////////////////////////////////////////////////////
//MainFunction
voidmain(void)
//Locals
u8boardID;//BoardIDasassignedbyMAX
f64bufferInterval=0;//Ignored
//Masteraxisinformation
u8masterAxis;//MasteraxisID
i32targetPos;//Positiontomoveto
f64velocity;//Velocitylimitforthismove
f64camCycle=70000;//Positioncycletorepeatthecammingprocess
NIMC_DATAdata;//Genericdatastructure
i32masterPosition;//Currentmasterposition
u16masterStatus;//Currentmasterstatus
//Slaveaxisinformation
u8slaveAxis;//SlaveaxisID
u8buffer;//Buffertocontainthecamtable
i32positionArr[]=0,10000,40000,45000,45000,40000,10000,0;//
u32positionSize=sizeof(positionArr)/sizeof(i32);//Numberofpositionsinthearray
i32slavePosition;//Currentslaveposition
//Forerrorhandling
u16csr;//Communicationstatus
u16commandID;//CommandIDthatcausestheerror
u16resourceID;//ResourceIDthatissetonthefailedcommand
i32errorCode;//Errorcodefromthecontroller
i32scanVar;//Scanvariabletoreadinvaluesnotsupported
//bythescanffunction
//GettheboardID
printf("EntertheboardID:");
scanf("%d",&scanVar);
boardID=(u8)scanVar;
//Getmasteraxisinformation
printf("\nEnterinformationaboutthemasteraxis...\n");
printf("AxisID:");
scanf("%d",&scanVar);
masterAxis=(u8)scanVar;
![Page 160: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/160.jpg)
printf("Targetposition:");
scanf("%d",&targetPos);
printf("Velocitylimit:");
scanf("%lf",&velocity);
//GettheslaveAxis
printf("\nEnterinformationabouttheslaveaxis...\n");
printf("AxisID:");
scanf("%d",&scanVar);
slaveAxis=(u8)scanVar;
printf("BufferID:");
scanf("%d",&scanVar);
buffer=(u8)scanVar;
//Configurethecammaster&mastercycle
err=flex_configure_camming_master(boardID,slaveAxis,masterAxis,camCycle);
CheckError;
//Configurethecamtable
err=flex_configure_buffer(boardID,buffer,slaveAxis,
NIMC_CAMMING_POSITION,
positionSize,positionSize,
TRUE,bufferInterval,&bufferInterval);
CheckError;
//Writethedatatothebuffer
err=flex_write_buffer(boardID,buffer,positionSize,
NIMC_REGENERATION_NO_CHANGE,
positionArr,0xFF);
CheckError;
//Enablecammingimmediately
err=flex_enable_camming_single_axis(boardID,slaveAxis,TRUE,-1.0);
CheckError;
//Settoabsolutemode
err=flex_set_op_mode(boardID,masterAxis,NIMC_ABSOLUTE_POSITION);
CheckError;
//Setthemaximumvelocity
data.doubleData=velocity;
err=flex_load_move_constraint(boardID,masterAxis,
TnimcMoveConstraintVelocity,&data);
CheckError;
//Setthetargetposition
err=flex_load_target_pos(boardID,masterAxis,targetPos,0xFF);
CheckError;
![Page 161: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/161.jpg)
//Startthemasteraxismovement
err=flex_start(boardID,masterAxis,0x0);
CheckError;
//Keeprunninguntilthemastercompletesorthere'samodalerror
do
Sleep(100);
//Getboththemasterandtheslavecurrentpositions.
err=flex_read_pos_rtn(boardID,masterAxis,&masterPosition);
CheckError;
err=flex_read_pos_rtn(boardID,slaveAxis,&slavePosition);
CheckError;
//Displaythemasterandtheslavecurrentpositions.
printf("Axis%d(master)positionis%d,Axis%d(slave)positionis%d.\r",
masterAxis,masterPosition,slaveAxis,slavePosition);
//Readcurrentmastertrajectorystatus
err=flex_read_axis_status_rtn(boardID,masterAxis,&masterStatus);
CheckError;
//Checkformodalerror
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
while(!(masterStatus&NIMC_MOVE_COMPLETE_BIT)&&
!(csr&NIMC_MODAL_ERROR_MSG));
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//Disablecamming
flex_enable_camming_single_axis(boardID,slaveAxis,FALSE,-1.0);
//Clear(delete)thebuffer
flex_clear_buffer(boardID,buffer);
//Makesurethemasterisnotrunning
flex_stop(boardID,masterAxis,0x0);
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
![Page 162: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/162.jpg)
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 163: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/163.jpg)
AcquiringTime-SampledPositionandVelocityDataNImotioncontrollerscanacquireabufferofpositionandvelocitydatathatisfirmware-timed.Afteryoucommandthemotioncontrollertoacquirepositionandvelocitydata,aseparateacquiredatataskiscreatedinthereal-timeoperatingsystemthatreadstime-sampledpositionandvelocitydataintoaFIFObufferonthemotioncontroller.Youcanreaddatainfromthisbufferasynchronouslyfromthehostcomputer,asshowninthefollowingfigure.
Theacquiredatataskhashigherprioritythananyonboardprogramsorhousekeepingtasks,butithasalowerprioritythantheI/Oreactionandhostcommunicationtasks.Toachievethebestpossibleperformance,keephostcommunicationstoaminimumwhenacquiringdata.TheFIFObufferisofafixedsizethatcanaccommodate4,096samplesforoneaxis.Onesampleconsistsofpositiondata,incountsorsteps,andvelocitydata,incounts/sorsteps/s.Asyouincreasethenumberofaxesfromwhichyouareacquiringdata,youalsodecreasethetotalnumberofsamplesyoucanacquireperaxis.Forexample,youcanacquireupto1,024samplesperaxisforfouraxes.Youalsocanvarythetimeperiodbetweenacquiredsamplesfrom3msto65,535ms.
![Page 164: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/164.jpg)
AcquireDataAlgorithmThefollowingfigureshowsagenericalgorithmapplicabletobothC/C++andLabVIEWcode.
Thedatamustbereadonesampleatatime.Afour-axissampleusesthefollowingpatternforreturningthedata.
Axis1positionAxis1velocity
Axis2positionAxis2velocity
Axis3positionAxis3velocity
Axis4positionAxis4velocity
Ifyourequest1,024samples,youmustreadeachofthe1,024samplesindividually.
![Page 165: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/165.jpg)
AcquireDataLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoacquiresdatafortwoaxes,200samples,andthreemillisecondsapart.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1AcquireTrajectoryData 3MotionErrorHandler2ReadTrajectoryData
![Page 166: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/166.jpg)
AcquireDataC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u16csr=0;//Communicationstatusregister
i32i;
u16axisMap;//Bitmapofaxesforwhichdataisrequested
i32axis1Positions[200];//Arraytostorethepositions(1)
i32axis1Velocities[200];//Arraytostorevelocities(1)
i32axis2Positions[200];//Arraytostorethepositions(2)
i32axis2Velocities[200];//Arraytostorevelocities(2)
u16numSamples=200;//Numberofsamples
i32returnData[4];//Needsizeof4for2axesworthofdata
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Axeswhosedataneedstobeacquired
axisMap=((1<<1)|(1<<2));//Axis1andaxis2
////////////////////////////////
err=flex_acquire_trajectory_data(boardID,axisMap,numSamples,3/*mstimeperiod*/);
CheckError;
for(i=0;i<numSamples;i++)
Sleep(10);//Checkevery10msandgivetimeforthedata
//tobecopiedtoonboardFIFO
//Readthetrajectorydata
err=flex_read_trajectory_data_rtn(boardID,returnData);
CheckError;
![Page 167: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/167.jpg)
//Twoaxesworthofdataisreadeverysample
axis1Positions[i]=returnData[0];
axis1Velocities[i]=returnData[1];
axis2Positions[i]=returnData[2];
axis2Velocities[i]=returnData[3];
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 168: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/168.jpg)
SynchronizationYoucansynchronizeNImotioncontrollerswithNIdataandimageacquisitiondevicesusingbreakpointsandhigh-speedcaptures.Thefollowingfigureillustratesanexpandedviewofthetopicscoveredinthissection.
*Breakpointscauseadigitaloutputtochangestatewhenaspecifiedpositionisreachedbyanencoder.BreakpointsarenotsupportedbytheNISoftMotionController.**Ahigh-speedcapturerecordsthepositionofanencoderwhenadigitallineisusedasatrigger.High-speedcapturesarenotsupportedbytheNISoftMotionController.
NoteIfyouareusingRTSItoconnectyourmotioncontrollertoaNationalInstrumentsdataorimageacquisitiondevice,beawarethattheNISoftMotionControllerdoesnotsupportRTSI.
TimingandtriggeringwithNI-Motionisalwaysrelatedtoeitherpositionorvelocity.Synchronizingpositionandvelocityinformationwiththeexternalworldallowsyoutocoordinatemeasurementswithmoves.YoucanprogramthemotioncontrollertotriggeranotherdeviceatspecifiedpositionsusingRTSIorapinontheMotionI/Oconnector.This
![Page 169: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/169.jpg)
functionalityiscalledbreakpoints,whicharedividedintoabsolutebreakpoints,relativepositionbreakpoints,andperiodicallyoccurringbreakpoints.Insomecases,itmaybenecessarytosynchronizepositionwithsomemeasurementoccurringexternaltothemotioncontroller.Forexample,youmightbealigningtwofiberopticcables,inwhichcasethemaximumopticalpowerneedstocorrespondwiththealignmentposition.Toalignthefibers,theexternaldevicethatisrecordingtheopticalpowermusttriggerthemotioncontrollersothatpositionsandopticalpowermeasurementscanbesynchronizedandanalyzed.Thisfunctionalityisknownashigh-speedcaptureortriggerinputs.ThemotioncontrollercanbetriggeredbyanotherdeviceusingRTSIorexternallyusingapinontheMotionI/Oconnector.Whentriggered,themotioncontrollercanlatchthecurrentpositionoftheencoder,whichcanbereadandrecorded.ThefollowingtableshowstheavailabilityofbreakpointmodesoneachNImotioncontroller.
BreakpointMode NI7350 NI7340,NI7330,andNI7390Absolute* Y Y
Relative* Y Y
Periodic Y NModulus N YBuffered Y N*AvailableinbufferedandsingleoperationforNI7350andinsingleoperationonlyforallothercontrollers
![Page 170: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/170.jpg)
AbsoluteBreakpointsAbsolutepositionbreakpointsallowyoutotriggerexternalactivitiesasthemotorsreachspecifiedpositions.Forexample,ifyouneedtouseanimageacquisitiondevicetocaptureanimagefromacertainpositionwhilethedeviceundertestisincontinuousmotion,themotioncontrollermustbeabletotriggertheimageacquisitiondeviceasitreachesthosepositions.Thecurrentpositioniscontinuouslycomparedagainstthespecifiedbreakpointpositionbytheencodercircuitrytoproducealatencyoflessthan100ns.Afterabreakpointtriggers,youmustre-enableitforthebreakpointtoworkagain.Incertaincases,suchasbufferedandperiodicbreakpoints,themotioncontrollerautomaticallyre-enablesthebreakpoints.Theimplementationforabsolutebreakpointsisdividedintothebufferedbreakpointandsinglepositionbreakpointmethods.
NoteAllbreakpointscanbeaffectedbyjitterinthemotioncontrolsystem.Forexample,ifyouhaveaverysmallbreakpointwindow,thejitterinthemotioncontrolsystemcouldcausethepositiontochangeenoughtoreachthebreakpointwhenabreakpointisnotintended.Increasethesizeofthebreakpointwindowtocompensateforsystemjitter.
![Page 171: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/171.jpg)
BufferedBreakpoints(NI7350only)Insteadofenablingbreakpointsinyourapplicationatthesoftwarelevel,youcancreateabufferofbreakpointsthatyoucanpre-loadintothemotioncontroller.Themotioncontrollerautomaticallyarmsthenextbreakpointinthebufferwhentheprecedingbreakpointtriggers.Therefore,enablingbreakpointsoccursonafirmware-timedbasis,whichenablesyoutouseahigherbandwidth.
![Page 172: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/172.jpg)
BufferedBreakpointAlgorithmThefollowingshowsthebasicalgorithmforimplementingbufferedbreakpointsapplicabletobothC/C++andLabVIEWcode.
![Page 173: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/173.jpg)
BufferedBreakpointLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontocompleteablendedmove.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureBuffer 4EnableBreakpointOutput
6ClearBuffer
2WriteBuffer 5CheckBuffer 7MotionErrorHandler
3ConfigureBreakpoint
![Page 174: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/174.jpg)
BufferedBreakpointC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
//Resourcevariables
u8boardID=1;//Boardidentificationnumber
u8axis=NIMC_AXIS1;//Axisnumber
u8buffer=1;//Buffernumber
//Modalerrorhandlingvariables
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
u16csr=0;//Communicationstatus
//Bufferresources
i32breakpointPositions[]=1000,1100,1200,1300,1400,1500,1600;
u16numberOfPoints=7;//Numberofbreakpoints
f64actualInterval;//Requiredinthefunctioncallbutnotbeingused
f64requestedInterval=10.0;//Requiredinthefunctioncallbutnotbeingused
u32backLog;//Numberofspaceavailableinbuffer
u16bufferState;//Bufferstate
u32pointsDone;//Numberofbreakpointsdoneorconsumed
//Configurethebufferforbufferedbreakpoint
err=flex_configure_buffer(boardID,buffer,axis,NIMC_BREAKPOINT_DATA,
numberOfPoints,numberOfPoints,NIMC_TRUE,
requestedInterval,&actualInterval);
CheckError;
//Writethebreakpointpositiontothebuffer
err=flex_write_buffer(boardID,buffer,numberOfPoints,
NIMC_REGENERATION_NO_CHANGE,breakpointPositions,0xFF);
CheckError;
//Configurethebreakpointtobebufferedbreakpoint
err=flex_configure_breakpoint(boardID,axis,NIMC_ABSOLUTE_BREAKPOINT,
NIMC_PULSE_BREAKPOINT,NIMC_OPERATION_BUFFERED);
CheckError;
//Enablethebreakpoint
err=flex_enable_breakpoint(boardID,axis,NIMC_TRUE);
CheckError;
![Page 175: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/175.jpg)
//Pollthestatusofthebuffer,ifyoumorebreakpointpositions
//towrite,insertflex_write_buffercallhere.
do
//Checkthebufferstatus
err=flex_check_buffer_rtn(boardID,buffer,
&backLog,&bufferState,&pointsDone);
CheckError;
Sleep(50);
while((pointsDone!=numberOfPoints)||
(bufferState!=NIMC_BUFFER_DONE));
//Clearthebuffer
err=flex_clear_buffer(boardID,buffer);
CheckError;
return;
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 176: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/176.jpg)
SinglePositionBreakpointsSinglepositionbreakpointsexecuteonebreakpointperenabling.
![Page 177: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/177.jpg)
SinglePositionBreakpointAlgorithmThefollowingfiguresshowsthebasicalgorithmforimplementingsinglepositionbreakpointsapplicabletobothC/C++andLabVIEWcode.
![Page 178: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/178.jpg)
SinglePositionBreakpointLabVIEWDiagramThefollowingblockdiagramsdemonstrateusingNI-Motiontoprogramasinglepositionbreakpoint,bothwithandwithoutRTSI.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureBreakpoint
3EnableBreakpointOutput
5MotionErrorHandler
2LoadBreakpointPosition
4ReadperAxisStatus
ThefollowingfigureshowshowtoroutethisbreakpointusingRTSI.
1SelectSignal 3LoadBreakpointPosition
5ReadperAxisStatus
2ConfigureBreakpoint
4EnableBreakpointOutput
6MotionErrorHandler
AfterthebreakpointisroutedthroughRTSI,thetriggerappearsonboth
![Page 179: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/179.jpg)
theRTSIlineandthebreakpointlineontheMotionI/Oconnector.
![Page 180: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/180.jpg)
SinglePositionBreakpointC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
i32breakpointPosition[3]=10000,15000,20000;
i32i;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
////////////////////////////////
//Routebreakpoint1toRTSIline1
err=flex_select_signal(boardID,NIMC_RTSI1/*destination*/,NIMC_BREAKPOINT1/*source*/);
CheckError;
//ConfigureBreakpoint
err=flex_configure_breakpoint(boardID,axis,NIMC_ABSOLUTE_BREAKPOINT,NIMC_SET_BREAKPOINT,0);
CheckError;
for(i=0;i<3;i++)
//LoadBreakpointPosition-positionatwhichbreakpointshouldoccur
err=flex_load_pos_bp(boardID,axis,breakpointPosition[i],0xFF);
CheckError;
//Enablethebreakpointonaxis1
err=flex_enable_breakpoint(boardID,axis,NIMC_TRUE);
![Page 181: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/181.jpg)
CheckError;
do
//Checkthebreakpointstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkformodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(10);//Checkevery10ms
while(!(axisStatus&NIMC_POS_BREAKPOINT_BIT));//Waitforbreakpointtobetriggered
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 182: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/182.jpg)
RelativePositionBreakpointsRelativepositionbreakpointstriggereventsbasedonachangeinpositionrelativetothepositionatwhichthebreakpointwasenabled.Insteadofkeepingtrackofabsolutepositionsandthecurrentposition,youcanuserelativebreakpointstospecifythebreakpointrelativetothepositionwherethebreakpointisenabled.Forexample,ifyouarecreatingamotioncontrolsystemtocontrolthetwo-dimensionalmovementofamicroscope,youmightuserelativepositionbreakpointstomovethemicroscopeaspecificdistanceinadirection,andthenhitabreakpointthattriggersacamerasnap.Therelativebreakpointisusefulinthisexamplebecausethecurrentpositionisnotimportant.Theapplicationmustmovetheaxisaspecificnumberofcountsfromwhereveritis,andthengenerateabreakpoint.
NoteAllbreakpointscanbeaffectedbyjitterinthemotioncontrolsystem.Forexample,ifyouhaveaverysmallbreakpointwindow,thejitterinthemotioncontrolsystemcouldcausethepositiontochangeenoughtoreachthebreakpointwhenabreakpointisnotintended.Increasethesizeofthebreakpointwindowtocompensateforsystemjitter.
![Page 183: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/183.jpg)
RelativePositionBreakpointsAlgorithmThefollowingfigureshowsthebasicalgorithmforrelativebreakpointsapplicabletobothC/C++andLabVIEWcode.
Noticethatrelativebreakpointsarenotidealforperiodicbreakpoints.Thereisalatencybetweenthetimeabreakpointgeneratesandisre-enabled.Iftheaxisismovingatsufficientvelocity,thebreakpointre-enablesonlyaftertheaxishasmovedslightly.Becausearelativebreakpointgeneratesrelativetothepositiontheaxiswasinwhenthebreakpointwasenabled,thelatencybetweengenerationandre-enablingcancauseadditionalcountsbetweenbreakpoints.Forexample,theactualbreakpointsmightoccuratpositions5,000;10,003;15,006;and20,012.Inthisexample,theaxismovesthreecountsbetweenabreakpointandthesubsequentre-enabling.Forexactdistancesbetweenbreakpointsathighspeeds,useBufferedBreakpoints(NI7350only)orPeriodicallyOccurringBreakpoints.
![Page 184: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/184.jpg)
RelativePositionBreakpointsLabVIEWDiagramInthisexample,abreakpointgeneratesandthenisre-enabled5,000countsfromwherethemovestartsusingRTSI.Thefollowingcodeexamplesaredesignedtoillustratetherelativebreakpointalgorithmonly.Theseexamplesarenotcomplete.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1SelectSignal 3LoadBreakpointPosition
5ReadperAxisStatus
2ConfigureBreakpoint
4EnableBreakpointOutput
6MotionErrorHandler
![Page 185: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/185.jpg)
RelativePositionBreakpointsC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
i32breakpointPosition=5000;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
////////////////////////////////
//Routebreakpoint1toRTSIline1
err=flex_select_signal(boardID,NIMC_RTSI1/*destination*/,NIMC_BREAKPOINT1/*source*/);
CheckError;
//ConfigureBreakpoint
err=flex_configure_breakpoint(boardID,axis,NIMC_RELATIVE_BREAKPOINT,NIMC_SET_BREAKPOINT,0);
CheckError;
//LoadBreakpointPosition-positionatwhichbreakpointshouldoccur
err=flex_load_pos_bp(boardID,axis,breakpointPosition,0xFF);
CheckError;
for(;;)
//Enablethebreakpointonaxis1
err=flex_enable_breakpoint(boardID,axis,NIMC_TRUE);
CheckError;
do
![Page 186: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/186.jpg)
//Checkthebreakpointstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkformodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(10);//Checkevery10ms
while(!(axisStatus&NIMC_POS_BREAKPOINT_BIT));//Waitforbreakpointtobetriggered
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 187: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/187.jpg)
PeriodicallyOccurringBreakpointsNI-Motionallowsyoutoprogramthemotioncontrollertogeneratemultiplebreakpointsatfixedandexactintervals,regardlessofthedirectionoftravelorvelocity.TherearetwowaystocreateperiodicallyoccurringbreakpointsusingNI-Motionfunctions,dependingonwhichmotioncontrolleryouhave.FortheNI7350controller,useperiodicbreakpoints.ForNI7330,NI7340,andNI7390controllers,usemodulobreakpoints.
NoteAllbreakpointscanbeaffectedbyjitterinthemotioncontrolsystem.Forexample,ifyouhaveaverysmallbreakpointwindow,thejitterinthemotioncontrolsystemcouldcausethepositiontochangeenoughtoreachthebreakpointwhenabreakpointisnotintended.Increasethesizeofthebreakpointwindowtocompensateforsystemjitter.
![Page 188: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/188.jpg)
PeriodicBreakpoints(NI7350only)Periodicbreakpointsrequirethatyouspecifyaninitialbreakpointandanongoingrepeatperiod.Whenenabled,theperiodicbreakpointsbeginwhentheinitialbreakpointoccurs.Fromthenon,anewbreakpointoccurseachtimetheaxismovesadistanceequaltotherepeatperiod,withnore-enablingrequired.Forexample,ifanaxisisenabledatpositionzero,theinitialbreakpointissetforposition100,andthebreakpointperiodissetat1,000,thentheaxisbehavesasshowninthefollowingfigure.
![Page 189: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/189.jpg)
PeriodicBreakpointAlgorithmThefollowingfigureshowsthebasicalgorithmforperiodicbreakpointsapplicabletobothC/C++andLabVIEWcode.
![Page 190: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/190.jpg)
PeriodicBreakpointLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontogenerateaperiodicbreakpointoutput.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureBreakpoint
4EnableBreakpointOutput
7ReadperAxisStatus
2LoadBreakpointPosition
5LoadTargetPosition 8MotionErrorHandler
3LoadBreakpointModulus
6StartMotion
![Page 191: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/191.jpg)
PeriodicBreakpointC/C++CodeThefollowingsectionincludesC/C++codeforexecutingahigh-speedcapture,aswellasusingRTSItoexecuteahigh-speedcapture.Thefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axis
u16csr=0;//CommunicationstatusRegister
u8profileStatus;//ProfileCompleteStatus
u8bpStatus;//BreakpointfoundStatus
i32bpPos;//BreakpointPosition
i32bpPer;//BreakpointPeriod
i32targetPos;//TargetPosition
i32currentPos;//CurrentPosition
u16axisStatus;//Statusoftheaxis
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
//GettheboardID
printf("EntertheBoardID:");
scanf("%u",&boardID);
//Gettheaxisnumber
printf("Enteraaxisnumber:");
scanf("%u",&axis);
//GettheTargetPosition
printf("Enteratargetposition:");
scanf("%ld",&targetPos);
//GettheBreakpointPosition
printf("Enterabreakpointposition:");
scanf("%ld",&bpPos);
//GettheBreakpointPeriod
printf("Enterabreakpointperiod:");
scanf("%ld",&bpPer);
![Page 192: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/192.jpg)
//Configurethebreakpointtobeabsolute
err=flex_configure_breakpoint(boardID,axis,NIMC_PERIODIC_BREAKPOINT,NIMC_NO_CHANGE,0);
CheckError;
//Loadthepositiontostartbreakpoints
err=flex_load_pos_bp(boardID,axis,bpPos,0xFF);
CheckError;
//SetthePeriod
err=flex_load_bp_modulus(boardID,axis,bpPer,0xFF);
CheckError;
//Enablethebreakpoint
err=flex_enable_breakpoint(boardID,axis,NIMC_TRUE);
CheckError;
//Loadatargetposition
err=flex_load_target_pos(boardID,axis,targetPos,0xFF);
CheckError;
//Startthemotion
err=flex_start(boardID,axis,0);
CheckError;
printf("\n");
do
//Readtheaxisstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
err=flex_read_pos_rtn(boardID,axis,¤tPos);
CheckError;
//Checkthebreakpointbit
bpStatus=!((axisStatus&NIMC_POS_BREAKPOINT_BIT)==0);
//Checktheprofilecompletebit
profileStatus=!((axisStatus&NIMC_PROFILE_COMPLETE_BIT)==0);
printf("CurrentPosition=%10dBreakpointStatus=%dProfileComplete=%d\r",currentPos,bpStatus,profileStatus);
//Checkformodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
flex_stop_motion(boardID,NIMC_VECTOR_SPACE1,NIMC_DECEL_STOP,0);//
![Page 193: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/193.jpg)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
while(!profileStatus);
printf("\nFinished.\n");
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 194: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/194.jpg)
ModuloBreakpoints(NI7330,NI7340,andNI7390only)Modulobreakpointsuseabreakpointwindow,whichdefinesanareaaroundthecurrentposition.Thetwobreakpointsaroundthecurrentpositionarealwaysenabled.Thebreakpointmoduluscreatesarepeatperiodforthebreakpoints,andthebreakpointpositionistheoffsetfromabsolutezero.Forexample,tocreateabreakpointevery500counts,settherepeatperiodto500andthebreakpointpositionto0.Ifthebreakpointisenabledwhentheaxisisat710,thebreakpointsat1000and500arebotharmed,asshowninthefollowingfigure.
Asanotherexample,ifyousetthebreakpointrepeatperiodtobe2000countsandtheoffsettobe500,breakpointsoccurat4500,2500,500,1500,3500.Ifthebreakpointisenabledwhentheaxisisat2210,thebreakpointsat1500and3500arebotharmed,asshowninthefollowingfigure.
Eachtimeabreakpointoccurs,re-enableittoloadthenextbreakpoint.
![Page 195: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/195.jpg)
ModuloBreakpointsAlgorithmThefollowingfigureshowsthebasicalgorithmformodulobreakpointsapplicabletobothC/C++andLabVIEWcode.
![Page 196: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/196.jpg)
ModuloBreakpointsLabVIEWDiagramThefollowingblockdiagramsdemonstrateusingNI-MotiontogenerateamodulobreakpointsbothwithandwithoutRTSI.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureBreakpoint
3LoadBreakpointPosition
5ReadperAxisStatus
2LoadBreakpointModulus
4EnableBreakpointOutput
6MotionErrorHandler
1SelectSignal 4LoadBreakpointPosition
6ReadperAxisStatus
2ConfigureBreakpoint
5EnableBreakpointOutput
7MotionErrorHandler
3LoadBreakpointModulus
![Page 197: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/197.jpg)
ModuloBreakpointsC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
////////////////////////////////
//Routebreakpoint1toRTSIline1
err=flex_select_signal(boardID,NIMC_RTSI1/*destination*/,NIMC_BREAKPOINT1/*source*/);
CheckError;
//ConfigureBreakpoint
err=flex_configure_breakpoint(boardID,axis,NIMC_MODULO_BREAKPOINT,NIMC_SET_BREAKPOINT,0);
CheckError;
//LoadBreakpointModulus-repeatperiod
err=flex_load_bp_modulus(boardID,axis,500,0xFF);
CheckError;
//LoadBreakpointPosition-positionatwhichbreakpointshouldoccur
//everymodulo
err=flex_load_pos_bp(boardID,axis,0,0xFF);
CheckError;
for(;;)
![Page 198: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/198.jpg)
//Enablethebreakpointonaxis1
err=flex_enable_breakpoint(boardID,axis,NIMC_TRUE);
CheckError;
do
//Checkthemovecompletestatus/followingerror/axisoffstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(10);//Checkevery10ms
while(!(axisStatus&NIMC_POS_BREAKPOINT_BIT));//Waitforbreakpointtobetriggered
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 199: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/199.jpg)
ConfiguringtheBreakpointPulseWidth(NI7350only)OnNI7350devicesyoucanconfigureacustomizedpulsewidthforbreakpoints(positioncompareoutputs)totriggerdevicesthathavespecificminimumactivepulserequirements.Thedefaultbreakpointpulsewidthis200ns.YoucanuseMAXortheWriteCaptureCompareDataVIorfunctiontosetapulsewidthofbetween1µsand65,535µs.Onabreakpointevent,thebreakpointsignalisactivefortheconfiguredpulsewidth,asshowninthefollowingfigure.
NoteAbreakpointacrossRTSIalwaysgeneratesanactivehighpulseof200nsduration.
CautionThebreakpointfrequencydependsonthevelocityanddistancebetweenbreakpointsandislimitedbythepulsewidth.Thebreakpointfrequencymustmeetthefollowingrequirementsforcorrectoperation.
![Page 200: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/200.jpg)
BreakpointFrequencyRequirementsThebreakpointpulsemustnotoverlapwiththenextbreakpointevent.Ifthebreakpointpulseoverlapswiththenextbreakpointevent,breakpointgenerationisstoppedandthebreakpointisdisabled.Torecoverfromthissituationchangethepulsewidth,velocity,ordistancebetweenbreakpoints.Inaddition,thebreakpointfrequencycannotbegreaterthanthemaximumvalueallowedforthespecifiedbreakpointtype.Therefore,thebreakpointfrequency,inhertz,atthespecifiedpulsewidth,inseconds,mustconformtomustconformtothefollowingtwoconditions:
AND
PositionCompare(Breakpoint)OutputType MaximumFrequencySingle 150HzBuffered,PIDrateof62.5µsto250µs
2kHz
Buffered,PIDrategreaterthan250µs
1kHz
Periodic 4MHz
![Page 201: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/201.jpg)
High-SpeedCaptureSomemotioncontrolapplicationsrequirethatyouexecuteamoveandrecordthelocationswhereexternaltriggershappen.Toaccomplishthis,youmustusethehigh-speedcapturefunctionalityofNImotioncontrollers.Theimplementationforhigh-speedcaptureisdividedintothebuffered(NI7350controllersonly)andnon-bufferedhigh-speedcapturemethods.
![Page 202: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/202.jpg)
High-SpeedCaptureAlgorithmThefollowingfigureshowsthebasicalgorithmforhigh-speedcapturesapplicabletobothC/C++andLabVIEWcode.
![Page 203: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/203.jpg)
BufferedHigh-SpeedCapture(NI7350only)Bufferedhigh-speedcaptureletsyoucreateabufferthatholdscapturedpositionsthatyoucanreadasynchronouslyfromthemotioncontroller.Themotioncontrollerautomaticallyarmsthenexthigh-speedcapture,andwritesthecapturedhigh-speeddataintoitsonboardbuffer.Theenablingofhigh-speedcaptureoccursonafirmware-timedbasis,whichprovidesbetterfrequencythanthenon-bufferedhigh-speedcapturemethod.
![Page 204: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/204.jpg)
BufferedHigh-SpeedCaptureAlgorithmThefollowingfigureshowsthebasicalgorithmforbufferedhigh-speedcapturesapplicabletobothC/C++andLabVIEWcode.
![Page 205: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/205.jpg)
BufferedHigh-SpeedCaptureLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoperformabufferedhigh-speedcapture.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureBuffer 4CheckBuffer
6ClearBuffer
2ConfigureHigh-SpeedCapture
5ReadBuffer
7MotionErrorHandler
3EnableHigh-SpeedCapture
![Page 206: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/206.jpg)
BufferedHigh-SpeedCaptureC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
i32bufferSize=100;//Thesizeofthebuffertoallocateonthemotioncontroller
u32totalPoints=100;//Thenumberofhighspeedcapturetoacquire
i32capturedPositions[100];//Arraytostorethecapturedpositions
f64actualInterval;//Theintervalthecontrollercanreallycontourat
u32backlog;//Indicatestheavailablespaceforcapturedpositions
u32pointsDone;//Indicatesthenumberofpointsthathavebeenconsumed
u16bufferState;//Indicatesthestateoftheonboardbuffer
u32currentDataPoint=0;//Indicatesthenextpointstobereadfromthebuffer
i32*readBuffer=NULL;//Thetemporaryarraythatiscreatedtoreadcapturedpositions
u32i;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=NIMC_AXIS1;
////////////////////////////////
//Configurebufferonmotioncontrollermemory(RAM)
//Noterequestedtimeintervalishardcodedto10milliseconds
err=flex_configure_buffer(boardID,1/*buffernumber*/,axis,NIMC_HS_CAPTURE_READBACK,bufferSize,
totalPoints,NIMC_TRUE,10,&actualInterval);
CheckError;
//ConfigureHighSpeedCapture
err=flex_configure_hs_capture(boardID,axis,NIMC_HS_LOW_TO_HIGH_EDGE,NIMC_OPERATION_BUFFERED);
CheckError;
//Enablethehighspeedcaptureonaxis
![Page 207: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/207.jpg)
err=flex_enable_hs_capture(boardID,axis,NIMC_TRUE);
CheckError;
do
err=flex_check_buffer_rtn(boardID,1/*buffernumber*/,&backlog,&bufferState,&pointsDone);
CheckError;
//Checkbacklogforcapturedpositioninbuffer
if(backlog>0)
readBuffer=(i32*)malloc(sizeof(i32)*backlog);
//Ifcapturedpositionavailableinthebuffer,readthecapturedpositionfromthebuffer
err=flex_read_buffer_rtn(boardID,1/*buffernumber*/,backlog,readBuffer);
for(i=0;i<backlog;i++)
if(currentDataPoint>totalPoints)break;
capturedPositions[currentDataPoint]=readBuffer[i];
printf("capturepos%d\n",capturedPositions[currentDataPoint]);
currentDataPoint++;
free(readBuffer);
readBuffer=NULL;
CheckError;
//Checkforaxisoffstatus/followingerrororanymodalerrors
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(60);//Checkevery60ms
while(bufferState!=NIMC_BUFFER_DONE);
//Freethebufferallocatedonthecontrollermemory
err=flex_clear_buffer(boardID,1/*buffernumber*/);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
![Page 208: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/208.jpg)
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 209: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/209.jpg)
Non-BufferedHigh-SpeedCaptureNon-bufferedhigh-speedcaptureallowsyoutoconfigureasinglehigh-speedcaptureevent.Formultiplehigh-speedcaptures,youmustre-enablethehigh-speedcaptureeachtimeittriggers.
![Page 210: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/210.jpg)
High-SpeedCaptureAlgorithmThefollowingfigureshowsthebasicalgorithmforhigh-speedcapturesapplicabletobothC/C++andLabVIEWcode.
![Page 211: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/211.jpg)
High-SpeedCaptureLabVIEWDiagramThefollowingblockdiagramsdemonstrateusingNI-Motiontoperformahigh-speedcapture,bothwithandwithoutRTSI.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureHigh-SpeedCapture 3ReadperAxisStatus2EnableHigh-SpeedCapture 4ReadCapturedPosition
Totriggerthehigh-speedcapturefromaRTSIline,settheDestinationparameterinSelectSignaltoHighSpeedCapture1,asshowninthefollowingblockdiagram.
1SelectSignal 3EnableHigh-SpeedCapture
5ReadCapturedPosition
2ConfigureHigh-SpeedCapture
4ReadperAxisStatus
![Page 212: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/212.jpg)
High-SpeedCaptureC/C++CodeThefollowingsectionincludesC/C++codeforexecutingahigh-speedcapture,aswellasusingRTSItoexecuteahigh-speedcapture.Thefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
i32capturedPositions[6];//Arraytostorethecapturedpositions
i32i;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
////////////////////////////////
//Routebreakpoint1toRTSIline1
err=flex_select_signal(boardID,NIMC_HS_CAPTURE1/*destination*/,NIMC_RTSI1/*source*/);
CheckError;
//ConfigureHighSpeedCapture
err=flex_configure_hs_capture(boardID,axis,NIMC_HS_LOW_TO_HIGH_EDGE,0);
CheckError;
for(i=0;i<6;i++)
//Enablethehighspeedcaptureonaxis
err=flex_enable_hs_capture(boardID,axis,NIMC_TRUE);
CheckError;
![Page 213: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/213.jpg)
do
//Checkthehighspeedcapturestatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(10);//Checkevery10ms
while(!(axisStatus&NIMC_HIGH_SPEED_CAPTURE_BIT));//Waitforhighspeedcapturetobetriggered
err=flex_read_cap_pos_rtn(boardID,axis,&capturedPositions[i]);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 214: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/214.jpg)
Real-TimeSystemIntegrationBus(RTSI)RTSIisadedicatedhigh-speeddigitalbusdesignedtofacilitatesystemintegrationbylow-level,high-speed,real-timecommunicationbetweenNationalInstrumentsdevices.Manyapplications,suchasscanningandalignment,synchronizemeasurementsmadewithdataandimageacquisitiondeviceswithpositionandvelocity.Thissynchronizationrequireshighspeedswithlowlatencies.UsingRTSI,theNImotioncontrollercansharehigh-speeddigitalsignalswithNIdataacquisitiondevices,NIimageacquisitiondevices,digitalI/O,orotherNImotiondeviceswithnoexternalcablingandwithoutconsumingbandwidthonthehostbus.TheRTSIbusalsohasbuilt-inswitching,soyoucanroutesignalstoandfromthebuson-the-flyusingsoftware.Inadditiontothebreakpointandhighspeedcapturesignals,youcanrouteencoderpulsesovertheRTSIlines,whichservesasawaytotriggeranexternaldeviceoneverychangeintheencoderchannels.YoucanroutephaseA,phaseB,andtheindexpulseoftheencoderoverRTSI.YoualsocancreateasoftwaretriggerbywritingtotheRTSIlinesdirectlyfromsoftware.YoucanroutepositionbreakpointsandencoderpulsesusingtheRTSIbustotriggerotherdevices.Youalsocanconfiguredataandimageacquisitiondevicestotriggerhigh-speedcapturesontheNImotioncontrollersusingtheRTSIbus.
![Page 215: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/215.jpg)
RTSIImplementationontheMotionControllerYoucanconfigureanonboardbufferonthemotioncontrollerandusethebufferedhigh-speedcaptureorbreakpointfunctionalitytosynchronizethemotionapplicationwithdataorimageacquisition.Asshowninthefollowingfigure,theI/Oreactiontaskautomaticallyre-enablesthebreakpointsorhigh-speedcapturesontheNI7350motioncontroller.OnNI7340motioncontrollers,youmustwriteanonboardprogramorusethehosttoperformthesamere-enablingtasks.
![Page 216: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/216.jpg)
RTSIInputandOutputThefollowingsectionsexplaintheusageofRTSIforinputandoutputsignals.
![Page 217: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/217.jpg)
PositionBreakpointsUsingRTSIYoucanusetheSelectSignalVIorfunctiontoroutepositionbreakpointsusingoneoftheRTSIlines.Inthiscase,themotioncontrollertriggerstheexternaldeviceatagivenposition,asshown.
NoteAbreakpointacrossRTSIalwaysgeneratesanactivehighpulseof200nsduration.
![Page 218: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/218.jpg)
EncoderPulsesUsingRTSIYoumayneedtotriggertheexternaldevicetoacquiredataeveryencoderphaseoronanencoderindexpulse,asshown.
![Page 219: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/219.jpg)
SoftwareTriggerUsingRTSIYoucanusetheSetI/OPortMOMOVIorfunctiontowritedirectlytotheRTSIlinestotriggerotherdevices,asshown.
![Page 220: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/220.jpg)
High-SpeedCaptureInputUsingRTSIWhentheRTSIlinereceivesthetriggerfromadataorimageacquisitiondevice,thecorrespondinghigh-speedcaptureoccurs,asshown.
![Page 221: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/221.jpg)
TorqueControlTomaintainconstanttorqueorforce,thesensorthatreturnsthefeedbacktothemotioncontrollermustreturnavalueproportionaltothetorqueorforce.Themotioncontrolleroperatestorque-controlandposition-controlsystemsinmuchthesameway.Themaindifferenceisthatthefeedbackinposition-controlsystemsreturnsthecurrentposition,whilethefeedbackintorque-controlsystemsreturnsavoltageproportionaltothecurrentforceortorque.YoucanimplementforcefeedbackonNImotioncontrollersusingeitheranalogfeedbackorbymonitoringforce.
NoteTheNISoftMotionControllerdoesnotsupportanalogfeedback.
![Page 222: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/222.jpg)
AnalogFeedbackInthismode,thetorqueorforcesensorisconnectedtooneoftheanaloginputsontheNImotioncontroller.Thatanalogchannelisusedasthefeedbacksensor.
Tuningthecontrolloopwithaforcesensor,whichisananalogfeedbacksensor,producesthesameresultsaswithapositionfeedbacksensor.Dependingupontheresolutionyouareusing,thesystemmayrequirehighergainstoensureafasterresponse.NImotioncontrollershave12-bitor16-bitanaloginputs,whoserangescanbesetfrom0Vto5V,5Vto+5V,0Vto10V,and10Vto+10V.Whenyouusecountsforenteringthevaluesofposition,velocity,acceleration,anddeceleration,youdonotneedtoenterthecounts/revolutionvaluefortheaxis.Refertothemotioncontrollerusermanualforinformationaboutanaloginputranges.
![Page 223: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/223.jpg)
TorqueControlUsingAnalogFeedbackAlgorithmThefollowingfigureshowsthebasicalgorithmfortorquecontrolusinganalogfeedbackapplicabletobothC/C++andLabVIEWcode.
![Page 224: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/224.jpg)
TorqueControlUsingAnalogFeedbackLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoperformtorquecontrolusinganalogfeedback.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1LoadVelocity 4SetOperationMode
7ReadperAxisStatus
2LoadAcceleration/Deceleration
5LoadTargetPosition
8MotionErrorHandler
3LoadAcceleration/Deceleration
6StartMotion
![Page 225: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/225.jpg)
TorqueControlUsingAnalogFeedbackC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
u16moveComplete;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
////////////////////////////////
//-----------------------------------------------------------
//IsisassumedthattheaxisbeingmovedhasanADCchannel
//mappedasitsprimaryfeedback.Positionistreatedasbinary
//volts.Hencevelocityisloadedinbinaryvolts/secand
//accelerationasbinaryvolts/sec^2.
//-----------------------------------------------------------
//Setthevelocityforthemove(inbinaryvolts/sec)
err=flex_load_velocity(boardID,axis,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(inbinaryvolts/sec^2)
err=flex_load_acceleration(boardID,axis,NIMC_ACCELERATION,100000,0xFF);
CheckError;
//Setthedecelerationforthemove(inbinaryvolts/sec^2)
err=flex_load_acceleration(boardID,axis,NIMC_DECELERATION,100000,0xFF);
CheckError;
![Page 226: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/226.jpg)
//Setthejerk-s-curvetime(insampleperiods)
err=flex_load_scurve_time(boardID,axis,1000,0xFF);
CheckError;
//Settheoperationmode
err=flex_set_op_mode(boardID,axis,NIMC_ABSOLUTE_POSITION);
CheckError;
//LoadPositioncorrespondingtothevoltagewhichyouwant
//themotortomaintain(2047~5Vinthisexample)
err=flex_load_target_pos(boardID,axis,2047,0xFF);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
do
axisStatus=0;
//Checkthemovecompletestatus
err=flex_check_move_complete_status(boardID,axis,0,&moveComplete);
CheckError;
//Checkthefollowingerror/axisoffstatusforaxis1
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
while(!moveComplete&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
![Page 227: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/227.jpg)
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 228: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/228.jpg)
MonitoringForceYoucanusethissecondforce-feedbackmodeifyouhaveapositionsensoronthemotor,inadditiontothetorquesensor.Thecontrollooponthemotioncontrollerclosesthepositionandvelocityloopsasusual.UseMAXtomaptheencoderasthefeedbackdevicefortheaxis.
Formonitoringforce,createanouterlooptomonitorthetorquesensor,andmovethemotorbasedonthevaluereadfromthetorquesensor.
![Page 229: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/229.jpg)
TorqueControlUsingMonitoringForceAlgorithmThefollowingfigureshowsthebasicalgorithmfortorquecontrolusingmonitoringforceapplicabletobothC/C++andLabVIEWcode.
![Page 230: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/230.jpg)
TorqueControlUsingMonitoringForceLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoperformtorquecontrolusingmonitoringforce.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1LoadVelocity 4SetOperationMode
7StartMotion
2LoadAcceleration/Deceleration
5ReadADC 8ReadperAxisStatus
3LoadAcceleration/Deceleration
6LoadTargetPosition
9MotionErrorHandler
![Page 231: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/231.jpg)
TorqueControlUsingMonitoringForceC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
i32constant;//Constantforce
i16adcValue;//ADCvalueread
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
//constantforceneededtobemaintained
//correspondsto5Vfora+/-5VADCsettings
constant=2047;
////////////////////////////////
//-----------------------------------------------------------
//Isisassumedthattheaxisbeingmovedhasanencoder
//mappedasitsprimaryfeedback
//-----------------------------------------------------------
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,axis,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,axis,NIMC_ACCELERATION,100000,0xFF);
CheckError;
![Page 232: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/232.jpg)
//Setthedecelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,axis,NIMC_DECELERATION,100000,0xFF);
CheckError;
//Setthejerk(s-curvevalue)forthemove(insampleperiods)
err=flex_load_scurve_time(boardID,axis,100,0xFF);
CheckError;
//Settheoperationmodetovelocity
err=flex_set_op_mode(boardID,axis,NIMC_RELATIVE_POSITION);
CheckError;
do
//ReadtheADCchannelnumber1andcalculatethepositiontobeupdated
err=flex_read_adc_rtn(boardID,NIMC_ADC1,&adcValue);
CheckError;
if((constant-adcValue)!=0)
err=flex_load_target_pos(boardID,axis,(constant-adcValue),0xFF);
CheckError;
//Movebasedondeltaforce
err=flex_start(boardID,axis,0);
CheckError;
//Checkthemovecompletestatus/followingerror/axisoffstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(50);//Checkevery10ms
while(!(axisStatus&NIMC_AXIS_OFF_BIT));//Exitonaxisoff
![Page 233: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/233.jpg)
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 234: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/234.jpg)
SpeedControlBasedonAnalogValueInasystemwhereafeedrollmustrunatspeedsbasedonaninputvoltage,thealgorithmtomaintainthespeedconsistsofreadingtheanalogvoltageconnectedtooneoftheanalogchannelsonthemotioncontroller,andupdatingthespeedoftheaxisbasedonthevalueofthevoltageread.Inthissystem,thefeedbackisanormalpositionsensor,suchasanencoder.
![Page 235: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/235.jpg)
SpeedControlBasedonAnalogFeedbackAlgorithmThefollowingfigureshowsthebasicalgorithmforspeedcontrolusingbasedonanalogfeedbackapplicabletobothC/C++andLabVIEWcode.
Theanaloginputcouldbeconnectedtoaforcesensor,whichensuresthatthetensionofawebbeingfedismaintained.
![Page 236: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/236.jpg)
SpeedControlBasedonAnalogFeedbackLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoperformspeedcontrolbasedonanalogfeedback.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1LoadVelocity 5StartMotion
8StartMotion
2LoadAcceleration/Deceleration
6ReadADC 9ReadperAxisStatus
3LoadAcceleration/Deceleration
7LoadVelocity
10MotionErrorHandler
4SetOperationMode
![Page 237: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/237.jpg)
SpeedControlBasedonAnalogFeedbackC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
i32constant;//Constantmultiplier
i16adcValue;//ADCvalueread
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
//constanttomultiplytheADCvaluereadtocalculatetherequiredvelocity
constant=10;
////////////////////////////////
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,axis,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,axis,NIMC_ACCELERATION,100000,0xFF);
CheckError;
//Setthedecelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,axis,NIMC_DECELERATION,100000,0xFF);
CheckError;
//Setthejerk(s-curvevalue)forthemove(insampleperiods)
err=flex_load_scurve_time(boardID,axis,100,0xFF);
![Page 238: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/238.jpg)
CheckError;
//Settheoperationmodetovelocity
err=flex_set_op_mode(boardID,axis,NIMC_VELOCITY);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
do
//ReadtheADCchannelnumber1andcalculatethevelocitytobeupdated
err=flex_read_adc_rtn(boardID,NIMC_ADC1,&adcValue);
CheckError;
//SetthevelocitybasedontheADCvalueread
err=flex_load_velocity(boardID,axis,(adcValue*constant),0xFF);
CheckError;
//Updatethevelocity
err=flex_start(boardID,axis,0);
CheckError;
//Checkthemovecompletestatus/followingerror/axisoffstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(50);//Checkevery50ms
while(!(axisStatus&NIMC_AXIS_OFF_BIT));//Exitonaxisoff
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
![Page 239: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/239.jpg)
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 240: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/240.jpg)
OnboardProgramsThissectionprovidesinformationabouthowonboardprogramsworkfortheNISoftMotionControllerandforNI73xxmotioncontrollers.
![Page 241: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/241.jpg)
UsingOnboardProgramswiththeNISoftMotionControllerTouseonboardprogramswiththeNISoftMotionController,usetheLabVIEWReal-TimeModule(RT)totargetyourapplicationtoruninthesameenvironmentastheNISoftMotionController.BecausetheNISoftMotionControlleronboardprogramsharesthesameprocessorandsystemresourceswiththeNISoftMotionController,ensureyouconsiderthefollowingpointsbeforerunningyourapplicationinLabVIEWRT:
EnsurethatyourtoplevelVIisconfiguredtorunatnormal,abovenormal,orhighpriority.IfyouaretargetingLabVIEWRTforETS,usethetimedloopinsteadofchangingthepriorityofyourtoplevelVI.FollowtheguidelinesintheLabVIEWReal-TimeModuleUserManual.Theguidelinesregardingmemoryallocationandusingsharedresourcesareespeciallyimportant.ThejitterofthesystemincreaseswiththenumberofdevicesusedinyourRTsystem.Enableonlythedevicesyouneedtouseforthecurrentapplication.Becauseinterruptscausejitter,NationalInstrumentsrecommendsyouconfigureyourapplicationtopollfordataperiodicallyratherthanwaitonaninterrupt.YoucanfurtherdecreasethejitterunderETSbyconfiguringtheEthernetmodetobepolling.YouconfigurethesesettingsfortheRTcontrollerinMeasurement&AutomationExplorer(MAX).UnderLabVIEWRT,theNISoftMotionControllerrunsinthebackgroundattimecriticalpriority.TheNISoftMotionControllerisdesignedtoconsumelessthan40%oftheprocessorbandwidth.TherateatwhichtheNISoftMotionControllerupdatesitsdataistypically100Hz.
![Page 242: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/242.jpg)
UsingOnboardProgramswithNI73xxMotionControllersYoucanusethereal-timeoperatingsystemontheNI73xxmotioncontrollertoruncustomprograms.Thisfunctionalityallowsyoutooffloadtasksfromthehostprocessorandontothemotioncontroller.Usingonboardvariables,whichareglobaldataonthedevice,arithmeticandloopoperations,andefficientwaitfunctions,youcanwriteonboardprogramstoexecutepartsofthemotionapplicationwithalmostnohostinteraction.Youcanexecuteupto10onboardprogramssimultaneously.OnboardprogramshavetheleastpriorityinapreemptivemultitaskingenvironmentrunningontheembeddedmicroprocessorbecausetheprimaryfunctionoftheembeddedprocessorissupervisorycontrolandI/Oreaction.Instead,theonboardprogramsruninatime-slicedmanneratthelowestpriority.Eachonboardprogramgetsadefaulttimesliceoftwomilliseconds,afterwhichitrelinquishescontroloftheprocessortothenextonboardprogramorhousekeepingtask.ThehostcommunicationandI/Oreactiontaskstakehigherprioritythantheonboardprogramsandhousekeepingtasks,asshowninthefollowingfigure.Theonboardprogramsandhousekeepingtasksaretime-slicedamongthemselves.Forgreatercontrolanddeterminismforthemotioncontrolsystem,NationalInstrumentsofferstheLabVIEWReal-Time(RT)modulemotioncontrolsystem,whichconsistsofaPXIchassis,PXImotioncontrollerorcontrollers,LabVIEWRT,andNI-Motiondriversoftware.
![Page 243: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/243.jpg)
NoteIfyoucontinuouslypolldatafromthehost,theonboardprogramgetspreemptedandhaslesstimetorun.Tokeepthisfromhappening,insertasmalldelayinthepollingloopsonthehost.RefertoTimingLoopsforinformationaboutprogrammingdelaysintheloops.
![Page 244: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/244.jpg)
WritingOnboardProgramsNoteThissectionappliesonlytoNI73xxmotioncontrollers.
AlmostallNI-Motionfunctionsthatexecuteonthehostcanrunonboard.Thesizeandnumberofprogramsiscompletelyflexible.Itisultimatelylimitedbythe32totalmemoryobjectsintheObjectRegistryorbytotalavailablememory,whicheverisreachedfirst.RefertoBeginProgramStorageVIorfunctionformoreinformation.Theseonboardprogramsremainonthemotioncontrolleruntilyouresetit.Ifyouwanttheonboardprogramstopersistthrougharesetofthemotioncontroller,savethemtoFLASH,asshown.
1Writetheprogramyouwanttoloadontoonboardmemory.
YoucanusemostNI-MotionfunctionsbetweentheBeginProgramStorageVIorfunctionandtheEndProgramStorageVIorfunction.2RuntheprogramtostoretheNI-MotionfunctionsontotheonboardRAM.3StoretheprogramtoFLASHmemoryusingtheObjectMemoryManagementVIorfunctionorMAXformorepermanentstorage(optional).
![Page 245: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/245.jpg)
OnboardProgramAlgorithmThefollowingfigureshowsanonboardprogramalgorithmapplicabletobothC/C++andLabVIEWcode.
![Page 246: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/246.jpg)
OnboardProgramLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motionwithonboardprograms.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1BeginProgramStorage
4LoadAccel/DecelinRPS/s
6StartMotion
2LoadTargetPosition
5LoadAccel/DecelinRPS/s
7EndProgramStorage
3LoadVelocityinRPM
![Page 247: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/247.jpg)
OnboardProgramC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
////////////////////////////////
//--------------------------------------------------------
//Onboardprogram1.Thisonboardprogrammovesaxisone
//clockwise5000counts(steps).Toexecutethisonboardprogram
//calltheRunProgramfunction
//--------------------------------------------------------
//Beginonboardprogramstorage-programnumber1
err=flex_begin_store(boardID,1);
CheckError;
//Settheoperationmodetorelative
err=flex_set_op_mode(boardID,axis,NIMC_RELATIVE_POSITION);
CheckError;
//LoadTargetPositiontomoveclockwise5000counts(steps)
err=flex_load_target_pos(boardID,axis,5000,0xFF);
CheckError;
//LoadVelocityinRPM
err=flex_load_rpm(boardID,axis,100.00,0xFF);
CheckError;
![Page 248: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/248.jpg)
//LoadAccelerationandDecelerationinRPS/sec
err=flex_load_rpsps(boardID,axis,NIMC_BOTH,50.00,0xFF);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
//Waitformovetocomplete
err=flex_wait_on_condition(boardID,0,NIMC_WAIT,NIMC_CONDITION_MOVE_COMPLETE,2/*Indicatesaxis1*/,
0,NIMC_MATCH_ALL,1000/*timeout*/,0);
CheckError;
//EndProgramStorage
err=flex_end_store(boardID,1);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 249: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/249.jpg)
Running,Stopping,andPausingOnboardPrograms
NoteThissectionappliesonlytoNI73xxmotioncontrollers.
UseRunProgram,StopProgram,andPause/ResumeProgramtorun,stop,andpauseanonboardprogramthatresidesintheonboardmemoryofamotioncontroller.
NoteRecursivelycallinganonboardprogramgeneratesanerror.
![Page 250: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/250.jpg)
RunninganOnboardProgramTheRunProgramVIorfunctionexecutespreviouslystoredprogramsfromRAMorFLASH.Typically,youmustcallRunProgramfromthehost,becauseitisnotpossibleforanonboardprogramtorunitself.However,itispossibletoconfigurethemotioncontrollertoautomaticallyrunanonboardprogramuponpoweringupthemotioncontrolsystem.YoualsocancallanonboardprogramfromanotheronboardprogramusingRunProgram.
![Page 251: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/251.jpg)
StoppinganOnboardProgramTheStopProgramVIorfunctionendstheexecutionofanonboardprogramthatiscurrentlyrunning.StoppinganonboardprogramusingStopProgramcompletelyendsexecution.Itisnotpossibletoresumeexecutionofthestoppedonboardprogram,butyoucanre-runtheprogramfromthebeginning.YoucanstopanonboardprogramwithaStopProgramVIorfunctioncallfromthehostorfromanotheronboardprogram.
NoteItisnotpossibleforanonboardprogramtostopitself.
TipStoppinganonboardprogramisdifferentfromstoppingthemotionoftheaxisoraxes.Whenyoustopanonboardprogram,anymovesthathavestartedcontinuetorun.YoumustseparatelycalltheStopMotionVIorfunctiontostopthemotionoftheaxisoraxes.
![Page 252: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/252.jpg)
Pausing/ResuminganOnboardProgramThePause/ResumeProgramVIorfunctionsuspendsexecutionofarunningonboardprogram,orresumesexecutionofapreviouslypausedonboardprogram.Youcanpauseanonboardprogramwithafunctioncallfromthehost,fromtheonboardprogramitself,orfromanotherrunningonboardprogram.Youcanresumeanonboardprogramwithafunctioncallfromthehostorfromanotherrunningonboardprogram.
NoteItisnotpossibleforanonboardprogramtoresumeitself.
TipSimilartotheStopProgramVIorfunction,Pause/ResumeProgramhasnoeffectonmovesthathavestarted.
AutomaticPausingAnyrun-timeerrorthatoccursduringexecutionautomaticallypausestheonboardprogram.AnonboardprogramalsopausesautomaticallywhenitexecutestheStartMotionVIorfunctionortheBlendMotionVIorfunctiononanaxisthathasbeenstoppedbythehost,orwhenanaxisisstoppedduetoalimit,home,softwarelimit,orfollowingerrorcondition.Single-SteppingUsingPauseYoucanusethePause/ResumeProgramVIorfunctiontoeffectivelysingle-stepthroughanonboardprogram.Tosingle-step,addaPause/ResumeProgramcallaftereachfunction,andthenresumetheonboardprogramfromthehost.
![Page 253: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/253.jpg)
ConditionallyExecutingOnboardProgramsNoteThissectionappliesonlytoNI73xxmotioncontrollers.
Youcansetconditionsthataffecttheexecutionoftheonboardprograms.Forexample,youmaywanttheonboardprogramtowaituntilaspecificeventoccurs,andthencontinueexecuting.TheWaitonConditionVIortheWaitonEventfunctionallowsyoutocreateonboardprogramsthatwaitforevents,suchasmovecompleteandblendcomplete.Theseonboardprogramscansendfunctionstostartmovesandwaitformovestocomplete.Theonboardprogramusesalmostnoprocessortimewhilewaitingforaneventsuchasmovecomplete.Whenthemoveiscomplete,thetrajectorygeneratorenablestheI/Oreactiontask,whichcausestheonboardprogramtocontinueexecutingthenextfunctioninitssequence,asshowninthefollowingfigure.
![Page 254: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/254.jpg)
OnboardProgramConditionalExecutionAlgorithmThefollowingfigureshowsthebasicalgorithmforconditionallyexecutinganonboardprogramapplicabletobothC/C++andLabVIEWcode.
![Page 255: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/255.jpg)
OnboardProgramConditionalExecutionLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoconditionallyexecuteanonboardprogram.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1BeginProgramStorage
4LoadTargetPosition
7StartMotion
2SetOperationMode 5SelectMOMO 8EndProgramStorage
3LoadVelocityinRPM
6WaitonCondition 9MotionErrorHandler
![Page 256: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/256.jpg)
OnboardProgramConditionalExecutionC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
////////////////////////////////
//Beginonboardprogramstorage-programnumber1
err=flex_begin_store(boardID,1);
CheckError;
//LoadVelocityinRPM
err=flex_load_rpm(boardID,axis,100.00,0xFF);
CheckError;
//LoadAccelerationandDecelerationinRPS/sec
err=flex_load_rpsps(boardID,axis,NIMC_BOTH,50.00,0xFF);
CheckError;
//Settheoperationmodetorelative
err=flex_set_op_mode(boardID,axis,NIMC_RELATIVE_POSITION);
CheckError;
//LoadTargetPositiontomoverelative5000counts(steps)
err=flex_load_target_pos(boardID,axis,5000,0xFF);
![Page 257: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/257.jpg)
CheckError;
//Waitforline1onport1togoactivetofinishexecuting
err=flex_wait_on_condition(boardID,NIMC_IO_PORT1,NIMC_WAIT,NIMC_CONDITION_IO_PORT_MATCH,(u8)(1<<1)/*Indicatesline1*/,
0,NIMC_MATCH_ALL,10000/*timeout*/,0);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
//Waitformovetocomplete
err=flex_wait_on_condition(boardID,0,NIMC_WAIT,NIMC_CONDITION_MOVE_COMPLETE,(u8)(1<<axis),
0,NIMC_MATCH_ALL,1000/*timeout*/,0);
CheckError;
//EndProgramStorage
err=flex_end_store(boardID,1);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 258: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/258.jpg)
UsingOnboardMemoryandDataNoteThissectionappliesonlytoNI73xxmotioncontrollers.
NImotioncontrollersallowyoutoaccesstheonboardRAMandFLASHtocreatedatabuffersandusesomegeneral-purposeonboardvariablesfordatamanipulation.Youcanusethismemorytoupdatedatathatisloadedbyfunctionsthatareexecutinginanonboardprogram.Youalsocansynchronizeexecutionordatabetweenthehostcomputerandthemotioncontroller.Forexample,youmaywanttoupdatethevelocityofanaxisbasedontheanalogvoltagereadfromanADCchannel.Thismemoryisstaticallyallocated.
![Page 259: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/259.jpg)
UpdatingVelocityBasedonADCChannelAlgorithmThefollowingfigureshowsthebasicalgorithmforupdatingvelocitybasedonanADCchannelusinganonboardprogramapplicabletobothC/C++andLabVIEWcode.
Beforeyouexecutethisprogram,settheoperationmodeoftheaxistovelocitymode.
![Page 260: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/260.jpg)
UpdatingVelocityBasedonADCChannelLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-MotiontoupdatevelocitybasedonanADCchannel.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1LoadConstanttoVariable
6ReadADC 11StartMotion
2LoadConstanttoVariable
7MultiplyVariables 12ReadVariable
3BeginProgramStorage
8SubtractVariables 13JumptoLabelonCondition
4SetOperationMode
9JumptoLabelonCondition
14EndProgramStorage
5InsertProgramLabel
10LoadVelocity 15MotionErrorHandler
![Page 261: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/261.jpg)
UpdatingVelocityBasedonADCChannelC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
i32constant;//Constantmultiplier
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
//constanttomultiplytheADCvaluereadtocalculatetherequiredvelocity
constant=10;
////////////////////////////////
//Initializeonboardvariable4to0
err=flex_load_var(boardID,0,4);
CheckError;
//Initializeonboardvariable1totheconstantmultiplier
err=flex_load_var(boardID,constant,1);
CheckError;
//Beginonboardprogramstorage-programnumber1
err=flex_begin_store(boardID,1);
//Settheoperationmodetovelocity
err=flex_set_op_mode(boardID,axis,NIMC_VELOCITY);
CheckError;
//InsertLabelnumber1
err=flex_insert_program_label(boardID,1);
![Page 262: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/262.jpg)
CheckError;
//ReadADCchannelandstoreADCvalueinvariable2
err=flex_read_adc(boardID,NIMC_ADC1,2);
CheckError;
//MultiplyVariables2i.e.theADCvaluewith1i.e.theconstant
//Savetheresultinvariable3
err=flex_mult_vars(boardID,1,2,3);
CheckError;
//Subtractvalueinvariable3fromvariable4
//Wearenotinterestedintheresult-justwantto
//settheconditiononboard.
err=flex_sub_vars(boardID,3,4,0);
CheckError;
//Jumptolabel1asthesubtractionabovesetthecondition
//to"equaltozero"whichimpliesthatthevaluesinvariable
//3and4arethesame
err=flex_jump_label_on_condition(boardID,0,NIMC_CONDITION_EQUAL,0,0,NIMC_MATCH_ALL,1/*labelnumber*/);
//Setthevelocityforthemove(incounts/sec)byloadingthe
//valuefromvariable3whichis(adcvalue*constant)
err=flex_load_velocity(boardID,axis,0,3);
CheckError;
//Startthemovetoupdatethevelocity
err=flex_start(boardID,axis,0);
CheckError;
//Savethevalueinvariable3tovariable4foruse
//innextcycle
err=flex_read_var(boardID,3,4);
CheckError;
//Jumpbacktolabel1unconditionally
err=flex_jump_label_on_condition(boardID,0,NIMC_CONDITION_TRUE,0,0,NIMC_MATCH_ALL,1/*labelnumber*/);
CheckError;
//EndProgramStorage
err=flex_end_store(boardID,1);
//ToexecutethisprogramusetheRunProgramfunction
return;//ExittheApplication
![Page 263: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/263.jpg)
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 264: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/264.jpg)
BranchingOnboardProgramsNoteThissectionappliesonlytoNI73xxmotioncontrollers.
Tocreateloops,orconditionalifstatements,insertlabelsintheprogramyouarestoringandusetheJumptoLabelonConditionVIortheJumponEventfunctiontojumptothatlabelbasedonthecondition.
![Page 265: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/265.jpg)
BranchingOnboardProgramsAlgorithmThefollowingfigureshowsanonboardprogramwaitingforanI/OlinetogoactivebeforestartingamoveapplicabletobothC/C++andLabVIEWcode.
![Page 266: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/266.jpg)
BranchingOnboardProgramsLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoaddconditionaljumpsinanonboardprogram.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1BeginProgramStorage
6SelectMOMO 10WaitonCondition
2SetOperationMode
7WaitonCondition
11JumptoLabelonCondition
3LoadVelocityinRPM
8StartMotion 12EndProgramStorage
4InsertProgramLabel
9SelectMOMO 13MotionErrorHandler
5LoadTargetPosition
![Page 267: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/267.jpg)
BranchingOnboardProgramsC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
////////////////////////////////
//Beginonboardprogramstorage-programnumber1
err=flex_begin_store(boardID,1);
CheckError;
//LoadVelocityinRPM
err=flex_load_rpm(boardID,axis,100.00,0xFF);
CheckError;
//LoadAccelerationandDecelerationinRPS/sec
err=flex_load_rpsps(boardID,axis,NIMC_BOTH,50.00,0xFF);
CheckError;
//Settheoperationmodetorelative
err=flex_set_op_mode(boardID,axis,NIMC_RELATIVE_POSITION);
CheckError;
//InsertLabelnumber1
err=flex_insert_program_label(boardID,1);
CheckError;
//LoadTargetPositiontomoverelative5000counts(steps)
![Page 268: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/268.jpg)
err=flex_load_target_pos(boardID,axis,5000,0xFF);
CheckError;
//Waitforline1onport1togoactivetofinishexecuting
err=flex_wait_on_condition(boardID,NIMC_IO_PORT1,NIMC_WAIT,NIMC_CONDITION_IO_PORT_MATCH,(u8)(1<<1)/*Indicatesline1*/,
0,NIMC_MATCH_ALL,10000/*timeout*/,0);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
//Waitformovetocomplete
err=flex_wait_on_condition(boardID,0,NIMC_WAIT,NIMC_CONDITION_MOVE_COMPLETE,(u8)(1<<axis),
0,NIMC_MATCH_ALL,1000/*timeout*/,0);
CheckError;
//Jumpunconditionallytolabel1andcheckIOlineagain
err=flex_jump_label_on_condition(boardID,0,NIMC_CONDITION_TRUE,0,0,NIMC_MATCH_ALL,1/*labelnumber*/);
CheckError;
//EndProgramStorage
err=flex_end_store(boardID,1);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 269: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/269.jpg)
![Page 270: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/270.jpg)
MathOperationsNoteThissectionappliesonlytoNI73xxmotioncontrollers.
NI-Motionalwaysperformsmathoperationsonvaluesstoredinonboardvariables,andallmathoperationssetaglobalconditionthattheJumptoLabelonConditionVIortheJumponEventfunctionusestodetermineiftheoperationjumpstoaparticularlabelintheonboardprogram.Toloadtheonboardvariables,usetheLoadConstanttoVariableVIorfunctionorpointthereturnvectorintheReadfunctionstotheonboardvariablewhereyouwantthedatatobesaved.Inthepreviousexample,theADCchannelisreadtoonboardvariable2.Thisvalueisthenmultipliedwithascalefactorloadedintovariable1usingtheLoadConstanttoVariableVIorfunction.YoucanperformAdd,Multiply,Subtract,Divide,AND,OR,XOR,NOT,andlogicalshiftmathoperations.Theconditioncodealwaysreflectsthelastmathoperationperformed.LessThanimplieslessthanzero,Equalimpliesequaltozero,andsoon.
![Page 271: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/271.jpg)
IndirectVariablesNoteThissectionappliesonlytoNI73xxmotioncontrollers.
Ifyoumakethereadorloadfunctionspointtovariables0x81to0xF8,thefunctionsusethevalueloadedinvariables1to0x78andinterpretthemastheaddresswherethevalueisreadorloaded.Thiscreatestwolevelsofindirection.MakingthereturnvectoroftheReadPositionVIorfunctionpointto0x81causesthepositiontoendupintheaddresscontainedinonboardvariable1,asshown.
Usingindirectvariablescanbeveryusefulinloopinginonboardprograms,aswellasdynamicallychangingtheinputvaluestofunctions.
![Page 272: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/272.jpg)
OnboardBuffersNoteThissectionappliesonlytoNI73xxmotioncontrollers.
YoucanusethememoryontheNImotioncontrollerstocreategeneral-purposebufferstoreadandwritedata,asshowninthefollowingfigure.
Buffersarecreatedfromadynamicpoolofmemory,soyoumustfreethememorywhenthebufferisnotrequired.ThissamepoolofmemoryisusedtostoreonboardprogramsinRAM.Asthenumberorsizeofbuffersincreases,theavailablememoryforstoringonboardprogramsdecreases.
![Page 273: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/273.jpg)
OnboardBuffersAlgorithmThefollowingfigureshowsthealgorithmforusingonboardbufferstostoredataapplicabletobothC/C++andLabVIEWcode.
![Page 274: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/274.jpg)
SynchronizingHostApplicationswithOnboardPrograms
NoteThissectionappliesonlytoNI73xxmotioncontrollers.
Thehostandtheonboardprogramcanwritetothemovecompletestatus(MCS)registerusingtheSetUserStatusMOMOVIorfunction.ThisVIorfunctioncontrolstheupperthreebitsintheMCSregisterusingtheMustOn/MustOff(MOMO)protocol.Usethesebitstosynchronizeanapplicationrunningonthehostcomputerwithanonboardprogram,asshowninthefollowingfigure.
Forexample,considerahostapplicationthatreadsanonboardvariablethathasbeenupdatedbyanonboardprogram.Usethefollowingalgorithmtosynchronizethehostapplicationwithanonboardprogram,andreadanonboardvariablethathasbeenupdatedbyanonboardprogram.
![Page 275: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/275.jpg)
SynchronizingHostApplicationswithOnboardProgramsAlgorithmThefollowingfigureshowsanalgorithmforusinganonboardprogramtosynchronizehostapplicationsapplicabletobothC/C++andLabVIEWcode.
![Page 276: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/276.jpg)
SynchronizingHostApplicationswithOnboardProgramsLabVIEWDiagram
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
Thisexamplemovesaxis1betweentargetpositionsof5000and5000.Thehostreadsthetargetpositiononlyafterthemovehascompleted,andthenewtargetpositionhasbeencalculated.Thefollowingfigureshowsthecodethatrunsasanonboardprogram.
1LoadConstanttoVariable
6InsertProgramLabel
11MultiplyVariables
2LoadConstanttoVariable
7LoadTargetPosition
12SetUserStatusMOMO
3BeginProgramStorage
8StartMotion 13JumptoLabelonCondition
4SetOperationMode 9SelectMOMO 14EndProgramStorage
5LoadVelocity 10WaitonCondition
15MotionErrorHandler
Thefollowingfigureshowsthecodethatrunsonthehost.
![Page 277: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/277.jpg)
1ReadMoveCompleteStatus
2SetUserStatusMOMO
3ReadVariable
NoteAsthehostispollingaregisteronthemotioncontroller,itisnotinvokingtheHostCommunicationTaskonthereal-timeoperatingsystemonthemotioncontroller.Therefore,theonboardprogramsexecutingarenotpreempted.Inthissituation,theonboardprogramsrundeterministically.
![Page 278: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/278.jpg)
SynchronizingHostApplicationswithOnboardProgramsC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
i32targetPosition;//Movelength
i32multiplier;//multiplier
u16axisStatus;//Axisstatus
u16moveCompleteStatus;//Movecompletestatus
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
//Setthemovelength
targetPosition=5000;
//Setthemultiplier
multiplier=-1;
////////////////////////////////
//--------------------------------------------------------
//Onboardprogram.Thisonboardmovesanaxisbackand
//forthbetweentargetPositionand-targetPosition.Before
//reversingdirectionsitindicatestothehostcomputerthat
//itisabouttodoso.
//--------------------------------------------------------
//Initializeonboardvariable2tothemultiplierusedtochangethe
//targetposition
err=flex_load_var(boardID,multiplier,2);
CheckError;
![Page 279: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/279.jpg)
//Initializeonboardvariable1tothetargetposition
err=flex_load_var(boardID,targetPosition,1);
CheckError;
//Beginonboardprogramstorage-programnumber1
err=flex_begin_store(boardID,1);
//Settheoperationmodetoabsoluteposition
err=flex_set_op_mode(boardID,axis,NIMC_ABSOLUTE_POSITION);
CheckError;
//Setthevelocity
err=flex_load_velocity(boardID,axis,10000,0xFF);
CheckError;
//InsertLabelnumber1
err=flex_insert_program_label(boardID,1);
CheckError;
//LoadTargetPositionfromonboardvariable1
err=flex_load_target_pos(boardID,axis,0,1);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
//Waitformovetocomplete
err=flex_wait_on_condition(boardID,0,NIMC_WAIT,NIMC_CONDITION_MOVE_COMPLETE,(u8)(1<<axis)/*Indicatesaxistowaiton*/,
0,NIMC_MATCH_ALL,3000/*timeout*/,0);
CheckError;
//MultiplyVariables1i.e.thetargetpositionwith2i.e.themultiplier
//Savetheresultinvariable1-thiscalculatesthenegativeoflasttargetposition
err=flex_mult_vars(boardID,1,2,1);
CheckError;
//Setthe13thbitinthemovecompletestatusregistersothatthehost
//knowsthattheaxisisabouttoreversedirection
err=flex_set_status_momo(boardID,0x20,0);
CheckError;
//Jumpunconditionallytoloadnewtargetposition
err=flex_jump_label_on_condition(boardID,0,NIMC_CONDITION_TRUE,0,0,NIMC_MATCH_ALL,1/*labelnumber*/);
CheckError;
//EndProgramStorage
err=flex_end_store(boardID,1);
![Page 280: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/280.jpg)
CheckError;
//--------------------------------------------------------
//Hostprogram.Thisprogramsmonitorsthe13thbitinthe
//movecompletestatusregisterandrecordstheposition
//theaxisisgoingtomoveto
//--------------------------------------------------------
do
//Checkthemovecompletestatus/followingerror/axisoffstatus
err=flex_read_axis_status_rtn(boardID,axis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
//Readthemovecompletestatusregisterandoncethe13thbitisset
//resetthebitandreadsthetargetposition
err=flex_read_mcs_rtn(boardID,&moveCompleteStatus);
CheckError;
if(moveCompleteStatus&(1<<13))
i32currentTargetPosition;
//Resetthe13thbitinthemovecompletestatusregister
err=flex_set_status_momo(boardID,0,0x20);
CheckError;
err=flex_read_var_rtn(boardID,1,¤tTargetPosition);
CheckError;
Sleep(50);//Checkevery50ms
while(!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
return;//ExittheApplication
![Page 281: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/281.jpg)
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 282: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/282.jpg)
OnboardSubroutinesNoteThissectionappliesonlytoNI73xxmotioncontrollers.
Youcancreatesubroutinestorunasonboardprogramsandexecutethemfromwithinanonboardprogram.
![Page 283: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/283.jpg)
OnboardSubroutineAlgorithmThefollowingfigureshowsanonboardprogramalgorithmthatcheckstheI/OlinestatetodeterminewhichonboardsubroutinetoexecuteapplicabletobothC/C++andLabVIEWcode.
IftheI/Olineisactive,themainonboardprogramcallsanonboardsubroutinethatrotatesthemotorclockwise.IftheI/Olineisinactive,themainonboardprogramcallsanonboardsubroutinethatrotatesthemotorcounterclockwise.
![Page 284: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/284.jpg)
OnboardSubroutineLabVIEWDiagramTipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
Thefollowingfigureshowsthemainonboardprogramusedtodeterminethesubroutinecall.
1BeginProgramStorage
6WaitonCondition 10WaitonCondition
2InsertProgramLabel
7JumptoLabelonCondition
11JumptoLabelonCondition
3SelectMOMO 8InsertProgramLabel
12EndProgramStorage
4JumptoLabelonCondition
9RunProgram 13MotionErrorHandler
5RunProgram
Thefollowingfigureshowsthesubroutinethatcausesthemotortorotateclockwise.
![Page 285: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/285.jpg)
1BeginProgramStorage
5LoadAccel/DecelinRPS/sec
8WaitonCondition
2SetOperationMode
6StartMotion 9EndProgramStorage
3LoadTargetPosition
7SelectMOMO 10MotionErrorHandler
4LoadVelocityinRPM
Thefollowingfigureshowsthesubroutinethatcausesthemotortorotatecounterclockwise.
1BeginProgramStorage
5LoadAccel/DecelinRPS/sec
8WaitonCondition
![Page 286: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/286.jpg)
2SetOperationMode
6StartMotion 9EndProgramStorage
3LoadTargetPosition
7SelectMOMO 10MotionErrorHandler
4LoadVelocityinRPM
![Page 287: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/287.jpg)
OnboardSubroutineC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8axis;//Axisnumber
u16csr=0;//Communicationstatusregister
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
axis=1;
////////////////////////////////
//--------------------------------------------------------
//Onboardprogram2.Thisonboardprogrammovesaxisone
//clockwise5000counts(steps).Thisonboardprogram
//isexecutedbyonboardprogramone.
//--------------------------------------------------------
//Beginonboardprogramstorage-programnumber2
err=flex_begin_store(boardID,2);
CheckError;
//Settheoperationmodetorelative
err=flex_set_op_mode(boardID,axis,NIMC_RELATIVE_POSITION);
CheckError;
//LoadTargetPositiontomoveclockwise5000counts(steps)
err=flex_load_target_pos(boardID,axis,5000,0xFF);
CheckError;
//LoadVelocityinRPM
err=flex_load_rpm(boardID,axis,100.00,0xFF);
CheckError;
![Page 288: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/288.jpg)
//LoadAccelerationandDecelerationinRPS/sec
err=flex_load_rpsps(boardID,axis,NIMC_BOTH,50.00,0xFF);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
//Waitformovetocomplete
err=flex_wait_on_condition(boardID,0,NIMC_WAIT,NIMC_CONDITION_MOVE_COMPLETE,2/*Indicatesaxis1*/,
0,NIMC_MATCH_ALL,1000/*timeout*/,0);
CheckError;
//EndProgramStorage
err=flex_end_store(boardID,2);
CheckError;
//--------------------------------------------------------
//Onboardprogram3.Thisonboardprogrammovesaxisone
//counterclockwise5000counts(steps).Thisonboardprogram
//isexecutedbyonboardprogramone.
//--------------------------------------------------------
//Beginonboardprogramstorage-programnumber3
err=flex_begin_store(boardID,3);
CheckError;
//Settheoperationmodetorelative
err=flex_set_op_mode(boardID,axis,NIMC_RELATIVE_POSITION);
CheckError;
//LoadTargetPositiontomovecounterclockwise5000counts(steps)
err=flex_load_target_pos(boardID,axis,-5000,0xFF);
CheckError;
//LoadVelocityinRPM
err=flex_load_rpm(boardID,axis,100.00,0xFF);
CheckError;
//LoadAccelerationandDecelerationinRPS/sec
err=flex_load_rpsps(boardID,axis,NIMC_BOTH,50.00,0xFF);
CheckError;
//Startthemove
err=flex_start(boardID,axis,0);
CheckError;
//Waitformovetocomplete
![Page 289: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/289.jpg)
err=flex_wait_on_condition(boardID,0,NIMC_WAIT,NIMC_CONDITION_MOVE_COMPLETE,2/*Indicatesaxis1*/,
0,NIMC_MATCH_ALL,1000/*timeout*/,0);
CheckError;
//EndProgramStorage
err=flex_end_store(boardID,3);
CheckError;
//--------------------------------------------------------
//Onboardprogram1.Themainonboardprogrammonitors
//anIOlineandbasedonstateoftheIOlineexecutes
//onboardprogram2oronboardprogram3
//--------------------------------------------------------
//Beginonboardprogramstorage-programnumber1
err=flex_begin_store(boardID,1);
CheckError;
//InsertLabelnumber1
err=flex_insert_program_label(boardID,1);
CheckError;
//Jumptolabel2iftheline1onportoneisactive
err=flex_jump_label_on_condition(boardID,NIMC_IO_PORT1,NIMC_CONDITION_IO_PORT_MATCH,2/*Indicatesline1*/,0,NIMC_MATCH_ALL,2/*labelnumber*/);
CheckError;
//Iftheabovejumpfailedi.e.theIOlineisnotactive
//executeprogram#3
err=flex_run_prog(boardID,3);
CheckError;
//Waitforprogram#3tofinishexecuting
err=flex_wait_on_condition(boardID,3/*program#*/,NIMC_WAIT,NIMC_CONDITION_PROGRAM_COMPLETE,0,0,NIMC_MATCH_ALL,1000/*timeout*/,0);
CheckError;
//Jumpunconditionallytolabel1andcheckIOlineagain
err=flex_jump_label_on_condition(boardID,0,NIMC_CONDITION_TRUE,0,0,NIMC_MATCH_ALL,1/*labelnumber*/);
CheckError;
//InsertLabelnumber2
err=flex_insert_program_label(boardID,2);
CheckError;
//Executeprogram#2
err=flex_run_prog(boardID,2);
CheckError;
//Waitforprogram#2tofinishexecuting
![Page 290: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/290.jpg)
err=flex_wait_on_condition(boardID,2/*program#*/,NIMC_WAIT,NIMC_CONDITION_PROGRAM_COMPLETE,0,
0,NIMC_MATCH_ALL,1000/*timeout*/,0);
CheckError;
//Jumpunconditionallytolabel1andcheckIOlineagain
err=flex_jump_label_on_condition(boardID,0,NIMC_CONDITION_TRUE,0,0,NIMC_MATCH_ALL,1/*labelnumber*/);
CheckError;
//
//
//EndProgramStorage
err=flex_end_store(boardID,1);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 291: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/291.jpg)
AutomaticallyStartingOnboardProgramsNoteThissectionappliesonlytoNI73xxmotioncontrollers.
YoucanconfiguretheonboardprogramtostartautomaticallywithoutcallingtheRunProgramVIorfunction.Theonboardprogramrunsassoonasthemotioncontrollerexitstheresetstate.Tousethisfeature,savetheonboardprogramtoFLASH,andthencalltheEnableAutoStartVIorfunction.Themotioncontrollercheckstoseeiftheauto-startflagissetwhenitbootsup.Iftheflagisset,themotioncontrollerexecutestheonboardprogramconfiguredtoautomaticallystart.Theauto-startrequiresnohostinteractionafteritissetup.Automaticallystartingtheonboardprogramsisveryusefulifyouneedtoexecutemonitoringtaskstobeginassoonasthecomputerandcontrollerbootup.
![Page 292: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/292.jpg)
ChangingaTimeSliceNoteThissectionappliesonlytoNI73xxmotioncontrollers.
UsetheLoadProgramTimeSliceVIorfunctiontospecifytheminimumtimeanonboardprogramhastoberunperwatchdogperiod,withatotalof20msallowedforallrunningonboardprograms.Thedefaultvalueof2msallowsamaximumof10onboardprogramsrunningsimultaneouslywithequaltimeslices.Youcanincreasethetimesliceoftheprogramtochangeitsperformance.Thehigheryousetthetimeslice,themoretheprogramcanexecute,becauseitcommandsmoreprocessortime.However,becausetheprocessingpowerisbeingheldlongerbytheonboardprogram,theresponsetimesofotheronboardprogramsareslower.Also,increasingthetimesliceofaprogrammayreducehostresponsivenessandincreaseI/Oreactiontime,eventhoughhostcommunicationsandI/Oreactionhavehigherprioritiesthanonboardprogramsbecausethemotioncontrollermustguaranteethateveryprogramrunsforitsallottedtimeperwatchdogperiod.
![Page 293: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/293.jpg)
CreatingApplicationsUsingNI-MotionYoucancombinethemoves,input/output,andotherfunctionalitydiscussedinProgrammingwithNI-Motion,tocreatecompletemotioncontrolapplications.ThefollowingsectionsshowexamplesoftypicalmotioncontrolapplicationsandhowtheyareimplementedusingNI-Motion.
ScanningRotatingKnife
![Page 294: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/294.jpg)
ScanningThegoalofthescanningapplicationistoinspectawaferunderafixedlaser.Multipledetectorscollectthescatteredlaserlightandfeedthedatatoananalysissystemthatmapsanydefects.ThewaferrestsonanXYstagethatmovesintwodimensions.Theobjectiveofthescanistocoverasmuchspaceonthewaferaspossibleintheshortestamountoftime.Scanningagreaterareaincreasesthechancesofdetectingalldefects.Shorteningthescantimelowersthecycletime,andincreasesthespeedoftheproductionortesting.Youcanperformascanningapplicationinoneofthefollowingthreeways:
Movethestageinarasterbyconnectingseveralstraight-linemovesegments.Useblendingtoperformthescaninasinglecontinuousmove.Usecontouringtocreateacustomscanningpathforthestage.
![Page 295: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/295.jpg)
ConnectingStraight-LineMoveSegmentsYoucancovertheentireareaofthewaferbyvaryingthesizeoftherasterarea.Youcanincreasetheresolutionofthescanningpathbyshorteningthedistanceoftheverticalstraight-linemoves.However,rememberthatincreasingtheresolutionalsoincreasesthecycletime.
![Page 296: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/296.jpg)
RasterScanningUsingStraightLinesAlgorithmThefollowingfigureshowsthebasicalgorithmforrasterscanningforstraight-linemovesapplicabletobothC/C++andLabVIEWcode.
Therasterscanningalgorithmforstraight-linemovesstopsthemotorsaftereverysegmentofthemove,sothecycletimeislongerthanothermethods.
![Page 297: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/297.jpg)
RasterScanningUsingStraightLinesLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoperformrasterscanningusingstraightlines.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureVectorSpace
5LoadS-CurveTime
9CheckMoveCompleteStatus
2LoadVelocity 6SetOperationMode
10ReadperAxisStatus
3LoadAcceleration/Deceleration
7LoadVectorSpacePosition
11ReadperAxisStatus
4LoadAcceleration/Deceleration
8StartMotion 12MotionErrorHandler
![Page 298: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/298.jpg)
RasterScanningUsingStraightLinesC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8vectorSpace;//Vectorspacenumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
u16status;
u16moveComplete;
u32i;
i32xPosition[11]=5000,5000,0,0,5000,5000,0,0,5000,5000,0;
i32yPosition[11]=0,1000,1000,2000,2000,3000,3000,4000,4000,5000,5000;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
vectorSpace=NIMC_VECTOR_SPACE1;
////////////////////////////////
//Configurea2DVectorSpacecomprisingofaxes1,and2
err=flex_config_vect_spc(boardID,vectorSpace,1,2,3);
CheckError;
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,vectorSpace,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_ACCELERATION,100000,0xFF);
CheckError;
//Setthedecelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_DECELERATION,100000,0xFF);
CheckError;
![Page 299: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/299.jpg)
//Setthejerkors-curveinsampleperiods
err=flex_load_scurve_time(boardID,vectorSpace,100,0xFF);
CheckError;
//Settheoperationmodetoabsoluteposition
err=flex_set_op_mode(boardID,vectorSpace,NIMC_ABSOLUTE_POSITION);
CheckError;
//Loadthestraightlinesegmentsonebyone
for(i=0;i<11;i++)
//LoadTargetPosition
err=flex_load_vs_pos(boardID,vectorSpace,xPosition[i],yPosition[i],0,0xFF);
CheckError;
//Startthemove
err=flex_start(boardID,vectorSpace,0);
CheckError;
do
axisStatus=0;
//Checkthemovecompletestatus
err=flex_check_move_complete_status(boardID,vectorSpace,0,&moveComplete);
CheckError;
//Checkthefollowingerror/axisoffstatusforaxis1
err=flex_read_axis_status_rtn(boardID,1,&status);
CheckError;
axisStatus|=status;
//Checkthefollowingerror/axisoffstatusforaxis2
err=flex_read_axis_status_rtn(boardID,2,&status);
CheckError;
axisStatus|=status;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(50);//Checkevery50ms
![Page 300: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/300.jpg)
while(!moveComplete&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
if((axisStatus&NIMC_FOLLOWING_ERROR_BIT)||(axisStatus&NIMC_AXIS_OFF_BIT))
break;//Breakoutoftheforloopasanaxiswaskilled
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 301: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/301.jpg)
BlendingStraight-LineMoveSegmentsBlendingthestraight-linemovesegmentsenablescontinuousmotion,whichdecreasesthecycletimeofthescan.Thecycletimeismuchfasterbecausethemotorsarenotforcedtostopaftereachmovesegment.Thefollowingfigureshowsthepathoftheblendedmovesegments.
RefertoBlendingforinformationaboutusingblendingwithNI-Motion.
![Page 302: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/302.jpg)
RasterScanningUsingBlendedStraightLinesAlgorithmThefollowingfigureshowsthebasicalgorithmforrasterscanningusingblendedstraight-linemovesapplicabletobothC/C++andLabVIEWcode.
![Page 303: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/303.jpg)
RasterScanningUsingBlendedStraightLinesLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoperformrasterscanningusingblendedstraight-linemoves.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureVectorSpace
6LoadBlendFactor
10CheckMoveCompleteStatus
2LoadVelocity 7SetOperationMode
11ReadperAxisStatus
3LoadAcceleration/Deceleration
8LoadVectorSpacePosition
12ReadperAxisStatus
4LoadAcceleration/Deceleration
9StartMotion 13MotionErrorHandler
5LoadS-CurveTime
![Page 304: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/304.jpg)
RasterScanningUsingBlendedStraightLinesC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8vectorSpace;//Vectorspacenumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
u16status;
u16complete;//Moveorblendcompletestatus
u32i;
i32xPosition[11]=5000,5000,0,0,5000,5000,0,0,5000,5000,0;
i32yPosition[11]=0,1000,1000,2000,2000,3000,3000,4000,4000,5000,5000;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
vectorSpace=NIMC_VECTOR_SPACE1;
////////////////////////////////
//Configurea2DVectorSpacecomprisingofaxes1,and2
err=flex_config_vect_spc(boardID,vectorSpace,1,2,3);
CheckError;
//Setthevelocityforthemove(incounts/sec)
err=flex_load_velocity(boardID,vectorSpace,10000,0xFF);
CheckError;
//Settheaccelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_ACCELERATION,100000,0xFF);
CheckError;
//Setthedecelerationforthemove(incounts/sec^2)
err=flex_load_acceleration(boardID,vectorSpace,NIMC_DECELERATION,100000,0xFF);
![Page 305: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/305.jpg)
CheckError;
//Setthejerkors-curveinsampleperiods
err=flex_load_scurve_time(boardID,vectorSpace,100,0xFF);
CheckError;
//Settheoperationmodetoabsoluteposition
err=flex_set_op_mode(boardID,vectorSpace,NIMC_ABSOLUTE_POSITION);
CheckError;
//Loadthestraightlinesegmentsonebyone
for(i=0;i<11;i++)
//LoadTargetPosition
err=flex_load_vs_pos(boardID,vectorSpace,xPosition[i],yPosition[i],0,0xFF);
CheckError;
if(i==0)
//Startthemove
err=flex_start(boardID,vectorSpace,0);
CheckError;
else
//Blendthemove
err=flex_blend(boardID,vectorSpace,0);
CheckError;
do
axisStatus=0;
if(i==10)
//Checkthemovecompletestatus
err=flex_check_move_complete_status(boardID,vectorSpace,0,&complete);
CheckError;
else
//Checktheblendcompletestatus
err=flex_check_blend_complete_status(boardID,vectorSpace,0,&complete);
CheckError;
//Checkthefollowingerror/axisoffstatusforaxis1
err=flex_read_axis_status_rtn(boardID,1,&status);
CheckError;
axisStatus|=status;
//Checkthefollowingerror/axisoffstatusforaxis2
![Page 306: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/306.jpg)
err=flex_read_axis_status_rtn(boardID,2,&status);
CheckError;
axisStatus|=status;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
Sleep(50);//Checkevery50ms
while(!complete&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
if((axisStatus&NIMC_FOLLOWING_ERROR_BIT)||(axisStatus&NIMC_AXIS_OFF_BIT))
break;//Breakoutoftheforloopasanaxiswaskilled
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 307: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/307.jpg)
User-DefinedScanningPathYoucancreateacustompaththatcoversthemaximumscanareaintheshortesttimeusingthecontouredmovefeatureoftheNImotioncontroller.Thiswayyoubypassthetrajectorygeneratorandsendexactpositionstothemotioncontroller.Thecontrollertheninterpolatesthedistancebetweenthegivenpointsusingacubicsplinealgorithm.Thefollowingfigureshowsthescanningpathusedintheexamples.
Usingthecontouredmovegivesyouthegreatestamountofflexibilityregardingthescanareaandspeed.HoweveryoulosethebenefitofthetrajectorygeneratoroftheNImotioncontroller.RefertoContouredMovesforinformationaboutusingcontouredmoveswithNI-Motion.
![Page 308: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/308.jpg)
User-DefinedScanningPathAlgorithmThefollowingfigureshowsthebasicalgorithmforrasterscanningusingauser-definedpathapplicabletobothC/C++andLabVIEWcode.
![Page 309: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/309.jpg)
User-DefinedScanningPathLabVIEWDiagramThefollowingblockdiagramdemonstratesusingNI-Motiontoperformscanningusingacontouredmove.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureVectorSpace 5StartMotion 8ClearBuffer2SetOperationMode 6CheckBuffer 9SetOperationMode3ConfigureBuffer 7WriteBuffer 10MotionErrorHandler4WriteBuffer
![Page 310: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/310.jpg)
User-DefinedScanningPathC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8vectorSpace;//Vectorspacenumber
u16csr=0;//Communicationstatusregister
u16axisStatus;//Axisstatus
u16status;//Temporarycopyofstatus
u16moveComplete;//Movecompletestatus
i32i;
i32points[1994]=NIMC_SPIRAL_ARRAY;//Arrayof2Dpointstomove
u32numPoints=1994;//Totalnumberofpointstocontourthrough
i32bufferSize=1000;//Thesizeofthebuffertoallocateonthemotioncontroller
f64actualInterval;//Theintervalthecontrollercanreallycontourat
i32*downloadData=NULL;//Thetemporaryarraythatiscreatedtodownloadthepointstothecontroller
u32currentDataPoint=0;//Indicatesthenextpointinthepointsarraythatistobedownloaded
i32backlog;//Indicatestheavailablespacetodownloadmorepoints
u16bufferState;//Indicatesthestateoftheonboardbuffer
u32pointsDone;//Indicatesthenumberofpointsthathavebeenconsumed
u32dataCopied=0;//Keepstackofthepointscopied
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
vectorSpace=NIMC_VECTOR_SPACE1;
////////////////////////////////
//Configurea2DVectorSpacecomprisingofaxes1and2
err=flex_config_vect_spc(boardID,vectorSpace,1,2,3);
CheckError;
//Settheoperationmodetoabsoluteposition
err=flex_set_op_mode(boardID,vectorSpace,NIMC_ABSOLUTE_CONTOURING);
CheckError;
![Page 311: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/311.jpg)
//Configurebufferonmotioncontrollermemory(RAM)
//Noterequestedtimeintervalishardcodedto10milliseconds
err=flex_configure_buffer(boardID,1/*buffernumber*/,vectorSpace,NIMC_POSITION_DATA,bufferSize,
numPoints,NIMC_TRUE,10,&actualInterval);
//Sendthefirst1000pointsofthedata
downloadData=malloc(sizeof(i32)*bufferSize);
for(i=0;i<bufferSize;i++)
downloadData[i]=points[i];
currentDataPoint++;
err=flex_write_buffer(boardID,1/*buffernumber*/,bufferSize,0,downloadData,0xFF);
free(downloadData);
downloadData=NULL;
CheckError;
//StartMotion
err=flex_start(boardID,vectorSpace,0);
CheckError;
for(;;)
axisStatus=0;
//Checkforavailablespaceanddownloadremainingpointsevery50milliseconds
Sleep(50);
//Checktoseeifwehavemorepointstodownload
if(currentDataPoint<numPoints)
err=flex_check_buffer_rtn(boardID,1/*buffernumber*/,&backlog,&bufferState,&pointsDone);
CheckError;
if(backlog>=300)
downloadData=malloc(sizeof(i32)*backlog);
dataCopied=0;
for(i=0;i<backlog;i++)
if(currentDataPoint>numPoints)break;
downloadData[i]=points[currentDataPoint];
currentDataPoint++;
dataCopied++;
err=flex_write_buffer(boardID,1/*buffernumber*/,dataCopied,0,downloadData,0xFF);
free(downloadData);
downloadData=NULL;
CheckError;
![Page 312: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/312.jpg)
//Checkthemovecompletestatus
err=flex_check_move_complete_status(boardID,vectorSpace,0,&moveComplete);
CheckError;
if(moveComplete)break;
//Checkforaxisoffstatus/followingerrororanymodalerrors
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
//Checkthemotoroffstatusonalltheaxesoraxis
err=flex_read_axis_status_rtn(boardID,1,&status);
CheckError;
axisStatus|=status;
err=flex_read_axis_status_rtn(boardID,2,&status);
CheckError;
axisStatus|=status;
if((axisStatus&NIMC_FOLLOWING_ERROR_BIT)||(axisStatus&NIMC_AXIS_OFF_BIT))
break;//Breakoutoftheforloopasanaxiswaskilled
//Setthemodebacktoabsolutemodetogetthecontrolleroutofcontouring
//mode
err=flex_set_op_mode(boardID,vectorSpace,NIMC_ABSOLUTE_POSITION);
CheckError;
//Freethebufferallocatedonthecontrollermemory
err=flex_clear_buffer(boardID,1/*buffernumber*/);
CheckError;
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
![Page 313: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/313.jpg)
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 314: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/314.jpg)
RotatingKnifeThepurposeofthisapplicationistocutawebwitharotatingknife.Theblademustcutpreciselybetweenlabelsontheweb.Becausethewebmaterialcanstretchundercertainconditions,itisnotenoughtocutthewebatconstantlength,becausethelengthofeachlabelcanvary.Toaccomplishthistask,thewebismarkedonetimepercycleattherequiredcuttinglocation.Themotioncontrollerreadsthismarkusingasensorandperformsthenecessarycorrection.Tosimplifythisexample,assumethatthelengthofthecutisequaltothecircumferenceoftheknife.Underidealconditions,themarkshouldbereadwhenthebladeisatpositionA,asshowninthefigurebelow.Therefore,themotorshouldmoveonerevolutionwithoutanycorrectionbeforecausingthecut.
TipRefertoElectronicGearingandCammingforinformationaboutsuperimposedmoves/registrationapplications.
![Page 315: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/315.jpg)
SolutionTherotaryknifeiselectronicallygearedtothewebwithagearratioof1:1,whichensuresthatatthetimeofcut,thespeedofthewebandtheknifeisthesame.Thespeedofeachmustbethesametomakeacleancutwithoutstretchingtheweb.Also,underidealconditions,thewebandrotatingknifemovetheexactsamedistance.Forexample,thelengthofthecutmightbeonerevolution,whichisequalto2,000counts.Thesensorreadingthemarkisconnectedtooneofthehigh-speedcapturelinesonthemotioncontroller.Becausetheelasticityofthewebmaterialresultsinvaryinglabellengths,themarkcanbereadbeforethebladeisatpositionAorafteritisatpositionA.Theapplicationmustcorrectthepositionwherethebladeoftherotaryknifeshouldbewhenthehigh-speedcaptureoccurs.ThiscorrectionmustoccurafterthebladehascrossedpositionAsothatthecurrentcutisnotdamaged.Toaccomplishthisgoal,markthecorrectionpointtobeatpositionB,asshowninthefollowingfigure.
ASynchronizationPoint BCorrectionPoint
![Page 316: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/316.jpg)
RotatingKnifeAlgorithmThefollowingfigureshowsthebasicalgorithmfortherotatingknifeapplicationapplicabletobothC/C++andLabVIEWcode.
![Page 317: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/317.jpg)
RotatingKnifeLabVIEWDiagramThefollowingblockdiagramsdemonstrateusingNI-Motiontoprogramtherotatingknifeapplication.
TipRefertoNI-Motion\Documentation\Examples\NI-MotionUserManual\fortheLabVIEWVIsfortheseexamples.
1ConfigureGearMaster
4LoadAccel/DecelinRPS/s
7EnableHigh-SpeedCapture
2LoadGearRatio 5SetOperationMode
8ReadHigh-SpeedCaptureStatus
3LoadVelocityinRPM
6EnableGearingSingleAxis
9MotionErrorHandler
Thefollowingfiguresshowtheremainingcasesfortheblockdiagramabove.
1ReadCapturedPosition 2LoadTargetPosition
![Page 318: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/318.jpg)
1ReadPosition 2StartMotion
![Page 319: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/319.jpg)
RotatingKnifeC/C++CodeThefollowingexamplecodeisnotnecessarilycomplete,andmaynotcompileifcopiedexactly.RefertotheexamplesfolderontheNI-MotionCDforfilesthatarecompleteandcompileasis.
//Mainfunction
voidmain(void)
u8boardID;//Boardidentificationnumber
u8slaveAxis;//Slaveaxisnumber
u8master;//Gearmaster
u16csr=0;//Communicationstatusregister
i32synchronizationPosition=0;//Synchronizationposition
i32correctionPoint=500;//Pointwherethecorrectioncanbeapplied
i32cyclePosition=2000;//Onerevolutionis2000counts
i32currentPosition;//Thecurrentslaveposition
i32capturedPosition;//Thepositionatwhichthetriggerhappens
u16axisStatus;
//Variablesformodalerrorhandling
u16commandID;//ThecommandIDofthefunction
u16resourceID;//TheresourceID
i32errorCode;//Errorcode
///////////////////////////////
//SettheboardID
boardID=1;
//Settheaxisnumber
slaveAxis=1;
//Masterisencoder4
master=NIMC_ENCODER4;
////////////////////////////////
//--------------------------------------------------------
//Setupthegearingconfigurationfortheslaveaxis
//--------------------------------------------------------
//ConfigureGearMaster
err=flex_config_gear_master(boardID,slaveAxis,master);
CheckError;
//LoadGearRatio1:1
err=flex_load_gear_ratio(boardID,slaveAxis,NIMC_ABSOLUTE_GEARING,
1/*ratioNumerator*/,1/*ratioDenominator*/,0xFF);
CheckError;
//--------------------------------------------------------
![Page 320: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/320.jpg)
//Setupthemoveparametersforthesuperimposedmove
//tobedoneonregistration
//--------------------------------------------------------
//Settheoperationmodetorelative
err=flex_set_op_mode(boardID,slaveAxis,NIMC_RELATIVE_TO_CAPTURE);
CheckError;
//LoadVelocityinRPM
err=flex_load_rpm(boardID,slaveAxis,100.00,0xFF);
CheckError;
//LoadAccelerationandDecelerationinRPS/sec
err=flex_load_rpsps(boardID,slaveAxis,NIMC_BOTH,50.00,0xFF);
CheckError;
//--------------------------------------------------------
//EnableGearingonslaveaxis
//--------------------------------------------------------
err=flex_enable_gearing_single_axis(boardID,slaveAxis,NIMC_TRUE);
CheckError;
//--------------------------------------------------------
//Waitfortriggertodotheregistrationmove
//--------------------------------------------------------
for(;;)
//EnableHighspeedcaptureforslaveaxis
err=flex_enable_hs_capture(boardID,slaveAxis,NIMC_TRUE);
CheckError;
do
//Checkthehighspeedcapturestatus/followingerror/axisoffstatus
err=flex_read_axis_status_rtn(boardID,slaveAxis,&axisStatus);
CheckError;
//Readthecommunicationstatusregisterandcheckthemodalerrors
err=flex_read_csr_rtn(boardID,&csr);
CheckError;
//Checkthemodalerrors
if(csr&NIMC_MODAL_ERROR_MSG)
err=csr&NIMC_MODAL_ERROR_MSG;
CheckError;
![Page 321: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/321.jpg)
while(!(axisStatus&NIMC_HIGH_SPEED_CAPTURE_BIT)&&!(axisStatus&NIMC_FOLLOWING_ERROR_BIT)&&!(axisStatus&NIMC_AXIS_OFF_BIT));//
if((axisStatus&NIMC_FOLLOWING_ERROR_BIT)||(axisStatus&NIMC_AXIS_OFF_BIT))
break;//Breakoutoftheforloop
//Updatethevariablesforthiscycle
synchronizationPosition+=cyclePosition;
correctionPoint+=cyclePosition;
//Readthecapturedposition
err=flex_read_cap_pos_rtn(boardID,slaveAxis,&capturedPosition);
CheckError;
//Loadthetargetpositionfortheregistration(superimposed)move
err=flex_load_target_pos(boardID,slaveAxis,(synchronizationPosition-capturedPosition),0xFF);
CheckError;
//Waituntilwehavepassedthecorrectionpointbeforeweapplythecorrection
currentPosition=0;
while(currentPosition<correctionPoint)
err=flex_read_pos_rtn(boardID,slaveAxis,¤tPosition);
CheckError;
//Startregistrationmoveontheslave
err=flex_start(boardID,slaveAxis,0);
CheckError;
//Forloop
return;//ExittheApplication
/////////////////////////////////////////////////////////////////////////
//ErrorHandling
//
nimcHandleError;//NIMCCATCHTHIS:
//ChecktoseeiftherewereanyModalErrors
if(csr&NIMC_MODAL_ERROR_MSG)
do
//GetthecommandID,resourceandtheerrorcodeofthemodal
//errorfromtheerrorstackontheboard
flex_read_error_msg_rtn(boardID,&commandID,&resourceID,&errorCode);
nimcDisplayError(errorCode,commandID,resourceID);
//ReadtheCommunicationStatusRegister
flex_read_csr_rtn(boardID,&csr);
![Page 322: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/322.jpg)
while(csr&NIMC_MODAL_ERROR_MSG);
else//Displayregularerror
nimcDisplayError(err,0,0);
return;//ExittheApplication
![Page 323: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/323.jpg)
TuningServoSystemsWhenyourmotioncontrolsystemincludesaservomotor,youmusttuneandcalibratethesystemtoensureproperperformance.Thischaptercoversgeneralinformationabouttuningandcalibratingyourservosystemusingcontrolloopparameters.RefertotheTuningServoMotorssectionoftheMeasurement&AutomationExplorerHelpforMotionformoreinformationaboutandinstructionsfortuningservomotorsinMeasurement&AutomationExplorer(MAX).
NoteThissectiondoesnotapplyifyouareusingtheNISoftMotionControllerbecausethecontrolloopisimplementedonthedrive.RefertothedrivedocumentationforinformationabouttuningtheservomotorsyouareusingwiththeCANopendrive.
![Page 324: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/324.jpg)
UsingControlLoopstoTuneServoMotorsTuningmaximizestheperformanceofyourservomotors.Aservosystemusesfeedbacktocompensateforerrorsinpositionandvelocity.Forexample,whentheservomotorreachesthedesiredposition,itcannotstopinstantaneously.Thereisanormalovershootthatmustbecorrected.Thecontrollerturnsthemotorintheoppositedirectionfortheamountofdistanceequaltothedetectedovershoot.However,thiscorrectivemovealsoexhibitsasmallovershoot,whichmustalsobecorrectedinthesamemannerasthefirstovershoot.Aproperlytunedservosystemexhibitsovershootasshownthefollowingfigure.
Theamountoftimerequiredforthemotorstosettleonthecommandedpositioniscalledthesettlingtime.Bytuningtheservomotors,youcanaffectthesettlingtime,theamountofovershoot,andvariousotherperformancecharacteristics.
![Page 325: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/325.jpg)
ControlLoopNImotionservocontrolusescontrolloopstocontinuouslycorrecterrorsinpositionandvelocity.YoucanconfigurethecontrollooptoperformaProportional,IntegralandDerivative(PID)looporamoreadvancedcontrolloop,suchasthevelocityfeedback(PIV)orvelocityfeedforward(PIVff)loops.
![Page 326: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/326.jpg)
PIDLoopDescriptionsThefollowingarecommonvariablesrelatingtothePIDcontrolloop.Kp(ProportionalGain)Theproportionalgain(Kp)determinesthecontributionofrestoringforcethatisdirectlyproportionaltothepositionerror.Thisrestoringforcefunctionsinmuchthesamewayasaspringinamechanicalsystem.Eachsampleperiod,thePIDloopcalculatesthepositionerror,whichisthedifferencebetweentheinstantaneoustrajectorypositionandtheprimaryfeedbackposition,andmultipliesthepositionerrorbyKptoproducetheproportionalcomponentofthe16-bitDACcommandoutput.AnaxiswithtoosmallavalueofKpisunabletoholdtheaxisinpositionandisverysoft.IncreasingKpstiffenstheaxisandimprovesitsdisturbancetorquerejection.However,toolargeavalueofKpoftenresultsininstability.Ki(IntegralGain)Theintegralgain(Ki)determinesthecontributionofrestoringforcethatincreaseswithtime,ensuringthatthestaticpositionerrorintheservoloopisforcedtozero.Thisrestoringforceworksagainstconstanttorqueloadstohelpachievezeropositionerrorwhentheaxisisstopped.Eachsampleperiod,thepositionerrorisaddedtotheaccumulationofpreviouspositionerrorstoformanintegrationsum.Thisintegrationsumisscaledbydividingby256priortobeingmultipliedbyKi.Inapplicationswithsmallstatictorqueloads,thisvaluecanbeleftatitsdefaultvalueofzero(0).Forsystemshavinghighstatictorqueloads,thisvalueshouldbetunedtominimizepositionerrorwhentheaxisisstopped.Althoughnon-zerovaluesofKicausereducedstaticpositionerror,theytendtocauseincreasedpositionerrorduringaccelerationanddeceleration.ThiseffectcanbemitigatedthroughtheuseoftheIntegrationLimitparameter.ToohighavalueofKioftenresultsinservoloopinstability.NationalInstrumentsthereforerecommendsthatyouleaveKiatitsdefaultvalueofzerountiltheservosystemoperationisstable.ThenyoucanaddasmallamountofKitominimizestaticpositionerrors.
![Page 327: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/327.jpg)
Kd(DerivativeGain)Thederivativegain(Kd)determinesthecontributionofrestoringforceproportionaltotherateofchange(derivative)ofpositionerror.Thisforceactsmuchlikeviscousdampinginadampedspringandmassmechanicalsystem.Ashockabsorberisanexampleofthiseffect.ThePIDloopcomputesthederivativeofpositionerroreveryderivativesampleperiod.Anon-zerovalueofKdisrequiredforallsystemsthatusetorqueblockamplifiers,wherethecommandoutputisproportionaltomotortorque,fortheservoloopoperationtobestable.ToosmallaKdvalueresultsinservoloopinstability.Withvelocityblockamplifiers,wherethecommandoutputisproportionaltomotorvelocity,itistypicaltosetKdtozerooraverysmallpositivevalue.Kv(VelocityFeedback)Youcanuseaprimaryorsecondaryfeedbackencoderforvelocityfeedback.Settingthevelocityfeedbackgain(Kv)toavalueotherthanzero(0)enablesvelocityfeedbackusingthesecondaryencoder,ifconfigured,ortheprimaryencoderifasecondaryencoderisnotconfigured.Kvisusedtoscalethisvelocityfeedbackbeforeitisaddedtotheothercomponentsinthe16-bitDACcommandoutput.Kvissimilartoderivativegain(Kd)exceptthatitscalesthevelocityestimatedfromencoderresourcesonly.Thederivativegainscalesthederivativeofthepositionerror,whichisthedifferencebetweentheinstantaneoustrajectorypositionandtheprimaryfeedbackposition.LiketheKdterm,thevelocityfeedbackderivativeiscalculatedeveryderivativesampleperiodandthecontributionisupdatedeveryPIDsampleperiod.Velocityfeedbackisestimatedthroughacombinationofspeed-dependentalgorithms.Velocityismeasuredbasedonthetimeelapsedbetweeneachencodercount.Vff(VelocityFeedforward)Thevelocityfeedforwardgain(Vff)determinesthecontributioninthe16-bitDACcommandoutputthatisdirectlyproportionaltotheinstantaneoustrajectoryvelocity.ThisvalueisusedtominimizefollowingerrorduringtheconstantvelocityportionofamoveandcanbechangedatanytimetotunethePIDloop.
![Page 328: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/328.jpg)
Velocityfeedforwardisanopen-loopcompensationtechniqueandcannotaffectthestabilityofthesystem.However,ifyouusetoolargeavalueforVff,followingerrorcanreverseduringtheconstantvelocityportion,thusdegradingperformance,ratherthanimprovingit.VelocityfeedforwardistypicallyusedwhenoperatinginPIVffmodewitheitheravelocityblockamplifierorsubstantialamountofvelocityfeedback(Kv).Inthesecases,theuncompensatedfollowingerrorisdirectlyproportionaltothedesiredvelocity.Youcanreducethisfollowingerrorbyapplyingvelocityfeedforward.Increasingtheintegralgain(Ki)alsoreducesthefollowingerrorduringconstantvelocitybutonlyattheexpenseofincreasedfollowingerrorduringaccelerationanddecelerationandreducedsystemstability.Forthesereasons,increasingKiisnotarecommendedsolution.
TipInPIVffmode,theKdandKvgainsaresettozero.
VelocityfeedforwardisrarelyusedwhenoperatinginPIDmodewithtorqueblockamplifiers.Inthiscase,becausethefollowingerrorisproportionaltothetorquerequired,ratherthanthevelocity,itistypicallymuchsmalleranddoesnotrequirevelocityfeedforward.Aff(AccelerationFeedforward)Theaccelerationfeedforwardgain(Aff)determinesthecontributioninthe16-bitDACcommandoutputthatisdirectlyproportionaltotheinstantaneoustrajectoryacceleration.Affisusedtominimizefollowingerror(positionerror)duringaccelerationanddecelerationandcanbechangedatanytimetotunethePIDloop.Accelerationfeedforwardisanopen-loopcompensationtechniqueandcannotaffectthestabilityofthesystem.However,ifyouusetoolargeavalueofAff,followingerrorcanreverseduringaccelerationanddeceleration,thusdegradingperformance,ratherthanimprovingit.KdacKdacistheDigitaltoAnalogConverter(DAC)gain.UsethefollowingequationtocalculateKdac:
20Vrepresentsthe±10Vrangeinthemotioncontroller.Ga
![Page 329: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/329.jpg)
GaistheAmplifierGain.KtKtistheTorqueConstantofthemotor.KtisrepresentedinNewtonMetersperAmp.1/J1/Jrepresentsthemotorplusloadinertiaofthemotionsystem.KeKerepresentstheconversionfactortorevolutions.Thismayinvolveascalingfactor.
![Page 330: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/330.jpg)
DualLoopFeedbackMotioncontrolsystemsoftenusegearstoincreaseoutputtorque,increaseresolution,orconvertrotarymotiontolinearmotion.Themaindisadvantageofusinggearsisthebacklashcreatedbetweenthemotorandtheload.Thisbacklashcancausealossofpositionaccuracyandsysteminstability.Thecontrollooponthemotionsystemcorrectsforerrorsandmaintainstightcontroloverthetrajectory.Thecontrolloopconsistsofthreemainparts—proportional,integralandderivative—knownasPIDparameters.Thederivativepartestimatesmotorvelocitybydifferentiatingthefollowingerror(positionerror)signal.Thisvelocitysignaladds,totheloop,dampingandstability.Ifbacklashispresentbetweenthemotorandthepositionsensor,thepositionsofthemotorandthesensorarenolongerthesame.Thisdifferencecausesthederivedvelocitytobecomeineffectiveforloopdampingpurposes,whichcreatesinaccuracyinpositionandsysteminstability.Usingtwopositionsensorsforanaxiscanhelpsolvetheproblemscausedbybacklash.Asshowninthefollowingfigure,onepositionsensorresidesontheloadandtheotheronthemotorbeforethegears.Themotorsensorisusedtogeneratetherequireddampingandtheloadsensorforpositionfeedback.Themixofthesetwosignalsprovidesthecorrectpositionfeedbackwithdampingandstability.
TipYoucanenabledual-loopfeedbackontheNImotioncontrollerbymappinganencoderasthesecondaryfeedbackfortheaxis,andthenusingthevelocityfeedbackgaininsteadofthederivativegaintodampenandstabilizethesystem,asshowninthefollowingfigure.
![Page 331: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/331.jpg)
![Page 332: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/332.jpg)
VelocityFeedbackYoucanconfiguretheNImotioncontrollerforvelocityfeedbackusingtheKv(velocityfeedback)gain.UsingKvcreatesaminorvelocityfeedbackloop.Thisisverysimilartothetraditionalanalogservocontrolmethodofusingatachometerforclosingthevelocityloop.Thistypeoffeedbackisnecessaryforsystemswhereprecisespeedcontrolisessential.Youcanusealessexpensivestandardtorque,orcurrentmode,amplifierwiththevelocityfeedbacklooponNImotioncontrollerstoachievethesameresultsyouwouldgetfromusingvelocityamplifiers,asshowninthefollowingfigure.
Settinganynon-zerovalueforKvallowsyoutousetheKvterminsteadoforinadditiontotheKdtermtostabilizethesystem.Velocityfeedbackgain(Kv)issimilartoderivativegain(Kd)exceptthatitscalesthevelocityestimatedfromencoderresourcesonly.Thederivativegainscalesthederivativeofthepositionerror,whichisthedifferencebetweentheinstantaneoustrajectorypositionandtheprimaryfeedbackposition.LiketheKdterm,thevelocityfeedbackderivativeiscalculatedeveryderivativesampleperiod,andthecontributionisupdatedeveryPIDsampleperiod,asshowninthefollowingfigure.
![Page 333: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/333.jpg)
![Page 334: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/334.jpg)
NIMotionControllerswithVelocityAmplifiersVelocityamplifiersclosethevelocityloopusingatachometerontheamplifieritself,asshowninthefollowingfigure.Inthiscase,thecontrollermustensurethatthevoltageoutputisproportionaltothevelocity.Usethevelocityfeedforwardterm(Vff)toensurethatthereisminimumfollowingerrorduringtheconstantvelocityprofiles.
ThefollowingfiguredescribeshowtouseNImotioncontrollerswithvelocityamplifiers.
Youtypicallyusevelocityfeedforwardwhenusingcontrollerswithvelocityamplifiers.Theuncompensatedfollowingerrorisdirectlyproportionaltothespecifiedvelocity.Youcanreducethefollowingerrorbyapplyingvelocityfeedforward.Increasingtheintegralgain(Ki)alsoreducesthefollowingerrorduringconstantvelocity,butattheexpenseofincreasedfollowingerrorduringaccelerationanddecelerationandreducedsystemstability.
NoteNationalInstrumentsdoesnotrecommendincreasingKi.
VelocityfeedforwardisrarelyusedwhenoperatinginPIDmodewithtorqueblockamplifiers.Inthiscase,followingerroristypicallymuchsmallerbecauseitisproportionaltothetorquerequiredratherthantothevelocity.WhenoperatinginPIDmodewithtorqueblockamplifiers,velocityfeedforwardisnotrequired.
![Page 335: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/335.jpg)
SinusoidalCommutationforBrushlessServoMotionControlSinusoidalcommutationallowsyoutouselessexpensiveservomotordriveswithNImotioncontrollersthatsupportthisfeature.
PhaseInitializationDeterminingtheCountsperElectricalCycleoftheMotorCommutationFrequencyTroubleshootingHallEffectSensorConnections
![Page 336: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/336.jpg)
PhaseInitializationWhenthesystemisfirstpoweredon,thecontrollermustdeterminetheinitialcommutationphase.NImotioncontrollerssupportseveralmethodsofphaseinitialization,includingHalleffectsensors,shakeandwake,anddirectset.
![Page 337: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/337.jpg)
HallEffectSensorsThecontrollercanuseHalleffectsensorstoestimatethecommutationphasebasedonthestateofthesensors.AfteraHalleffectstatetransitionoccurs,thecontrollerrecalculatesthephaseanglebasedonthetransitionlocation.Toobtainmaximumtorqueatthebeginningofthemove,performamovethatis1/6thofthemagneticcycleaftersysteminitialization.RefertothehardwaredocumentationforHalleffectsensortypesandconnectionschemes.
![Page 338: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/338.jpg)
ShakeandWake"Shakeandwake"isaninitializationmethodwherethemotioncontrolleroutputsaspecifiedvoltageforaspecifiedduration.Thisdrivesthesystemtothezero-degreephasepositionandallowsyoutoestablishthepositionasabaselineforallotherphasepositions.Duringthisprocess,themotormovestothezero-degreepositionwithhightorque.Ensurethesystemisawayfromanylimitsbeforeperformingshakeandwakeinitialization.Ifthesystemhasloadorismovingagainstgravity,increasetheshakeandwakevoltage.Ifthereissignificantjitterastheaxisapproacheszero,increasetheduration.
![Page 339: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/339.jpg)
DirectSetDirectsetisaninitializationmethodwherethecontrollersetsthecurrentpositionasthespecifiedphaseangle.Thisinitializationmethodisrecommendedonlyforacustomsystemwithknowninitialphaseangle.Whenevertheaxisisenabled,thecontrollermustperformthephaseinitializationproceduretodeterminethephase.
![Page 340: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/340.jpg)
DeterminingtheCountsperElectricalCycleoftheMotorThecontrollerneedstoknowthecountsperelectricalcycleofthemotortodeterminethecommutationphase.Themotormanufacturerusuallygivesthisspecification.Inmanycases,theinformationalsomaybespecifiedasthenumberofpoles.Toconvertfromthenumberofpolestothenumberofcountsperelectricalcycle,usethefollowingformula:
countsperelectricalcycle=CautionCountsperelectricalcyclemustbesetcorrectlytoavoidoverheatinganddamagingyourmotor.
![Page 341: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/341.jpg)
CommutationFrequencyThecontrollerupdatesthecommandvoltageandthecommutationphaseeveryupdateperiod.Tocommutatebrushlessmotorssmoothly,thecontrollermustupdatethephaseatleastsixtimesperelectricalcycle.Therefore,thecommutationfrequencyislimitedbytheupdaterateofthecontrolloop.TocalculatethemaximumcommutationfrequencysupportedataparticularPIDupdaterate,usethefollowingformula:
commutationfrequency=
![Page 342: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/342.jpg)
TroubleshootingHallEffectSensorConnectionsCompletethefollowingstepsifyouhaveproblemswithHalleffectsensorconnections.
1. Checkthemanualsthatshippedwiththehardwareforconnectionprocedures.
2. Performa"shakeandwake"phaseinitialization.Duringthisprocess,themotorisdriventothezerodegreephasepositionwiththecommandedvoltage.Makesurethemotorisclearofanylimitsbeforeyoustart.
3. RecordtheHalleffectsensorsstatesbyreadingtheDIOlinesconnectedtotheHallsensors.RefertothehardwaredocumentationfortheHalleffectsensorlines.ThisisthestateoftheHalleffectsensorsatthezero-degreephaseposition.
4. Commandthemotortomoveforwardataslowvelocity.RecordthestateoftheHalleffectsensorsateachstatetransition.ThestateoftheHalleffectsensorsshouldreturntothestaterecordedinstep2aftersixstatetransitions.
5. UsetheHallsensorstransitionstateastheHallsensorsdiagram.RefertothehardwaredocumentationformoreinformationonHallsensordiagrams.Followtheprocedureoutlinedinthehardwaredocumentation.
![Page 343: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/343.jpg)
SwitchingFeedbackontheFly(NI7350Only)NI7350devicesallowswitchingbetweenfeedbackdeviceswithoutdisablingtheaxis,suchaswhenswitchingbetweenencoderandanalogfeedback.Completethefollowingstepstoconfigureyoursystemforswitchingfeedbackdevicesonthefly:
1. TunethesystemwiththefirstfeedbackdeviceinMAX.2. TunethesystemwiththesecondfeedbackdeviceinMAX.3. StorethefirstsetofPIDgainsusingtheLoadAllPIDParameters
VIorfunction.4. StorethesecondsetofPIDgainsusingtheLoadAllPID
ParametersVIorfunction,followingtheinstructionsintheLoadingaSecondSetofPIDParameterssectionofthetopic.
5. EnablethecontrollertousethesecondsetofPIDparameterswhenswitchingfeedbackontheflyusingtheLoadAdvancedControlParameterVIorfunction.
6. UsetheConfigureAxisResourcesVIorfunctiontoconfiguretheaxistousethefirstfeedbackdevice.
Toswitchbetweenthefirstandsecondfeedbackdevices,callConfigureAxisResourceswiththeotherfeedbackdevicewhentheaxisisnotmoving.
![Page 344: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/344.jpg)
InitializingtheControllerProgrammaticallyYoucaninitializethemotioncontrollerfromwithinaLabVIEW,VisualBasic,orC/C++program,inadditiontoinitializingcontrollersinMeasurement&AutomationExplorer(MAX).RefertothefollowingtableforthestepsyoumusttaketoinitializeacontrollerprogrammaticallyandthefunctionsandVIsyouuseforeachstep.
Step Functionand/orVI1. Clearthe
power-upstate.
UsetheClearPowerUpStatusVIorfunction.
2. Reviewanyerrorsthatoccurredonthecontrollertodeterminehowbesttohandlethem.
UsetheReadErrorMessageVIorfunction.
3. Makesureallaxesarestoppedanddisabled.
UsetheStopMotionVIorfunctionandEnableAxesVIsorfunctions.IntheStopMotionVIorfunction,setStopType(Decel)settoHalt.IntheEnableAxesVIorfunction,setAxisBitmaptoFalseforeachaxisyouwanttodisable.
4. Unconfigurevectorspaces.
UsetheConfigureVectorSpaceVIorfunctionwiththeXAxis,YAxis,andZAxisinputssettoNone.
5. Configureresourcesforaxes.
UsetheConfigureAxisResourcesVIorfunction.
6. Loadallaxisconfigurationoptionsyouwanttouse.
UsetheAxis&ResourceConfigurationVIsorfunctions.
![Page 345: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/345.jpg)
7. InitializeencodersandADCs,asappropriate.
UsetheappropriateVIsorfunctionsontheAnalog&DigitalI/Opalette.
8. Enabletheaxes,butleavethemdeactivated.
UsetheEnableAxesVIorfunction.
9. Loadtheappropriatecontrolloopparameters.
UsetheLoadAdvancedControlParameterVIorfunctionandeitherLoadSinglePIDParameterVIorfunctionorLoadAllPIDParametersVIorfunction.
10. Callhaltonallaxestoactivatethem.
UsetheStopMotionVIorfunctionwithStopType(Decel)settoHaltstop.
11. Configurecaptureandcomparesettings.
UsetheVIsorfunctionsontheMotionI/Opalettetoconfigurethecaptureandcomparesettings.
12. Configurethefollowingoptionalsettings:
ConfiguretrajectorysettingsConfigurefindreferencesettingsConfigureDIOsettingsConfigure
UsethefollowingpalettesorVIs/functionstoconfiguretheoptionalsettings:
TrajectoryControlVIsorfunctionsFindReferenceVIsorfunctionsAnalog&DigitalI/OVIsorfunctionsConfigurePWMOutputVIorfunctionandLoadPWMDutyCycleVIorfunctionGearingVIsorfunctions
![Page 346: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/346.jpg)
PWMsettingsGearing
![Page 347: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/347.jpg)
UsingtheMotionControllerwiththeLabVIEWReal-TimeModuleUsingNI-Motiononareal-time(RT)systemisdesignedtobealmosttransparentforanyonefamiliarwithNI-Motion.UsingNI-MotionwithRTrequiresthefollowinghardwareandsoftware:
NIPXIchassiswithanavailablePXIslotNIPXIMotioncontrollerHostcomputerLabVIEWReal-TimeModuleOneofthefollowingmotionsoftwareoptions:
NI-Motion(73xxcontrollersupport)NISoftMotionController
RefertotheRemoteSystemsandNI-MotiontopicintheMeasurement&AutomationExplorerHelpforMotionfordetailedinstructionsaboutconfiguringtheNImotioncontrolleronaremotePXIchassis.
![Page 348: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/348.jpg)
GlossaryPrefixes Numbers/Symbols A B C D E F G H I J
K L M N O P Q R S T U V W Z
![Page 349: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/349.jpg)
PrefixesSymbol Prefix Valuep pico 10-12
n nano 10-9
µ micro 10-6
m milli 10-3
k kilo 103
M mega 106
G giga 109
T tera 1012
![Page 350: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/350.jpg)
Numbers/SymbolsnV nanovolts 10-9volts
µV microvolts 10-6volts
µΩ microohms 10-6ohms
mΩ milliohms 10-3ohms
MΩ megaohms 106ohms
pA picoamps 10-12amperes
nA nanoamps 10-9amperes
µA microamps 10-6amperes
mA milliamps 10-3amperes
![Page 351: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/351.jpg)
A
A amperesA/D analog-to-digitalabsolutemode Treatthetargetpositionloadedasposition
relativetozero(0)whilemakingamove.absoluteposition Positionrelativetozero.acceleration/deceleration Measurementofthechangeinvelocityasa
functionoftime.Accelerationanddecelerationdescribestheperiodwhenvelocityischangingfromonevaluetoanother,suchasfromastop(zerovelocity)toaspecifiedspeed(targetvelocity)orviceversa.Decelerationisalsoconsiderednegativeacceleration.
activeclosed Asignalisactivewhencurrentisflowingthroughtheoptocoupledinput.
activehigh Signalisactivewhenitsvaluegoeshigh(1).Seealsonon-inverting.
activelow Signalisactivewhenitsvaluegoeslow(0).Seealsoinverting.
activeopen Asignalisactivewhencurrentisnotflowingthroughtheoptocoupledinput.
ADC analog-to-digitalconverteraddress Charactercodethatidentifiesaspecific
location,orseriesoflocations,inmemoryoronahostPCbussystem.
amplifier Drivethatdeliverspowertooperatethemotorinresponsetocontrolsignals.Ingeneral,theamplifierisdesignedtooperatewithaparticularmotortype.Forexample,youcannotuseastepperdrivetooperateaDCbrushmotor.
API applicationprogramminginterface
![Page 352: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/352.jpg)
axis Unitthatcontrolsamotororanysimilarmotionorcontroldevice.
![Page 353: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/353.jpg)
B
b bit—Onebinarydigit,either0or1.baseaddress
MemoryaddressthatservesasthestartingaddressforprogrammableorI/Obusregisters.Allotheraddressesarelocatedbyaddingtothebaseaddress.
binary Numbersystemwithabaseof2.blending Blendingconnectsmovesegmentswhilemaintainingvelocity
withinthegivenphysicalconstraints.Theseconstraintsarethespecificmovesegmentsbeingblended,forexample,velocity,acceleration,deceleration,ands-curveforeachmove.
buffer Temporarystorageforacquiredorgenerateddata(insoftware).
bus Groupofconductorsthatinterconnectindividualcircuitryinacomputer.Typically,abusistheexpansionvehicletowhichI/Oorotherdevicesareconnected.ExamplesofPCbusesaretheISAandPCIbus.
byte Eightrelatedbitsofdata,an8-bitbinarynumber.Alsousedtodenotetheamountofmemoryrequiredtostoreonebyteofdata.
![Page 354: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/354.jpg)
C
CCW counterclockwise—Impliesthedirectionthemotorrotatesin.
closed-loop Broadlyappliedtermrelatingtoanysystemwhereoutputismeasuredandcomparedtoinput.Theoutputisthenadjustedtoreachtheappropriatecondition.Inmotioncontrolthistermappliestoamotionsystemthatusesafeedbackdevicetoprovidepositionandvelocitydataforstatusreportingandaccuratelycontrollingpositionandvelocity.
commutation Sequentialcontrolofswitchedwaveformsfromthepowerdriveramplifierintothemotorphasewindingsthatcausesrotationorlinearmotiondependingonmotortype.Brushtypemotorsauto-commutateduetothebrushcontactwiththemotorwindings.Brushlesstypemotorsrequiretheadvanceinformationofpositionanddirectiontoaccuratelyprovidecorrectwaveformswitchingsequences.Brushlessmotorstypicallyusehall-effecttypesensorstogeneratethecommutationcontrolwaveforms.
controlsystembandwidth
Measureofaclosed-loopsystem'sresponseandistypicallyrepresentedasafrequencyrangeoranupdateperiodforthePIDloopinadigitalservocontroller.Forexample,ifaPIDloophasanupdaterateof250µs,itwouldhaveabandwidthof4kHz.
CPU centralprocessingunitCSR communicationsstatusregisterCW clockwise—Impliesthedirectionthemotorrotatesin.
![Page 355: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/355.jpg)
D
DAC digital-to-analogconverterdataacquisition
Theprocessofcollectingandmeasuringelectricalsignalsfromsensors,transducers,andtestprobesorfixturesandinputtingthemtoacomputerforprocessing.
DC directcurrentDGND digitalgrounddigitalI/Oport
Groupofdigitalinput/outputsignals.
DIP dualinlinepackageDLL DynamiclinklibraryforWindows.ProvidestheAPIforthe
motioncontroldevices.drive Electronicsignalamplifierthatconvertsmotorcontrol
commandsignalsintohigher-voltagesignalssuitablefordrivingmotors.
driver SoftwarethatcontrolsaspecifichardwaredevicesuchasaDAQboardoramotioncontroller.
![Page 356: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/356.jpg)
E
encoder Devicethattranslatesmechanicalmotionintoelectricalsignals;usedformonitoringpositionorvelocityinaclosed-loopsystem.
encoderresolution
NumberofencoderlinesbetweenconsecutiveencodermarkerorZ-bitindexes.Iftheencoderdoesnothaveanindexoutputtheencoderresolutioncanbereferredtoaslinesperrevolution.
![Page 357: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/357.jpg)
F
F faradFIFO First-in-first-outmemorybuffer—thefirstdatastoredisthe
firstdatasenttotheacceptor.FIFOsareoftenusedonDAQdevicestotemporarilystoreincomingoroutgoingdatauntilthatdatacanberetrievedoroutput.Forexample,ananaloginputFIFOstorestheresultsofA/Dconversionsuntilthedatacanberetrievedintosystemmemory,aprocessthatrequirestheservicingofinterruptsandoftentheprogrammingoftheDMAcontroller.Thisprocesscantakeseveralmillisecondsinsomecases.Duringthistime,dataaccumulatesintheFIFOforfutureretrieval.WithalargerFIFO,longerlatenciescanbetolerated.Inthecaseofanalogoutput,aFIFOpermitsfasterupdaterates,becausethewaveformdatacanbestoredontheFIFOaheadoftime.ThisagainreducestheeffectoflatenciesassociatedwithgettingthedatafromsystemmemorytotheDAQdevice.
filterparameters
Indicatesthecontrolloopparametergains(PIDgains)foragivenaxis.
filtering Typeofsignalconditioningthatfiltersunwantedsignalsfromthesignalbeingmeasured.
flashROM Typeofelectricallyreprogrammableread-onlymemory.followingerrortrippoint
Thedifferencebetweentheinstantaneouscommandedtrajectorypositionandthefeedbackposition.Ifthefollowingerrorincreasesbeyondthemaximumallowablevalueentered—referredtoasthefollowingerrortrippoint—themotortripsonfollowingerrorandiskilled,preventingtheaxisfromrunningaway.
freewheel Conditionofamotorwhenpowerisde-energizedandthemotorshaftisfreetoturnwithonlyfrictionalforcestoimpedeit.
full-step Full-stepmodeofasteppermotor—Foratwo-phasemotor,thisreferstoenergizingtwowindingsorphasessimultaneously.
![Page 358: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/358.jpg)
G
Gnd groundGND ground
![Page 359: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/359.jpg)
H
half-step Modeofasteppermotor—Foratwophasemotor,thisreferstoalternatelyenergizingtwowindingsandthenonlyone.Inhalfstepmode,alternatestepsarestrongandweak,butthereissignificantimprovementinlow-speedsmoothnessoverthefull-stepmode.
hex hexadecimalholdingtorque
Forcethatamotorcanprovideorwithstandwhilestillremaininginafixedstoplocationwithoutanyrotation,translationormovement.
homeswitch/homeposition(input)
Referencepositioninamotioncontrolsystemderivedfromamechanicaldatumorswitch.Oftendesignatedasthezeropositioninanabsolutepositionframeofreference.Themotioncontrollerhaltsthemotorifitfindsthisswitchactivewhileperformingafindhomesequence.
hostcomputer
Computerinwhichthemotioncontrollerisinstalled,orthatiscontrollingtheremotesysteminwhichthemotioncontrollerisinstalled.
hybridsteppermotor
Motortypedesignedtomoveindiscretestepincrements,(typicallyspecifiedindegrees).Hybridsteppermotorshavepermanentmagnetrotorelementswithacoilwoundstator(outershell)andnobrushescontactingbetweenthetwo.Thecurrentthroughthecoilphasesisswitchedinapredeterminedsequence(commutated)toproducetheappropriatemotioninagivendirection.
Hz hertz—thenumberofscansreadorupdateswrittenpersecond.
![Page 360: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/360.jpg)
I
I/O input/output—Thetransferofdatatoandfromacomputersysteminvolvingcommunicationschannels,operatorinterfacedevices,dataacquisition,and/ormotioncontrolinterfaces.
ID identificationimportlibrary
Windows-specificfilethatcontainsinformationabouttheVIscontainedinacompaniondynamiclinklibrary(DLL).Windowsapplicationsaretypicallylinkedtooneormoreimportlibraries.
in inchesindex Markerbetweenconsecutiveencoderrevolutions.inverting Definesthepolarityofaswitch(limitswitch,homeswitch,and
soon)whenitisinitsactivestate.Iftheseinputsareactivelowtheyaresaidtohaveinvertingpolarity.Seealsoactivelow.
IRQ interruptrequestISA industry-standardarchitecture
![Page 361: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/361.jpg)
Jjerk Derivativeofacceleration(changeofaccelerationperunittime)
measuredinunitsofcounts(steps)/s3.
![Page 362: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/362.jpg)
K
k kilo—Thestandardmetricprefixfor1,000,or103,usedwithunitsofmeasuresuchasvolts,hertz,andmeters.
K kilo—Theprefixfor1,024,or210,usedwithBinquantifyingdataorcomputermemory.
![Page 363: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/363.jpg)
L
latching Signalthatmaintainsitsvaluewhileinagivenstate,asopposedtoasignalthatmomentarilypulseswhenenteringorexitingastate.
LIFO last-in,first-outlimitswitch/end-of-travelposition(input)
Sensorsthatalertthecontrolelectronicsthatthephysicalendoftravelisnearandthatthemotionmuststop.
![Page 364: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/364.jpg)
M
m metersMCS MoveCompleteStatusmicrostep Proportionalcontrolofenergyinthecoilsofasteppermotor
thatallowsthemotortomovetoorstopatlocationsotherthanthefixedmagnetic/mechanicalpolepositionsdeterminedbythemotorspecifications.Thiscapabilityfacilitatesthesubdivisionoffullmechanicalstepsonasteppermotorintofinermicrosteplocationsthatgreatlysmoothmotorrunningoperationandincreasetheresolutionornumberofdiscretepositionsthatasteppermotorcanattainineachrevolution.
moduloposition
Treatthepositionasifitiswithintherangeoftotalquadraturecountsperrevolutionforanaxis.
MustOff Stateorbitthatisforcedoff(False)ormustbeofftosatisfyacondition.
MustOn Stateorbitthatisforcedon(True)ormustbeontosatisfyacondition.
![Page 365: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/365.jpg)
N
noise Anundesirableelectricalsignal.NoisecomesfromexternalsourcessuchastheACpowerline,motors,generators,transformers,fluorescentlights,solderingirons,CRTdisplays,computers,electricalstorms,welders,radiotransmitters,andinternalsourcessuchassemiconductors,resistors,andcapacitors.Noisecorruptssignalsyouaretryingtosendorreceive.
non-inverting
Definesthepolarityofaswitch(limitswitch,homeswitch,andsoon)whenitisinitsactivestate.Iftheseinputsareactivehightheyaresaidtohavenon-invertingpolarity.Seealsoactivehigh.
![Page 366: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/366.jpg)
O
opencollector
Methodofoutputcapableofsinkingcurrent,butnotsourcingcurrent.
open-loop
Referstoamotioncontrolsystemwherenoexternalsensors,orfeedbackdevices,areusedtoprovidepositionorvelocitycorrectionsignals.
![Page 367: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/367.jpg)
P
packets Commandanddatasentasagroupoveracomputerbus.
PCI peripheralcomponentinterconnect—Ahigh-performanceexpansionbusarchitectureoriginallydevelopedbyInteltoreplaceISAandEISA.PCIisachievingwidespreadacceptanceasastandardforPCsandworkstations;itoffersatheoreticalmaximumtransferrateof132MB/s.
phaseangle/phasemargin
ValuepresentedinPIDLoopTuningBodePlotanalysisthatrepresentstheadvanceorleadofaninputsignaltotheoutputsignalinaclosed-loopservocontroller.Usedtodetermineclosed-loopsystemstabilityatagivencrossoverfrequency.
PIDcontrolloop
proportional-integral-derivativecontrolloop—Acontrolmethodinwhichthecontrolleroutputisproportionaltotheerror,theerrortimehistory,andtherateatwhichtheerrorischanging.Theerroristhedifferencebetweentheobservedandthecommandedvaluesofavariablethatisundercontrolaction.
PIDlooptuning/servocompensation
FlexibleadjustmentoftheProportional,Integral,andDerivativeGainParametersalongwithloopupdaterateorfrequencytoassurestableoperationandappropriatedynamicresponseofaclosed-loopservosystem.
PIVffcontrolloop
proportional-integral-velocityfeedforwardcontrolloop—Acontrolmethodthatoperateswithzeroderivativegainandeithervelocityfeedbackoravelocityblockamplifier.
port 1. Communicationsconnectiononacomputeroraremotecontroller.
2. Digitalport,consistingoffouroreightlinesofdigitalinput,and/oroutput.
positionbreakpoint
Allowsamotortostopatagivenpointsothatanotheraction,suchasadataacquisitionoranimageacquisition,cantakeplace.Youcansetpositionbreakpointsinabsoluteorrelativequadraturecounts.
![Page 368: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/368.jpg)
Whentheencoderreachesapositionbreakpoint,theassociatedbreakpointoutputimmediatelytransitions.
positionresolution
Typicallydeterminedbythesmallestincrementofmotionthatcanbecontrolled.Insteppermotorsystems,itisdeterminedbythenumberofstepsperrevolution,typicallyasalimitationofthestepperdrivermicrosteppingvalueorofthefeedbackdeviceresolution.Inservomotorsystems,itisentirelydeterminedbytheresolutionofthefeedbackdeviceincountsperrevolutionofthemotor.
powercycling Turningthehostcomputeroffandthenbackon.Thisresetsthemotioncontroller.
profile Instantaneouspositionversustimeoutputofatrajectorygenerator.
pull-inmove Whensteppermotorsareruninclosed-loopmode,theencoderfeedbackisusedtoverifythepositionofanaxiswhenthemotionends.Themotioncontrollerthencommandstheaxistodoafinalmovesothatitisatthespecifiedtargetposition.
PWM pulsewidthmodulation—Methodofcontrollingtheaveragecurrentinamotorphasewindingbyvaryingtheon-time(dutycycle)oftransistorswitches.
PXI PCIeXtensionsforInstrumentation
![Page 369: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/369.jpg)
Q
quadraturecounts
Encoderlineresolutiontimesfour.Theencoderresolutionisthenumberofencoderlinesbetweenconsecutiveencoderindexes(markerorZ-bit).Iftheencoderdoesnothaveanindexoutputtheencoderresolutioncanbereferredtoaslinesperrevolution,linesperinch,linespermillimeter,andsoon.
![Page 370: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/370.jpg)
R
RAM random-accessmemoryRDB returndatabufferrelativebreakpoint
Setsthepositionbreakpointforanencoderinrelativequadraturecounts.
relativeposition
Destinationortargetpositionformotionspecifiedwithrespecttothecurrentlocation,regardlessofitsvalue.
relativepositionmode
Treatthetargetpositionloadedaspositionrelativetocurrentpositionwhilemakingamove.
ribboncable
Flatcableinwhichtheconductorsaresidebyside.
ROM read-onlymemory—non-volatilememoryusedforstoringcode,programs,anddata.
rotaryaxis Axisforwhichrotarycountsareloaded.Theaxismovestothetargetpositionbytakingtheshortestpath,eitherforwardorbackwards,whileremainingwithintheonerevolutiondefinedbytheloadedmodulovalue.
RPM revolutionsperminute—Unitsforvelocity.RPSPSorRPS/S
revolutionspersecondsquared—Unitsforaccelerationanddeceleration.
RTR ReadytoReceiveRTSI real-timesystemintegrationbus—theNationalInstruments
timingbusthatconnectscontrollersdirectly,bymeansofconnectorsontopofthecontrollers,forprecisesynchronizationoffunctions.
![Page 371: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/371.jpg)
S
s,sec secondsservo 1. Specifiesanaxisthatcontrolsaservomotor.
2. Specifieswhenaservomotorbecomesactive.
sinusoidalcommutation
Methodofcontrollingcurrentinthewindingsofabrushlessservomotorbyusingthepatternofasinewavetoshapethesmoothdeliveryofcurrenttothreemotorinputs,each120°outofphasefromthenext.
slot PositionwhereamodulecanbeinsertedintoanISAorPCIbackplane.
stepoutputrate
Thefrequencyofthestepoutputcontrolpulsesgeneratedbyacontroller/indexerandprovidedtoanamplifierdriver.Thecombinationofstepoutputrate(steps/s),stepsperrevolution(steps/rev),andtime(60s/minute)provideabasicrepresentationofmotorvelocityinRPM.Linearspeedmaybefurtherderivedbyadditionalmechanicaldata,leadscrewrevolutionsperinch,andsoon.
stepper Specifiesanaxisthatcontrolsasteppermotor.
![Page 372: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/372.jpg)
T
toggle Changingstatefromhightolow,backtohigh,andsoon.torque Forcetendingtoproducerotation.totempole Methodofoutputcapableofsinkingandsourcingcurrent.trapezoidalprofile
Typicalmotiontrajectory,whereamotoracceleratesuptotheprogrammedvelocityusingtheprogrammedacceleration,traversesattheprogrammedvelocity,andthendeceleratesattheprogrammedaccelerationtothetargetposition.
trigger Anyeventthatcausesorstartssomeformofdatacapture.triggerbufferinputs
Digitalsignalthatbeginstheexecutionofasequenceofmotioncommandsstoredonthecontroller/indexerallowingthecommandstofullyexecuteuntiltheendofthesequenceisreached.
TTL transistor-transistorlogic
![Page 373: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/373.jpg)
UUOM unitofmeasure
![Page 374: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/374.jpg)
V
V voltsvelocitymode Movetheaxiscontinuouslyataspecifiedvelocity.
![Page 375: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/375.jpg)
W
watchdog Timertaskthatshutsdown,orresets,themotioncontroldeviceifanyseriouserroroccurs.
word Standardnumberofbitsthataprocessorormemorymanipulatesatonetime,typically8-bit,16-bit,or32-bit.
![Page 376: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/376.jpg)
ZZ-bit Markerorindexbetweenconsecutiveencoderrevolutions.
![Page 377: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/377.jpg)
ImportantInformationWarrantyCopyrightTrademarksPatentsWarningRegardingUseofNIProducts
![Page 378: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/378.jpg)
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 379: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/379.jpg)
accrues.NationalInstrumentsshallnotbeliableforanydelayinperformanceduetocausesbeyonditsreasonablecontrol.Thewarrantyprovidedhereindoesnotcoverdamages,defects,malfunctions,orservicefailurescausedbyowner'sfailuretofollowtheNationalInstrumentsinstallation,operation,ormaintenanceinstructions;owner'smodificationoftheproduct;owner'sabuse,misuse,ornegligentacts;andpowerfailureorsurges,fire,flood,accident,actionsofthirdparties,orothereventsoutsidereasonablecontrol.
![Page 380: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/380.jpg)
CopyrightUnderthecopyrightlaws,thispublicationmaynotbereproducedortransmittedinanyform,electronicormechanical,includingphotocopying,recording,storinginaninformationretrievalsystem,ortranslating,inwholeorinpart,withoutthepriorwrittenconsentofNationalInstrumentsCorporation.NationalInstrumentsrespectstheintellectualpropertyofothers,andweaskouruserstodothesame.NIsoftwareisprotectedbycopyrightandotherintellectualpropertylaws.WhereNIsoftwaremaybeusedtoreproducesoftwareorothermaterialsbelongingtoothers,youmayuseNIsoftwareonlytoreproducematerialsthatyoumayreproduceinaccordancewiththetermsofanyapplicablelicenseorotherlegalrestriction.
![Page 381: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/381.jpg)
TrademarksNationalInstruments,NI,ni.com,andLabVIEWaretrademarksofNationalInstrumentsCorporation.RefertotheTermsofUsesectiononni.com/legalformoreinformationaboutNationalInstrumentstrademarks.FireWire®istheregisteredtrademarkofAppleComputer,Inc.HandleGraphics®,MATLAB®,Real-TimeWorkshop®,Simulink®,Stateflow®,andxPCTargetBox®areregisteredtrademarks,andTargetBox™andTargetLanguageCompiler™aretrademarksofTheMathWorks,Inc.Tektronix®andTekareregisteredtrademarksofTektronix,Inc.Otherproductandcompanynamesmentionedhereinaretrademarksortradenamesoftheirrespectivecompanies.MembersoftheNationalInstrumentsAlliancePartnerProgramarebusinessentitiesindependentfromNationalInstrumentsandhavenoagency,partnership,orjoint-venturerelationshipwithNationalInstruments.
![Page 382: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/382.jpg)
PatentsForpatentscoveringNationalInstrumentsproducts,refertotheappropriatelocation:Help»Patentsinyoursoftware,thepatents.txtfileonyourCD,orni.com/patents.
![Page 383: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/383.jpg)
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 384: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/384.jpg)
APPLICATIONDESIGNERISULTIMATELYRESPONSIBLEFORVERIFYINGANDVALIDATINGTHESUITABILITYOFNATIONALINSTRUMENTSPRODUCTSWHENEVERNATIONALINSTRUMENTSPRODUCTSAREINCORPORATEDINASYSTEMORAPPLICATION,INCLUDING,WITHOUTLIMITATION,THEAPPROPRIATEDESIGN,PROCESSANDSAFETYLEVELOFSUCHSYSTEMORAPPLICATION.
![Page 385: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/385.jpg)
TechnicalSupportandProfessionalServicesVisitthefollowingsectionsoftheNationalInstrumentsWebsiteatni.comfortechnicalsupportandprofessionalservices:
Support—Onlinetechnicalsupportresourcesatni.com/supportincludethefollowing:
Self-HelpResources—Foranswersandsolutions,visittheaward-winningNationalInstrumentsWebsiteforsoftwaredriversandupdates,asearchableKnowledgeBase,productmanuals,step-by-steptroubleshootingwizards,thousandsofexampleprograms,tutorials,applicationnotes,instrumentdrivers,andsoon.FreeTechnicalSupport—AllregisteredusersreceivefreeBasicService,whichincludesaccesstohundredsofApplicationsEngineersworldwideintheNIDiscussionForumsatni.com/forums.NationalInstrumentsApplicationsEngineersmakesureeveryquestionreceivesananswer.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/niglobaltoaccessthebranchofficeWebsites,whichprovideup-to-datecontactinformation,supportphonenumbers,emailaddresses,andcurrentevents.
![Page 386: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/386.jpg)
BranchOfficesOffice TelephoneNumberAustralia 1800300800Austria 43662457990-0Belgium 32(0)27570020Brazil 551132623599Canada 8004333488China 862165557838CzechRepublic 420224235774Denmark 4545762600Finland 385(0)972572511France 33(0)148142424Germany 49897413130India 918041190000Israel 972036393737Italy 3902413091Japan 81354722970Korea 820234513400Lebanon 961(0)1332828Malaysia 1800887710Mexico 018000100793Netherlands 31(0)348433466NewZealand 0800553322Norway 47(0)66907660Poland 48223390150Portugal 351210311210Russia 74957836851Singapore 18002265886Slovenia 38634254200
![Page 387: NI-Motion™ Help · help you develop NI-Motion applications. This help file is intended for experienced LabVIEW, C/C++, or other developers. Code instructions and examples assume](https://reader036.vdocuments.us/reader036/viewer/2022062605/5fcca38bdf463a49b64fff05/html5/thumbnails/387.jpg)
SouthAfrica 270118058197Spain 34916400085Sweden 46(0)858789500Switzerland 41562005151Taiwan 8860223772222Thailand 6622786777Turkey 902122793031UnitedKingdom 44(0)1635523545UnitedStates(Corporate) 5126830100