Go to Post I like the way you are saving weight by cutting out the center of the speed controllers. - jcatt [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 20-01-2005, 13:59
cabbagekid2 cabbagekid2 is offline
Registered User
#0368 (Kika Mana)
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Honolulu, HI
Posts: 85
cabbagekid2 has a spectacular aura aboutcabbagekid2 has a spectacular aura aboutcabbagekid2 has a spectacular aura about
Lightbulb FYI about using PWM 13-16 with interrupts

Here's what I posted to Innovation FIRST and their answer.

Question:
In the original default code, for the v2.2 compiler, PWMs 13-16 use a generate function to control the PWMs. How does this function work and what exactly does it do? How are PWMs 13-16 different from PWMs 1-12? I am asking this because yesterday we were testing our modified default code using optical encoders connected to the digital I/O pins. The wierd thing that happened was that as the encoders were rotated faster (about 900rpm attached to a cordless drill) the drive wheels started rotating. I looked through the code and did not see any other function other than the generate function that calls pwms 13-16. For now we just changed our drive wheels to operate off of PWM 9-12 and the wheels do not turn by themselves when the encoders are rotated really fast.

Also, is there a reason why the default code used with the camera uses pwm 11 and 12 while the default code without the camera uses pwms 13-16? Is this similar to the issue I am having now?

Answer:
The PWM outputs 1 - 12 are handled by the Master microprocessor. PWM outputs 13 - 16 are generated via the user code. All four of these PWMs get generated within 2ms at a 26.2 ms rate. These PWMs are susceptible to interrupt interference. PWM signals have 255 steps and each step is ~5us. Since interrupts have at least a 5us latency, they will stretch a PWM signal up to the amount of time it takes to process the interrupt. So if your user code is processing interrupts at a high rate or your interrupt routines are long, the pwm signals on outputs 13 – 16 could be modified/stretched to create a forward condition on a motor. PWM outputs 13 – 16 should be avoided if user code is interrupt intensive.

My thoughts: I guess that's why most people don't use pwm 13-16

Last edited by cabbagekid2 : 20-01-2005 at 14:17.
  #2   Spotlight this post!  
Unread 20-01-2005, 16:30
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: FYI about using PWM 13-16 with interrupts

Can someone verify this? I believe (though could be wrong) that the generate PWMs function just gives it to the hardware, and that handles it.

If I'm wrong, I guess we have ourselves 4 more digital outputs.
  #3   Spotlight this post!  
Unread 20-01-2005, 17: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: FYI about using PWM 13-16 with interrupts

Quote:
Originally Posted by Astronouth7303
Can someone verify this? I believe (though could be wrong) that the generate PWMs function just gives it to the hardware, and that handles it.

If I'm wrong, I guess we have ourselves 4 more digital outputs.
Yes, I noted some general wackyness in PWM13-16 last year and mentioned it in the IR beacon tracking FAQ.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #4   Spotlight this post!  
Unread 20-01-2005, 23:50
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: FYI about using PWM 13-16 with interrupts

Team 177 also abandoned PWMs 13-16 last year for the same reason.

Note to self: Use PWM16 to power camera!
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #5   Spotlight this post!  
Unread 21-01-2005, 07:09
MarkVH's Avatar
MarkVH MarkVH is offline
Registered User
AKA: Mark VanHaitsma
FRC #0288 (RoboDawgs)
Team Role: College Student
 
Join Date: Dec 2004
Rookie Year: 2003
Location: Grandville
Posts: 30
MarkVH is on a distinguished road
Re: FYI about using PWM 13-16 with interrupts

I am using the default code and it is sending the same value to pwm13 ,. 14 , 15 , and 16. Any ideas on how to fix it? Right know on the test robot I have 2 mootars wired backward to get it to go straight when the joystick is in the forward positon.
  #6   Spotlight this post!  
Unread 21-01-2005, 08:05
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: FYI about using PWM 13-16 with interrupts

PWMs 13-16 appear to be bit-banged. We had trouble with them last year. If an interrupt occurs while the generate_pwms function is running, the pulse width will be lengthend (or shortened, depending on the part of the cycle you're in) by the amount of time that the uC takes to handle the interrupt. We moved the generate_pwms call to the very last thing that happened each loop - this solved the problem.
__________________
-
An ounce of perception is worth a pound of obscure.
  #7   Spotlight this post!  
Unread 22-01-2005, 00:54
ConKbot of Doom ConKbot of Doom is offline
Team Alumni
FRC #1184 (Cobra Robotics)
Team Role: Leadership
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Maryland
Posts: 153
ConKbot of Doom has a spectacular aura aboutConKbot of Doom has a spectacular aura aboutConKbot of Doom has a spectacular aura about
Re: FYI about using PWM 13-16 with interrupts

Quote:
Originally Posted by Chris Hibner
PWMs 13-16 appear to be bit-banged.
The CCP module on the PICs generates a pwm signal that is variable in the duty cycle. The kind that the victors and servos use is variable in the pulse width. (sounds similar, but they are different) So the pwm signal would have to be generated in software, since the hardware isn't suitable for what we need.

But like you pointed out, nothing that careful programming can't resolve.
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
Assistance for First-Year Teams - MOEmentum: FYI Mr MOE General Forum 0 13-01-2005 17:01
First Year Team Assistance - MOEmentum: FYI Mr MOE General Forum 0 07-01-2005 14:07
Using an Operator Interface with the 2004 EDU RC wirelessly Dave Flowerday Robotics Education and Curriculum 34 19-04-2004 19:06
pwm 13-15 wayne 05 Programming 2 04-10-2003 12:08
PWM and burning out motors patrickrd Technical Discussion 7 19-06-2003 15:30


All times are GMT -5. The time now is 21:50.

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