Go to Post Engineers can really make a difference when people are in their time of need. - Elgin Clock [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 02-12-2011, 11:58 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,998
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: LabVIEW PID for angles


Quote:
Originally Posted by Ether View Post
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.


Attached Thumbnails
Click image for larger version

Name:	angle_error correction floor.png
Views:	285
Size:	2.5 KB
ID:	10083  Click image for larger version

Name:	angle_error correction.png
Views:	265
Size:	2.0 KB
ID:	10084  
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:43 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi