Skip to content

Resetting phase index in velocity mode #2

Description

@JohnJohanssonChalmers

In the functions Roll1_vel() and Roll2_vel() the following code is supposed to keep the phase index in the interval 0 to 2*pi:

	//RESET PHASE INDEX AFTER 2PI
	if (phaseindex1 >= 2*pi) {   //Reset phaseindex_U1 once it completes 2*180o in phase.
		phaseindex1 = 0;
	}
	else if (phaseindex1 <= 0){
		phaseindex1 = 2*pi - phaseindex1;
	}

For the case of phaseindex1 <= 0, I believe is should really be phaseindex1 = 2*pi + phaseindex1; rather than phaseindex1 = 2*pi - phaseindex1;. For the case of phaseindex1 >= 2*pi, it's not really wrong, but setting it to 0 could cause a small speed inconsistency. It would be better to use phaseindex1 = phaseindex1 - 2*pi;.

All together, I would propose the following code:

	//RESET PHASE INDEX AFTER 2PI
	if (phaseindex1 >= 2*pi) {   //Reset phaseindex_U1 once it completes 2*180o in phase.
		phaseindex1 -= 2*pi;
	}
	else if (phaseindex1 < 0){
		phaseindex1 += 2*pi;
	}

The reason I found this was that I experienced that the motor got stuck after rotating just a little bit at certain speeds. I believe this is due to the controller getting stuck in an infinite loop jumping between the edge cases. It only seems to happen at certain negative speeds, which I think is due to floating point imprecision.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions