Go to Post Thinking about this game within the confines of previous years will limit you. - Gregor [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
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 09-05-2005, 00:12
billbo911's Avatar
billbo911 billbo911 is online now
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,353
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Concept of PID explained

Eugene,
Thanks for the input. I truly appreciate any I can get! Your description of the code and how it is affected by mass and friction match exactly my thoughts and intent for this code. I understand that the adjustments thrown in for compensation of the Victors deadband characteristics are fairly generic and will not be accurate for all Victors, let alone one that has been "experimented" on by a curious student. (But, I gotta' say, I love their willingness to try something without really knowing the result. I just wish they would let me know before they try it on the competition robot )
Maybe in the next re-write I can move it outside this code and place it in a separate function.

As for the declaration of the two variables as "char" instead of "int":
The maximum range of PosError3 is -254 to 254. This is limited by they following code to -127 to 127 before it is used to create DrvCmd3. At the point DrvCmd3 is created, it can only take on a values of 0 to 254. (Again, I am new to C so here is where I may be mistaken) Both of these ranges of values can be represented by a "char" as well as a "int". I chose the "char" just to save a little memory space. I guess as sloppy as this code is, that really doesn't matter.

Either way, I have seen lots of coding examples where "int" is used as more of a standard, even though a "char" would work. Oh well, I'm still learning, and your input really helps.
Thanks again!!!!
  #2   Spotlight this post!  
Unread 09-05-2005, 01:46
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: Concept of PID explained

Quote:
Originally Posted by billbo911
As for the declaration of the two variables as "char" instead of "int":
The maximum range of PosError3 is -254 to 254.
This is limited by they following code to -127 to 127 before it is used to create DrvCmd3. At the point DrvCmd3 is created, it can only take on a values of 0 to 254. (Again, I am new to C so here is where I may be mistaken) Both of these ranges of values can be represented by a "char" as well as a "int". I chose the "char" just to save a little memory space. I guess as sloppy as this code is, that really doesn't matter.

Either way, I have seen lots of coding examples where "int" is used as more of a standard, even though a "char" would work. Oh well, I'm still learning, and your input really helps.
Thanks again!!!!
The range of PosError3, declared as a char, is -128 to 127.
The range of the expression assigned to it is larger. When you
assign 254, for instance, and read the value back from PosError3,
you will get -2, not the value intended. Looking at your code,
it looks like the result would be a pwm signal in the dead band,
instead of full forward. Assigning 128 will be read as -128,
and in this case your code will cause the motor to go full speed
in the wrong direction.

In the case of DrvCmd3, you have the same problem, but you are
saved by the fact that the computer takes the misinterpreted 8 bits
and blindly shoves them into the unsigned char, pwm03, so the result is
the one you expect.

As I noted, the issue a visible bug for PosError3, but does not manifest
itself as a bug for DrvCmd3. If you, or someone else, were to modify
the code to somehow test the value of DrvCmd3 and manipulate it
before assigning it to pwm03, the additional bug would surface.

A table of widths, and range, of integer types on the robot controller
can be found in "An introduction to C programming for FIRST robotics
applications." See "C programming for the robot controller"
at the web address
http://srvhsrobotics.org/index.php?g...tarticle&cat=2
for the latest version.

I hope this is helpful...

Eugene

Last edited by eugenebrooks : 09-05-2005 at 02:07.
  #3   Spotlight this post!  
Unread 09-05-2005, 08:58
ConKbot of Doom ConKbot of Doom is offline
Team Alumni
FRC #1184 (Cobra Robotics)
Team Role: Leadership
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Maryland
Posts: 153
ConKbot of Doom has a spectacular aura aboutConKbot of Doom has a spectacular aura aboutConKbot of Doom has a spectacular aura about
Re: Concept of PID explained

Thanks, this helped out a lot, I have a feeling that even though I am graduating this year, I'm going to be doing the code for our team next year. No one to really pass on the knowlege to. Hopefully we gan get someone that can at least solder good, and make up sensors for the bot. We didn't use any this year. Not even any limit switches. Though it I had it my way, it would have been otherwise.
__________________
2005 Philly #1 seeded team, highest average points, and semi-finalists
Thanks to 103 and 484 for being alliance mates.
  #4   Spotlight this post!  
Unread 09-05-2005, 10:48
billbo911's Avatar
billbo911 billbo911 is online now
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,353
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Concept of PID explained

Quote:
Originally Posted by eugenebrooks
The range of PosError3, declared as a char, is -128 to 127.
The range of the expression assigned to it is larger. When you
assign 254, for instance, and read the value back from PosError3,
you will get -2, not the value intended. Looking at your code,
it looks like the result would be a pwm signal in the dead band,
instead of full forward. Assigning 128 will be read as -128,
and in this case your code will cause the motor to go full speed
in the wrong direction.

In the case of DrvCmd3, you have the same problem, but you are
saved by the fact that the computer takes the misinterpreted 8 bits
and blindly shoves them into the unsigned char, pwm03, so the result is
the one you expect.

As I noted, the issue a visible bug for PosError3, but does not manifest
itself as a bug for DrvCmd3. If you, or someone else, were to modify
the code to somehow test the value of DrvCmd3 and manipulate it
before assigning it to pwm03, the additional bug would surface.

A table of widths, and range, of integer types on the robot controller
can be found in "An introduction to C programming for FIRST robotics
applications." See "C programming for the robot controller"
at the web address
http://srvhsrobotics.org/index.php?g...tarticle&cat=2
for the latest version.

I hope this is helpful...

Eugene
After reading through the Integer Types and their Properties section of the paper you linked to and re-reading the IFI Programming Reference Guide and the MPLAB Compiler Users Guide, I see my error . With out a doubt, "int" should be used for both DrvCmd3 and PosError3.


Curiosity question here.
I noted significant differences between your paper and the IFI documents when it came to variable types and their ranges, primarily "int". Again I'm pleading ignorance here as I'm so new to coding. Why are they different?

Again, Thanks for your help! It would not have been fun trying to figure out where we/I had gone wrong with the code with out your input.
  #5   Spotlight this post!  
Unread 09-05-2005, 11:56
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: Concept of PID explained

Quote:
Originally Posted by billbo911
Curiosity question here.
I noted significant differences between your paper and the IFI documents when it came to variable types and their ranges, primarily "int". Again I'm pleading ignorance here as I'm so new to coding. Why are they different?
There are two tables in the paper. Table 1 is for EiC, the freely available
C interpreter used in the paper as a learning tool. Int is a 32 bit object
in EiC, with the associated signed and unsigned range. Table 2 is for
the C18 compiler used for the robot controller, where int is a 16 bit
type, with the associated signed and unsigned range. The text discusses
the issue. I hope that Table 2 is consistent with the data in IFI documents,
and the MPLAB C18 compiler documentation, it has been checked in
the past.

If you note a difference, please identify the document and page number.
  #6   Spotlight this post!  
Unread 09-05-2005, 12:17
billbo911's Avatar
billbo911 billbo911 is online now
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,353
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Concept of PID explained

Quote:
Originally Posted by eugenebrooks
There are two tables in the paper. Table 1 is for EiC, the freely available
C interpreter used in the paper as a learning tool. Int is a 32 bit object
in EiC, with the associated signed and unsigned range. Table 2 is for
the C18 compiler used for the robot controller, where int is a 16 bit
type, with the associated signed and unsigned range. The text discusses
the issue. I hope that Table 2 is consistent with the data in IFI documents,
and the MPLAB C18 compiler documentation, it has been checked in
the past.

If you note a difference, please identify the document and page number.

Sorry for the confusion. I did not look beyond Table 1. I assumed, and there lies the problem, that the first table I came across covered what I was looking for.

Either way, you were correct about the "int" declaration, it would have worked regardless which table I looked at.

Thanks again.
  #7   Spotlight this post!  
Unread 27-01-2008, 00:11
DarKCroNo's Avatar
DarKCroNo DarKCroNo is offline
Registered User
FRC #2670
 
Join Date: Dec 2007
Location: Toronto
Posts: 37
DarKCroNo is an unknown quantity at this point
Re: Concept of PID explained

is there a way to apply this concept onto easy C? Sorry but it's our rookie year and we have no clue what we're in for, but basically we have gone for a design of 3 wheels, 2 being powered by a motor and running on an axle, and 1 in the front being steered by another motor, but the problem that arises is that after steering the motor to the left what I want to do is when the joystick is back at the centre position I would like the wheel to also move back into the centre position. I've been doing alot of research on PID closed loops, but all I've been getting is the theory behind it and I have no clue how to apply the programming for it. We went with easyC and I'm wondering if it works with it. Thanks in advance!

Last edited by DarKCroNo : 27-01-2008 at 00:15.
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
All-Time PID Drive with Hall-effects: Coming along very nicely jdong Programming 6 05-02-2005 19:39
Whegs, PID, and climbing phrontist Technical Discussion 9 02-05-2004 00:21
PID control loops - closed loop feedback KenWittlief Technical Discussion 56 26-04-2004 21:27


All times are GMT -5. The time now is 23:18.

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