Go to Post Thank you GDC, for keeping everyone honest! - dtengineering [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 15-03-2007, 21:56
Spencer E.'s Avatar
Spencer E. Spencer E. is offline
Android junkie
FRC #1305 (NNSRI Ice3 (cubed))
Team Role: Alumni
 
Join Date: Apr 2005
Rookie Year: 2004
Location: Ontario, Canada
Posts: 91
Spencer E. has a spectacular aura aboutSpencer E. has a spectacular aura about
Send a message via MSN to Spencer E.
Anyone actually using hardware timers?

I was just reading the white paper from IFI for the timers (I'm using one for the movement of my arm, I had no other choice) and I was wondering if anyone had any feedback on how well the actual RC timers work or if anyone has tried them. This is the first time I've ever used hardware level timers and I'm hoping the example given in IFI's paper will be a good enough supplement for the function I need it for.

EDIT: By the way, I'm willing to offer the timer code for all 5 timers once I get my robot code up and running.

Last edited by Spencer E. : 15-03-2007 at 22:41.
  #2   Spotlight this post!  
Unread 15-03-2007, 22:41
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: Anyone actually using hardware timers?

We have the wallclock code to operate Timer 1 from here running on our robot. I won't really say use, because it was going to be used to send the robot into different states (End of autonomous, not enough time left to score, so on) during autonomous, but that code was removed due to difficulties with the feedback system. It'll probably end up being used in autonomous at Palmetto for, at the very least, deploying the robot into scoring mode during autonomous. (Ideally, depending on how busy the practice field is, we'd like to get some scoring going with dead reckoning, but that is far less likely)
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
  #3   Spotlight this post!  
Unread 15-03-2007, 22:49
Spencer E.'s Avatar
Spencer E. Spencer E. is offline
Android junkie
FRC #1305 (NNSRI Ice3 (cubed))
Team Role: Alumni
 
Join Date: Apr 2005
Rookie Year: 2004
Location: Ontario, Canada
Posts: 91
Spencer E. has a spectacular aura aboutSpencer E. has a spectacular aura about
Send a message via MSN to Spencer E.
Re: Anyone actually using hardware timers?

Our team was originally going to use gear tooth sensors to get feedback from the arm during autonomous but it kind of fell through due to time constraints and I'm now working on code that will move the arm based on the amount of time passed since the function first began.
  #4   Spotlight this post!  
Unread 15-03-2007, 23:17
Jake M Jake M is offline
void* Jake;
FRC #1178 (DURT)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Missouri
Posts: 118
Jake M has a spectacular aura aboutJake M has a spectacular aura about
Re: Anyone actually using hardware timers?

If you just to designate the arm to move to certain positions at a certain time, just in autonomous mode, you don't need to use the timer. In 2005, we had a 3 point autonomous by just doing something like this....

Code:
Autonomous_Mode(void)
 {
  static int timer = 0;

  if(timer == 20)
    move arm up;
  else if(timer == 40)
    move forward;
  else if(timer == 60)
    drop arm;

  ++ timer;
 }
Surprisingly, we didn't even overflow once within the 15 second autonomous. Those may not have been the exact values we used, but they pretty low. I think the first two were under 100.
__________________
Code:
void function(void)
 {
  function();
 }

Last edited by Jake M : 15-03-2007 at 23:20.
  #5   Spotlight this post!  
Unread 15-03-2007, 23:27
Spencer E.'s Avatar
Spencer E. Spencer E. is offline
Android junkie
FRC #1305 (NNSRI Ice3 (cubed))
Team Role: Alumni
 
Join Date: Apr 2005
Rookie Year: 2004
Location: Ontario, Canada
Posts: 91
Spencer E. has a spectacular aura aboutSpencer E. has a spectacular aura about
Send a message via MSN to Spencer E.
Re: Anyone actually using hardware timers?

I think a timer would be nice to use for my needs since it is exact to the second so I know how long I will need to move the arm rather than relying on the processors looping to change the arm position. I have looked into doing it the processor looping way but I feel safer using interrupt timers, it seems more exact to me .
  #6   Spotlight this post!  
Unread 15-03-2007, 23:41
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: Anyone actually using hardware timers?

well... lets see... using ccp's on TMR3:
1. Period Clock for 'overclocked' PWM's (update @100Hz as opposed to IFI's
38Hz update.... a 263% improvement )
2. %duty cycle up time (@16bits as opposed to IFI's 8) for left motors
(resolution increases x256 )
3. " " for right motors

TMR1:
1. In combination with INT2 on PORTB, timing pulses coming back from
ultrasonic transceiver to get distance in great 16bit accuracy (+/-0.05")

CCP's with programmable hardware triggers on compare matches... with the prescalar I'm using for the pwm timebase, getting accuracy of 0.0000002sec on pulse timing. Embedded peripherals make me happy!

For those of you who follow RALFF, I just finished v2 for 1024's 2007 robot. Have to say it was quite a bit more complicated than last years with the SDAR and all....

-q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08

Last edited by Qbranch : 15-03-2007 at 23:51.
  #7   Spotlight this post!  
Unread 15-03-2007, 23:50
Spencer E.'s Avatar
Spencer E. Spencer E. is offline
Android junkie
FRC #1305 (NNSRI Ice3 (cubed))
Team Role: Alumni
 
Join Date: Apr 2005
Rookie Year: 2004
Location: Ontario, Canada
Posts: 91
Spencer E. has a spectacular aura aboutSpencer E. has a spectacular aura about
Send a message via MSN to Spencer E.
Re: Anyone actually using hardware timers?

Wow! Even I didn't understand that haha I think I was being agreed with. Seems like 1024's robot is going to have one complicated code this year
  #8   Spotlight this post!  
Unread 16-03-2007, 00:01
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: Anyone actually using hardware timers?

Well Spencer if you want to know about any of it just give me a yell. Or, better yet if you are going to Buckeye or the Championship come over to 1024, ask for Q and I'll help you out in person.

Once you learn the hardware... you'll love the hardware... you can do so much cool stuff! It takes the mystique away from things like PWM too, lets you see how downright simple it is.... not to mention gives you the capability of updating PID's at 100Hz as opposed to 38Hz.... and don't forget the extra resolution!

Anyhow.... if you all have any questions about onboard peripherals (i.e. CCP's, Timers, ADCs, UARTS, etc), or anything of the kind, give me a yell, always glad to help.

one last thing... if anybody is having the encoder blues of too fast of an interrupt rate or not enough resolution, try out the analog encoders by US digital.... they are awesome... about 1008 counts of resolution and you don't need to sample them very fast at all... only about 4 times per revolution, unless you figure out a better driver that needs less... for us, to get resolution of about 0.1" the encoder only needs to be sampled at 90Hz and goes up to about 80~90Hz.... which paired perfectly with the PID and PWM update rate of my CCP based high frequency PWM driver.

*whew* ok well i need to get some sleep, sure there'll be plenty of coding to do come tomorrow morning. good luck to everybody else who at boilermaker this weekend!

-q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08

Last edited by Qbranch : 16-03-2007 at 00:06. Reason: added link
  #9   Spotlight this post!  
Unread 16-03-2007, 00:10
Spencer E.'s Avatar
Spencer E. Spencer E. is offline
Android junkie
FRC #1305 (NNSRI Ice3 (cubed))
Team Role: Alumni
 
Join Date: Apr 2005
Rookie Year: 2004
Location: Ontario, Canada
Posts: 91
Spencer E. has a spectacular aura aboutSpencer E. has a spectacular aura about
Send a message via MSN to Spencer E.
Re: Anyone actually using hardware timers?

Thanks Qbranch! If I ever need any interrupt help, I'll gladly ask . I was reading through IFI's white paper on timer interrupts and they have two methods: polled and interrupt driven. They say that either way is the same result but if it is suppose to cause an intterrupt at 25ms, and the fast loop is 26.2ms would it not cause some bias? I think the interrupt route would be more exact. Is there any difference?
  #10   Spotlight this post!  
Unread 16-03-2007, 00:18
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: Anyone actually using hardware timers?

Don't be fooled... there is a HUGE difference!

Picture this... the IFI main program loop polls for a bit saying that a new packet of data has been passed to the user processor from the master. Then, the IFI code calls Process_Data_From_Master_uP(). The whole time you are in this routine, you wont be polling for your flag... so that can mean up to many milliseconds of delay! Definitely not acceptible error for running a PID, calclating RPM, timing pulses, etc.

The interrupts will always be more (key word: more) exact than polling. While it does take a few microseconds to get into the interrupt, this is surely better than a few MILLIseconds. Of course there's a way around even the delay of interrupts... but we'll save CCP's for some time when I can talk with pad and pen and not have to type it all out.

Do you know how to use interrupts? Its kind of fun... but then again I think a lot of things are fun others dont . Kidding aside, if you need some tips/tricks/hints/explanations i'll give em.

Sometime i'm going to write a whitepaper on all the internal peripherals inside the processor... should be helpful. Just have to sit down and do it... ugh.

-q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
  #11   Spotlight this post!  
Unread 16-03-2007, 07:43
Spencer E.'s Avatar
Spencer E. Spencer E. is offline
Android junkie
FRC #1305 (NNSRI Ice3 (cubed))
Team Role: Alumni
 
Join Date: Apr 2005
Rookie Year: 2004
Location: Ontario, Canada
Posts: 91
Spencer E. has a spectacular aura aboutSpencer E. has a spectacular aura about
Send a message via MSN to Spencer E.
Re: Anyone actually using hardware timers?

All I need the timer for is moving the arm, like I've said before, but I would like it to be exact so I guess I'll work with the interrupt then, thanks for the clarification. I'm not exactly an expert when it comes to writing interrupt code but I can do the bare minimum needed. I've learned from Kevin Watson's interrupt codes how they should be handled and everything. IFI mentions in their white paper that what I should do is get out of the interrupt as fast as possible and just set a variable inside the interrupt and handle it later. I find this kind of weird so what I'm planning on doing is instead of doing it their way, just incrementing the variable I have for keeping the seconds timed and incrementing it inside the interrupt. I don't see a problem with it, is there anything I should know about this?

EDIT: When I mention incrementing the seconds in the interrupt, I mean after the initial 25ms and 100ms interrupts
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
Are you actually using bumpers? Chriszuma Technical Discussion 28 16-02-2006 18:41
Using Timers psquared Programming 9 30-01-2006 10:29
IS ANYONE USING PNUEMATICS archiver 2001 14 24-06-2002 00:18
Does anyone know what actually happened...? Adam Y. Regional Competitions 7 30-03-2002 01:48
Does anyone actually plan on playing rough? Joe Menassa General Forum 10 10-02-2002 05:09


All times are GMT -5. The time now is 20:15.

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