|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code Beta Test
Quote:
|
|
#2
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code Beta Test
Quote:
I've already enumerated some other advantages above. Quote:
For grins, I used digital servos (not FRC legal) with my code and after modifying tracking.c a bit, I can find a green light and start tracking in somewhere between one and two seconds, without the software having any a priori knowledge of where the light is located. I suspect nearly the same level of performance can be had with the HS322HD servos. -Kevin |
|
#3
|
|||
|
|||
|
Re: PWM 13-16 Replacement Code Beta Test
Kevin,
I would expect that the code should work fine. We (1126) used my version throughout the 2006 season without any issues. Your increase in gain from 40 to 50 is probably a good idea, as we found one of the Victors did not quite go to maximum at the high end (2 msec) without recalibration. The additional 25% on range should easily eliminate this potential problem. You may want to think about modifying your "temp_pwm_xx" calculation so it doesn't require the signed int multiplication. This adds a fair amount of execution time to the routine (relative to how quick it could execute, not to overall processor usage which is extremely minor). It also requires the use of the MATH_DATA section so if someone ever wanted to use the routine from within an interrupt (why? I don't know, but I never rule anything out), they would need to save that data section. I do like the addition of the CENTER & GAIN options it allows for much more flexibility. Mike |
|
#4
|
|||||
|
|||||
|
Re: PWM 13-16 Replacement Code Beta Test
So... is the legality of this confirmed?
-Adam |
|
#5
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code Beta Test
There are no rules preventing teams from using this code, so there is nothing to confirm. If you're thinking that this somehow gets around the ability to safe motors, it doesn't because IFI's mechanism for doing that is under the master microcontrollers control.
-Kevin |
|
#6
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code Beta Test
Quote:
Also, how did you get around the interrupt-glitch thing? I'm missing something obvious when I look at the code... |
|
#7
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code Beta Test
Most likely the PWM outputs from the user processor run through a buffer with an enable line, and the master disables the buffers when the robot is to be disabled, which tri-states the buffer outputs.
|
|
#8
|
|||
|
|||
|
Re: PWM 13-16 Replacement Code Beta Test
He disabled the interrupts when the pwm's transition from low to high
|
|
#9
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code Beta Test
Quote:
Edit: Actually, Dave's explanation may be closer to the truth. If the master is capable of generating the PWM output, why do we have the Generate_Pwms() kludge to deal with. Still, the 1.5 ms PWM neutral pulse needs to get generated for safety reasons. If not the master, who? Quote:
-Kevin Last edited by Kevin Watson : 15-01-2007 at 18:23. |
|
#10
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code Beta Test
If you're talking about when the robot is disabled, I'm pretty sure the PWM pins are left floating. We noticed a side effect of this last year when we ran some servo wires close to our RS232 for the camera, and when the robot was disabled the RS232 would generate enough noise on the (floating) PWM line to cause our camera servos to twitch. Actually, now that I think about it, if those PWM wires had been connected to a Victor, it could have been a dangerous situation. When the robot was enabled, the PWM output was being driven such that noise was not an issue.
|
|
#11
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code Beta Test
Quote:
-Kevin |
|
#12
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code Beta Test
Quote:
|
|
#13
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code
IMHO, one of the nice things about this software is the ability to define how the PWM range of 0-255 maps to the servo position range. So for fun, I decided that I'd like to wring-out as much pointing accuracy from my camera's tilt mechanism by mapping the entire 0-255 PWM range to the more useful 0 to 90 degree tilt range. These are the steps I took:
1) Moved the tilt PWM from PWM output 2 to 16. This is necessary because PWM() can only contol PWM outputs 13 through 16. 2) The first piece of information I needed was to find the PWM pulse width that caused the servo to rotate the camera to the 90 degree position. Using the camera software's interactive PWM adjustment menu to command the tilt mechanism to rotate the lens up, I found that the default gain of 5.0 us per PWM step wasn't high enough to rotate the camera to the 90 degree position. I opened up pwm.h and increased to gain on PWM output 16 to a value of 70 for a pulse step size of 7.0 us. I re-compiled and downloaded the code to the RC and found that I could command the servo to 90 degrees with a PWM value of 254. Using the inverse of the algorithm from PWM(), I calculated that PWM() was sending a PWM pulse width of 2.389 ms. 3) Using the same technique described above, I determined the pulse width I needed to send for 0 degrees to be 1.479 ms. 4) I then calculated the pulse width range that I needed to cover by subtracting the result of #2 from #3 for a range of 0.910 ms. 5) To calculate the gain, I just divided the pulse range needed by the available PWM range of 256 for a gain of 36 or 3.6 us per PWM step. This is the gain value that is needed to limit the range of servo motion to 90 degrees. 6) I now needed to calculate a new center point for the servo. If I leave it at 1.5 ms, the servo will rotate through a 90 degree range, but it will be -45 degrees to 45 degrees. I needed to change the center point to +45 degrees so the servo will rotate from 0 to 90 degrees. To calculate the new center point, I just divided the range (from #4) by 2 and added that to the 0 degree pulse width (from #3) for a value of 19340 (or 1.934 ms). 7) Plugging the values from #5 and #6 into pwm.h, re-compiling, loading the RC, and then testing, I found the range to be the desired 0 to 90 degree range! 8) I then changed the PWM value to angle code in terminal.c from: printf("Tilt Angle (degrees) = %d\r\n", (((int)TILT_SERVO - 144) * 25)/50); to: printf("Tilt Angle (degrees) = %d\r\n", ((int)TILT_SERVO * 90)/250); 9) The tilt gain was then changed from 8 to 4 for faster tracking. 10) Because I now have better pointing ability, I was also able to change the TILT_ALLOWABLE_ERROR_DEFAULT value to 3 pixels. 11) Finally, I changed the min tilt PWM value to 0, the maximum to 250 (255 is a degree or two past 90), adjusted the mid-point to 50. This new found pointing accuracy might come in handy if you're using the green tracking light for navigation. -Kevin |
|
#14
|
|||||
|
|||||
|
Re: PWM 13-16 Replacement Code
Using the Bells & Whistles camera code, PMWs 13-16 twitch for a moment when data is stored to EEPROM. I can work around it easily, but it's definitely undesired operation.
|
|
#15
|
||||
|
||||
|
Re: PWM 13-16 Replacement Code
Quote:
-Kevin |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vex start up code run PWM outputs without Rx | intellec7 | Programming | 3 | 05-05-2006 23:29 |
| Pwm 11, 12 and CMU code | Chris Bright | Programming | 3 | 01-02-2005 19:34 |
| Victor Replacement | JamesCH95 | Electrical | 4 | 15-12-2004 20:12 |
| Replacement Parts | archiver | 1999 | 0 | 23-06-2002 22:01 |
| replacement gears | joni_m | Technical Discussion | 1 | 22-01-2002 18:01 |