Thanks a lot. Actually I am trying to generate a sinewave, and some different wave shapes all synchronized to the mains. Moreover I have to phase shift the outputs i= n certain cases. Therefore LUT is the only way out. For all them there are corresponding tables each with 256 values. The problem now remains how to synchronize them with the supply(this may vary by +-1.5Hz). Any idea? Deep. On Wed, Jul 13, 2011 at 4:24 PM, Michael Watterson wrote= : > On 13/07/2011 10:10, dipten wrote: > > However the problem now is: how to synchronize with some arbitrary inpu= t > > waveform or arbitrary frequency (changed to square wave using > comparator). > > > > Can any one please suggest me a scheme? > > Count between two rising (or falling) edges to measure very low > frequencies. > Count using onboard HW counter and read & reset at fixed time interval > to measure higher frequencies > > Use XOR between your current O/P (internal Squarewave at 0 or 90 > degrees) 1 or 0 and software low pass filter to retard or increase the > start time of scanning the 256 table. > > Read up on how PLLs work. > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 "*Don't worry about people stealing your ideas. If your ideas are any good, you'll have to ram them down people's throats*."----- Howard Aiken --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .