Singularity error number?

The most common singularity problem is when axis 5 goes thru 0 deg in linear motion (+ to - or - to +). There are some other cases when using bend back robots. So one way could be that you check where axis 5 is right now and then Use CalcJointT to calculate the axis values for the target you want to go to and see axis 5 is going thru 0 deg.