Go to Post However, I think the laws of physics indicate that doing so is going to be very difficult at best. - EricH [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
  #361   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
  #362   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.
  #363   Spotlight this post!  
Unread 10-02-2008, 19:54
amk's Avatar
amk amk is offline
Registered User
AKA: Ann Kowalczyk
FRC #0503 (Frog Force)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Novi, MI
Posts: 30
amk is an unknown quantity at this point
Re: New C18 3.0+ Compatible FRC Code

Have you resolved this issue? We're having the same problem, but with the C18 V3.10 compiler & beta code.

Quote:
Originally Posted by ayeckley View Post
There seems to be something amiss when using the combination of MPLAB 8.0, C18 V2.4, the V2.4 beta code and the MPLAB SIM debugger. I think that's a "legal" combination, right? The simulator seems to be going off into the weeds when it hits line 373 (serial port enable) of serial_ports.c. The odd thing is that if you step through it it hangs up on that line, but if you let it run it instead hangs up on line 427 of ifi_frc.c, which is _do_cinit();

Is this just a question of the beta code not supporting MPLAB SIM? I don't think I've seen any _SIMULATOR definitions in either the 2.4 or the 3.1 beta code.

Edit: The same thing happens when I run the 3.1 beta code with C18 v3.1. Maybe I'm the only one trying to use MPLAB SIM? It worked like a champ with last year's code.
  #364   Spotlight this post!  
Unread 10-02-2008, 22:58
mandrews281 mandrews281 is offline
Registered User
FRC #0281
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Greenville SC
Posts: 82
mandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to beholdmandrews281 is a splendid one to behold
Re: New C18 3.0+ Compatible FRC Code

First, I really like the new code organization (that seems to be a common theme). One suggestion though. I'd like to see the *_Init routines called whenever the mode switches. This probably won't affect the matches where things are always: disable->autonomous->teleop->disable. But we were chasing a bug in our autonomous because we were forgetting to reset the robot between runs, and the Autonomous_Init() routine wasn't getting called (we were continuously toggling between disabled and autonomous.

Anyway, back to autonomous programming.
  #365   Spotlight this post!  
Unread 11-02-2008, 03:21
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

Just FYI, I've updated the code to address these three minor issues:

http://www.chiefdelphi.com/forums/sh...&postcount=348

http://www.chiefdelphi.com/forums/sh...&postcount=351

http://www.chiefdelphi.com/forums/sh...&postcount=360

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #366   Spotlight this post!  
Unread 11-02-2008, 03:28
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 amk View Post
Have you resolved this issue? We're having the same problem, but with the C18 V3.10 compiler & beta code.
For some unknown reason (yes, I've checked the RCON register) the simulated processor is resetting when serial port one gets enabled. This causes the 32 entry call stack to overflow (which shouldn't happen in real hardware). This seems to be a problem with the simulator and not something I can fix.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org

Last edited by Kevin Watson : 11-02-2008 at 03:33.
  #367   Spotlight this post!  
Unread 11-02-2008, 06:32
amk's Avatar
amk amk is offline
Registered User
AKA: Ann Kowalczyk
FRC #0503 (Frog Force)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Novi, MI
Posts: 30
amk is an unknown quantity at this point
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by Kevin Watson View Post
For some unknown reason (yes, I've checked the RCON register) the simulated processor is resetting when serial port one gets enabled. This causes the 32 entry call stack to overflow (which shouldn't happen in real hardware). This seems to be a problem with the simulator and not something I can fix.

-Kevin
Is there a workaround? Why is this happening this year and not last year? Thanks for your help.

Ann
  #368   Spotlight this post!  
Unread 11-02-2008, 13:12
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,574
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 mandrews281 View Post
I'm having trouble with the Gyro bias calculation in the code posted on 2/2. If I use the previous code (without the circular buffer), I get a gyro bias of ~2080. With the newer code, I get a gyro bias of ~1660. This make the code think the gyro is spinning continuously. Is there an OBO (off by one) error lurking somewhere? Is anyone else having problems with the updated code?
I heavily modified the ADC code and was having issues with the data in the gyro bias buffer being corrupted. In the process of trying to figure that out, I looked at the bias calculation heavily and did not find any logic errors in it.

I never did solve my problem, though, so there might be a problem lurking in that code.
  #369   Spotlight this post!  
Unread 11-02-2008, 13:14
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,574
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 amk View Post
Is there a workaround? Why is this happening this year and not last year? Thanks for your help.

Ann
See if the solution in this thread helps: http://www.chiefdelphi.com/forums/sh...ad.php?t=62816
  #370   Spotlight this post!  
Unread 11-02-2008, 13:55
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 Kevin Watson View Post
but I don't see where this could cause a ploblem as the OI data from the previous Getdata() should be valid. What problem were you having?
Here's the deal. When the robot powers up in teleop, as is normal outside of competition, the first routine of ours that gets called is teleop_init, before (at least originally) the first call to getdata (except for the getdata before initialization, which I suspect doesn't include OI data).

We were grabbing some switch values in teleop_init into a static variable to detect when/if the operator changes those switches during the normal teleop(). We do this to avoid moving some of our appendages on first power up until someone at the control panel asks them to move (safety considerations).

Since telop_init() was only invoked once, before the first (real) getdata, we didn't see the real OI switches and concluded that the operator had, in fact, moved them when teleop got called after the getdata invocation.

Thanks for considering the changes, and check out my next post. It's going to point out another 26.2msec issue in this same area of the code.

Lynn (D) - Team Voltage 386 Software
  #371   Spotlight this post!  
Unread 11-02-2008, 14:01
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

Kevin,

Given the structure of the code in main() surrounding the modal invocations and the position of the getdata() calls, it appears to me that the new code structure actually invokes the previous mode with the new mode's getdata() results immediately after a mode switch.

Consider: robot is in disable, rcdata has that fact recorded, hybrid begins. main() detects disabled mode, detects that new data is available, calls getdata() receiving the new autonomous flag but invokes disabled() anway. Autonomous_init() and Autonomous() doesn't get called until the NEXT command packet, 26.2msec later.

I've not done it yet, but I'm planning to restructure our main() to something like this (just pseudo code, not real code):

main loop:

if (new data available)
{ getdata();
set newdata flag;
}
if (...mode...)
{
all of the existing mode_init and mode() calls here, but no getdata or putdata() calls
}
if (newdata flag)
{ putdata();
}

goto main loop:

With this structure, the newly gotten mode is the one checked and invoked with the getdata() packet.

I hope to first prove this with a mode-checking printf in one (or all) of the _init() routine that check if the mode we're in is reflected in rcdata (hidden by the #defines for the mode flags). I suspect it is not.

Lynn (D) - Team Voltage 386 Software

PS. This also makes our new always_before(), always_after(), and always_spin MUCH easier to hook in, now that I've written it out! always_before() right after the getdata(), always_after() just before the putdata(), and always_spin, well, always in the loop!

Last edited by ldeffenb : 11-02-2008 at 14:04.
  #372   Spotlight this post!  
Unread 11-02-2008, 15:04
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: New C18 3.0+ Compatible FRC Code

Kevin,
We discovered a side effect of the new code setup that I thought I should point out. I've only read this thread sporadically, so maybe it's already been mentioned - if so apologies for bringing it up again.

We had some feedback code that we implemented in the _Spin() functions since we wanted it to execute faster than the 26.2ms rate. The side effect that we found was that if you do something which causes your Autonomous() code (for instance) to take longer than 26.2ms to execute, then Autonomous_Spin() will never execute. The problem this caused for us was that our feedback was obviously not running when this occurred.

Anyway, I don't consider this a flaw in the code or anything, merely a behavior that I wanted to make sure others were aware of. We will probably modify ifi_frc.c and remove the "else" blocks around the _Spin() functions, which will ensure that the _Spin() code gets executed at least once per main loop.

Maybe it would be worth a note in the comment blocks before each _Spin() function noting that those functions will only be called if there's extra time left over after processing the new command packet.

Dave
  #373   Spotlight this post!  
Unread 12-02-2008, 04:17
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 Dave Flowerday View Post
...we found was that if you do something which causes your Autonomous() code (for instance) to take longer than 26.2ms to execute, then Autonomous_Spin() will never execute. The problem this caused for us was that our feedback was obviously not running when this occurred.
Dave,

Thanks for catching this. IFI's code behaves the way you describe, so I went ahead and removed the three surrounding else statements. I also added support for the MPLAB simulation tool. The code is up on my website now.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #374   Spotlight this post!  
Unread 12-02-2008, 14:34
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

Kevin,

What is the procedure for adding additional analog sensors with the gyro code? I changed the number of ADC channels, plugged the (pots, in my case) in to channels 2 and 3, and added the code to read them in the Process_Gyro_Data function.

While I've been able to read the values (by converting the number to milivolts, as otherwise I'm not exactly sure what I'm seeing), the gyro has since been going crazy. I wired the gyro to an oscilloscope, and it still works, but the code (after given time to initialize and computing the bias) sees crazy values. Any idea what I'm doing wrong? Is there any readme to using the gyro with other analog values I'm missing?

Thanks.
__________________
  #375   Spotlight this post!  
Unread 12-02-2008, 14:58
billbo911's Avatar
billbo911 billbo911 is offline
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,368
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: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by sumadin View Post
Kevin,

What is the procedure for adding additional analog sensors with the gyro code? I changed the number of ADC channels, plugged the (pots, in my case) in to channels 2 and 3, and added the code to read them in the Process_Gyro_Data function.

..the gyro has since been going crazy. I wired the gyro to an oscilloscope, and it still works, but the code (after given time to initialize and computing the bias) sees crazy values ...
Thanks.
Just a thought, here is a quote from the header of the gyro.c/Process_Gyro_Data

Code:
FUNCTION:		Process_Gyro_Data()
*
*	PURPOSE:		Manages ADC data and does gyro rate integration
*
*	CALLED FROM:	ifi_frc.c/Disabled_Spin(),
*					ifi_frc.c/Autonomous_Spin(),
*					ifi_frc.c/Teleop_Spin()
*
*	PARAMETERS:		Unsigned char with a value of zero will prevent this
*					function from calling Reset_ADC_Result_Count() when
*					ADC data has been processed. If you do use this mode
*					of operation you must call Reset_ADC_Result_Count()
*					from your own code. Failure to do this will cause
*					the gyro to stop functioning.
Are you calling Reset_ADC_Result_Count() from your code?
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
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 14: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