Go to Post Best way to get the word out for FIRST is Demo, Demo, Demo. There's no reason anyone in your community shouldn't know what you folks are doing. - Martinez [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 04-02-2006, 17:29
Kyveck Kyveck is offline
Registered User
FRC #1014 (Dublin Robotics)
Team Role: Programmer
 
Join Date: Jan 2006
Location: Ohio
Posts: 16
Kyveck is an unknown quantity at this point
ADC code effecting motor outs???

Our robot's motors seem to be receiving some sort of signal even when all pwm outs are hardcoded to zero. We systematically turned off sensors and bits of code, until we isolated the problem with the adc software. Unless we disable the adc code, (by commenting out the adc initialization or the adc/timer interrupt routines) the drive wheels act as if they are set to 10 or 20 above neutral, instead of 127. If we enable the joystick and pull it back about 10 or so, the wheels stop. If we set one wheel to be mapped as (255-p2_y) then ten forward or so stops one wheel and speeds up the other, and vice versa. If we change the sampling rate from 200Hz that we were using to 800Hz, then the wheels spin much faster, but in the same manner.

If anyone has any clue what's going on, I would be very grateful for insight. I realize that both ways that we have found to stop the motor movement have the net effect of not causing any adc interrupts, but I don't see what could be going wrong. The dashboard viewer continues to read neutral pwm values for all RC pwm outs. The gyro is on analog in 1, and the motors are on pwms 13 and 15. We have patched in Kevin Watson's gyro and adc code, version 0.4. Once again, if any one can help, we'd all appreciate it.

KLW,
Controls Software Lead,
Team 1014, Dublin Robotics (Bad Robots)
  #2   Spotlight this post!  
Unread 04-02-2006, 18:25
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: ADC code effecting motor outs???

Quote:
Originally Posted by Kyveck
Our robot's motors seem to be receiving some sort of signal even when all pwm outs are hardcoded to zero. We systematically turned off sensors and bits of code, until we isolated the problem with the adc software. Unless we disable the adc code, (by commenting out the adc initialization or the adc/timer interrupt routines) the drive wheels act as if they are set to 10 or 20 above neutral, instead of 127. If we enable the joystick and pull it back about 10 or so, the wheels stop. If we set one wheel to be mapped as (255-p2_y) then ten forward or so stops one wheel and speeds up the other, and vice versa. If we change the sampling rate from 200Hz that we were using to 800Hz, then the wheels spin much faster, but in the same manner.
This explains the symptoms we've been seeing as well. Our current code (which uses Kevin's ADC code for the gyro, DAA, and one other channel) shows a slightly positive value on the PWMs, but the default code doesn't. It 's not causing us any problems, but it's enough to cause the CIMs to hum even when everything is set to 127.
  #3   Spotlight this post!  
Unread 04-02-2006, 19:37
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,082
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: ADC code effecting motor outs???

This is news to me...

Have you tried recalibrating the speed controllers?
  #4   Spotlight this post!  
Unread 04-02-2006, 19:41
Kyveck Kyveck is offline
Registered User
FRC #1014 (Dublin Robotics)
Team Role: Programmer
 
Join Date: Jan 2006
Location: Ohio
Posts: 16
Kyveck is an unknown quantity at this point
Re: ADC code effecting motor outs???

This is more than a slight hum. At 800Hz, the robot drives about 3 m/s when we take it off blocks.
  #5   Spotlight this post!  
Unread 04-02-2006, 19:56
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: ADC code effecting motor outs???

Quote:
Originally Posted by Kyveck
Our robot's motors seem to be receiving some sort of signal even when all pwm outs are hardcoded to zero. We systematically turned off sensors and bits of code, until we isolated the problem with the adc software. Unless we disable the adc code, (by commenting out the adc initialization or the adc/timer interrupt routines) the drive wheels act as if they are set to 10 or 20 above neutral, instead of 127. If we enable the joystick and pull it back about 10 or so, the wheels stop. If we set one wheel to be mapped as (255-p2_y) then ten forward or so stops one wheel and speeds up the other, and vice versa. If we change the sampling rate from 200Hz that we were using to 800Hz, then the wheels spin much faster, but in the same manner.

If anyone has any clue what's going on, I would be very grateful for insight. I realize that both ways that we have found to stop the motor movement have the net effect of not causing any adc interrupts, but I don't see what could be going wrong. The dashboard viewer continues to read neutral pwm values for all RC pwm outs. The gyro is on analog in 1, and the motors are on pwms 13 and 15. We have patched in Kevin Watson's gyro and adc code, version 0.4. Once again, if any one can help, we'd all appreciate it.

KLW,
Controls Software Lead,
Team 1014, Dublin Robotics (Bad Robots)
The problem is that PWM channels 13-16 are "bit banged" by code running on the user processor. When you have a lot of interrupts firing-off in the background, IFI's code get's interrupted while running, which causes jitter in the outputs. The only solution is to not use PWMs 13-16.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #6   Spotlight this post!  
Unread 04-02-2006, 20:47
Kyveck Kyveck is offline
Registered User
FRC #1014 (Dublin Robotics)
Team Role: Programmer
 
Join Date: Jan 2006
Location: Ohio
Posts: 16
Kyveck is an unknown quantity at this point
Re: ADC code effecting motor outs???

Thanks. That makes sence. I tried to find the source for the Generate_pwms function, but it was in a library. Between the adc, timer, serail comms, and encoders, we probably get about 400 interrupts a second. We'll just switch to a different pwm out. Thanks again,
KLW
  #7   Spotlight this post!  
Unread 04-02-2006, 23:06
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: ADC code effecting motor outs???

Quote:
Originally Posted by Abwehr
This is news to me...

Have you tried recalibrating the speed controllers?
Ours are calibrated. For us, the problem is slight (it's just a few steps outside of the Victor's deadband).
  #8   Spotlight this post!  
Unread 04-02-2006, 23:07
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: ADC code effecting motor outs???

Quote:
Originally Posted by Kevin Watson
The problem is that PWM channels 13-16 are "bit banged" by code running on the user processor. When you have a lot of interrupts firing-off in the background, IFI's code get's interrupted while running, which causes jitter in the outputs. The only solution is to not use PWMs 13-16.
That's rather what I suspected. I'll try having the guys shuffle around the PWMs.
  #9   Spotlight this post!  
Unread 05-02-2006, 21:31
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: ADC code effecting motor outs???

Kyveck,

If you still want to use PWMs 13-16, you can try this piece of code (hopefully this is the working version...). It replaces the Generate_Pwms function call and utilizes Timer 3 and the CCP modules to control the pwm 13-16 pulse width. Since the pulse is controlled by hardware, it should be independent of other interrupts. My team was planning on using PWM 13, 15 & 16 this year in order to improve the Victor response time since PWMs 1-12 seem to put around a 50 millisecond delay between setting the pwm output variable and for the Victor to respond (communication to the master processor plus some other delay). But based on the recent comments I've read on CD, having a jittery PWM output would not be unacceptable.

I have not had a chance to do any extensive testing on this code other than a quick check to be sure that it is indeed generating a 1-2 millisecond pulse, so it may still have some bugs. I plan on running more tests over the next week but if you decide to use it and have any questions or problems, let me know.

Mike
Attached Files
File Type: zip User_PWMs.zip (2.4 KB, 77 views)
  #10   Spotlight this post!  
Unread 05-02-2006, 21:47
Eldarion's Avatar
Eldarion Eldarion is offline
Electrical Engineer / Computer Geek
AKA: Eldarion Telcontar
no team (Teamless Orphan)
Team Role: Alumni
 
Join Date: Nov 2005
Rookie Year: 2005
Location: Númenor
Posts: 558
Eldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond repute
Send a message via AIM to Eldarion Send a message via Yahoo to Eldarion
Re: ADC code effecting motor outs???

Thanks for posting that code. I will be trying it out sometime soon, but I will have to port it to Timer 2, as Timer 3 is in use already.
__________________
CMUCam not working? Tracks sporadically? Try this instead: http://www.falconir.com!
PM me for more information if you are interested (it's open source!).

Want the FIRST Email blasts? See here: http://www.chiefdelphi.com/forums/sh...ad.php?t=50809

"The harder the conflict, the more glorious the triumph. What we obtain too cheaply, we esteem too lightly; it is dearness only that gives everything its value."
-- Thomas Paine

If it's falling apart it's a mechanical problem. If it's spewing smoke it's a electrical problem.
If it's rampaging around destroying things it's a programming problem.

"All technology is run on 'Magic Smoke' contained within the device. As everyone knows, whenever the magic smoke is released, the device ceases to function."
-- Anonymous

I currently speak: English, some German, Verilog, x86 and 8051 Assembler, C, C++, VB, VB.NET, ASP, PHP, HTML, UNIX and SQL
  #11   Spotlight this post!  
Unread 06-02-2006, 01:42
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: ADC code effecting motor outs???

Quote:
Originally Posted by Mike Bortfeldt
Kyveck,

If you still want to use PWMs 13-16, you can try this piece of code (hopefully this is the working version...). It replaces the Generate_Pwms function call and utilizes Timer 3 and the CCP modules to control the pwm 13-16 pulse width. Since the pulse is controlled by hardware, it should be independent of other interrupts. My team was planning on using PWM 13, 15 & 16 this year in order to improve the Victor response time since PWMs 1-12 seem to put around a 50 millisecond delay between setting the pwm output variable and for the Victor to respond (communication to the master processor plus some other delay). But based on the recent comments I've read on CD, having a jittery PWM output would not be unacceptable.

I have not had a chance to do any extensive testing on this code other than a quick check to be sure that it is indeed generating a 1-2 millisecond pulse, so it may still have some bugs. I plan on running more tests over the next week but if you decide to use it and have any questions or problems, let me know.

Mike
Mike, this is cool. If someone has some free time <grin>, a good experiment would be to use Mike's code to see if you can wring-out a little more pointing accuracy from the camera servos.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #12   Spotlight this post!  
Unread 06-02-2006, 09:25
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: ADC code effecting motor outs???

Quote:
Originally Posted by Kevin Watson
Mike, this is cool. If someone has some free time <grin>, a good experiment would be to use Mike's code to see if you can wring-out a little more pointing accuracy from the camera servos.
I'm working on that as a side project.
  #13   Spotlight this post!  
Unread 06-02-2006, 09:38
Joel J's Avatar
Joel J Joel J is offline
do you..
no team
 
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
Joel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond repute
Re: ADC code effecting motor outs???

This made me smile:

pwm13 * 40; // Calculate the time delay for PWM13
CCPR2 = PROD + 9913;

Beautiful!
__________________
Joel Johnson

Division By Zero (229) Alumni, 2003-2007
RAGE (173) Alumni, 1999-2003
  #14   Spotlight this post!  
Unread 27-03-2006, 20:07
Gary Bonner Gary Bonner is offline
Registered User
FRC #3974
 
Join Date: Jan 2002
Rookie Year: 2000
Location: PA
Posts: 120
Gary Bonner has a spectacular aura aboutGary Bonner has a spectacular aura about
Re: ADC code effecting motor outs???

Can someone explain what this does, particularly the first line?

Thanks.

Code:
	pwm13 * 40;		// Calculate the time delay for PWM13
	CCPR2 = PROD + 9913;
  #15   Spotlight this post!  
Unread 27-03-2006, 20:14
Joel J's Avatar
Joel J Joel J is offline
do you..
no team
 
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
Joel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond repute
Re: ADC code effecting motor outs???

The first line does a multiplication. When you do a multiplication on the PIC, it is stored in the PROD register. The second line gets the value from the PROD and uses it. He does it this way so he has one less section to save before servicing the interrupt.
__________________
Joel Johnson

Division By Zero (229) Alumni, 2003-2007
RAGE (173) Alumni, 1999-2003
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
Out of the Box Camera Code russell Programming 9 21-10-2009 05:28
Analog-to-Digital Converter Code Kevin Watson Programming 29 17-02-2008 13:07
adc code problem railerobotics Programming 6 24-01-2006 22:26
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
heres the code. y this not working omega Programming 16 31-03-2004 15:18


All times are GMT -5. The time now is 02:10.

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