Author Topic: Variable CPU clock speed?  (Read 3667 times)

0 Members and 1 Guest are viewing this topic.

Offline pmbrunelleTopic starter

  • Regular Contributor
  • *
  • Posts: 183
  • Country: ca
  • lost mech. guy
Variable CPU clock speed?
« on: September 09, 2016, 05:34:53 am »
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?
 

Offline CJay

  • Super Contributor
  • ***
  • Posts: 4136
  • Country: gb
Re: Variable CPU clock speed?
« Reply #1 on: September 09, 2016, 06:31:25 am »
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.3

have been around ages and work well.
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: Variable CPU clock speed?
« Reply #2 on: September 09, 2016, 06:45:02 am »
Hi

With 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.

Quote
  Am I out of my mind?
Is it you or just everyone else?
I would need more imperical evidence before I could pass judment  ;)
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Variable CPU clock speed?
« Reply #3 on: September 09, 2016, 07:33:52 am »
LT has adjustable oscillator that allow setting the freq with a trimmer -> TimerBlox -> LTC6990
« Last Edit: September 09, 2016, 08:22:22 am by tatus1969 »
We Are The Watt - Resistance Is Futile!
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Variable CPU clock speed?
« Reply #4 on: September 09, 2016, 08:06:36 am »
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.
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Variable CPU clock speed?
« Reply #5 on: September 09, 2016, 08:13:19 am »
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.
Sounds like overkill to me, the TimerBlox do the same (no crystal though) in a SOT23-6.
We Are The Watt - Resistance Is Futile!
 

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
Re: Variable CPU clock speed?
« Reply #6 on: September 09, 2016, 08:14:26 am »
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.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Variable CPU clock speed?
« Reply #7 on: September 09, 2016, 08:17:36 am »
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.
Sounds like overkill to me, the TimerBlox do the same (no crystal though) in a SOT23-6.
It 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.
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Variable CPU clock speed?
« Reply #8 on: September 09, 2016, 08:19:02 am »
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.
Sounds like overkill to me, the TimerBlox do the same (no crystal though) in a SOT23-6.
It 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.
good point!
We Are The Watt - Resistance Is Futile!
 

Offline bson

  • Supporter
  • ****
  • Posts: 2270
  • Country: us
Re: Variable CPU clock speed?
« Reply #9 on: September 09, 2016, 05:30:16 pm »
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.
« Last Edit: September 09, 2016, 05:35:19 pm by bson »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf