Variable CPU clock speed? - Page 1
Forum section: electronics / beginners

author: pmbrunelle
author_rank: Regular Contributor
timestamp: September 09, 2016, 05:34:53 am
content: I'm looking to replace the external clock crystal on a microcontroller with an adjustable LC tank.Has anyone ever done this?I'm considering this as a method of fine-tuning the speedometer on a Pontiac Fiero (produced 1984-1988).Here is the general architecture of the speedometer:A rotating magnet is rotated by a gear on the differential of the car.The rotating magnet induces a sine wave voltage in the coil of the vehicle speed sensor (VSS).The sine wave of variable frequency and amplitude is amplified and squared off.At this point there is a nominally 4000 pulses per mile digital signal.A microcontroller counts clock cycles between edges of the 4000 PPM signal.Based on the number of clock cycles between edges, the microcontroller can determine the speed of the vehicle, and then command the meter driver to point the needle in the right direction.The microcontroller has an external crystal, typically in the 4 MHz range (not all Fieros are the same).When people want to re-calibrate the speedometer, ex. after a tire size change, then they over or underclock the microcontroller by installing a different crystal. This works, but the adjustment is discrete.So I was wondering if a tank could replace a crystal. The idea is that the calibration could be done with a trimmer, which would be more flexible.I would be looking for 1 or 2 percent frequency drift over a temperature range of suppose, -20°C to +60°C.I don't know which component should be the adjustable one; the capacitor or the inductor?Am I out of my mind?

author: CJay
author_rank: Super Contributor
timestamp: September 09, 2016, 06:31:25 am
content: If you've got a nice square wave speed signal why not adjust that instead of tinkering with the cpu clock?Kits and projects like this:http://www.siliconchip.com.au/Issue/2013/September/Speedo+Corrector,+Mk.3have been around ages and work well.

author: MosherIV
author_rank: Super Contributor
timestamp: September 09, 2016, 06:45:02 am
content: HiWith microcontrollers, it is quite easy to do timing with a built in timer peripheral. It is then easy to adjust the timing by changing the value in a register. I guess you do not want to re-enginer the whole thing.I have heard of people using external sig gen to clock uprocessors.It is also possible to adjust crystal freq by tens of Hz by replacing one of the decoupling caps with avariable cap. I found lots of info about it when research xtal circuits.QuoteIs it you or just everyone else?I would need more imperical evidence before I could pass judment

author: tatus1969
author_rank: Super Contributor
timestamp: September 09, 2016, 07:33:52 am
content: LT has adjustable oscillator that allow setting the freq with a trimmer -> TimerBlox -> LTC6990

author: Kalvin
author_rank: Super Contributor
timestamp: September 09, 2016, 08:06:36 am
content: Attiny with 4MHz Xtal, using the internal x8 PLL generating the 32MHz CPU and Timer clock. Timer is used for generating the desired output frequency feeding the original microcontroller. The software will adjust (dither) the Timer so that its average output frequency is the desired frequency. The Attiny has on-chip ADC which will be used to read a trimpot value. The trimpot is used for adjusting/finetuning the Timer's dither sequence in order to produce the desired average output frequency. Pretty simple, one chip solution but requires some programming effort.

author: tatus1969
author_rank: Super Contributor
timestamp: September 09, 2016, 08:13:19 am
content: Quote from: Kalvin on September 09, 2016, 08:06:36 amSounds like overkill to me, the TimerBlox do the same (no crystal though) in a SOT23-6.

author: bobaruni
author_rank: Regular Contributor
timestamp: September 09, 2016, 08:14:26 am
content: That's a great idea, keep it simple, just use a series tuned LC circuit in place of the Xtal and try it.If you wan't to tune it externally, you could use a varicap diode driven by a variable voltage from a trimpot to control the frequency without opening up the circuit inside the dashboard every time you change tires or as the tires wear.

author: Kalvin
author_rank: Super Contributor
timestamp: September 09, 2016, 08:17:36 am
content: Quote from: tatus1969 on September 09, 2016, 08:13:19 amIt was just an idea in order to preserve the Xtal's temperature accuracy. The microcontroller solution would easily provide nice-to-have options for pre-selecting certain tire sizes with a dip switch given that the microcontroller has few extra I/O-pins.

author: tatus1969
author_rank: Super Contributor
timestamp: September 09, 2016, 08:19:02 am
content: Quote from: Kalvin on September 09, 2016, 08:17:36 amgood point!

author: bson
author_rank: Unknown
timestamp: September 09, 2016, 05:30:16 pm
content: Many a low-frequency clock has been generated using small pin-count PICs and their internal oscillators. As long as you don't vary the input clock the uC should be perfectly happy with it, just take care that the transitions are clean and it won't dropout or glitch when it changes clocks. Some old uC's don't like to go clockless or can seize on a clock glitch. Modern uC's are much more tolerant because the clock actually feeds their internal oscillator (sometimes with a programmable bypass), which then goes into a programmable, fractional PLL which will block junk on the input. If you only change it using dip switches or a rotary positional switch during power-off, then this isn't an issue, but again make sure the clock comes up cleanly on power-on.