What if the duty cycle is not 50%, and say variable? RA ----- Original Message ----- From: "Bill & Pookie" To: Sent: Tuesday, April 29, 2003 12:57 PM Subject: Re: [PIC]: Frequency multiplier? > Great, very simple, very good. > > Bill > > ----- Original Message ----- > From: "Rychta Bretislav" > > To: > Sent: Monday, April 28, 2003 11:48 PM > Subject: SV: [PIC]: Frequency multiplier? > > > The better way is to add 10 to input count and > subtract 13 from output > count. When output count underflow, toggle output > pulse and ADD 'last pulse > count' to output count. > This approach don't need any further correction > and allow you to easy change > ratio of input and output frequency by changing > only 2 constants. > Run sequence on interrupt from timer to get > constant sampling frequency > which is in your case higher than 2*4000*13/10 Hz > and lower than 2*200*65536/10 Hz (for 2-Byte > counters) > > Breta > > -----Ursprungligt meddelande----- > Fren: Bill & Pookie > [mailto:williamcornutt111@ATTBI.COM] > Skickat: mendag 28 april 2003 16:05 > Till: PICLIST@MITVMA.MIT.EDU > Dmne: Re: [PIC]: Frequency multiplier? > > > Looking at the question as inputting a signal with > a 50% duty cycle and outputting a signal 130% > greater with a 50% duty cycle, here is my > solution. > > Requires 4 routines, > > count input pulse width > see if input changed > decrement output count > see if time to change output > > > COUNT INPUT PULSE WIDTH > > In order to get the increase in frequency, the > input count must be reduced before it becomes the > count for the output. This is done by not > counting the input pulse every forth time. > > The 'fourth input counter' will add a count to the > input count to 'tweak it from 125% to 130% every > 13th time it is called. The 52 (4*13) input > timings results in 39 (3*13) input counts, and if > 1 input count is added at this time, the > percentage of 40 counts to 52 timings is 130%. > > SEE IF INPUT CHANGES > > When the input state changes, the input count is > moved to the 'last pulse count' and the input > pulse count is cleared. It may be a good idea to > average the last pulse count and input pulse > instead of just moving it. This is easily done by > adding the two and right shifting the results. > This averaging will encourage a 50% duty cycle for > the output pulses. > > DECREMENT OUTPUT COUNT > > Just subtract one from output count. > > SEE IF TIME TO CHANGE OUTPUT > > if output count is zero, toggle output pulse and > move 'last pulse count' to output count > > So there would be three series of > count input pulse width > see if input changed > decrement output count > see if time to change output > > And a fourth series with the 'count input pulse > width' modified to only counting every 13th time. > > One main concept is that the input pulse and > output pulse have no relationship in time except > the 'last pulse count', and that count can change > any time with the output routine using it when it > toggles the output pulse and starts a new pulse. > > Bill > > > ----- Original Message ----- > From: "Gary Neal" > To: > Sent: Wednesday, April 23, 2003 6:08 PM > Subject: [PIC]: Frequency multiplier? > > > > Hi, > > > > I've got a variable frequency signal (200hz to > 4khz) whose frequency I want > > to increase by 30% (5v signal). IE if the input > frequency is 1000hz, I > > want to output 1300hz. Is there an easy method > of doing this? I've heard > > of PLL, but don't have a clue how to build them, > so if there's an easier > > option that would be great. > > > > Thanks, > > > > Gary > > > > -- > > http://www.piclist.com hint: The list server can > filter out subtopics > > (like ads or off topics) for you. See > http://www.piclist.com/#topics > > -- > http://www.piclist.com hint: The list server can > filter out subtopics > (like ads or off topics) for you. See > http://www.piclist.com/#topics > > -- > http://www.piclist.com hint: The PICList is > archived three different > ways. See http://www.piclist.com/#archives for > details. > > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.