A brief demonstration of how to interact with various RapidCode objects in RapidScript.
- Warning
- This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.
The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.
- Precondition
- This sample application requires:
1. At least one network node (drive or I/O) if using HelloNetworkNode()
2. At least one I/O node if using HelloIO()
3. At least one axis (phantom or real) if using HelloAxis()
4. At least one multiaxis if using HelloMultiAxis()
📜 Hello Sequencer Sample App
A sample application that calls one of the following functions from the main()
function:
1. HelloMotionController()
2. HelloAxis()
3. HelloIO()
4. HelloNetworkNode()
5. HelloMultiAxis()
6. HelloEnum()
7. HelloArray()
To change what function(s) is/are called, edit the contents of the main()
function and add the desired functions from the list above.
1global int32 globalSerialNumber;
5 HelloMotionController();
8void HelloMotionController()
10 int32 serialNumber = ControllerSerialNumberGet();
11 print(
"MotionController serial number is " + serialNumber);
12 globalSerialNumber = serialNumber;
17 uint32 axisNumber = 0;
18 double commandPosition = AxisCommandPositionGet(axisNumber);
19 print(
"Axis " + axisNumber +
" CommandPosition is " + commandPosition);
25 int32 digitalInNumber = 0;
26 bool inputState = IODigitalInGet(ioNumber, digitalInNumber);
27 print(
"IO node " + ioNumber +
" Digital Input bit number " + digitalInNumber +
" state is " + inputState);
30void HelloNetworkNode()
32 uint32 networkNodeNumber = 1;
33 string nodeName = NetworkNodeNameGet(networkNodeNumber);
34 print(
"Node " + networkNodeNumber +
" is a " + nodeName );
39 uint32 multiAxisNumber = 2;
40 int32 axisCount = MultiAxisAxisCountGet(multiAxisNumber);
41 print(
"MultiAxis " + multiAxisNumber +
" Axis Count is " + axisCount);
42 MultiAxisAbort(multiAxisNumber);
43 MultiAxisClearFaults(multiAxisNumber);
48 enum operational = 260;
49 enum currentState = ControllerNetworkStateGet();
51 if(currentState == operational)
53 print(
"Network is OPERATIONAL");
57 print(
"Network is not operational");
63 string arrayId =
"anyUniqueStringHere";
65 array_create(arrayId, arraySize);
67 array_set(arrayId, 0, 111.111);
68 array_set(arrayId, 1, 222.222);
69 array_set(arrayId, 2, 333.333);
71 for(uint64 i = 0; i < arraySize; ++i)
73 print(i +
" = " + array_get(arrayId, i));
75 array_destroy(arrayId);
Learn more in topic page.