Go to Post Brandon Martus, making CD readers' lives easier since May 2001/Fall 98 - Beth Sweet [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 12-02-2009, 06:24
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Problems with using 330's goal tracking code

Hi, We took team 330's goal tracking code and made modifications so that the X axis output would be to control a victor for a turret. We pretty much just removed the Y-axis PID control loop and are using only the X-axis PID control loop for control the position of a turret. When we run the code, the bot finds the target and oscillates left and right. I increased the integral gain to reduce the steady state error, but there was no improvement. I also tried playing around with the proportional and derivative gains, but there was also no improvement.

Has anyone attempted what I'm doing and might know the source of my problem?

I attached two screenshots of my code for reference. As an incentive, feel free to use my ideas for your bot as well if you feel that they are useful to you. All the credit should go to team 330 though!
Attached Files
File Type: pdf goal_track_main.pdf (215.1 KB, 83 views)
File Type: pdf goal_track.pdf (169.9 KB, 68 views)

Last edited by windell747 : 12-02-2009 at 06:27.
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2009, 06:33
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Problems with using 330's goal tracking code

I have a private message from Matt Krass from a very long time ago that seems to apply here:

Quote:
Originally Posted by Matt Krass
How are you tuning your PID? The proper method is to tune P until you have a constant, minor oscillation that's stable, and then increase I until it stabilizes, then start to oscillate again, and then turn up D until it stabilizes. Tweak and tune as necessary, YMMV
I personally have never used D. I gave up working on the mental gymnastics to make it work on our non-floating-point controller last year, and haven't done much at all with the cRIO. These young whipper-snappers...when I was your age, we had to use fixed-point math, and walk uphill--both ways--to the competition field...

I'm sure someone a bit more qualified to answer will see this post later today, and you will get a collection of responses better-constructed and -advised than mine.

Good luck,
Jacob
__________________
Aren't signatures a bit outdated?
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2009, 06:49
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Problems with using 330's goal tracking code

Thanks for the tuning procedure, Jacob! I will definitely try your suggestion! I'm really concerned that I have a bug in my code somewhere that I'm not seeing. Before I assume that it is a tuning problem, I really would like a fresh set of eyes to take a look at my code and see if there is anything fishy.

Your advice is great Jacob! Thanks for the quick reply...i'm actually loosing sleep over this code!

Last edited by windell747 : 12-02-2009 at 06:55.
Reply With Quote
  #4   Spotlight this post!  
Unread 12-02-2009, 08:04
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,748
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: Problems with using 330's goal tracking code

Someone else may be able to tell you exactly what to change, but I don't see it. What I'd do is modify the code to plot your process variable and your output against time. If you post that, people can tell you much more about your system.

To get the plot, take the vision value you are trying to center and bundle it with the output of the PID. Then wire the cluster to a waveform chart. Next you "bump" the system. Start with the target in the center and move it to one side pretty quickly and hold it there until the control system moves to that area. Do this again to the other side. You may need to increase the X scale or even the history length to log enough data.

Greg McKaskle
Reply With Quote
  #5   Spotlight this post!  
Unread 12-02-2009, 12:03
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,557
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Problems with using 330's goal tracking code

Jacob's recommendation on tuning P first is exactly what you should do. We've used PID controllers for the past 5 years, and used just P control on almost all of them. There are several good white papers on CD about PID, including one by Matt Krass. Greg's suggestion of plotting the values is a good one. One way to get the step input is to change the setpoint. See also, the following excerpt from the PID article on wikipedia: http://en.wikipedia.org/wiki/PID_con...#Manual_tuning. Once you understand the manual process, you could try to play around with autotuning: http://forums.usfirst.org/showthread.php?t=10555


The example was optimized for driving on the regolith, so there's a few things you'd probably want to change for driving a turret.

The first thing I'd do is remove the PID rate limiter. This was designed to keep the wheels from slipping. Hopefully your turret doesn't have that problem. Leaving that in there will slow down the response and make it more likely to oscillate.

I'd also replace the robot drive VIs with the motor control VIs. Since you aren't using the features of robot drive, I'd go with the lower overhead.

You mentioned using a Victor speed controller. I'd highly recommend using a jaguar. It will give a more linear response (PID is designed for linear systems). It also gives you much better slow speed control, which will help in reducing the oscillations. http://forums.usfirst.org/showthread.php?t=10182
Reply With Quote
  #6   Spotlight this post!  
Unread 12-02-2009, 16:37
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Problems with using 330's goal tracking code

Thanks for the replies Joe and Greg! Since you guys haven't mentioned anything about the layout of my code, can I assume that you think my code layout is correct, but I need to adjust the PID gains? I just want to validate my code before I start tuning.

Right now I'm testing the code by having it turn the bot towards the goal to ensure that the code is written correctly. I understand that I'll need to change the gains for the turret application, but it will be nice to know that the gains is all i need to change. When I ran the code out of the box from the team 330 posting, I figured that since our bots are similar in size, mass and drive configuration (tank drive) that their PID gains would be close to what I would want. So when I saw the bot oscillating, I immediately thought that it was a code problem. Just for confirmation, the out of the box gains in the program was proportional=0.5, derivative=integral=0.0.

Thanks!

Last edited by windell747 : 12-02-2009 at 16:39.
Reply With Quote
  #7   Spotlight this post!  
Unread 12-02-2009, 17:25
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,557
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Problems with using 330's goal tracking code

Quote:
Originally Posted by windell747 View Post
When I ran the code out of the box from the team 330 posting, I figured that since our bots are similar in size, mass and drive configuration (tank drive) that their PID gains would be close to what I would want. So when I saw the bot oscillating, I immediately thought that it was a code problem. Just for confirmation, the out of the box gains in the program was proportional=0.5, derivative=integral=0.0.
The out of the box settings were 0.05 for P, 0 for the others. Due to a few mistakes, the settings in the code didn't match the settings from the video. I think the gains might have been the very, but the maximum output values were higher in the code then the video. I figured that most people would have to tune the values anyway, so I didn't spend the extra time to recreate the ones from the video. Sorry for leading you down the wrong path.
Reply With Quote
  #8   Spotlight this post!  
Unread 12-02-2009, 23:49
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Problems with using 330's goal tracking code

No worries, Joe! Thanks for the reply! is it possible to get an example set of gains from you so that I have something to start with that will tell me weather or not the code is correct and that the problem is only with tuning? Maybe not your best set of parameters, but something that converges to no error over time. That way if mine doesn't converge then I know something is wrong.

I'm a fulltime engineering student and although I would like to mentor the team all day and get things just right, I have to do my studies too so it is hard sometimes to find the time to tune things from scratch. Again im not asking for competition gains, but something that will guarantee converge. Thanks!
Reply With Quote
  #9   Spotlight this post!  
Unread 14-02-2009, 16:04
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Problems with using 330's goal tracking code

Thanks for your help! It looks like I was able to get the response to converge. here are my gains for anyone interested. x-axis0.003,I0.5. y-axis: P0.015,I0.70. derivative terms 0. max x=0.45,max y=0.7

I'm trying to plot the x and y axis outputs to a graph but im having some trouble. I'm using the plot waveform and feeding to the input a get waveform time array, but im not getting the correct data types. Can anyone briefly explain the process to do this?

Thanks!
Reply With Quote
  #10   Spotlight this post!  
Unread 14-02-2009, 16:14
airnate airnate is offline
Registered User
FRC #0236 (Techno Ticks)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: southeastern CT
Posts: 93
airnate is a jewel in the roughairnate is a jewel in the roughairnate is a jewel in the rough
Re: Problems with using 330's goal tracking code

One of the easiest ways to do this is to:

1. Go to your Front Panel
2. Select Express->Graph Indicators->XY Graph (aka Express XY Graph)
3. On the block diagram, wire your X and Y inputs
4. Double click the Build XY Graph on the block diagram and turn off Clear Data on Each Call.

-Nate
Reply With Quote
  #11   Spotlight this post!  
Unread 15-02-2009, 22:57
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Problems with using 330's goal tracking code

how do you put time values for the x variable each iteration? I guess I could just put a counter that increments, but im not sure how to do this either. I would like to not use a for loop. Any suggestions?

Last edited by windell747 : 15-02-2009 at 23:04.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with tracking Shinsa Programming 2 07-02-2010 14:35
Using kevin's code for driving and camera tracking razzoc Programming 3 18-02-2007 08:50
Enabling Multiple Light Tracking Using Kevin's Code Mitch Programming 7 05-02-2007 06:17
problems using gyro/adc code with camera default code tanstaafl Programming 7 22-01-2006 23:09
Problems tracking with CMUCam2 in LabVIEW PhilBot LabView and Data Acquisition 5 17-01-2006 20:42


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

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