Go to Post I check CD while I'm waiting for ProE to reload everytime it crashes. So that's about 20 times a day :ahh: - Gary Dillard [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-02-2007, 22:30
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Gyro PID User drive - How we did it

Quote:
Originally Posted by tdlrali View Post
Looks great!

Hey Alan, is 254 really the max in the IFI setup? I always thought 255 was the max... I think I incorrectly corrected a few people if that is the case.
255 can do some wierd stuff. Way back in 2003, I couldn't figure out why our robot wouldn't drive straight. Another team pointed out that 255 was some sort of null character. I changed it to 254, and the thing started driving perfectly.
Quote:
The X axis sets the "desired" heading.
Last year we found that our robot could massively out-spin the maximum rotation rate supported by the gyro. What do you do once the gyro reading goes 'beyond' the maximum/minimum of the chip?
  #2   Spotlight this post!  
Unread 25-02-2007, 23:04
Render Render is offline
Registered User
AKA: Robert Udicious
FRC #1885 (Robocats)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Haymarket, Virginia
Posts: 18
Render will become famous soon enoughRender will become famous soon enough
Re: Gyro PID User drive - How we did it

one way you could improve your code is remove the floats since they are very expensive to the processor and replace them with a numerator and denominator. Then when doing your math you do everything for that portion and divide last.

ex.
char Kp = 5;
char kpDiv = 100;

pTerm = (Kp * p_error) / KpDiv;

You will lose the precision of having a floating point value in the end, but with PWM values I do not think that matters anyways

also I am wondering why your errors are floats?

Last edited by Render : 25-02-2007 at 23:08.
  #3   Spotlight this post!  
Unread 25-02-2007, 23:28
adamdb adamdb is offline
Registered User
#1583
 
Join Date: Feb 2005
Location: Parker, CO
Posts: 64
adamdb has a spectacular aura aboutadamdb has a spectacular aura aboutadamdb has a spectacular aura about
Re: Gyro PID User drive - How we did it

Alan,
I did sort of say we weren't using the I component by saying we were using P&D, but should have been a little more clear. I took a pass through the comments, but as usual missed a few that no longer matched up with the code. Odd that you have had issues with 255, we have always used it without issues.

Don,
The drive setup is a typical setup with one motor on each side (facing opposite directions) that power the drive wheels on that side. As the motors face opposite directions we need to do the inversion for (in our case) the right side as shown in the bottom of the PID_adjust() routine.

// Invert the right output and put them to the wheels
OUT_PWM_LM = left_out;
OUT_PWM_RM = 255 - right_out;

I definitely urge you to play with the gyro and this code and the other available examples for driving the robot. We hadn't used a gyro in previous years because I didn't understand them or PID routines, but dug into it this year and did some reading and the result has been great.

Render,
As I mentioned in the original post the code was not optimized for size or speed and we will get rid of the floats in future revisions. The errors were made floats so it didn't have to add code to convert from an integer to floating point before it made the calculations.

Thanks all for the feedback!
Adam
  #4   Spotlight this post!  
Unread 26-02-2007, 11:14
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,113
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: Gyro PID User drive - How we did it

Quote:
Originally Posted by tdlrali
Hey Alan, is 254 really the max in the IFI setup?
The proper maximum pwm output is indeed 254. Here is one bit of documentation to that effect:
Quote:
Originally Posted by IFI Tech Support
In the Robot Controller program, a value of 0 corresponds to a 1ms pulse. A 1.5ms pulse means neutral, or a value of 127, while a 254 corresponds to a 2ms pulse.
See also this post on the IFI Technical Support forum, which shows the range 231-254 as "Full Forward" on a Victor.
Quote:
Originally Posted by Bongle View Post
255 can do some wierd stuff. Way back in 2003, I couldn't figure out why our robot wouldn't drive straight. Another team pointed out that 255 was some sort of null character. I changed it to 254, and the thing started driving perfectly.
The communication protocol between OI and RC uses a pair of 255 (0xFF) characters to synchronize frames of data. Back in the pre-C days, it might have been possible to confuse it by setting adjacent pwm values to 255. My experience is with the 2004 and later control system, which refuses to report a pwm value greater than 254. I don't know whether the limit is enforced on the actual pwm output or if it's just the dashboard data coming back from the RC that won't go that high.
  #5   Spotlight this post!  
Unread 26-02-2007, 15:29
adamdb adamdb is offline
Registered User
#1583
 
Join Date: Feb 2005
Location: Parker, CO
Posts: 64
adamdb has a spectacular aura aboutadamdb has a spectacular aura aboutadamdb has a spectacular aura about
Re: Gyro PID User drive - How we did it

Tom,
I saw your post of your PID code, thanks! Reviewing this with my programming students will be a great learning exercise as we haven't covered structures yet.

Alan,
Thanks for the info on the max value of 254. Looks like we need to go through our code and make some changes.
__________________
Adam Bryant
Programming Mentor
Team 1583
Ridge View Academy Rambotics
  #6   Spotlight this post!  
Unread 26-02-2007, 15:33
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Gyro PID User drive - How we did it

Quote:
Originally Posted by adamdb View Post
Tom,
I saw your post of your PID code, thanks! Reviewing this with my programming students will be a great learning exercise as we haven't covered structures yet.
That was Billy's from 1124. Either way, its a pretty good way to get into structures. It covers typedefs, local declarations, and pointers.
  #7   Spotlight this post!  
Unread 26-02-2007, 17:00
artdutra04's Avatar
artdutra04 artdutra04 is offline
VEX Robotics Engineer
AKA: Arthur Dutra IV; NERD #18
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2002
Location: Greenville, TX
Posts: 3,078
artdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond repute
Re: Gyro PID User drive - How we did it

Quote:
Originally Posted by Bongle View Post
Last year we found that our robot could massively out-spin the maximum rotation rate supported by the gyro. What do you do once the gyro reading goes 'beyond' the maximum/minimum of the chip?
Team 228 purchased an additional 300 degree/second gyro for use with PID control with our drivetrain, as this proved much more adequate for drive-train use than the Kit of Parts gyro. So we used the stock KoP gyro for PID control on our arm instead.
__________________
Art Dutra IV
Robotics Engineer, VEX Robotics, Inc., a subsidiary of Innovation First International (IFI)
Robowranglers Team 148 | GUS Robotics Team 228 (Alumni) | Rho Beta Epsilon (Alumni) | @arthurdutra

世上无难事,只怕有心人.
  #8   Spotlight this post!  
Unread 26-02-2007, 19:52
ay2b's Avatar
ay2b ay2b is offline
Registered User
AKA: Andy
FRC #2928
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 1994
Location: Seattle, WA
Posts: 211
ay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant future
Re: Gyro PID User drive - How we did it

Quote:
Originally Posted by Bongle View Post
255 can do some wierd stuff. Way back in 2003, I couldn't figure out why our robot wouldn't drive straight. Another team pointed out that 255 was some sort of null character. I changed it to 254, and the thing started driving perfectly.
I believe the limit today is actually 255. "Back in the day", when the user microprocessor was a BASIC stamp, instead of a PIC, it used the serial i/o from the stamp to communicate with the master processor. Each packet had a 0xFF 0xFF header (i.e. 255, 255). The PWM out values were interlaced with the relays and the digital outs, and we were told not to run PWMs above 254. If a PWM was run at 255, then being next to some other byte, which could be 255, it could look like a packet header, and throw things off. Now, however, with the use of a PIC instead of the BASIC stamp, the problem of getting this false header no longer exists, so it's safe to run PWM outs at 255. (Tangentially, I think the user and master processors now communicate via shared memory, but I'm not certain of the details.)

The difference in output between 255 and 254 is not going to be noticeable, and Victors have a small center deadband, so both 127 and 128 are going to give you a "full off" from the Victor, so it really doesn't matter which way you do it. Just don't try to use 256 as your "full on" value.
__________________

2011 - SD Quarterfinalists (980), LA Quarterfinalists (980)
2010 - LA (2404) Finalists (980), AZ Motorola Quality (980)
2009 - LA Semifinalists (980); Las Vegas Quarterfinalists (980); SD (2404); IRI #1 Seed, Finalist (980)
2008 - SD Quarterfinalists (980), LA Champions (980), LA Rookie Inspiration Award (2404); CalGames Finalists
2007 - So.Cal Finalists (980), SD Quarterfinalists (980); CalGames Finalists
2006 - So.Cal Regional Champion (4), Toronto Judge's Award Day 1 (4)
2005 - SVR Champions, Delphi "Driving Tomorrow's Technology" (980); AZ Xerox Creativity (980); So.Cal Finalists, RadioShack Innovation in Control (980); Championship Archimedes Division Semifinalists; IRI Finalists (980)
2004 - So.Cal Regional Champions, Leadership in Controls (980); AZ GM Industrial Design (980); Championship Galileo Division #2 Seed; IRI Champions
2003 - PNW Semi-finalists (488)
2002 - PNW Finalists (488)
2000 - X-bot / 488 - Mentor / Founder
1994 - Sunny Delight - Driver - champion
  #9   Spotlight this post!  
Unread 26-02-2007, 20:09
meatmanek meatmanek is offline
Programmer/physicist/mathematician
FRC #0868 (TechHounds)
Team Role: Programmer
 
Join Date: Mar 2004
Rookie Year: 2004
Location: Carmel, Indiana
Posts: 142
meatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to behold
Re: Gyro PID User drive - How we did it

Quote:
Originally Posted by Bongle View Post
255 can do some wierd stuff. Way back in 2003, I couldn't figure out why our robot wouldn't drive straight. Another team pointed out that 255 was some sort of null character. I changed it to 254, and the thing started driving perfectly.
Keep in mind that 2003 was a radically different RC than today's C-based controllers. The radio protocols changed as well in 2004, and so 255 doesn't have the stigma it used to. You may not see any difference between 255 and 254 in actual PWM output, but the only thing weird about 255 now is that 255+1 = 0.
__________________
Real programmers use vim.
  #10   Spotlight this post!  
Unread 26-02-2007, 20:16
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Gyro PID User drive - How we did it

Quote:
Originally Posted by meatmanek View Post
Keep in mind that 2003 was a radically different RC than today's C-based controllers. The radio protocols changed as well in 2004, and so 255 doesn't have the stigma it used to. You may not see any difference between 255 and 254 in actual PWM output, but the only thing weird about 255 now is that 255+1 = 0.
The radio protocol really didn't change. There were minor changes but the protocol still uses (255, 255) as a synch code which is why PWMs aren't allowed to use 255.
Closed Thread


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
PID cmd_drive can't drive straight? gnormhurst Programming 4 18-02-2005 01:54
Drive Straight C Code using Encoders without PID? Chris_Elston Programming 17 15-02-2005 23:41
How many drive motors did you use (per side) this year? Billfred Motors 19 16-10-2004 20:27
How did YOU drive your team nuts these six weeks? archiver 2001 10 24-06-2002 01:13
How did YOU drive your team nuts these past 6 weeks? Jessica Boucher Chit-Chat 35 16-03-2002 01:04


All times are GMT -5. The time now is 04:55.

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