Go to Post Don’t let the medals you win and the trophies on your mantel define who you are. Let it be the lives you’ve touched and the legacy you leave behind. - Sean Schuff [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 26-02-2007, 13:42
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Generic PID control code

I was asked by Adamdb of team #1583 to post a code example of what we did to execute a PID loop. The two files, pid.c and pid.h are attached below.

in order to use a pid loop, you must do a couple of things. first, you create the data structure, for example:
PHP Code:
DT_PID arm
in some initialization code later, you need to initialize the constants
PHP Code:
init_pid(&arm10010101005); 
(see the included file for the argument list)

then finally, you can execute the loop by doing this
PHP Code:
pwm03 pid_control(&armerrorValue); 
It really isnt that bad, and if you notice a lack of comments/explanation, please make a note of it. Also, this code doesnt go into the theory behind it, it only executes the theory. so if you dont know what a proportional coefficient is, then i suggest that you read this: PID without a PhD

happy control-loop-ing.

Edit: i added the default code plus the PID code for those of you who are having trouble getting started.
Attached Files
File Type: zip pid.zip (1.5 KB, 525 views)
File Type: zip pidController.zip (206.3 KB, 516 views)
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY

Last edited by Uberbots : 26-02-2007 at 22:30. Reason: added default code + pid code
  #2   Spotlight this post!  
Unread 26-02-2007, 14:06
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,187
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: Generic PID control code

I was going to post mine, but beside for some minor syntax differences, the drivers are identical.

Good work.

PS. It looks like the uberbots' programmers have come a long way since I last talked to you before eliminations at UTC last year.
  #3   Spotlight this post!  
Unread 26-02-2007, 16:32
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: Generic PID control code

Again, nearly identical PID code. I constructed mine from the PID without a PhD article as well.
__________________
http://www.mikesorrenti.com/
  #4   Spotlight this post!  
Unread 26-02-2007, 16:59
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: Generic PID control code

I was about to make code from PID without a PhD, but then I saw this. It's always great to see teams post code for others to use.
__________________
Real programmers use vim.
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
Integral Window for PID Control phrontist Programming 2 16-02-2008 17:32
PID Control Chris Bright Programming 9 26-03-2005 19:44
(Experimental) PID Control System jdong Programming 14 18-06-2004 15:55
PID control loop/Encoder question Zee Programming 18 30-01-2004 23:14
PID Control Loops ttedrow Programming 7 05-12-2002 12:03


All times are GMT -5. The time now is 15:27.

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