|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: ADC code effecting motor outs???
Quote:
|
|
#3
|
|||||
|
|||||
|
Re: ADC code effecting motor outs???
This is news to me...
Have you tried recalibrating the speed controllers? |
|
#4
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: ADC code effecting motor outs???
Quote:
|
|
#6
|
||||
|
||||
|
Re: ADC code effecting motor outs???
Quote:
-Kevin |
|
#7
|
|||
|
|||
|
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 |
|
#8
|
||||
|
||||
|
Re: ADC code effecting motor outs???
Quote:
|
|
#9
|
|||
|
|||
|
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 |
|
#10
|
|||||
|
|||||
|
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.
|
|
#11
|
||||
|
||||
|
Re: ADC code effecting motor outs???
Quote:
-Kevin |
|
#12
|
||||
|
||||
|
Re: ADC code effecting motor outs???
Quote:
|
|
#13
|
||||
|
||||
|
Re: ADC code effecting motor outs???
This made me smile:
pwm13 * 40; // Calculate the time delay for PWM13 CCPR2 = PROD + 9913; Beautiful! |
|
#14
|
|||
|
|||
|
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
|
||||
|
||||
|
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.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |