All About Circuits Forum  

Go Back   All About Circuits Forum > Electronics Forums > The Projects Forum


The Projects Forum Working on an electronics project and would like some suggestions, help or critiques? If you would like to comment or assist others with their projects, this is the place to do it.

Reply   Post New Thread
Thread Tools Display Modes
Old 07-04-2009, 02:41 PM
eblc1388's Avatar
eblc1388 eblc1388 is offline
Senior Member
Join Date: Nov 2008
Location: UK
Posts: 1,542
Default 50/60Hz Frequency conversion using PIC

For electric clock using synchronous motor designed for the other frequency vs local mains frequency, some form of frequency conversion is required.

It is often not satisfactory to use just a crystal oscillator as one can expect timing error of about 1~4 minute per month, with the changing of ambient room temperature. An AC connected clock will do much better in long term period of months or year as the power company often undertake to correct for any timing error between an AC powered clock and an accurate time source by varying system frequency to compensate.

In simple term, the converted frequency must be somehow related/locked to the mains frequency and the clock powered by this frequency will keep time fine as any other clock.

There are many possibilities:

A. using a single 8-pin PIC - By eblc1388

1. single chip solution, works also for 60Hz into 50Hz
2. standalone 50Hz or 60Hz standard frequency output, crystal accuracy
3. no adjustment required
4. software ensure exact cycles tally. e.g 600 cycle of 60Hz vs 500 cycles of 50Hz

YouTube: 50/60Hz Frequency Conversion Using PIC

B. Phase locked loop & 600Hz to 60Hz direct conversion - By eblc1388

1. use x6 PLL to get 600Hz square wave from 100Hz
2. use 5-stage ring counter to build staircase waveform(see image below)
3. pass staircase waveform to RC filter to get 60Hz sine wave

More information here: post#32

Forum Post#32: frequency multiplier

C. Harmonic method - By Rod Elliott

1. Picking out the sixth harmonic of 100Hz (50Hz fullwave rectified) signal
2. amplified and squaring the signal to get 600Hz square wave
3. divide by 10 to get 60Hz square wave
4. pass into active filter to remove all higher harmonic leaving fundamental 60Hz sine wave

The link is here: Frequency Changer for Low Voltage Synchronous Clocks

The bottom trace is the combined waveform output of the five stage ring counter and the top trace signal after RC filter, mentioned in option B above.

Attached Images
File Type: jpg P005a_60Hz_From_4018.jpg (94.8 KB, 132 views)
Reply With Quote
Old 07-06-2009, 01:40 PM
THE_RB's Avatar
THE_RB THE_RB is online now
Senior Member
Join Date: Feb 2008
Posts: 5,222

Really nice! I've been watching the frequency conversion threads.

Here is some minimalist math to add to the list, it converts 120Hz to 1200Hz, then generates 100Hz locked to the orig 120Hz. For use in clocks/timers etc that display hundredths of seconds but are still locked to 60Hz mains.

It will also convert 100Hz->120Hz, 50->60, 60->50 etc with zero-error using the very simplest of math (a bresenham accumulator system) and just 2 variables;

	// C code for low-jitter generation of 100Hz from 120Hz mains
	// PIC code, 4MHz xtal, TMR1 at 1:8 prescale 
	// uses 2 variables;
	//   unsigned int bres
	//   unsigned char pulse


	// wait here for 120Hz pulse

	// now generate 10 "fake" pulses, each is "1200Hz"
	// which is 833uS. PIC 1Mhz xtal, TMR1 1:8 prescale,
	// we use TMR1L period of 104 = 832uS 
	// note! TMR1L loop is also another zero-error system
	// that we keep subtracting 104 from while retaining
	// its internal error.

	pulse = 10;		// make 10 "fake" pulses
	TMR1L = 0;		// make first pulse immediately

		// wait here for fake 1200Hz pulse	

		// now fix TMR1L and do the main bres event
		TMR1L -= 104;	// subtract 1/1200th of a second

		bres += 100;
		if(bres >= 1200)	// if 100th sec reached!
			bres -= 1200;
			do_100th_event();	// update clock, etc

		// subract a pulse, see if 10 done yet

	// gets here after 10 "fake" 1200Hz pulses,
	// need to detect a real 120Hz pulse, then
	// do it all again!

	goto start;
Select All
It can be seen halfway down the page under "Advanced bresenham timing techniques" on this page;
and there's more code on that page for generating exact 1 second periods for clock use etc.
Reply With Quote
Old 07-06-2009, 05:36 PM
eblc1388's Avatar
eblc1388 eblc1388 is offline
Senior Member
Join Date: Nov 2008
Location: UK
Posts: 1,542

Well in digital clocking one can wait until the correct moment to do things, or puts out all the required pulses within 10% of the start of the whole interval. The counter that accept the clocking pulses would not care.

In analogue world, the AC sine waveform cannot be put on hold, and one cannot have 3/4 or 1.25 cycles of a waveform and then suddenly starts a new one.
Reply With Quote
Old 07-07-2009, 02:46 PM
THE_RB's Avatar
THE_RB THE_RB is online now
Senior Member
Join Date: Feb 2008
Posts: 5,222

I agree. That is exactly the problem that the code I posted fixes. It acts as a mathematical PLL.

That is why it is in the advanced section of the page and labeled as "low jitter".
Reply With Quote
Reply   Post New Thread

, , ,

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amplifier Measurement PRS General Electronics Chat 24 05-17-2009 11:17 PM
analog to digital conversion using pic 16f877a ibrahim Embedded Systems and Microcontrollers 1 01-13-2009 09:55 AM
op amp based frequency to voltage conversion garry.owens The Projects Forum 8 12-20-2008 09:12 AM
Low frequency LFO with a DVM meter? relicmarks General Electronics Chat 14 05-03-2008 06:50 PM
frequency analyzer or spectrum analyzer troubleshotting relicmarks General Electronics Chat 25 04-28-2008 08:18 AM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 12:33 AM.

User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License.
Powered by vBulletin
Copyright ©2000 - 2014, vBulletin Solutions, Inc.