Skip to main content

System startup

Define the function SystemStartup()

void  SystemStartup()
{
cout<<"Library version:"<< NRC_GetNexMotionLibVersion()<<endl;//Output NexMotion library version information
NRC_StartController(); //Start control system
while(NRC_GetControlInitComplete() != 1) //Detect whether the control system is initialized
{
NRC_Delayms(100); //Delay 100ms
cout << "Starting Controller" << endl;
}
}

In the code, we mainly use the following interfaces:

  • NRC_GetNexMotionLibVersion(): Get NexMotion library version information
  • NRC_StartController(): Start control system
  • NRC_GetControlInitComplete(): Get the initialization status of the controller, true means success, false means it has not been initialized yet
  • NRC_Delayms(): Delay function, in milliseconds (ms)

and call them in the main function

int main()
{
SystemStartup();//System startup
while(1)//Keep the program running
{
NRC_Delayms(1000);
}
}

The complete code is as follows

#include <iostream>
#include "nrcAPI.h"
using namespace std;

void SystemStartup(){
cout<<"Library version:"<< NRC_GetNexMotionLibVersion()<<endl;//Output Nexmotion library version information
NRC_StartController(); //Start control system
while(NRC_GetControlInitComplete() != 1) //Detect whether the control system is initialized
{
NRC_Delayms(100); //Delay 100ms
cout << "Starting Controller" << endl;
}
}
int main()
{
SystemStartup();//System startup
while(1)//Keep the program running
{
NRC_Delayms(1000);
}
}