View Single Post
  #12   Spotlight this post!  
Unread 11-03-2004, 15:16
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: quick question: TIMERS

Quote:
Originally Posted by Xufer
yea kind of but what tells it when a state is complete ? how would i say
case 1 is to happen for 2 seconds and case 2 is supposed to happen for 3 seconds?
pseudo of what im talking about :

case 1 for 2 seconds
pwm01= 200
pwm02= 200
pwm03= 150
pwm04= 200

then go to case 2

case 2 for 3 seconds
pwm01= 200
pwm02= 100

then go to case 3

case 3
pwm01= 200
pwm02= 200

etc . what keeps it with in time constraints and what cuases it to go to the next case statement.

You could have a variable that gets increment every 26.2ms. If this functions is getting called that often, it could be static to it. If not, it could be a global variable that is incremented in something that is. Then, for the tests, you would check if the variable was greater than, say, 78. This would make it run for approzimately 2 second ((1000ms/26.2ms)*x seconds). Or, if you need more accuracy than that, and that's not bad, you can have an external clock attched to pin 1/2 and have an interrunpt that increments it.
__________________