|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Re: ADC code effecting motor outs???
Refreshing the victors faster will not help. It's a limitation of the vectors. However, by generating the pulses with hardware could accomplish somethings with the hobby servos. The period could go below 1 ms and above 2 ms. This can give about 170 degree's on the model Hitec servo I have. The period generation can also be finer than the 8 bit values available with the default code. That may help with the resolution of the camera aiming.
|
|
#17
|
|||
|
|||
|
Re: ADC code effecting motor outs???
Gary,
Actually I wrote the code that way more for efficiency and to keep the footprint as small as possible. The first line, as Joel says, performs a multiplication that when used with the timer and CCP module determines the duration of the pulse. It is written in that particular manner to ensure that the compiler uses the 8x8 hardware multiplier (chapter 9 of the PIC18F8722 data sheet) rather than one of the math library routines to perform the operation. The result of the 8 bit multiply is automatically placed in the PROD register pair (this is a 1 instruction clock cycle operation). While I could have assigned a variable to receive the result of this multiplication (and cast the variables as ints), it was an unnecessary step as the next line can just as easily use the result from the PROD registers (10,000 = 1 millisecond). If you want, you can look in the generated .lst file to see how these statements are converted into assembly code. The relevant operation is the MULWF instruction and additional information on that can be found in chapter 26 (Instruction Set Summary) of the data sheet. (If you have some free time, take a look at what the C18 "WREG tracking" optimization does to the assembly code and how that would change the pulse width slightly) Mike |
![]() |
| 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 |