Go to Post So we can bring 6x more to the Lunar Regional than all other regionals? no fair to those not going! - BBray_T1296 [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-01-2011, 11:58
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
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
LabVIEW PID for angles


Is there a LabVIEW PID vi that has the built-in smarts
to generate the proper error angle (magnitude and sign)
if given a joystick command (e.g atan2(Xj,-Yj)*(180/pi)) as the setpoint
and the gyro angle as the process variable?


Reply With Quote
  #2   Spotlight this post!  
Unread 30-01-2011, 16:52
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: LabVIEW PID for angles

I don't fully understand what your question says, but I think I can figure out why you're asking it.

Would it be sufficient for your purpose if there were a function that took two angles and added a multiple of 360 degrees to the first angle so that it was within 180 degrees of the second one?

Or maybe you want to subtract two angles and modify the difference by adding a multiple of 360 degrees so that it was within the range -180 to +180?
Reply With Quote
  #3   Spotlight this post!  
Unread 30-01-2011, 18:40
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
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

Is there a LabVIEW PID vi that has the built-in smarts
to generate the proper error angle (magnitude and sign)
if given a joystick command (e.g atan2(Xj,-Yj)*(180/pi)) as the setpoint
and the gyro angle as the process variable?
I should clarify things a bit.

I am asking if LabVIEW has a PID designed to handle angular process_variable and setpoint inputs directly, without having to do something like this externally:


Code:
angle_error = joystick_command - gyro_angle;
while(angle_error>180)angle_error-=360;
while(angle_error<-180)angle_error+=360;
setpoint = gyro_angle + angle_error;
... and then feed the fabricated setpoint and the gyro_angle into the PID's setpoint and process_variable inputs, respectively.

Not that this is difficult to do, just wondering if there is a PID with this built-in capability.


Reply With Quote
  #4   Spotlight this post!  
Unread 30-01-2011, 20:51
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: LabVIEW PID for angles

Quote:
Originally Posted by Ether View Post
I am asking if LabVIEW has a PID designed to handle angular process_variable and setpoint inputs directly,...
LabVIEW PID functions don't care whether the variables represent angles, speeds, temperatures, etc. They're just numbers.

It seems that the specific application you have in mind assumes motor control of a mechanism capable of continuous rotation and negligible time for changing direction. That's not the only kind of mechanism one might want to control based on angle. Since each application is going to have its own requirements, a built-in function would have to have a lot of options, and it still might not accommodate some needs.

I think you're trying to ask whether there is a built-in function that combines PID with the specific way you want angular errors to be computed. You're the one who knows how you want it to work, so I don't think it's any great burden to have you implement that part of it yourself.
Reply With Quote
  #5   Spotlight this post!  
Unread 30-01-2011, 21:39
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: LabVIEW PID for angles

Just to confirm, no. If there are special conditions with the input or output of the PID, you add those to the front or back.

By the way, the integer divide is the LV way to do modulo math.

Greg McKaskle
Reply With Quote
  #6   Spotlight this post!  
Unread 30-01-2011, 21:40
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
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
I should clarify things a bit.

I am asking if LabVIEW has a PID designed to handle angular process_variable and setpoint inputs directly, without having to do something like this externally:


Code:
angle_error = joystick_command - gyro_angle;
while(angle_error>180)angle_error-=360;
while(angle_error<-180)angle_error+=360;
setpoint = gyro_angle + angle_error;
... and then feed the fabricated setpoint and the gyro_angle into the PID's setpoint and process_variable inputs, respectively.

Not that this is difficult to do, just wondering if there is a PID with this built-in capability.

The pre-processing shown above is of course a general solution to a wide class of angular position-control applications, of which FRC robot rotational orientation is but one example. Unlike linear position control or limited-rotation angular position control, control of angular rotational position in continuous-rotation situations requires that the wrap-around be considered.

There is a lot of interest here on CD about using gyro angular position to control robot orientation. A continuous-rotation wrapper around the LabVIEW PID might for some folks be a helpful addition to the WPI Library next year.


Reply With Quote
  #7   Spotlight this post!  
Unread 30-01-2011, 21:47
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
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 Greg McKaskle View Post
Just to confirm, no.
OK, thanks Greg.


Quote:
By the way, the integer divide is the LV way to do modulo math.
Yeah, I gave some passing thought to that but didn't spend the time to-rework it to get the same result with modulo.


Reply With Quote
  #8   Spotlight this post!  
Unread 12-02-2011, 23:58
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
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:	290
Size:	2.5 KB
ID:	10083  Click image for larger version

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


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 10:10.

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