Quote:
Originally Posted by Ether
Yeah, I gave some passing thought to that but didn't spend the time to-rework it to get the same result with modulo.
|
OK, I came back and took a closer look at this. The mod function is not the way to do it. The floor function gives the desired result:
Code:
angle_error = joystick_command - gyro_angle;
angle_error -= 360*floor(0.5+angle_error/360);
setpoint = gyro_angle + angle_error;
If your compiler supports the
REMAINDER function "x
REM y" per IEC 60559 (mine does not so I have not tested this) as specified on Page 235 Section 7.12.10.2 of ISO/IEC 9899:TC3, then I believe the following should work:
Code:
angle_error = remainder(angle_error,360);
The above can be done in LabVIEW as shown in either of the two attached screenshots.