Function that calculates QRef for the Q mode and the U mode depending on the setpoints for URef and QRef