| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,9 @@ | |||
| 1 | - /* Simple calibration routine for the Si5351 breakout board. | ||
| 1 | + /* | ||
| 2 | + * si5351_calibration.ino - Simple calibration routine for the Si5351 | ||
| 3 | + * breakout board. | ||
| 2 | 4 | * | |
| 3 | - * Copyright 2015 Paul Warren <pwarren@pwarren.id.au> | ||
| 5 | + * Copyright 2015 - 2016 Paul Warren <pwarren@pwarren.id.au> | ||
| 6 | + * Jason Milldrum <milldrum@gmail.com> | ||
| 4 | 7 | * | |
| 5 | 8 | * Uses code from https://github.com/darksidelemm/open_radio_miniconf_2015 | |
| 6 | 9 | * and the old version of the calibration sketch | |
@@ -22,7 +25,7 @@ | |||
| 22 | 25 | ||
| 23 | 26 | Si5351 si5351; | |
| 24 | 27 | ||
| 25 | - int32_t cal_factor; | ||
| 28 | + int32_t cal_factor = 0; | ||
| 26 | 29 | int32_t old_cal; | |
| 27 | 30 | ||
| 28 | 31 | uint64_t rx_freq; | |
@@ -32,40 +35,38 @@ void setup() | |||
| 32 | 35 | { | |
| 33 | 36 | // Start serial and initialize the Si5351 | |
| 34 | 37 | Serial.begin(57600); | |
| 35 | - si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0); | ||
| 36 | 38 | ||
| 37 | - // get old cal factor | ||
| 38 | - //old_cal = si5351.get_correction(); | ||
| 39 | - si5351.set_correction(0); | ||
| 40 | - // start on target frequency | ||
| 41 | - si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA); | ||
| 42 | - si5351.set_freq(target_freq, SI5351_PLL_FIXED, SI5351_CLK0); | ||
| 39 | + // The crystal load value needs to match in order to have an accurate calibration | ||
| 40 | + si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0); | ||
| 41 | + | ||
| 42 | + // Start on target frequency | ||
| 43 | + si5351.set_freq(target_freq, SI5351_CLK0); | ||
| 43 | 44 | } | |
| 44 | 45 | ||
| 45 | 46 | void loop() | |
| 46 | 47 | { | |
| 47 | 48 | si5351.update_status(); | |
| 48 | - if (si5351.dev_status.SYS_INIT == 1) { | ||
| 49 | - Serial.println("Initialising Si5351, you shouldn't see many of these!"); | ||
| 49 | + if (si5351.dev_status.SYS_INIT == 1) | ||
| 50 | + { | ||
| 51 | + Serial.println(F("Initialising Si5351, you shouldn't see many of these!")); | ||
| 50 | 52 | delay(500); | |
| 51 | - } else { | ||
| 52 | - cal_factor = 0; | ||
| 53 | - // Serial.print("Old cal factor was: "); | ||
| 54 | - // Serial.println(old_cal); | ||
| 55 | - // Serial.println("Cal factor now set to 0"); | ||
| 56 | - // si5351.set_correction(0); | ||
| 53 | + } | ||
| 54 | + else | ||
| 55 | + { | ||
| 57 | 56 | Serial.println(); | |
| 58 | - Serial.println(F("Adjust until your frequency counter reads as close to 10 MHz as possible")); | ||
| 57 | + Serial.println(F("Adjust until your frequency counter reads as close to 10 MHz as possible.")); | ||
| 58 | + Serial.println(F("Press 'q' when complete.")); | ||
| 59 | 59 | vfo_interface(); | |
| 60 | + | ||
| 61 | + Serial.println(); | ||
| 60 | 62 | Serial.print(F("Calibration factor is ")); | |
| 61 | 63 | Serial.println(cal_factor); | |
| 62 | - Serial.println("Setting calibration factor"); | ||
| 64 | + Serial.println(F("Setting calibration factor")); | ||
| 63 | 65 | si5351.set_correction(cal_factor); | |
| 64 | - Serial.println("Resetting target frequency"); | ||
| 65 | - si5351.set_freq(target_freq, SI5351_PLL_FIXED, SI5351_CLK0); | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - | ||
| 66 | + Serial.println(F("Resetting target frequency")); | ||
| 67 | + si5351.set_freq(target_freq, SI5351_CLK0); | ||
| 68 | + si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA); | ||
| 69 | + } | ||
| 69 | 70 | } | |
| 70 | 71 | ||
| 71 | 72 | static void flush_input(void) | |
@@ -80,10 +81,13 @@ static void vfo_interface(void) | |||
| 80 | 81 | Serial.println(F(" Up: r t y u i o p")); | |
| 81 | 82 | Serial.println(F(" Down: f g h j k l ;")); | |
| 82 | 83 | Serial.println(F(" Hz: 0.01 0.1 1 10 100 1K 10k")); | |
| 83 | - while (1) { | ||
| 84 | - if (Serial.available() > 0) { | ||
| 84 | + while (1) | ||
| 85 | + { | ||
| 86 | + if (Serial.available() > 0) | ||
| 87 | + { | ||
| 85 | 88 | char c = Serial.read(); | |
| 86 | - switch (c) { | ||
| 89 | + switch (c) | ||
| 90 | + { | ||
| 87 | 91 | case 'q': | |
| 88 | 92 | flush_input(); | |
| 89 | 93 | return; | |
@@ -105,11 +109,12 @@ static void vfo_interface(void) | |||
| 105 | 109 | // Do nothing | |
| 106 | 110 | continue; | |
| 107 | 111 | } | |
| 108 | - si5351.set_freq(rx_freq,SI5351_PLL_FIXED,SI5351_CLK0); | ||
| 112 | + | ||
| 109 | 113 | cal_factor = (int32_t)(target_freq - rx_freq); | |
| 110 | - Serial.print("Current difference:"); | ||
| 114 | + si5351.set_correction(cal_factor); | ||
| 115 | + si5351.set_freq(target_freq, SI5351_CLK0); | ||
| 116 | + Serial.print(F("Current difference:")); | ||
| 111 | 117 | Serial.println(cal_factor); | |
| 112 | 118 | } | |
| 113 | 119 | } | |
| 114 | 120 | } | |
| 115 | - | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,68 @@ | |||
| 1 | + /* | ||
| 2 | + * si5351_clk67_example.ino - Simple example of setting CLK6 and CLK7 | ||
| 3 | + * outputs using Si5351Arduino library | ||
| 4 | + * | ||
| 5 | + * Copyright (C) 2016 Jason Milldrum <milldrum@gmail.com> | ||
| 6 | + * | ||
| 7 | + * This program is free software: you can redistribute it and/or modify | ||
| 8 | + * it under the terms of the GNU General Public License as published by | ||
| 9 | + * the Free Software Foundation, either version 3 of the License, or | ||
| 10 | + * (at your option) any later version. | ||
| 11 | + * | ||
| 12 | + * This program is distributed in the hope that it will be useful, | ||
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | + * GNU General Public License for more details. | ||
| 16 | + * | ||
| 17 | + * You should have received a copy of the GNU General Public License | ||
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | + */ | ||
| 20 | + | ||
| 21 | + #include "si5351.h" | ||
| 22 | + #include "Wire.h" | ||
| 23 | + | ||
| 24 | + Si5351 si5351; | ||
| 25 | + | ||
| 26 | + void setup() | ||
| 27 | + { | ||
| 28 | + // Start serial and initialize the Si5351 | ||
| 29 | + Serial.begin(57600); | ||
| 30 | + si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0); | ||
| 31 | + | ||
| 32 | + // Set CLK0 to output 14 MHz | ||
| 33 | + si5351.set_freq(1400000000ULL, SI5351_CLK0); | ||
| 34 | + | ||
| 35 | + // Set CLK6 to 23 MHz, library sets PLL to 874 MHz | ||
| 36 | + si5351.set_freq(2300000000ULL, SI5351_CLK6); | ||
| 37 | + | ||
| 38 | + // This won't work since it is not an even multiple of the PLL (874 MHz) | ||
| 39 | + si5351.set_freq(1234567800ULL, SI5351_CLK7); | ||
| 40 | + | ||
| 41 | + // Setting CLK7 to 87.4 MHz will work | ||
| 42 | + si5351.set_freq(8740000000ULL, SI5351_CLK7); | ||
| 43 | + | ||
| 44 | + si5351.update_status(); | ||
| 45 | + delay(500); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + void loop() | ||
| 49 | + { | ||
| 50 | + // Read the Status Register and print it every 10 seconds | ||
| 51 | + si5351.update_status(); | ||
| 52 | + Serial.print("PLLA: "); | ||
| 53 | + Serial.print((uint32_t)(si5351.plla_freq/100)); | ||
| 54 | + Serial.print(" PLLB: "); | ||
| 55 | + Serial.print((uint32_t)(si5351.pllb_freq/100)); | ||
| 56 | + Serial.print(" SYS_INIT: "); | ||
| 57 | + Serial.print(si5351.dev_status.SYS_INIT); | ||
| 58 | + Serial.print(" LOL_A: "); | ||
| 59 | + Serial.print(si5351.dev_status.LOL_A); | ||
| 60 | + Serial.print(" LOL_B: "); | ||
| 61 | + Serial.print(si5351.dev_status.LOL_B); | ||
| 62 | + Serial.print(" LOS: "); | ||
| 63 | + Serial.print(si5351.dev_status.LOS); | ||
| 64 | + Serial.print(" REVID: "); | ||
| 65 | + Serial.println(si5351.dev_status.REVID); | ||
| 66 | + | ||
| 67 | + delay(10000); | ||
| 68 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | /* | |
| 2 | - * si5351example.ino - Simple example of using Si5351Arduino library | ||
| 2 | + * si5351_example.ino - Simple example of using Si5351Arduino library | ||
| 3 | 3 | * | |
| 4 | - * Copyright (C) 2015 Jason Milldrum <milldrum@gmail.com> | ||
| 4 | + * Copyright (C) 2015 - 2016 Jason Milldrum <milldrum@gmail.com> | ||
| 5 | 5 | * | |
| 6 | 6 | * This program is free software: you can redistribute it and/or modify | |
| 7 | 7 | * it under the terms of the GNU General Public License as published by | |
@@ -16,7 +16,6 @@ | |||
| 16 | 16 | * You should have received a copy of the GNU General Public License | |
| 17 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 18 | 18 | */ | |
| 19 | - | ||
| 20 | 19 | ||
| 21 | 20 | #include "si5351.h" | |
| 22 | 21 | #include "Wire.h" | |
@@ -27,14 +26,19 @@ void setup() | |||
| 27 | 26 | { | |
| 28 | 27 | // Start serial and initialize the Si5351 | |
| 29 | 28 | Serial.begin(57600); | |
| 30 | - si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0); | ||
| 29 | + si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0); | ||
| 31 | 30 | ||
| 32 | - // Set CLK0 to output 14 MHz with a fixed PLL frequency | ||
| 33 | - si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA); | ||
| 34 | - si5351.set_freq(1400000000ULL, SI5351_PLL_FIXED, SI5351_CLK0); | ||
| 31 | + // Set CLK0 to output 14 MHz | ||
| 32 | + si5351.set_freq(1400000000ULL, SI5351_CLK0); | ||
| 35 | 33 | ||
| 36 | - // Set CLK1 to output 20 MHz | ||
| 37 | - si5351.set_freq(2000000000ULL, 0ULL, SI5351_CLK1); | ||
| 34 | + // Set CLK1 to output 175 MHz | ||
| 35 | + si5351.set_ms_source(SI5351_CLK1, SI5351_PLLB); | ||
| 36 | + si5351.set_freq_manual(17500000000ULL, 70000000000ULL, SI5351_CLK1); | ||
| 37 | + | ||
| 38 | + // Query a status update and wait a bit to let the Si5351 populate the | ||
| 39 | + // status flags correctly. | ||
| 40 | + si5351.update_status(); | ||
| 41 | + delay(500); | ||
| 38 | 42 | } | |
| 39 | 43 | ||
| 40 | 44 | void loop() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,61 @@ | |||
| 1 | + /* | ||
| 2 | + * si5351_ext_ref.ino - Simple example of using an external reference | ||
| 3 | + * clock with the Si5351Arduino library | ||
| 4 | + * | ||
| 5 | + * Copyright (C) 2016 Jason Milldrum <milldrum@gmail.com> | ||
| 6 | + * | ||
| 7 | + * This program is free software: you can redistribute it and/or modify | ||
| 8 | + * it under the terms of the GNU General Public License as published by | ||
| 9 | + * the Free Software Foundation, either version 3 of the License, or | ||
| 10 | + * (at your option) any later version. | ||
| 11 | + * | ||
| 12 | + * This program is distributed in the hope that it will be useful, | ||
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | + * GNU General Public License for more details. | ||
| 16 | + * | ||
| 17 | + * You should have received a copy of the GNU General Public License | ||
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | + */ | ||
| 20 | + | ||
| 21 | + #include "si5351.h" | ||
| 22 | + #include "Wire.h" | ||
| 23 | + | ||
| 24 | + Si5351 si5351; | ||
| 25 | + | ||
| 26 | + void setup() | ||
| 27 | + { | ||
| 28 | + // Start serial | ||
| 29 | + Serial.begin(57600); | ||
| 30 | + | ||
| 31 | + // Initialize the Si5351 to use a 10 MHz clock input on CLKIN | ||
| 32 | + si5351.init(SI5351_CRYSTAL_LOAD_0PF, 10000000UL, 0); | ||
| 33 | + | ||
| 34 | + // Set PLLA and PLLB to use the signal on CLKIN instead of the XTAL | ||
| 35 | + si5351.set_pll_input(SI5351_PLLA, SI5351_PLL_INPUT_CLKIN); | ||
| 36 | + si5351.set_pll_input(SI5351_PLLB, SI5351_PLL_INPUT_CLKIN); | ||
| 37 | + | ||
| 38 | + // Set CLK0 to output 14 MHz | ||
| 39 | + si5351.set_freq(1400000000ULL, SI5351_CLK0); | ||
| 40 | + | ||
| 41 | + si5351.update_status(); | ||
| 42 | + delay(500); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + void loop() | ||
| 46 | + { | ||
| 47 | + // Read the Status Register and print it every 10 seconds | ||
| 48 | + si5351.update_status(); | ||
| 49 | + Serial.print(" SYS_INIT: "); | ||
| 50 | + Serial.print(si5351.dev_status.SYS_INIT); | ||
| 51 | + Serial.print(" LOL_A: "); | ||
| 52 | + Serial.print(si5351.dev_status.LOL_A); | ||
| 53 | + Serial.print(" LOL_B: "); | ||
| 54 | + Serial.print(si5351.dev_status.LOL_B); | ||
| 55 | + Serial.print(" LOS: "); | ||
| 56 | + Serial.print(si5351.dev_status.LOS); | ||
| 57 | + Serial.print(" REVID: "); | ||
| 58 | + Serial.println(si5351.dev_status.REVID); | ||
| 59 | + | ||
| 60 | + delay(10000); | ||
| 61 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,72 @@ | |||
| 1 | + /* | ||
| 2 | + * si5351_outputs.ino - How to set different output sources | ||
| 3 | + * with the Si5351Arduino library | ||
| 4 | + * | ||
| 5 | + * Copyright (C) 2016 Jason Milldrum <milldrum@gmail.com> | ||
| 6 | + * | ||
| 7 | + * This program is free software: you can redistribute it and/or modify | ||
| 8 | + * it under the terms of the GNU General Public License as published by | ||
| 9 | + * the Free Software Foundation, either version 3 of the License, or | ||
| 10 | + * (at your option) any later version. | ||
| 11 | + * | ||
| 12 | + * This program is distributed in the hope that it will be useful, | ||
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | + * GNU General Public License for more details. | ||
| 16 | + * | ||
| 17 | + * You should have received a copy of the GNU General Public License | ||
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | + */ | ||
| 20 | + | ||
| 21 | + #include "si5351.h" | ||
| 22 | + #include "Wire.h" | ||
| 23 | + | ||
| 24 | + Si5351 si5351; | ||
| 25 | + | ||
| 26 | + void setup() | ||
| 27 | + { | ||
| 28 | + // Start serial and initialize the Si5351 | ||
| 29 | + Serial.begin(57600); | ||
| 30 | + si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0); | ||
| 31 | + | ||
| 32 | + // Set CLK0 to output 14 MHz | ||
| 33 | + si5351.set_freq(1400000000ULL, SI5351_CLK0); | ||
| 34 | + | ||
| 35 | + // Enable clock fanout for the XO | ||
| 36 | + si5351.set_clock_fanout(SI5351_FANOUT_XO, 1); | ||
| 37 | + | ||
| 38 | + // Enable clock fanout for MS | ||
| 39 | + si5351.set_clock_fanout(SI5351_FANOUT_MS, 1); | ||
| 40 | + | ||
| 41 | + // Set CLK1 to output the XO signal | ||
| 42 | + si5351.set_clock_source(SI5351_CLK1, SI5351_CLK_SRC_XTAL); | ||
| 43 | + si5351.output_enable(SI5351_CLK1, 1); | ||
| 44 | + | ||
| 45 | + // Set CLK2 to mirror the MS0 (CLK0) output | ||
| 46 | + si5351.set_clock_source(SI5351_CLK2, SI5351_CLK_SRC_MS0); | ||
| 47 | + si5351.output_enable(SI5351_CLK2, 1); | ||
| 48 | + | ||
| 49 | + // Change CLK0 output to 10 MHz, observe how CLK2 also changes | ||
| 50 | + si5351.set_freq(1000000000ULL, SI5351_CLK0); | ||
| 51 | + | ||
| 52 | + si5351.update_status(); | ||
| 53 | + delay(500); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + void loop() | ||
| 57 | + { | ||
| 58 | + // Read the Status Register and print it every 10 seconds | ||
| 59 | + si5351.update_status(); | ||
| 60 | + Serial.print(" SYS_INIT: "); | ||
| 61 | + Serial.print(si5351.dev_status.SYS_INIT); | ||
| 62 | + Serial.print(" LOL_A: "); | ||
| 63 | + Serial.print(si5351.dev_status.LOL_A); | ||
| 64 | + Serial.print(" LOL_B: "); | ||
| 65 | + Serial.print(si5351.dev_status.LOL_B); | ||
| 66 | + Serial.print(" LOS: "); | ||
| 67 | + Serial.print(si5351.dev_status.LOS); | ||
| 68 | + Serial.print(" REVID: "); | ||
| 69 | + Serial.println(si5351.dev_status.REVID); | ||
| 70 | + | ||
| 71 | + delay(10000); | ||
| 72 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments