The Voltage Controlled Oscillator (VCO) is a device whose output frequency depends on a control voltage (the so-called “CV” on vintage synths frontpanes!). This device (associated with others like a Voltage Controlled Filter — VCF — and a Voltage Controlled Amplifier — VCA) can be used to create rich musical signals. This device however — as many analog devices — does experience temperature and humidity drifts and as such, requires precise calibrating if we want to play musically accurate notes!

The VCO calibration algorithm is the first task I carried out for the Themis project. I had to implement the algorithm on an STM32 board (this is a collective decision) and I split the associated code developpement in three parts:

  • First, implement the rising edge detection from a square signal (VCO square output signal) ;
  • Then perform frequency measurements by computing the inverse of the duration separating two rising edges ;
  • Finally, write the global calibration algorithm by averaging the frequency measurement over several periods ; because the VCO is controlled by a 12 bits digital-to-analog converter (DAC), as a whole there’s one measurement for every 4096 VCO control voltage levels.

I make use of one of the STM32 timers to measure the duration of a period. The timer configuration is such that it’s driven at 10MHz so that the resolution of this approach is 100ns. The measurement accuracy is enough for our purpose if we truncate the result to the first four digits.

Finally I fill a lookup-table with voltage-frequency pairs for every 4096 CV levels.

Next item of business: store the lookup-table in a NV Ram!

⤧  Next post Saving music calibration data in a flash memory ⤧  Previous post What is Themis