genuinequality

Download free music MP3s on genuine quality, the world’s largest online music catalogue, powered by your scrobbles. Free listening, videos, photos, The world’s largest online music catalogue, powered by your scrobbles. Free listening, videos, photos, stats, charts, biographies and concerts. stats, charts, biographies and concerts.

Monday, September 8, 2025

Arduino and SP0256A-AL2 – Part 5

This looks at another of the options from Part 4 - the I2C programmable Si5351 clock source. https://makertube.net/w/bX5QNRRkAomFJQo7qY17he Warning! I strongly recommend using old or second hand equipment for your experiments.  I am no…
Read on blog or Reader
Site logo image Simple DIY Electronic Music Projects Read on blog or Reader

Arduino and SP0256A-AL2 – Part 5

By Kevin on September 8, 2025

This looks at another of the options from Part 4 - the I2C programmable Si5351 clock source.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to microcontrollers, see the Getting Started pages.

I2C Si5351 Programmable Clock

From the datasheet of the Si5351:

"The Si5351 is an I2C configurable clock generator that is ideally suited for replacing crystals, crystal oscillators, VCXOs, phase-locked loops (PLLs), and fanout buffers in cost-sensitive applications. Based on a PLL/VCXO + high resolution MultiSynth fractional divider architecture, the Si5351 can generate any frequency up to 160 MHz on each of its outputs with 0 ppm error."

The device itself requires a 3V to 3.6V supply, but typical breakouts seem to include a LDO regulator meaning it can be powered from 3V to 5V. Logic outputs are always 3V but the I2C lines will be the same as the power supply.

The Circuit

I'm using a breakout board like the one shown above. This has header pins for the three clock outputs, power and ground, and I2C. Although the si5351 device itself is a 3V3 device, most breakouts like this seem to include components to allow them to be powered by either 3V3 or 5V. I'm using 5V in my circuit.

I'm only using one of the clocks, so output 0 is fed into the OSC1 input of the SP0256A-AL2. Otherwise the rest of the SP0256A-AL2/Arduino circuit is the same as for part 1.

The Code

There are two libraries I've found for this:

  • https://github.com/adafruit/Adafruit_Si5351_Library
  • https://github.com/etherkit/Si5351Arduino

The Adafruit library is a fairly low-level interface to the device. The device basically has a multiplier which is used to set a PLL clock to somewhere between 600 and 900MHZ; and then a divisor to drop that back down to something useful.

But the reality of setting the parameters is actually quite complicated. There is a full discussion of how to do it, with some example Arduino code, here: https://rfzero.net/tutorials/si5351a/

It is not for the faint hearted!

Thankfully the second library mentioned above, by "EtherKit", has a 'set_freq()' function that does it all for us. The code to use it is therefore fairly straight forward:

#include <si5351.h>
#include <Wire.h>

Si5351 si5351;

void clockSetup () {
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0);
si5351.set_freq(300000000ULL, SI5351_CLK0);
si5351.update_status();
}

void setClock (uint64_t freq) {
si5351.set_freq(freq, SI5351_CLK0);
si5351.update_status();
delay(300);
}

The initialisation function requires three things:

  • Which of 6, 8 or 10pF capacitors are used with the external oscillator.
  • Frequency of the external oscillator. Passing in 0 uses the default, 25MHz.
  • A parameter for frequency correction. I'm just using 0.

The set_freq() function takes a 64-bit value which gives a frequency in 0.01Hz units, so 3MHz is 3 followed by 8 zeros. This is an "unsigned long long" type, hence the "ULL" initialiser after the value in the code above. The other parameter states which clock to use - I'm just using clock 0.

It is possible to wire up a pot to an analog input and set the frequency using something like the following:

int alglast = 0;
void checkClock (void) {
int algval = analogRead(ALG_IN);
if (algval != alglast) {
uin64_t freq = 1000 + 5 * analogRead(ALG_IN); // in kHz
setClock(freq*100000); // Convert to 0.01Hz units
}
alglast = algval;
}

This maps a pot reading onto frequency values between 1MHz and just over 6MHz in units of 5kHz.

Alternatively, it is possible to set pitches for individual allophones. I've found that loosely speaking, 3MHz seems to correspond to talking at the pitch of G#2 (MIDI note 44) which is an audio pitch frequency of round 98Hz. 6MHz is, as you might expect, G#3 (MIDI note 56 at 196Hz).

This means that the I can calculate the required clock frequency for a MIDI note M using the formula:

  • Freq = 3MHz * 2 ^ (M - 44)/12

This function will set the clock based on the MIDI note number:

void midi2clock (int m) {
if (m < 36 || m > 56) {
return;
}

freq = 300000000 * pow (2.0, (((double)m-44.0)/12.0));
setClock (freq);
}

Note how I've limited the range to between C2 (36) and G#3 (56), which means frequencies of 1.889MHz to 6MHz.

It would probably go a bit lower - down to 1MHz is probably practical from the point of view of the chip functioning, but not so useful from the point of view of how long it would take to say a single allophone. Anything higher will cause the SP0256A-AL2 to lock up in a funny state.

But that gives me a good octave and a fifth, which is quite a useful and practical range.

Closing Thoughts

This is the most accurate and simplest to set up manner of providing a programmable clock I've found so far. The device itself is actually quite complex to use, but all that complexity has been hidden away in the Si5351 library published by EtherKit.

The device sometimes seemed to get stuck in a weird state where is wasn't recognised on the I2C bus. A power cycle or reset, or some combination of both, was usually required to get it going again. I don't know if that was dodgy cables somewhere, but when it got stuck, curiously my nearby FM radio receiver lost its signal... Hmm.

The downside of using the Arduino for both clock and speech control is that it isn't possible to adjust the clock whilst the speech is happening. That would need some kind of parallel execution to manage that - either adding in another microcontroller, or maybe moving to a dual-core microcontroller.

But as you can hear from the end of the video, this could still be pretty useful and I wish I'd had it for my Electric Lo-Fi Orchestra Concerto for a Rainy Day.

Kevin

Comment
Like
You can also reply to this email to leave a comment.

Simple DIY Electronic Music Projects © 2025.
Unsubscribe or manage your email subscriptions.

WordPress.com and Jetpack Logos

Get the Jetpack app

Subscribe, bookmark, and get real‑time notifications - all from one app!

Download Jetpack on Google Play Download Jetpack from the App Store
WordPress.com Logo and Wordmark title=

Automattic, Inc.
60 29th St. #343, San Francisco, CA 94110

Posted by BigPalaceNews at 2:12 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Search This Blog

About Me

BigPalaceNews
View my complete profile

Blog Archive

  • September (56)
  • August (116)
  • July (96)
  • June (100)
  • May (105)
  • April (95)
  • March (131)
  • February (111)
  • January (104)
  • December (98)
  • November (87)
  • October (126)
  • September (104)
  • August (97)
  • July (112)
  • June (113)
  • May (132)
  • April (162)
  • March (150)
  • February (342)
  • January (232)
  • December (260)
  • November (149)
  • October (179)
  • September (371)
  • August (379)
  • July (360)
  • June (385)
  • May (391)
  • April (395)
  • March (419)
  • February (356)
  • January (437)
  • December (438)
  • November (400)
  • October (472)
  • September (460)
  • August (461)
  • July (469)
  • June (451)
  • May (464)
  • April (506)
  • March (483)
  • February (420)
  • January (258)
  • December (197)
  • November (145)
  • October (117)
  • September (150)
  • August (132)
  • July (133)
  • June (117)
  • May (190)
  • January (48)
Powered by Blogger.