Example Programs

Showing results for 
Search instead for 
Did you mean: 

4DOF IK implemented in NI MathScript Maintaining Perpendicular End Effector in LabVIEW


This example demonstrates using the NI MathScript node to calculate required angles (and PWM values) to move the end effector of a 4 DOF robotic arm to a given position in XYZ co-ordinates, while keeping the End Effector perpendicular to the base.



This code was written as part of a project to use a myRIO to control a Draughts playing robot. A robotic arm was used to pick and place the pieces based instructions from the AI.


This piece of code uses the MathScript node to implement the Inverse Kinematic equations derived for this task. It allows for the dimensions etc. to be changed, so long  as consistent units are used throughout.

Information about the Inverse Kinematic equations can be found in the attached Excel sheet.


The calibration equations for the servo's were based on moving each servo to two points, and then using them to derive a straight line equation based on y=mx+c, where y is the PWM value and x is the angle.



LabVIEW 2013 (or compatible)


Steps to Implement or Execute Code

  1. Enter the XYZ position you wish to move to
  2. Enter the Arm Dimensions
  3. Enter constants (m and c) into the indicated section of the MathScript node which correspond to your servos
  4. Run the code


Additional Information or Resources

VI Block Diagram


Derivation of the Algorithm



**This document has been updated to meet the current required format for the NI Code Exchange.**


Al C
National Instruments,
Application Engineer
Member nickksh

Hi icouldnt find the type definition available so i was not able to run the program. could you please provide them also.


Member Al.C

Hi nickksh,

Thank you for flagging this up, I have uploaded the .ctl files for LV 13.


Al C
National Instruments,
Application Engineer
Member nickksh

Hello AI.C

I followed your program and got the concept u are using but I am sorry I am not able to get the angles for my robotic arm correct. In regards to my arm the servos are contrained by 180 degrees with angles going from -90 to +90. I did implement some changes but still the angles fail to work. could you please explain where am i going wrong.