-------------------------------------------------- From: Sent: Thursday, July 29, 2010 4:38 PM To: Subject: RE: [PIC] 16F747 UART errors >> Yes, the PWM module cannot achieve the low duty cycles required while >> maintaining adequate resolution. If I recall correctly I think if I > was >> willing to tolerate 10ms pulse spacing (instead of 20) then it would > have >> functioned but with very low resolution and I was told the short pulse >> spacing may have upset some servos. (Don't quote me, I'm speaking > from >> memory - but I'd wanted to use the PWM module and was forced to reject > that >> idea) >> >> The way I do it now is to set the TMR0 prescaler to 256, which gets me >> something like 12 or 13ms until the interrupt. The first time it > interrupts >> it resets the prescaler to 128 and returns which delivers the > remaining 7 or >> 8ms. The second time the interrupt is triggered it sets all the servo > lines >> high for 1ms followed by an additional 0 to 1ms. In this way I get > 8bit >> pulse width resolution but still have the processor yielded for >> communications about 90% of the time. I'm not saying this is the best >> way... but it was the only way I could come up with to combine control > of >> multiple servos, good resolution, serial communication, 6 ADCs for >> measurements, and fast 20MHz clock for computation. >> >> Drew > > OK, I have a feeling you could possibly select a better chip for the job > - seriously. > > The chip you have is not a nanowatt part - from what I can make out from > the Microchip site, it won't let me look at the page for that chip > currently. There are PIC24 chips that are nanowatt, and I suspect you > probably want to be saving all the power you can in a pilotless drone. > This may or may not be a consideration, it is not clear to me if you are > attempting a solar powered drone or not. > > As indicated above you are having problems with PWM resolution. PIC24 > PWM channels have 16 bit resolution in place of the 5/6/7/8/10 bit that > that the 16F series do. And they have a heap of hardware channels that > will do it for you - as Olin said, set and forget. The largest chips do > have 5 hardware PWM channels and 4 UART channels. There is also a number > of SPI channels that could be used (with a bit of thought) as PWM > channels, with 16 stages of resolution, by transmitting a 16 bit word > with the appropriate bits set, at a timer interrupt determined interval. > Set the SPI clock to make the 16 bits 2.5mS long if that gives you > enough resolution, or stuff a number of 16 bit words into the SPI Tx > FIFO with a suitably faster clock to achieve better resolution. > > You are already using a 40/44 pin part, so going to a large pin count > PIC24 won't be a hardship. Use the best tool for the job, instead of > make do and mend. I agree with Olin and Alan here too. For something like this I would use an= =20 18F minimum, but most likely something like a PIC24, dsPIC or maybe even a= =20 PIC32. The price differences are negligible for a hefty increase in performance. I= =20 hardly use 16Fs for anything apart from the most basic stuff nowadays, when= =20 you can get an 18F for just about the same prices, and PIC24s and PIC32s fo= r=20 a couple of pounds more. Few options here that maybe of interest: dsPIC33F - 16-bit, 40MIPS, 4 PWM modules: High-Speed PWM Module Features Up to Four PWM Generators with Four to Eight Outputs Dead Time for Rising and Falling Edges Duty Cycle Resolution of 1.04 ns for Dead-Time, Phase Shift, and Frequency Supported PWM modes: Standard Edge-Aligned, True Independent Output,=20 Complementary, Center-Aligned, Push-Pull, Multi-Phase, Variable Phase, Fixe= d=20 Off-Time, Current Reset, and Current-Limit PWMxL, PWMxH Output Pin Swapping PWM4H, PWM4L Pins Remappable On-the-Fly PWM Frequency, Duty Cycle and Phase Shift Changes http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=3Den537159 PIC24 - 16-bit, 16MIPS, nanowatt power, up to 5 PWM modules: Peripherals - CTMU supports Capacitive Touch applications -=20 Peripheral Pin Select allows I/O remapping of many peripherals in real=20 - 4xUART Modules with LIN and IrDA support, 4 Deep FIFO - 3xSPI=20 Modules with 8 Deep FIFO - 3xI2CT Modules with Master and Slave=20 - Five 16-bit Timer Modules - Up to 9 Input Capture and 5 Output= =20 Compare/PWM with dedicated time base - Hardware RTCC, Real-Time Clock= =20 Calendar with Alarms - PMP, Parallel Master Port, with 16 Address=20 Lines, and 8/16-bit Data http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=3Den531072 PIC32 - 32-bit, 80MHz, 1.56 DMIPS/MHz, 5 PWM modules: Max Speed MHz 80 Program Memory Size (KB) 512 RAM (KB) 32 DMA Channels 4 SPITM 2 I2CTM Compatible 2 A/D channels 16 Max A/D Sample Rate 1000 Input Capture 5 Output Compare/Std. PWM 5 16-bit Digital Timers 5 Parallel Port PMP16 Comparators 2 Internal Oscillator 8 MHz, 32 kHz RTCC Yes I/O Pins 85 Pin Count 100 http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=3Den532441 =20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .