Go to Post I would hate for you to get the impression that the Northeast is one big unending snowglobe during the winter months. - Elgin Clock [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, 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.
  #2   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.
  #3   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.
  #4   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