├── images └── AD9850.png ├── examples └── AD9850 │ └── AD9850.ino ├── keywords.txt ├── LICENSE ├── AD9850.h ├── AD9850.cpp ├── README.md └── LISEZMOI.md /images/AD9850.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/F4GOJ/AD9850/HEAD/images/AD9850.png -------------------------------------------------------------------------------- /examples/AD9850/AD9850.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | const int W_CLK_PIN = 7; 4 | const int FQ_UD_PIN = 8; 5 | const int DATA_PIN = 9; 6 | const int RESET_PIN = 10; 7 | 8 | double freq = 10000000; 9 | double trimFreq = 124999500; 10 | 11 | int phase = 0; 12 | 13 | void setup(){ 14 | DDS.begin(W_CLK_PIN, FQ_UD_PIN, DATA_PIN, RESET_PIN); 15 | DDS.calibrate(trimFreq); 16 | } 17 | 18 | void loop(){ 19 | DDS.setfreq(freq, phase); 20 | delay(10000); 21 | DDS.down(); 22 | delay(3000); 23 | DDS.up(); 24 | delay(2000); 25 | DDS.setfreq(freq + 500, phase); 26 | delay(5000); 27 | DDS.down(); 28 | while(1); 29 | } 30 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For AD9850 3 | ####################################### 4 | ####################################### 5 | # Datatypes (KEYWORD1) 6 | ####################################### 7 | 8 | AD9850 KEYWORD1 9 | DDS KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | calibrate KEYWORD2 17 | setfreq KEYWORD2 18 | down KEYWORD2 19 | up KEYWORD2 20 | 21 | ####################################### 22 | # Constants (LITERAL1) 23 | ####################################### 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /AD9850.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************************************** 2 | * Arduino library for AD9850 3 | * Created 23/08/2014 4 | * Christophe Caiveau f4goj@free.fr 5 | * 6 | * Use this library freely 7 | * 8 | * Hardware connections : 9 | * W_CLK -> any pin 10 | * FQ_UD -> any pin 11 | * DATA/D7 -> any pin 12 | * RESET -> any pin 13 | * 14 | * Functions : 15 | * dds.begin(W_CLK pin, FQ_UD pin, DATA pin, RESET pin); Initialize the output pins and master reset the AD9850 16 | * dds.calibrate(frequency); Compensation of crystal oscillator frequency 17 | * dds.setfreq(frequency,phase); frequency in Hz, phase coded on 5 bits 18 | * dds.down(); power down mode reducing the dissipated power from 380mW to 30mW @5V 19 | * dds.up(); wake-up the AD9850 20 | * 21 | * AD9850 datasheet at http://www.analog.com/static/imported-files/data_sheets/AD9850.pdf 22 | * 23 | *****************************************************************************************************************/ 24 | 25 | 26 | #ifndef AD9850_H 27 | #define AD9850_H 28 | #include 29 | 30 | class AD9850 31 | { 32 | public: 33 | AD9850(); 34 | 35 | void begin(int w_clk, int fq_ud, int data, int reset); 36 | void setfreq(double f, uint8_t p); 37 | void down(); 38 | void up(); 39 | void calibrate(double TrimFreq); 40 | 41 | private: 42 | int W_CLK; 43 | int FQ_UD; 44 | int DATA; 45 | int RESET; 46 | uint32_t deltaphase; 47 | uint8_t phase; 48 | void update(); 49 | void begin_priv(); 50 | void pulse(int pin); 51 | double calibFreq; 52 | }; 53 | 54 | extern AD9850 DDS; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /AD9850.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************************************************** 2 | * Arduino library for AD9850 3 | * Created 23/08/2014 4 | * Christophe Caiveau f4goj@free.fr 5 | * 6 | * Use this library freely 7 | * 8 | * Hardware connections : 9 | * W_CLK -> any pin 10 | * FQ_UD -> any pin 11 | * DATA/D7 -> any pin 12 | * RESET -> any pin 13 | * 14 | * Functions : 15 | * dds.begin(W_CLK pin, FQ_UD pin, DATA pin, RESET pin); Initialize the output pins and master reset the AD9850 16 | * dds.calibrate(frequency); Compensation of crystal oscillator frequency 17 | * dds.setfreq(frequency,phase); frequency in Hz, phase coded on 5 bits 18 | * dds.down(); power down mode reducing the dissipated power from 380mW to 30mW @5V 19 | * dds.up(); wake-up the AD9850 20 | * 21 | * AD9850 datasheet at http://www.analog.com/static/imported-files/data_sheets/AD9850.pdf 22 | * 23 | *****************************************************************************************************************/ 24 | 25 | #include 26 | 27 | AD9850 DDS; 28 | 29 | AD9850::AD9850() { 30 | 31 | } 32 | 33 | void AD9850::begin(int w_clk, int fq_ud, int data, int reset) { 34 | W_CLK = w_clk; 35 | FQ_UD = fq_ud; 36 | DATA = data; 37 | RESET = reset; 38 | deltaphase = 0; 39 | phase = 0; 40 | calibFreq = 125000000; 41 | begin_priv(); 42 | } 43 | 44 | void AD9850::begin_priv() { 45 | pinMode(W_CLK, OUTPUT); 46 | pinMode(FQ_UD, OUTPUT); 47 | pinMode(DATA, OUTPUT); 48 | pinMode(RESET, OUTPUT); 49 | 50 | pulse(RESET); 51 | pulse(W_CLK); 52 | pulse(FQ_UD); 53 | } 54 | 55 | void AD9850::update() { 56 | 57 | for (int i=0; i<4; i++, deltaphase>>=8) { 58 | shiftOut(DATA, W_CLK, LSBFIRST, deltaphase & 0xFF); 59 | } 60 | shiftOut(DATA, W_CLK, LSBFIRST, phase & 0xFF); 61 | pulse(FQ_UD); 62 | } 63 | 64 | 65 | void AD9850::setfreq(double f, uint8_t p) { 66 | deltaphase = f * 4294967296.0 / calibFreq; 67 | phase = p << 3; 68 | update(); 69 | } 70 | 71 | 72 | void AD9850::down() { 73 | pulse(FQ_UD); 74 | shiftOut(DATA, W_CLK, LSBFIRST, 0x04); 75 | pulse(FQ_UD); 76 | } 77 | 78 | 79 | void AD9850::up() { 80 | update(); 81 | } 82 | 83 | 84 | void AD9850::calibrate(double TrimFreq) 85 | { 86 | calibFreq = TrimFreq; 87 | } 88 | 89 | 90 | void AD9850::pulse(int pin) { 91 | digitalWrite(pin, HIGH); 92 | digitalWrite(pin, LOW); 93 | } 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arduino serial library for AD9850 # 2 | F4GOJ Christophe f4goj@free.fr 3 | 4 | August 2014 5 | 6 | AD9850 datasheet at http://www.analog.com/static/imported-files/data_sheets/AD9850.pdf 7 | 8 | Use this library freely. 9 | 10 | ## Installation ## 11 | To use the **AD9850** library: 12 | - Go to https://github.com/F4GOJ/AD9850, click the [Download ZIP](https://github.com/F4GOJ/AD9850/archive/master.zip) button and save the ZIP file to a convenient location on your PC. 13 | - Uncompress the downloaded file. This will result in a folder containing all the files for the library, that has a name that includes the branch name, usually **AD9850-master**. 14 | - Rename the folder to **AD9850**. 15 | - Copy the renamed folder to the Arduino sketchbook\libraries folder. 16 | 17 | 18 | ## Usage notes ## 19 | 20 | The **AD9850** library instantiates a **DDS** object, the user does not need to do this. 21 | 22 | ```c++ 23 | #include //http://github.com/F4GOJ/AD9850 24 | 25 | ``` 26 | ## Hardware connections : ## 27 | 28 | ![ad9850](https://raw.githubusercontent.com/F4GOJ/AD9850/master/images/AD9850.png) 29 | 30 | - W_CLK -> any pin 31 | - FQ_UD -> any pin 32 | - DATA/D7 -> any pin 33 | - RESET -> any pin 34 | 35 | ## Functions : ## 36 | 37 | ### begin(int w_clk_pin, int fq_ud_pin, int data_pin, int reset_pin) 38 | ##### Description 39 | Initialize the output pins and master reset the AD9850 40 | ##### Syntax 41 | `DDS.begin(w_clk, fq_ud, data, reset);` 42 | ##### Parameters 43 | **w_clk :** Working clock output pin, any pin *(int)*
44 | **fq_ud :** Frequency update pin, any pin. *(int)*
45 | **data :** Serial data output pin, any pin *(int)*
46 | **reset :** Reset output pin, any pin. *(int)* 47 | ##### Returns 48 | None. 49 | ##### Example 50 | ```c++ 51 | void setup(){ 52 | DDS.begin(6, 7, 8, 9); 53 | } 54 | ``` 55 | ### calibrate(double trim_frequency) 56 | ##### Description 57 | Compensation of crystal oscillator frequency.
58 | Can be used at any time after initialization. 59 | ##### Syntax 60 | `DDS.calibrate(trim_freq);` 61 | ##### Parameters 62 | **trim_freq :** Adjust around 125000000 to match the real crystal oscillator frequency. *(double)* 63 | ##### Returns 64 | None. 65 | ##### Example 66 | ```c++ 67 | void setup(){ 68 | DDS.begin(6, 7, 8, 9); 69 | } 70 | 71 | void loop(){ 72 | DDS.calibrate(124999000); 73 | } 74 | ``` 75 | ### setfreq(double frequency, int phase) 76 | ##### Description 77 | Sets the output frequency of the AD9850 and the phase of the signal. 78 | ##### Syntax 79 | `DDS.setfreq(frequency, phase);` 80 | ##### Parameters 81 | **frequency :** Output frequency in Hz. *(double)*
82 | **phase :** Sets the phase of the output signal, coded on 5 bits allows 32 phase steps of 11,25° each. *(int)* 83 | ##### Returns 84 | None. 85 | ##### Example 86 | ```c++ 87 | double frequency = 10000000; 88 | int phase = 0; 89 | DDS.setfreq(frequency, phase); 90 | ``` 91 | ### down() 92 | ##### Description 93 | Power down mode reducing the dissipated power from 380mW to 30mW at 5V 94 | ##### Syntax 95 | `DDS.down();` 96 | ##### Parameters 97 | None. 98 | ##### Returns 99 | None. 100 | ##### Example 101 | ```c++ 102 | DDS.down(); 103 | ``` 104 | ### up() 105 | ##### Description 106 | Wakes-up the AD9850 from power down mode. 107 | ##### Syntax 108 | `DDS.up();` 109 | ##### Parameters 110 | None. 111 | ##### Returns 112 | None. 113 | ##### Example 114 | ```c++ 115 | DDS.down(); // Entering power down mode 116 | 117 | // some code doing something 118 | 119 | ... 120 | 121 | DDS.up(); // WAKE-UP !!! :) 122 | ``` 123 | 124 | 125 | -------------------------------------------------------------------------------- /LISEZMOI.md: -------------------------------------------------------------------------------- 1 | # Librairie Arduino pour AD9850 # 2 | F4GOJ Christophe f4goj@free.fr 3 | 4 | Août 2014 5 | 6 | Documentation de l'AD9850 à http://www.analog.com/static/imported-files/data_sheets/AD9850.pdf 7 | 8 | Utilisez cette librairie librement. 9 | 10 | ## Installation ## 11 | Pour utiliser la librairie **AD9850** : 12 | - Allez à https://github.com/F4GOJ/AD9850, cliquez le bouton [Download ZIP](https://github.com/F4GOJ/AD9850/archive/master.zip) et enregistrez le fichier ZIP à l'endroit de votre convenance. 13 | - Décompressez le fichier. Vous obtiendrez un répertoire contenant tous les fichiers de la librairie avec un nom comprenant le nom de branche, typiquement **AD9850-master**. 14 | - Renommez le répertoire en **AD9850**. 15 | - Copiez le répertoire renommé dans le répertoire Arduino \libraries. 16 | 17 | 18 | ## Notes d'utilisation## 19 | 20 | La librairie **AD9850** crée une instance de l'objet **DDS**, l'utilisateur n'a pas pas besoin de le faire. 21 | 22 | ```c++ 23 | #include //http://github.com/F4GOJ/AD9850 24 | ``` 25 | ## Connexions : ## 26 | 27 | ![ad9850](https://raw.githubusercontent.com/F4GOJ/AD9850/master/images/AD9850.png) 28 | 29 | - W_CLK -> n'importe quelle broche. 30 | - FQ_UD -> n'importe quelle broche. 31 | - DATA/D7 -> n'importe quelle broche. 32 | - RESET -> n'importe quelle broche. 33 | 34 | ## Fonctions : ## 35 | 36 | ### begin(int w_clk_pin, int fq_ud_pin, int data_pin, int reset_pin) 37 | ##### Description 38 | Initialise les broches de sortie et effectue une remise à zéro générale de l'AD9850. 39 | ##### Syntaxe 40 | `DDS.begin(w_clk, fq_ud, data, reset);` 41 | ##### Paramètres 42 | **w_clk :** Broche de sortie SCK, n'importe quelle broche *(int)*
43 | **fq_ud :** Broche de sortie de mise à jour de la fréquence, n'importe quelle broche. *(int)*
44 | **data :** Broche de sortie de données, n'importe quelle broche *(int)*
45 | **reset :** Broche de sortie de RàZ, n'importe quelle broche. *(int)* 46 | ##### Retourne 47 | Rien. 48 | ##### Exemple 49 | ```c++ 50 | void setup(){ 51 | DDS.begin(6, 7, 8, 9); 52 | } 53 | ``` 54 | ### calibrate(double trim_frequency) 55 | ##### Description 56 | Compensation de la féquence de l'oscillateur.
57 | Peut être utilisée à n'importe quel moment après l'initialisation. 58 | ##### Syntaxe 59 | `DDS.calibrate(trim_freq);` 60 | ##### Paramètres 61 | **trim_freq :** Ajuster autour de 125000000 pour correspondre à la fréquence réelle de l'oscillateur. *(double)* 62 | ##### Retourne 63 | Rien. 64 | ##### Exemple 65 | ```c++ 66 | void setup(){ 67 | DDS.begin(6, 7, 8, 9); 68 | } 69 | 70 | void loop(){ 71 | DDS.calibrate(124999000); 72 | } 73 | ``` 74 | ### setfreq(double frequency, int phase) 75 | ##### Description 76 | Détermine la fréquence de sortie de l'AD9850 et la phase du signal. 77 | ##### Syntaxe 78 | `DDS.setfreq(frequency, phase);` 79 | ##### Paramètres 80 | **frequency :** Fréquence de sortie en HZ. *(double)*
81 | **phase :** Phase du signal, codée sur 5 bits permet 32 pas de phase de 11,25° *(int)* 82 | ##### Retourne 83 | Rien. 84 | ##### Exemple 85 | ```c++ 86 | double frequency = 10000000; 87 | int phase = 0; 88 | DDS.setfreq(frequency, phase); 89 | ``` 90 | ### down() 91 | ##### Description 92 | Mode "extinction" réduisant la puissance dissipée de 380mW à 30mW sous 5V 93 | ##### Syntaxe 94 | `DDS.down();` 95 | ##### Paramètres 96 | Aucun. 97 | ##### Retourne 98 | Rien. 99 | ##### Exemple 100 | ```c++ 101 | DDS.down(); 102 | ``` 103 | ### up() 104 | ##### Description 105 | Sort l'AD9850 du mode "extinction" 106 | ##### Syntaxe 107 | `DDS.up();` 108 | ##### Paramètres 109 | Aucun. 110 | ##### Retourne 111 | Rien. 112 | ##### Exemple 113 | ```c++ 114 | DDS.down(); // Entrée en mode "extinction" 115 | 116 | // du code faisant quelquechose 117 | 118 | ... 119 | 120 | DDS.up(); // REVEIL !!! :) 121 | ``` 122 | --------------------------------------------------------------------------------