Here you can find the MATLAB code for the algorithm described in the paper, Position-based kinematics for 7-DoF serial manipulators with global configuration control, joint limit and singularity avoidance.
The code was developed and tested with the kinematic structure of a KUKA iiwa R800.
I highly recommend installing the Peter Corke's Robotics Toolbox (https://petercorke.com/toolboxes/robotics-toolbox/).