Go to Post The version that finished nationals was about 50% aluminum and 50% the original PVC and we never had any member break. (structural member, not team member). - 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 Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 26-01-2008, 19:55
sparrowkc sparrowkc is offline
Registered User
AKA: Mark
FRC #1986 (Team Titanium)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Lees Summit
Posts: 114
sparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to behold
Variables Change randomly

PLEASE I CANNOT TAKE THIS ANYMORE

Any functions I create return seemingly random numbers

for example I put the function

unsigned int Motor_Limit (int motor)
{
static unsigned int lmnewmotor;
if(motor >= 254)
{
lmnewmotor = 254;
}
if(motor <= 0)
{
lmnewmotor = 0;
}
}

In ifi_code.c and a prototype in ifi_code.h. I call it with
motor1 = Motor_Limit((int) motor1);
where motor1 is a pwm value that may be invalid.


IT ALWAYS RETURNS 1919!!!!


WHYYYYYYYYYY

Is this a bug, I have the sensors version and kevin's site said that it was relatively bug free.


We have a demo tomorrow and whenever I try to run my code the robot goes int a spasm.
  #2   Spotlight this post!  
Unread 26-01-2008, 20:05
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,112
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: Variables Change randomly

Quote:
Originally Posted by sparrowkc View Post
IT ALWAYS RETURNS 1919!!!!
How do you know what the return value is? I once spent hours trying to debug a routine that seemed to be returning the wrong value, only to discover that the error was in the line of code that prints the value.

But upon further inspection, the problem with your code is rather obvious to someone who hasn't been staring at it for hours. You merely forgot to return the newly computed value.

Last edited by Alan Anderson : 26-01-2008 at 20:07.
  #3   Spotlight this post!  
Unread 26-01-2008, 20:13
sparrowkc sparrowkc is offline
Registered User
AKA: Mark
FRC #1986 (Team Titanium)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Lees Summit
Posts: 114
sparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to behold
Exclamation Re: New C18 3.0+ Compatible FRC Code

I cannot adequately express my frustration with myself and the people here who I asked to check this for error. Thank you for pointing out that I DIDNT HAVE IT RETURN ANYTHING AAAAAAAAAAAAA
  #4   Spotlight this post!  
Unread 27-01-2008, 00:38
Boku-Ni's Avatar
Boku-Ni Boku-Ni is offline
Registered User
AKA: Hank
FRC #1289 (Gearheadz)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2005
Location: Lawrence, MA
Posts: 4
Boku-Ni is an unknown quantity at this point
Send a message via ICQ to Boku-Ni Send a message via AIM to Boku-Ni Send a message via MSN to Boku-Ni
Re: New C18 3.0+ Compatible FRC Code

I looked at the link that was provided for a version of C18 other than 3.15 but couldn't find it. Can someone point to me where it is? >.< Any help appreciated.

-- Hank
__________________
Programmers don't byte, they nibble a bit.

"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." -- Albert Einstein

  #5   Spotlight this post!  
Unread 27-01-2008, 10:11
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,562
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: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by Boku-Ni View Post
I looked at the link that was provided for a version of C18 other than 3.15 but couldn't find it. Can someone point to me where it is? >.< Any help appreciated.

-- Hank
The link in the first post for C18 has both 3.10 and 3.15.
  #6   Spotlight this post!  
Unread 09-02-2008, 23:51
1jbinder 1jbinder is offline
Registered User
FRC #0852
 
Join Date: Jan 2008
Location: Athenian School
Posts: 35
1jbinder is an unknown quantity at this point
Re: New C18 3.0+ Compatible FRC Code

Hi Kevin,
Our robot this year is using four different omnis that need 4 different encoders. The problem is we need to use four encoders this year. We used the encoders 3-6. We noticed that 3-4 were working but 5-6 only gave 0's and 1's. After looking at the ISR's for the encoders 5 and 6 i realized that 3 and 4 only worked on rising edge interrupt but 5 and 6 worked on both. After i changed 5 and 6 to be like 3 and 4 they worked but i do not understand why. there are four variables that i am using, two of which you use that are not declared anywhere. They are Encoder_3_State, Encoder_4_State, Encoder_5_State, and Encoder_6_State. Do you know where these variables are declared. Also why are the encoder 3-4 ISR's different from the encoder 5-6 ISR's.
Thanks in advance,
Julian
  #7   Spotlight this post!  
Unread 10-02-2008, 00:09
ldeffenb ldeffenb is offline
Registered User
AKA: Lynn Deffenbaugh (Mr)
None #0386 (Team Voltage 386)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Florida
Posts: 75
ldeffenb has a spectacular aura aboutldeffenb has a spectacular aura aboutldeffenb has a spectacular aura about
Send a message via ICQ to ldeffenb Send a message via AIM to ldeffenb Send a message via Yahoo to ldeffenb
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by 1jbinder View Post
...They are Encoder_3_State, Encoder_4_State, Encoder_5_State, and Encoder_6_State. Do you know where these variables are declared.
Look at lines 70-86 (at least in my copy) of encoder.c. You'll see the declarations there.
Quote:
Originally Posted by 1jbinder View Post
.
Also why are the encoder 3-4 ISR's different from the encoder 5-6 ISR's.
From Kevin's encoder_readme.txt from 2 years ago:

Encoder channels one and two are optimized for velocity control
and will generate the least number of interrupts per encoder
count (one per encoder count). These channels may have problems
in position control applications because they can be fooled
into thinking that the encoder shaft is rotating if the shaft
happens to stop very near a phase-A transition and then wobbles
back and forth across that transition.

Encoder channels three and four are optimized for position
control. For these channels, software examines both transitions
of phase-A and can't be fooled into miscounting the number
of encoder counts. The downside to using these channels is that
for a given encoder, they will generate twice the number of
interrupts as channels one and two (two per encoder count).

Encoder channels five and six are just like channels three and
four, but offer the bonus of increasing the precision of your
encoder by a factor of two for free. Unlike channels one
through four, which will increment or decrement on each rising
(zero to one) transition, these two channels will increment or
decrement on both transitions of phase-A. In other words, if
you attach a 64 count-per-revolution encoder to one of these
two channels, you'll read 128 counts when you rotate the shaft
exactly one revolution.
  #8   Spotlight this post!  
Unread 18-02-2008, 21:30
spack spack is offline
Registered User
#1391
 
Join Date: Feb 2005
Location: Westtown PA
Posts: 6
spack is an unknown quantity at this point
Re: New C18 3.0+ Compatible FRC Code

Kevin.
I'm trying to get the camera code going with the new 3.0 code. I'm not receiving ACKs or NCKs so it fails at init state 3 return value 131. serial_ports.h/c looks ready to go for port2 9600 baud and interrupts.

Integrated camera.c terminal.c and tracking.c without any issues.

Anything obvious come to mind reagrding serial port initialization?

Chad
  #9   Spotlight this post!  
Unread 19-02-2008, 07:59
David Doerr's Avatar
David Doerr David Doerr is offline
Registered User
FRC #4478 (Materia Oscura)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2002
Location: Milford, Michigan, USA
Posts: 75
David Doerr has much to be proud ofDavid Doerr has much to be proud ofDavid Doerr has much to be proud ofDavid Doerr has much to be proud ofDavid Doerr has much to be proud ofDavid Doerr has much to be proud ofDavid Doerr has much to be proud ofDavid Doerr has much to be proud of
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by spack View Post
Kevin.
I'm trying to get the camera code going with the new 3.0 code... Anything obvious come to mind reagrding serial port initialization?
Chad,

Try setting serial port 2 to 115200 baud.

Dave
  #10   Spotlight this post!  
Unread 19-02-2008, 20:04
Guy Davidson Guy Davidson is offline
Registered User
AKA: formerly sumadin
FRC #0008 (Paly Robotics)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Ra'anana, Israel
Posts: 660
Guy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to behold
Send a message via ICQ to Guy Davidson Send a message via AIM to Guy Davidson Send a message via MSN to Guy Davidson
Re: New C18 3.0+ Compatible FRC Code

I've been running into an odd problem with encoders.

Encoder 1 works perfectly fine during the teleop period, but does not give me anything during the autonomous one. Encoder 2 works in both teleop and autonomous. The initialization functions is called during both the autonomous and disabled initialization routines.

I am running your latest code build, as far I as know, with MPLAB 8 and C18 3.10. While the robot is shipped already, I'd love to hear if you have any suggestions for what to try.

It could be that the encoder is working, and is giving the correct signals, but is always printing a zero in my debug statement, and the code that is executing makes me believe that it is seeing a zero (as the count). But when I print out the count in the teleop mode, I get numbers that make sense.
__________________
  #11   Spotlight this post!  
Unread 20-02-2008, 00:20
Lafleur Lafleur is offline
Registered User
AKA: Tom Lafleur
FRC #0812
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2006
Location: San Diego
Posts: 34
Lafleur will become famous soon enoughLafleur will become famous soon enough
New C18 3.0+ Compatible FRC Code

Kevin

Do you have access to an Explorer 16 board from Microchip??
  #12   Spotlight this post!  
Unread 20-02-2008, 01:42
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by Lafleur View Post
Kevin

Do you have access to an Explorer 16 board from Microchip??
No, most of my experience is with x86, PPC, Cell BE, TI DSP plus lots of FPGA work. My only real experience with PIC is side work using IFI hardware. Why do you ask?

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #13   Spotlight this post!  
Unread 20-02-2008, 10:36
Lafleur Lafleur is offline
Registered User
AKA: Tom Lafleur
FRC #0812
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2006
Location: San Diego
Posts: 34
Lafleur will become famous soon enoughLafleur will become famous soon enough
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by Kevin Watson View Post
No, most of my experience is with x86, PPC, Cell BE, TI DSP plus lots of FPGA work. My only real experience with PIC is side work using IFI hardware. Why do you ask?

-Kevin
I have a early port of your ATD code working on the board with DMA, also have the serial drivers working with a few bugs...

this was done to gain experience with the tools and processors...
  #14   Spotlight this post!  
Unread 20-02-2008, 00:32
pogenwurst pogenwurst is offline
Ubuntu User
AKA: Brian
FRC #2007 (Robots of the Round Table)
Team Role: Leadership
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Duluth, GA
Posts: 78
pogenwurst is on a distinguished road
Send a message via AIM to pogenwurst
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by sumadin View Post
I've been running into an odd problem with encoders.

Encoder 1 works perfectly fine during the teleop period, but does not give me anything during the autonomous one. Encoder 2 works in both teleop and autonomous. The initialization functions is called during both the autonomous and disabled initialization routines.

I am running your latest code build, as far I as know, with MPLAB 8 and C18 3.10. While the robot is shipped already, I'd love to hear if you have any suggestions for what to try.

It could be that the encoder is working, and is giving the correct signals, but is always printing a zero in my debug statement, and the code that is executing makes me believe that it is seeing a zero (as the count). But when I print out the count in the teleop mode, I get numbers that make sense.
I had the same issue in autonomous, except with both encoder 1 and encoder 2. I never had the chance to check in teleop mode, though.

I'll try with last year's board, if I can get the time (we removed our encoders from the bot for this reason).
  #15   Spotlight this post!  
Unread 20-02-2008, 01:38
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by sumadin View Post
I've been running into an odd problem with encoders.

Encoder 1 works perfectly fine during the teleop period, but does not give me anything during the autonomous one. Encoder 2 works in both teleop and autonomous. The initialization functions is called during both the autonomous and disabled initialization routines.

I am running your latest code build, as far I as know, with MPLAB 8 and C18 3.10. While the robot is shipped already, I'd love to hear if you have any suggestions for what to try.

It could be that the encoder is working, and is giving the correct signals, but is always printing a zero in my debug statement, and the code that is executing makes me believe that it is seeing a zero (as the count). But when I print out the count in the teleop mode, I get numbers that make sense.
A common reason for this is the wrong printf() format parameter is used. Use %ld instead of %d.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
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
Does the camera code suits to all versions of MPLAB and C18? razer Programming 3 04-01-2007 14:50
Trying to follow C18 interrupt context code... dcbrown Programming 5 21-12-2006 09:01
Error w/ FRC code JamesBrown Programming 2 08-01-2005 16:17
Programming code Fix FRC Ferazel2001 Programming 6 08-02-2004 02:46
FRC default code hedgehogger Programming 2 21-01-2004 18:41


All times are GMT -5. The time now is 22:33.

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