A step-by-step tutorial to show how to program the Si5351 via I2C and Arduino to generate a square clock signal in the range between 8Khz and 160 MHz with the 2€ module.
The Si5351 clock generator is an inexpensive device that can generate a square signal from 8kHz to 160Mhz, according to its specifications. You can buy it for 2 or 3€ at any shop online.
I tried and it works nicely! In this article, I will explain how to configure it
The clock generator Si5351 can not work standalone, as I thought initially, and it needs a I2C signal to activate the output and work. It doesn’t have any memory, so if you unplug the device from the supply voltage, it shuts down and resets.
Let’s see all the configuration process in an easy way and step-by-step:
Contents
Wiring Si5351 with Arduino via I2C
We need an I2C connection, which consists of 4 wires:
- GND
- +3V or +5V (you can connect either to +3V or +5V)
- SCL (clock line) → Arduino UNO (A5) → Nano (A5 ) → Mega (SCL)
- SCD (data) → Arduino UNO (A4) → Nano ( A4) → Mega (SDA)
You can check the pinout for different boards. I am using Arduino Uno.
Clock Configuration
The logic behind all the PLL loops and how the chip itself works is a bit complicated, and you maybe don’t need to go into details. You can find more information on the datasheet or this concrete math explanation to be able to calculate it by yourself.
Parameter Calculation
You can make the math by yourself, but… this work is already done by SiLabs. There is an app to make all the calculations.
It is simply: You enter the desired frequency and the software returns you the parameters of the PLL and the MultiSynth.
Download the app and enjoy and reutilize the work others have already made. The software can be downloaded on the adafruit website:
http://www.adafruit.com/downloads/ClockBuilderDesktopSwInstallSi5351.zip
The app is named “clockBuilder Desktop – Si5351”
But I had trouble with the download, because my computer mark is as unsafe and BLOCK it all the time. So I had to open the old Microsoft explorer to get it.
Check if you board has a 27MHz or 25MHz crystal
When you open the app, you must select your board type.
In my case, it has 3 outputs. That is also the most popular one:
In my case I wanted 5.85MHz
Then click on “View plan details” in small blue letters. We will obtain a list of parameters (like in the pic below), which are very useful to configure our clock generator. In the next step, we will see what to do with these parameters.
With these parameters, you will now introduce it to your code.
Let’s start coding!!! 🙂
Full Arduino Code
I program this using Arduino, but you may use another platform such as RaspberryPi, etc.
The Adafruit si5351 library is a standard to start programming easily. So go to libraries on your Arduino IDE and download it on tools>manage libraries>
Later you can copy my code example and create a new sketch in Arduino.
Generic Example
We configure it for 5.85MHz, but it can be extrapolated to other numbers. Let’s analyze the parameters we’ve got before:
Configuration within 4 steps:
1- So, the Feedback divider numbers are introduced into the function setupPLL
clockgen.setupPLL(SI5351_PLL_A, 28,2,25);
2- The MultiSynth goes with the function setupMultisynth. As there is only the 120 number I add 0 and 1.
Note 1: we can not divide by zero. So mathematically: 120 = 120 +0/1. Actually, there is a specific function to use for the cases when the number is an integer (clockgen.setupMultisynth), but I wanted to create a generic case.
Note 2: The first number of the function indicates the output
clockgen.setupMultisynth(0, SI5351_PLL_A, 120,0,1);
3- The R divider is only used for low frequencies (not this case). When the case, you add , changing the 64 for any value.
clockgen.setupRdiv(0, SI5351_R_DIV_64);
4- The final step is to enable the outputs:
clockgen.enableOutputs(true);
The full code is below. Feel free to copy and modify it!!
#include <Adafruit_SI5351.h> // Programmed by: // ALberto Lopez --> www.MisCircuitos.com // Adafruit_SI5351 clockgen = Adafruit_SI5351(); //includes the library void setup(void) { Serial.begin(9600); Serial.println("Si5351 Clockgen Test"); Serial.println(""); pinMode(LED_BUILTIN, OUTPUT); //led config output /* Initialise the sensor */ if (clockgen.begin() != ERROR_NONE) { /* There was a problem detecting the IC ... check your connections */ Serial.println("Houston, we have a problem! Any Clock Generator Si5351 is detected ... Check your wiring!"); while(1){ //led blinking fast digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(100); // wait for a second } } Serial.println("Start-up OK!"); //Configuration for 5.85MHz Alberto //Fractional mode fractional mode clockgen.setupPLL(SI5351_PLL_A, 28,2,25); //set to 702Mhz clockgen.setupMultisynth(0, SI5351_PLL_A, 120,0,1); /* Enable the clocks */ clockgen.enableOutputs(true); Serial.println("Clock correctly configured to 5.85MHz"); Serial.println("Programmed by Alberto Lopez: misCircuitos.com"); } void loop(void) { //DO nothing in the loop }
https://learn.adafruit.com/adafruit-si5351-clock-generator-breakout/pinouts?view=all
Results and Measurements
Once the code is loaded, we can measure the resulting frequency with an oscilloscope. In my example it was 5.85Mhz and it worked pretty well. The square signal is not the best at this frequency, but acceptable for most applications.
3D Soldering
In this case, when there are little electronics, I like to solder all together without a PCB. It is not scalable or easy to debug, but once it is working, it looks pretty compact and nice.
I hope that this tutorial has been useful and helpful, any suggestions, advice, or comments are welcome below!