Go to Post The Scouting Award exists. It's called "Championship Winner". - Chris is me [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 22-01-2004, 17:28
AlphaOmega870 AlphaOmega870 is offline
Registered User
AKA: Mike
#0870 (Southold RICE)
Team Role: Programmer
 
Join Date: Oct 2002
Location: Southold, NY
Posts: 18
AlphaOmega870 is an unknown quantity at this point
Send a message via AIM to AlphaOmega870
Question how do you...

create a counter for the autonomous code?
  #2   Spotlight this post!  
Unread 22-01-2004, 17:35
Kevin Casper Kevin Casper is offline
Registered User
#0171 (Hardcore Engineers)
 
Join Date: Oct 2003
Location: Platteville , WI
Posts: 15
Kevin Casper is an unknown quantity at this point
Re: how do you...

Quote:
Originally Posted by AlphaOmega870
create a counter for the autonomous code?
What type of counter do you want? Time based? Cycle based? Event Based? Code for a counter?

If it is time based then one of the loops of the program happens every 26ms(I think). Just count the program loops and you have time.
__________________
Kevin Casper
  #3   Spotlight this post!  
Unread 22-01-2004, 18:13
AlphaOmega870 AlphaOmega870 is offline
Registered User
AKA: Mike
#0870 (Southold RICE)
Team Role: Programmer
 
Join Date: Oct 2002
Location: Southold, NY
Posts: 18
AlphaOmega870 is an unknown quantity at this point
Send a message via AIM to AlphaOmega870
Re: how do you...

Quote:
Originally Posted by Kevin Casper
What type of counter do you want? Time based? Cycle based? Event Based? Code for a counter?

If it is time based then one of the loops of the program happens every 26ms(I think). Just count the program loops and you have time.
we want something like last years auton counter.
  #4   Spotlight this post!  
Unread 22-01-2004, 19:40
Bharat Nain's Avatar
Bharat Nain Bharat Nain is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: New York
Posts: 2,000
Bharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond repute
Send a message via AIM to Bharat Nain Send a message via MSN to Bharat Nain
Re: how do you...

How would you create a Time Based counter?
__________________
-= Bharat Nain =-

Whatever you do, you need courage. Whatever course you decide upon, there is always someone to tell you that you are wrong. There are always difficulties arising that tempt you to believe your critics are right. To map out a course of action and follow it to an end requires some of the same courage that a soldier needs. Peace has its victories, but it takes brave men and women to win them. - Ralph Waldo Emerson
  #5   Spotlight this post!  
Unread 22-01-2004, 20:20
Mercutio Mercutio is offline
Atticus Finch Wannabe
#1213 (The Grobots)
 
Join Date: Feb 2003
Location: Birmingham, Michigan
Posts: 63
Mercutio is on a distinguished road
Re: how do you...

Quote:
Originally Posted by TeknoBramha
How would you create a Time Based counter?
Read http://www.innovationfirst.com/FIRST...004-Jan-14.pdf. It'll tell you everything you need to know. Make sure you know the basics of interrupts too.

~Aaron
__________________
"If we knew what we were doing, it wouldn't be called research, would it?"
—Albert Einstein

<X3 What can I do? You broke the tie wraps that were holding together my heart. ^_^
  #6   Spotlight this post!  
Unread 22-01-2004, 22:18
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: how do you...

Quote:
Originally Posted by Kevin Casper
If it is time based then one of the loops of the program happens every 26ms(I think). Just count the program loops and you have time.
Don't Do this!! It was the only option last year, but we have much better options this year. Create a timer interrupt that triggers every X seconds(see above whitepaper link), that inctements a variable. Jut read this variable an you have a timer. If you need orther help, just let the peeps here and we can help.
__________________
1139 Alumni
  #7   Spotlight this post!  
Unread 23-01-2004, 15:31
Bharat Nain's Avatar
Bharat Nain Bharat Nain is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: New York
Posts: 2,000
Bharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond repute
Send a message via AIM to Bharat Nain Send a message via MSN to Bharat Nain
Re: how do you...

From where do you get all these help files and manuals?
__________________
-= Bharat Nain =-

Whatever you do, you need courage. Whatever course you decide upon, there is always someone to tell you that you are wrong. There are always difficulties arising that tempt you to believe your critics are right. To map out a course of action and follow it to an end requires some of the same courage that a soldier needs. Peace has its victories, but it takes brave men and women to win them. - Ralph Waldo Emerson
  #8   Spotlight this post!  
Unread 24-01-2004, 19:55
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: how do you...

IFI, mostly.
  #9   Spotlight this post!  
Unread 25-01-2004, 05:43
echos's Avatar
echos echos is offline
Jack of all trades
#1125
Team Role: Programmer
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 61
echos will become famous soon enough
Send a message via ICQ to echos Send a message via AIM to echos Send a message via MSN to echos Send a message via Yahoo to echos
Re: how do you...

here is some rather straight forward code, simular to previous years stuff.

Code:
 unsigned int counter;
 
 if(autonmous_code)
 	{
 	if(counter <= 20)
 		{
 		pwm01 = pwm02 = 255;
 		}
 
 	  else if(counter >= 21 && counter <= 100 && counter != 99)
 		{
 		pwm01 = 255;
 		pwm02 = (pwm01 -= 254);
 		}
 	  else
 		{
 		die(void);
 		}
 
 	counter++;
 	}
__________________

Entity Hosting Staff
http://www.entityhosting.com/
  #10   Spotlight this post!  
Unread 25-01-2004, 08:41
Obi's Avatar
Obi Obi is offline
Registered User
#0870
 
Join Date: Jan 2004
Location: Southold
Posts: 18
Obi is an unknown quantity at this point
Re: how do you...

Quote:
Originally Posted by echos
here is some rather straight forward code, simular to previous years stuff.

Code:
 unsigned int counter;
 
 if(autonmous_code)
 	{
 	if(counter <= 20)
 		{
 		pwm01 = pwm02 = 255;
 		}
 
 	  else if(counter >= 21 && counter <= 100 && counter != 99)
 		{
 		pwm01 = 255;
 		pwm02 = (pwm01 -= 254);
 		}
 	  else
 		{
 		die(void);
 		}
 
 	counter++;
 	}
Our program (Team #870) looks like that, except that we have counter = 40 x the MS (26.2, but we use 25). We then output that to the IFI loader screen, and we get a nice display, every second, declaring the amount of seconds, whether in Auton mode or Practice.
  #11   Spotlight this post!  
Unread 25-01-2004, 08:57
FotoPlasma FotoPlasma is offline
\: |
no team
 
Join Date: Jul 2001
Rookie Year: 2001
Location: San Jose
Posts: 1,900
FotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond repute
Send a message via AIM to FotoPlasma
Re: how do you...

Just like James said earlier in this thread, I highly recommend using something a little more advanced than just incrementing a counter variable every code cycle. The PIC18F8520 comes with 5 seperate timers (the first of which is used by IFI, so we have access to 4). They're pretty well documented in the datasheet for the microcontroller (sections 11 through 15). Three 8bit timers, and one 16bit timer. With all of the capabilities of the processor, itself, I would be very disappointed to see any team counting cycles as a timing system. I'm already forcing my programming mentees to learn about timers, interrupts, and other such features of these nice little machines.
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos
  #12   Spotlight this post!  
Unread 25-01-2004, 09:30
Obi's Avatar
Obi Obi is offline
Registered User
#0870
 
Join Date: Jan 2004
Location: Southold
Posts: 18
Obi is an unknown quantity at this point
Re: how do you...

I don't exactly see the advantage of using interrupts over counting cycles. Care to elaborate?
  #13   Spotlight this post!  
Unread 26-01-2004, 20:38
Rorschach's Avatar
Rorschach Rorschach is offline
2068 Mentor
AKA: Matt
FRC #2068 (Metal Jackets)
Team Role: Mentor
 
Join Date: Sep 2003
Rookie Year: 2002
Location: Staten Island
Posts: 4
Rorschach is an unknown quantity at this point
Send a message via AIM to Rorschach
Re: how do you...

Quote:
Originally Posted by echos
here is some rather straight forward code, simular to previous years stuff.

Code:
 unsigned int counter;
 
 if(autonmous_code)
 	{
 	if(counter <= 20)
 		{
 		pwm01 = pwm02 = 255;
 		}
 
 	  else if(counter >= 21 && counter <= 100 && counter != 99)
 		{
 		pwm01 = 255;
 		pwm02 = (pwm01 -= 254);
 		}
 	  else
 		{
 		die(void);
 		}
 
 	counter++;
 	}
I know this may sound rudimentary, but where is <i>die(void)</i>, is that the function that the routine is within?
  #14   Spotlight this post!  
Unread 27-01-2004, 09:21
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,854
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: how do you...

Quote:
Originally Posted by Obi
I don't exactly see the advantage of using interrupts over counting cycles. Care to elaborate?

Program cycles will vary as you add and remove code.
The cycles are also variable in general because of other events like interrupts that may be going on asynchronously. So one loop might take 50 clock ticks while the next takes 150 ticks. Over time you can accumulate large variations.

The clock approach always puts you within a few clock ticks of where you expect to be, and errors don't accumulate over time.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
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


All times are GMT -5. The time now is 19:56.

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