Hi Olin, > That doesn't make sense. A 4MHz clock results in a 1MHz > instruction rate, > which must be divided by 64 to get 8 bit PWM resolution, > which results in > 15.6KHz PWM rate. 8 bit resolution is certainly enough for > closed loop > control of a Peltier cooler. Actually, 6 bits is probably more than > adequate. > Oops, silly me. How did I ever drop that leading '1' in my calculations, I'll never know ;) > > Unfortunately, increasing crystal speed will require a > > considerable amount of code revision to adjust timing, > examples being > > PWM registers, serial registers, bit-bashing clocking loops, and PID > > timing loops. > > This should not be the case for well written code. You > should always have > an assembly constant the specifies the clock speed, then > everything else > computed from that. Take a look at my UART_BAUD and > TIMER2_USEC macros in > STD.INS.ASPIC at http://www.embedinc.com/pic for examples of > how this can be > done. Hard coding divider values and other timing parameters > is just plain > bad practise. > Agreed, but this is a project "in the works", and did not start out as my own code. It is also large, over 6k of code space. It does a lot more than just PID control of Peltier's. I will be going through the code and pulling all of this stuff together once the basic implementation is complete. I am still using absolute mode, and not the linker, which does not help ... but again, this is not originally my code so changing over from absolute mode *will* require considerable revision. > > However, I have almost finished a dual PIC PID controller design, > > runnning at 20MHz, and using interrupt driven bit-bashing to > > communicate between PICs, using one PIC as the PID controller, and > > the other as the master. This setup works really well. This one is completely my own design, done the way *I* like it. It implements all the points you have made out, and then some. > > > > PS: Olin - 1mF??? Isn't that just 1000uF? > > The "m" stands for "milli" meaning 1/1000 and the "u" for > "micro" meaning > 1/1000000. In engineering notation, one tries to keep the > mantissa part so > that it has 1 to 3 digits left of the point. While 1000uF > does express the > value, 1mF is the preferred way to write it. > > For some reason the standard engineering notation convention was not > followed for capacitance way back when. The milli and nano > ranges were > skipped so that everything was either micro or pico. This > led to cumbersome > values like .01uF or 10000pF. Lately this sillyness is being > abandoned. I > make it a point to use proper engineering notation for > values, including > capacitance. Try telling this to parts suppliers, electronics ans schematical texts, and, well, everywhere really. I know my engineering notation very well thank you Olin, but I am definately not used to seeing 1000uF written as 1mF, so I thought it might have been a typo on your behalf ;) I can understand the "non-standardness" with capacitance however, because the standard measure for 1 Farad is very big. This problem is not restricted to capacitance either. Inductance and the Henry share the same problem. Thanks and regards Ian -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body