Commit 5ddf572fd3d2d513103c948c3757371ba20eb9e8

Authored by bachi
1 parent e41d5220b5
Exists in master

ad9915.c & ad9915.h : suppression des fonctions softwares

Showing 2 changed files with 0 additions and 136 deletions Inline Diff

/* 1 1 /*
dds initialisation et SPI 2 2 dds initialisation et SPI
*/ 3 3 */
4 4
#include <stdint.h> 5 5 #include <stdint.h>
#include <unistd.h> 6 6 #include <unistd.h>
#include <stdio.h> 7 7 #include <stdio.h>
#include <stdlib.h> 8 8 #include <stdlib.h>
#include <getopt.h> 9 9 #include <getopt.h>
#include <fcntl.h> 10 10 #include <fcntl.h>
#include <sys/ioctl.h> 11 11 #include <sys/ioctl.h>
#include <linux/types.h> 12 12 #include <linux/types.h>
#include <linux/spi/spidev.h> 13 13 #include <linux/spi/spidev.h>
/* memory management */ 14 14 /* memory management */
#include <sys/mman.h> 15 15 #include <sys/mman.h>
#include "spi.h" 16 16 #include "spi.h"
#include <string.h> 17 17 #include <string.h>
#include <math.h> 18 18 #include <math.h>
#include <time.h> 19 19 #include <time.h>
20 20
21 21
static const char CFRAddress[] = {0x00,0x01,0x02,0x03}; 22 22 static const char CFRAddress[] = {0x00,0x01,0x02,0x03};
23 23
static const char CFR1Start[] ={0x00, 0x01, 0x00, 0x0a}; 24 24 static const char CFR1Start[] ={0x00, 0x01, 0x00, 0x0a};
//static const char CFR1Start[] ={0x00, 0x01, 0x01, 0x08}; //with osk enable 25 25 //static const char CFR1Start[] ={0x00, 0x01, 0x01, 0x08}; //with osk enable
static const char CFR2Start[] ={0x00, 0x80, 0x09, 0x00}; //0x80 enable prof mode 26 26 static const char CFR2Start[] ={0x00, 0x80, 0x09, 0x00}; //0x80 enable prof mode
static const char CFR3Start[] = {0x00, 0x00, 0x19, 0x1C}; 27 27 static const char CFR3Start[] = {0x00, 0x00, 0x19, 0x1C};
static const char CFR4Start[] = {0x00, 0x05, 0x21, 0x20}; 28 28 static const char CFR4Start[] = {0x00, 0x05, 0x21, 0x20};
//static const char CFR4Start[] = {0x20, 0x21, 0x05, 0x00}; 29 29 //static const char CFR4Start[] = {0x20, 0x21, 0x05, 0x00};
30 30
31 31
static const char USR0Address = 0x1B; 32 32 static const char USR0Address = 0x1B;
static const char FTW0Address = 0x0b; //profile 0 ftw 33 33 static const char FTW0Address = 0x0b; //profile 0 ftw
static const char PA0Address = 0x0c; //profile 0 34 34 static const char PA0Address = 0x0c; //profile 0
35 35
static const char DACCalEnable[] = {0x01, 0x05, 0x21, 0x20}; //Command to enable the DAC Cal, should be 0x01XXXXXX, where X is the last 6 digits of CFR4Start 36 36 static const char DACCalEnable[] = {0x01, 0x05, 0x21, 0x20}; //Command to enable the DAC Cal, should be 0x01XXXXXX, where X is the last 6 digits of CFR4Start
37 37
38 38
void sendReset(int f_dds); 39 39 void sendReset(int f_dds);
void sendIOUpdate (int f_dds); //Send the update to set the control registers 40 40 void sendIOUpdate (int f_dds); //Send the update to set the control registers
void writeRegister (int fd, unsigned char addr, unsigned char d3, unsigned char d2, unsigned char d1, unsigned char d0); 41 41 void writeRegister (int fd, unsigned char addr, unsigned char d3, unsigned char d2, unsigned char d1, unsigned char d0);
void readRegister (int fd, unsigned char addr, uint32_t *readword); 42 42 void readRegister (int fd, unsigned char addr, uint32_t *readword);
void readRegister_ini (int fd,unsigned char addr); 43 43 void readRegister_ini (int fd,unsigned char addr);
void initializeDDS (int fd, int f_dds); 44 44 void initializeDDS (int fd, int f_dds);
void calibrateDAC(int fd, int f_dds); 45 45 void calibrateDAC(int fd, int f_dds);
void basicSetup(int fd, int f_dds, uint16_t ampWord, uint16_t phaseWord); 46 46 void basicSetup(int fd, int f_dds, uint16_t ampWord, uint16_t phaseWord);
void modulusSetup(int fd, int f_dds); 47 47 void modulusSetup(int fd, int f_dds);
void setFreqMM(int fd, int f_dds, unsigned int ftw, unsigned int A, unsigned int B); 48 48 void setFreqMM(int fd, int f_dds, unsigned int ftw, unsigned int A, unsigned int B);
void setAmpPhaseWord(int fd, int f_dds,unsigned int phaseAmpWord); 49 49 void setAmpPhaseWord(int fd, int f_dds,unsigned int phaseAmpWord);
void checkSize(void); 50 50 void checkSize(void);
int openAndSetDdsFreq( char * device, char * gpio_update, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord); 51 51 int openAndSetDdsFreq( char * device, char * gpio_update, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord);
int receiveParameterFromPythonServer(char * device, double f_clk, double f_out); 52 52 int receiveParameterFromPythonServer(char * device, double f_clk, double f_out);
int setDdsFreqFull ( int fd, int f_dds, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord); 53 53 int setDdsFreqFull ( int fd, int f_dds, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord);
54 54
//------------ DRCTL 55 55 //------------ DRCTL
56 56
void sendCtrlUp(int fp); 57 57 void sendCtrlUp(int fp);
void SendCtrlDown(int fp); 58 58 void SendCtrlDown(int fp);
void SendHold(int fp); 59 59 void SendHold(int fp);
void SendUnhold(int fp); 60 60 void SendUnhold(int fp);
int testRampFreq(int fd, int f_dds, int fp); 61 61 int testRampFreq(int fd, int f_dds, int fp);
62 62
//-------Profile register mode 63 63 //-------Profile register mode
64 64
int initialisationProfileMode (int fd,int f_dds); 65 65 int initialisationProfileMode (int fd,int f_dds);
int putFrequencyAmpPhaseWord(int fd, int f_dds, double fout, double fclk,double amp, double phase); 66 66 int putFrequencyAmpPhaseWord(int fd, int f_dds, double fout, double fclk,double amp, double phase);
67 67
68 68
/* 1 1 /*
SPI : initialisation du dds et communication SPI 2 2 SPI : initialisation du dds et communication SPI
*/ 3 3 */
#include"ad9915.h" 4 4 #include"ad9915.h"
#include "spi.h" 5 5 #include "spi.h"
#include "ddsFreq.h" 6 6 #include "ddsFreq.h"
7 7
#define debug 8 8 #define debug
//fonction reset 9 9 //fonction reset
void sendReset(int f_dds) 10 10 void sendReset(int f_dds)
{ 11 11 {
write(f_dds,"2",1); 12 12 write(f_dds,"2",1);
} 13 13 }
14 14
//fonction ioupdate 15 15 //fonction ioupdate
void sendIOUpdate(int f_dds) 16 16 void sendIOUpdate(int f_dds)
{ 17 17 {
write(f_dds,"1",1); 18 18 write(f_dds,"1",1);
} 19 19 }
20 20
//fonction write register 21 21 //fonction write register
void writeRegister (int fd, unsigned char addr, unsigned char d3, unsigned char d2, unsigned char d1, unsigned char d0) 22 22 void writeRegister (int fd, unsigned char addr, unsigned char d3, unsigned char d2, unsigned char d1, unsigned char d0)
{ 23 23 {
unsigned char tx[5]={0}; 24 24 unsigned char tx[5]={0};
tx[0]=addr; 25 25 tx[0]=addr;
tx[1]=d3; 26 26 tx[1]=d3;
tx[2]=d2; 27 27 tx[2]=d2;
tx[3]=d1; 28 28 tx[3]=d1;
tx[4]=d0; 29 29 tx[4]=d0;
//spi_put_multiple envoie le vecteur dans cet ordre 30 30 //spi_put_multiple envoie le vecteur dans cet ordre
//[tx0]-[tx1]-[tx2] -> adresse->bit poids Fort->bit poids faible 31 31 //[tx0]-[tx1]-[tx2] -> adresse->bit poids Fort->bit poids faible
spi_put_multiple(fd,tx,5,NULL,0); 32 32 spi_put_multiple(fd,tx,5,NULL,0);
} 33 33 }
34 34
//fonction read register 35 35 //fonction read register
36 36
void readRegister (int fd,unsigned char addr, uint32_t *readword) 37 37 void readRegister (int fd,unsigned char addr, uint32_t *readword)
{ 38 38 {
unsigned char tx[1] = {0}; 39 39 unsigned char tx[1] = {0};
unsigned char rx[4] = {0}; 40 40 unsigned char rx[4] = {0};
addr = addr|0x80;//instruction byte for the read : 1000 0000 | byte_adress 41 41 addr = addr|0x80;//instruction byte for the read : 1000 0000 | byte_adress
tx[0]=addr; 42 42 tx[0]=addr;
spi_put_multiple(fd,tx,1,rx,4); 43 43 spi_put_multiple(fd,tx,1,rx,4);
//printf("TX:%x RX:%x %x %x %x\n",tx[0],rx[0],rx[1],rx[2],rx[3]); 44 44 //printf("TX:%x RX:%x %x %x %x\n",tx[0],rx[0],rx[1],rx[2],rx[3]);
*readword = 0x00000000; 45 45 *readword = 0x00000000;
*readword = *readword|(rx[0]<<24); 46 46 *readword = *readword|(rx[0]<<24);
*readword = *readword|(rx[1]<<16); 47 47 *readword = *readword|(rx[1]<<16);
*readword = *readword|(rx[2]<<8); 48 48 *readword = *readword|(rx[2]<<8);
*readword = *readword|rx[3]; 49 49 *readword = *readword|rx[3];
} 50 50 }
51 51
//fonction read register 52 52 //fonction read register
void readRegisterIni (int fd, unsigned char addr) 53 53 void readRegisterIni (int fd, unsigned char addr)
{ 54 54 {
unsigned char tx[1] = {0}; 55 55 unsigned char tx[1] = {0};
unsigned char rx[4] = {0}; 56 56 unsigned char rx[4] = {0};
addr = addr|0x80; 57 57 addr = addr|0x80;
tx[0]=addr; 58 58 tx[0]=addr;
spi_put_multiple(fd,tx,1,rx,4); 59 59 spi_put_multiple(fd,tx,1,rx,4);
printf("TX:%x RX:%x %x %x %x\n",tx[0],rx[0],rx[1],rx[2],rx[3]); 60 60 printf("TX:%x RX:%x %x %x %x\n",tx[0],rx[0],rx[1],rx[2],rx[3]);
// sendIOUpdate (f_dds); //Send the update to set the control registers 61 61 // sendIOUpdate (f_dds); //Send the update to set the control registers
} 62 62 }
63 63
//initialisation du dds 64 64 //initialisation du dds
void initializeDDS (int fd, int f_dds) 65 65 void initializeDDS (int fd, int f_dds)
{ 66 66 {
sendReset(f_dds); 67 67 sendReset(f_dds);
writeRegister(fd,CFRAddress[0],CFR1Start[0], CFR1Start[1], CFR1Start[2], CFR1Start[3]); 68 68 writeRegister(fd,CFRAddress[0],CFR1Start[0], CFR1Start[1], CFR1Start[2], CFR1Start[3]);
sendIOUpdate (f_dds); //Send the update to set the control registers 69 69 sendIOUpdate (f_dds); //Send the update to set the control registers
writeRegister(fd,CFRAddress[1], CFR2Start[0], CFR2Start[1], CFR2Start[2], CFR2Start[3]); 70 70 writeRegister(fd,CFRAddress[1], CFR2Start[0], CFR2Start[1], CFR2Start[2], CFR2Start[3]);
sendIOUpdate (f_dds); 71 71 sendIOUpdate (f_dds);
writeRegister(fd,CFRAddress[2], CFR3Start[0], CFR3Start[1], CFR3Start[2], CFR3Start[3]); 72 72 writeRegister(fd,CFRAddress[2], CFR3Start[0], CFR3Start[1], CFR3Start[2], CFR3Start[3]);
sendIOUpdate (f_dds); 73 73 sendIOUpdate (f_dds);
writeRegister(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]); 74 74 writeRegister(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]);
sendIOUpdate (f_dds); 75 75 sendIOUpdate (f_dds);
writeRegister(fd,USR0Address, 0xA2, 0x00, 0x08, 0x00); 76 76 writeRegister(fd,USR0Address, 0xA2, 0x00, 0x08, 0x00);
sendIOUpdate (f_dds); 77 77 sendIOUpdate (f_dds);
} 78 78 }
79 79
//calibration du dac 80 80 //calibration du dac
void calibrateDAC (int fd, int f_dds) 81 81 void calibrateDAC (int fd, int f_dds)
{ 82 82 {
writeRegister(fd,CFRAddress[3], DACCalEnable[0], DACCalEnable[1], DACCalEnable[2], DACCalEnable[3]); 83 83 writeRegister(fd,CFRAddress[3], DACCalEnable[0], DACCalEnable[1], DACCalEnable[2], DACCalEnable[3]);
sendIOUpdate (f_dds); 84 84 sendIOUpdate (f_dds);
writeRegister(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]); 85 85 writeRegister(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]);
sendIOUpdate (f_dds); 86 86 sendIOUpdate (f_dds);
} 87 87 }
88 88
void modulusSetup(int fd, int f_dds) 89 89 void modulusSetup(int fd, int f_dds)
{ 90 90 {
writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x0a); //OSK enable //0x08 91 91 writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x0a); //OSK enable //0x08
sendIOUpdate (f_dds); 92 92 sendIOUpdate (f_dds);
writeRegister(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp 93 93 writeRegister(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp
sendIOUpdate (f_dds); 94 94 sendIOUpdate (f_dds);
} 95 95 }
96 96
void basicSetup(int fd, int f_dds,uint16_t ampWord, uint16_t phaseWord) 97 97 void basicSetup(int fd, int f_dds,uint16_t ampWord, uint16_t phaseWord)
{ 98 98 {
writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x08); //OSK enable 99 99 writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x08); //OSK enable
sendIOUpdate (f_dds); 100 100 sendIOUpdate (f_dds);
writeRegister(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp 101 101 writeRegister(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp
sendIOUpdate (f_dds); 102 102 sendIOUpdate (f_dds);
writeRegister(fd,0x04,0x19, 0x99, 0x99, 0x99); //ftw 103 103 writeRegister(fd,0x04,0x19, 0x99, 0x99, 0x99); //ftw
sendIOUpdate (f_dds); 104 104 sendIOUpdate (f_dds);
writeRegister(fd,0x05,0xC0, 0x00, 0x00, 0x00); //A 105 105 writeRegister(fd,0x05,0xC0, 0x00, 0x00, 0x00); //A
sendIOUpdate (f_dds); 106 106 sendIOUpdate (f_dds);
writeRegister(fd,0x06,0x00, 0x00, 0x00, 0x05); //B 107 107 writeRegister(fd,0x06,0x00, 0x00, 0x00, 0x05); //B
sendIOUpdate (f_dds); 108 108 sendIOUpdate (f_dds);
writeRegister(fd,0x0c, (uint8_t)((ampWord>>8) & 0x0F), (uint8_t)(ampWord & 0xFF), (uint8_t)((phaseWord>>8) & 0xFF), (uint8_t)(phaseWord & 0xFF)); // amp (12b) ph(16) 109 109 writeRegister(fd,0x0c, (uint8_t)((ampWord>>8) & 0x0F), (uint8_t)(ampWord & 0xFF), (uint8_t)((phaseWord>>8) & 0xFF), (uint8_t)(phaseWord & 0xFF)); // amp (12b) ph(16)
sendIOUpdate (f_dds); 110 110 sendIOUpdate (f_dds);
} 111 111 }
112 112
void setFreqMM(int fd, int f_dds, unsigned int ftw, unsigned int A, unsigned int B) 113 113 void setFreqMM(int fd, int f_dds, unsigned int ftw, unsigned int A, unsigned int B)
{ 114 114 {
writeRegister(fd,0x04,ftw>>24&0xFF, ftw>>16&0xFF, ftw>>8&0xFF, ftw&0xFF); //ftw 115 115 writeRegister(fd,0x04,ftw>>24&0xFF, ftw>>16&0xFF, ftw>>8&0xFF, ftw&0xFF); //ftw
sendIOUpdate(f_dds); 116 116 sendIOUpdate(f_dds);
writeRegister(fd,0x05,A>>24&0xFF,A>>16&0xFF, A>>8&0xFF, A&0xFF); //A 117 117 writeRegister(fd,0x05,A>>24&0xFF,A>>16&0xFF, A>>8&0xFF, A&0xFF); //A
sendIOUpdate(f_dds); 118 118 sendIOUpdate(f_dds);
writeRegister(fd,0x06,B>>24&0xFF,B>>16&0xFF, B>>8&0xFF, B&0xFF); //B 119 119 writeRegister(fd,0x06,B>>24&0xFF,B>>16&0xFF, B>>8&0xFF, B&0xFF); //B
sendIOUpdate(f_dds); 120 120 sendIOUpdate(f_dds);
} 121 121 }
122 122
void setAmpPhaseWord(int fd, int f_dds,unsigned int phaseAmpWord) 123 123 void setAmpPhaseWord(int fd, int f_dds,unsigned int phaseAmpWord)
{ 124 124 {
writeRegister(fd,0x0c, phaseAmpWord>>24&0xFF, phaseAmpWord>>16&0xFF,phaseAmpWord>>8&0xFF,phaseAmpWord&0xFF); // amp (12b) ph(16) 125 125 writeRegister(fd,0x0c, phaseAmpWord>>24&0xFF, phaseAmpWord>>16&0xFF,phaseAmpWord>>8&0xFF,phaseAmpWord&0xFF); // amp (12b) ph(16)
sendIOUpdate(f_dds); 126 126 sendIOUpdate(f_dds);
} 127 127 }
128 128
void checkSize(void) 129 129 void checkSize(void)
{ 130 130 {
printf("int : %d\n",sizeof(unsigned int)); 131 131 printf("int : %d\n",sizeof(unsigned int));
} 132 132 }
133 133
int openAndSetDdsFreq( char * device, char * gpio_update, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord) 134 134 int openAndSetDdsFreq( char * device, char * gpio_update, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord)
{ 135 135 {
#ifdef debug 136 136 #ifdef debug
printf("device=%s\tgpio_update=%s\tf_clk=%e\tf_out=%e\tampWord=%d\tphaseWord=%d\n\n",device,gpio_update,f_clk,f_out,ampWord,phaseWord); 137 137 printf("device=%s\tgpio_update=%s\tf_clk=%e\tf_out=%e\tampWord=%d\tphaseWord=%d\n\n",device,gpio_update,f_clk,f_out,ampWord,phaseWord);
#else 138 138 #else
printf("device=%s\tgpio_update=%s\tf_clk=%e\tf_out=%e\tampWord=%d\tphaseWord=%d\n\n",device,gpio_update,f_clk,f_out,ampWord,phaseWord); 139 139 printf("device=%s\tgpio_update=%s\tf_clk=%e\tf_out=%e\tampWord=%d\tphaseWord=%d\n\n",device,gpio_update,f_clk,f_out,ampWord,phaseWord);
int fd=configureSpi(device); //ex #define FILENAME2 "/dev/spidev0.0" 140 140 int fd=configureSpi(device); //ex #define FILENAME2 "/dev/spidev0.0"
printf("fd(funct)=%d\n",fd); 141 141 printf("fd(funct)=%d\n",fd);
setMode(fd,SPI_MODE_0); 142 142 setMode(fd,SPI_MODE_0);
if (fd <= 0){ 143 143 if (fd <= 0){
printf("ERREUR : ouverture périphérique SPI %s\n",device); 144 144 printf("ERREUR : ouverture périphérique SPI %s\n",device);
return EXIT_FAILURE; 145 145 return EXIT_FAILURE;
} 146 146 }
int f_dds=open(gpio_update,O_RDWR); //ex #define UPDATE2 "/sys/dds/gpio24/updateOn" 147 147 int f_dds=open(gpio_update,O_RDWR); //ex #define UPDATE2 "/sys/dds/gpio24/updateOn"
printf("f_dds(funct)=%d\n",f_dds); 148 148 printf("f_dds(funct)=%d\n",f_dds);
if (f_dds <= 0){ 149 149 if (f_dds <= 0){
printf("ERREUR : ouverture ");printf(gpio_update);printf("\n"); 150 150 printf("ERREUR : ouverture ");printf(gpio_update);printf("\n");
printf("Chargez le module ddsIOupdateX\n"); 151 151 printf("Chargez le module ddsIOupdateX\n");
return EXIT_FAILURE; 152 152 return EXIT_FAILURE;
} 153 153 }
setddsFreq(fd,f_dds,f_out,f_clk); 154 154 setddsFreq(fd,f_dds,f_out,f_clk);
//debug 155 155 //debug
phaseWord = 0x0000; 156 156 phaseWord = 0x0000;
ampWord=0x0FFF; 157 157 ampWord=0x0FFF;
uint32_t phaseAmpWord = phaseWord | ampWord<<16; 158 158 uint32_t phaseAmpWord = phaseWord | ampWord<<16;
setAmpPhaseWord(fd, f_dds, phaseAmpWord); 159 159 setAmpPhaseWord(fd, f_dds, phaseAmpWord);
#endif 160 160 #endif
return EXIT_SUCCESS; 161 161 return EXIT_SUCCESS;
} 162 162 }
163 163
int setDdsFreqFull ( int fd, int f_dds, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord) 164 164 int setDdsFreqFull ( int fd, int f_dds, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord)
{ 165 165 {
setddsFreq(fd,f_dds,f_out,f_clk); 166 166 setddsFreq(fd,f_dds,f_out,f_clk);
#ifdef debug 167 167 #ifdef debug
phaseWord = 0x0000; 168 168 phaseWord = 0x0000;
ampWord=0x0FFF; 169 169 ampWord=0x0FFF;
#endif 170 170 #endif
uint32_t phaseAmpWord = phaseWord | ampWord<<16; 171 171 uint32_t phaseAmpWord = phaseWord | ampWord<<16;
setAmpPhaseWord(fd, f_dds, phaseAmpWord); 172 172 setAmpPhaseWord(fd, f_dds, phaseAmpWord);
173 173
return EXIT_SUCCESS; 174 174 return EXIT_SUCCESS;
} 175 175 }
176 176
void sendCtrlUp(int fp) 177 177 void sendCtrlUp(int fp)
{ 178 178 {
//pente positive 179 179 //pente positive
write(fp,"0",1); 180 180 write(fp,"0",1);
} 181 181 }
182 182
void sendCtrlDown(int fp) 183 183 void sendCtrlDown(int fp)
{ 184 184 {
//pente negative 185 185 //pente negative
write(fp,"2",1); 186 186 write(fp,"2",1);
} 187 187 }
188 188
void sendHold(int fp) 189 189 void sendHold(int fp)
{ 190 190 {
//rampe bloquee 191 191 //rampe bloquee
write(fp,"1",1); 192 192 write(fp,"1",1);
} 193 193 }
194 194
void sendUnhold(int fp) 195 195 void sendUnhold(int fp)
{ 196 196 {
//rampe debloquee 197 197 //rampe debloquee
write(fp,"3",1); //reset 198 198 write(fp,"3",1); //reset
} 199 199 }
200 200
201 201
int testRampFreq(int fd, int f_dds, int fp) 202 202 int testRampFreq(int fd, int f_dds, int fp)
{ 203 203 {
204 204
205 205
//3-Rampe de pente positive + debloquage 206 206 //3-Rampe de pente positive + debloquage
sendCtrlDown(fp);//rampe up 207 207 sendCtrlDown(fp);//rampe up
sendUnhold(fp); 208 208 sendUnhold(fp);
209 209
sendReset(f_dds); 210 210 sendReset(f_dds);
//Initialize_DDS (fd, f_dds); 211 211 //Initialize_DDS (fd, f_dds);
212 212
//0- paramètre de bases 213 213 //0- paramètre de bases
writeRegister(fd,0x00,0x00,0x01,0x01,0x0a);//OSKenable+Read&write 214 214 writeRegister(fd,0x00,0x00,0x01,0x01,0x0a);//OSKenable+Read&write
sendIOUpdate(f_dds); 215 215 sendIOUpdate(f_dds);
readRegisterIni(fd,0x00); 216 216 readRegisterIni(fd,0x00);
217 217
writeRegister(fd,0x01,0x00, 0x00, 0x09, 0x00); // enable amp ramp 218 218 writeRegister(fd,0x01,0x00, 0x00, 0x09, 0x00); // enable amp ramp
sendIOUpdate(f_dds); 219 219 sendIOUpdate(f_dds);
readRegisterIni(fd,0x00); 220 220 readRegisterIni(fd,0x00);
221 221
222 222
writeRegister(fd,0x0b,0x02,0xd0,0xe5,0x60);//mot de frequence 223 223 writeRegister(fd,0x0b,0x02,0xd0,0xe5,0x60);//mot de frequence
sendIOUpdate(f_dds); 224 224 sendIOUpdate(f_dds);
writeRegister(fd,0x0c,0x0F,0xFF,0x00,0x00); //mot de amp et de phase : amp max, phase nulle 225 225 writeRegister(fd,0x0c,0x0F,0xFF,0x00,0x00); //mot de amp et de phase : amp max, phase nulle
sendIOUpdate(f_dds); 226 226 sendIOUpdate(f_dds);
227 227
printf("Les mots de frequences, d'amplitudes et de phases sont envoyes\n"); 228 228 printf("Les mots de frequences, d'amplitudes et de phases sont envoyes\n");
printf("Lecture registre de frequence: 0x0b\n"); 229 229 printf("Lecture registre de frequence: 0x0b\n");
readRegisterIni(fd,0x0b); 230 230 readRegisterIni(fd,0x0b);
printf("Lecture registre de amp et phase: 0x0c\n"); 231 231 printf("Lecture registre de amp et phase: 0x0c\n");
readRegisterIni(fd,0x0c); 232 232 readRegisterIni(fd,0x0c);
233 233
calibrateDAC (fd,f_dds); 234 234 calibrateDAC (fd,f_dds);
printf("\n\n ----------------------- \n\n"); 235 235 printf("\n\n ----------------------- \n\n");
236 236
237 237
return EXIT_SUCCESS; 238 238 return EXIT_SUCCESS;
} 239 239 }
240 240
//---------------rajout 8/1 241 241 //---------------rajout 8/1
242 242
int putAmpWord(int fd, int f_dds, double amplitude) 243 243 int putAmpWord(int fd, int f_dds, double amplitude)
{ 244 244 {
uint16_t PhaseWord = 0x0000; 245 245 uint16_t PhaseWord = 0x0000;
uint16_t AmpWord = 0x0000; 246 246 uint16_t AmpWord = 0x0000;
uint32_t ReadPhaseAmpWord=0x00000000; 247 247 uint32_t ReadPhaseAmpWord=0x00000000;
248 248
AmpWord = rint(amplitude*(pow(2.0,12.0)-1)/100); 249 249 AmpWord = rint(amplitude*(pow(2.0,12.0)-1)/100);
250 250
readRegister(fd,0x0c,&ReadPhaseAmpWord); 251 251 readRegister(fd,0x0c,&ReadPhaseAmpWord);
252 252
PhaseWord = ReadPhaseAmpWord&0xFFFF; 253 253 PhaseWord = ReadPhaseAmpWord&0xFFFF;
254 254
writeRegister(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); 255 255 writeRegister(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF);
sendIOUpdate(f_dds); 256 256 sendIOUpdate(f_dds);
257 257
return 0; 258 258 return 0;
} 259 259 }
260 260
261 261
int putPhaseWord(int fd, int f_dds, double phase) 262 262 int putPhaseWord(int fd, int f_dds, double phase)
{ 263 263 {
//uint16_t PhaseWord = 0x0000; 264 264 //uint16_t PhaseWord = 0x0000;
//uint16_t AmpWord = 0x0000; 265 265 //uint16_t AmpWord = 0x0000;
uint32_t ReadPhaseAmpWord=0x00000000; 266 266 uint32_t ReadPhaseAmpWord=0x00000000;
267 267
uint16_t PhaseWord = rint(phase*(pow(2.0,16.0)-1)/360); 268 268 uint16_t PhaseWord = rint(phase*(pow(2.0,16.0)-1)/360);
269 269
readRegister(fd,0x0c,&ReadPhaseAmpWord); 270 270 readRegister(fd,0x0c,&ReadPhaseAmpWord);
271 271
uint16_t AmpWord = ReadPhaseAmpWord>>16&0xFFFF; 272 272 uint16_t AmpWord = ReadPhaseAmpWord>>16&0xFFFF;
273 273
writeRegister(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); 274 274 writeRegister(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF);
sendIOUpdate(f_dds); 275 275 sendIOUpdate(f_dds);
276 276
return 0; 277 277 return 0;
} 278 278 }
279 279
int putFrequencyWord(int fd, int f_dds, double fclk,double fout)//Attention uniquement valable pour fclk = 1 GHz 280 280 int putFrequencyWord(int fd, int f_dds, double fclk,double fout)//Attention uniquement valable pour fclk = 1 GHz
{ 281 281 {
282 282
//uint32_t FTWR = 0x00000000; 283 283 //uint32_t FTWR = 0x00000000;
uint32_t FTWR = rint((fout/fclk)*pow(2.0,32.0)); 284 284 uint32_t FTWR = rint((fout/fclk)*pow(2.0,32.0));
writeRegister(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence 285 285 writeRegister(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence
sendIOUpdate(f_dds); 286 286 sendIOUpdate(f_dds);
287 287
return 0; 288 288 return 0;
} 289 289 }
290 290
291 291
int putFrequencyAmpPhaseWord(int fd, int f_dds, double fout, double fclk,double amp, double phase)//n'existe pas dans le mode profile enable 292 292 int putFrequencyAmpPhaseWord(int fd, int f_dds, double fout, double fclk,double amp, double phase)//n'existe pas dans le mode profile enable
{ 293 293 {
294 294
//uint32_t FTWR = 0x00000000; 295 295 //uint32_t FTWR = 0x00000000;
296 296
uint32_t FTWR = rint((fout/fclk)*pow(2.0,32.0)); 297 297 uint32_t FTWR = rint((fout/fclk)*pow(2.0,32.0));
298 298
writeRegister(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence 299 299 writeRegister(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence
300 300
sendIOUpdate(f_dds); 301 301 sendIOUpdate(f_dds);
302 302
putPhaseWord(fd,f_dds,phase); 303 303 putPhaseWord(fd,f_dds,phase);
putAmpWord(fd,f_dds,amp); 304 304 putAmpWord(fd,f_dds,amp);
305 305
return 0; 306 306 return 0;
} 307 307 }
308 308
309 309
int initialisationProfileMode (int fd,int f_dds) 310 310 int initialisationProfileMode (int fd,int f_dds)
{ 311 311 {
312 312
sendReset(f_dds); //les registres sont maintenant par defaut 313 313 sendReset(f_dds); //les registres sont maintenant par defaut
writeRegister(fd,0x00,0x00,0x01,0x01,0x0a); //OSK+SDIO input only//ok 314 314 writeRegister(fd,0x00,0x00,0x01,0x01,0x0a); //OSK+SDIO input only//ok
sendIOUpdate(f_dds); 315 315 sendIOUpdate(f_dds);
writeRegister(fd,0x01,0x00,0x80,0x09,0x00); // profile mode enable very important 316 316 writeRegister(fd,0x01,0x00,0x80,0x09,0x00); // profile mode enable very important
sendIOUpdate(f_dds); 317 317 sendIOUpdate(f_dds);
writeRegister(fd,0x02,0x00,0x00,0x19,0x1c); // default 318 318 writeRegister(fd,0x02,0x00,0x00,0x19,0x1c); // default
sendIOUpdate(f_dds); 319 319 sendIOUpdate(f_dds);
writeRegister(fd,0x03,0x01,0x05,0x21,0x20); // calibration 1/2 :enable 320 320 writeRegister(fd,0x03,0x01,0x05,0x21,0x20); // calibration 1/2 :enable
sendIOUpdate(f_dds); 321 321 sendIOUpdate(f_dds);
writeRegister(fd,0x03,0x00,0x05,0x21,0x20); // calibration 2/2 :desenable 322 322 writeRegister(fd,0x03,0x00,0x05,0x21,0x20); // calibration 2/2 :desenable
sendIOUpdate(f_dds); 323 323 sendIOUpdate(f_dds);
324 324
return 0; 325 325 return 0;
} 326 326 }
327 327
328 328
329 329
//------------------- FIN RAJOUT 8/1 330 330 //------------------- FIN RAJOUT 8/1
331 331
332 332
//-------------------------FONCTIONS RAMPES HARDWARE 333 333 //-------------------------FONCTIONS RAMPES HARDWARE
334 334
//1-rampe de frequence 335 335 //1-rampe de frequence
336 336
//rampe simple de fréquence 337 337 //rampe simple de fréquence
int frequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown) 338 338 int frequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown)
{ 339 339 {
//calcul de N => N=DeltaF/df = DeltaT/dt 340 340 //calcul de N => N=DeltaF/df = DeltaT/dt
341 341
//1-fmax > fmin 342 342 //1-fmax > fmin
double DeltaFreq = FreqMax-FreqMin; 343 343 double DeltaFreq = FreqMax-FreqMin;
if(FreqMax<FreqMin) 344 344 if(FreqMax<FreqMin)
{ 345 345 {
printf("FreqMax should be > FreqMin\n"); 346 346 printf("FreqMax should be > FreqMin\n");
printf("Can't Start the ramp\n"); 347 347 printf("Can't Start the ramp\n");
return -1; 348 348 return -1;
} 349 349 }
350 350
//2- Calcul du nombre de points de la rampe 351 351 //2- Calcul du nombre de points de la rampe
int NumberPointsUp = DeltaFreq/dfUp; 352 352 int NumberPointsUp = DeltaFreq/dfUp;
int NumberPointsDown = DeltaFreq/dfDown; 353 353 int NumberPointsDown = DeltaFreq/dfDown;
354 354
//3- En déduire la valeur de dtUp et dtDown 355 355 //3- En déduire la valeur de dtUp et dtDown
double dtUp = DeltaTimeUp/NumberPointsUp; 356 356 double dtUp = DeltaTimeUp/NumberPointsUp;
double dtDown = DeltaTimeDown/NumberPointsDown; 357 357 double dtDown = DeltaTimeDown/NumberPointsDown;
358 358
double dtmin = 24/fclk; 359 359 double dtmin = 24/fclk;
double dtmax = dtmin*(pow(2.0,16.0)-1); 360 360 double dtmax = dtmin*(pow(2.0,16.0)-1);
361 361
//Check Up 362 362 //Check Up
if(dtUp<dtmin) 363 363 if(dtUp<dtmin)
{ 364 364 {
printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp); 365 365 printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp);
printf("Can't start the ramp\n"); 366 366 printf("Can't start the ramp\n");
return -1; 367 367 return -1;
} 368 368 }
369 369
if(dtUp>dtmax) 370 370 if(dtUp>dtmax)
{ 371 371 {
printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp); 372 372 printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp);
printf("Can't start the ramp\n"); 373 373 printf("Can't start the ramp\n");
return -1; 374 374 return -1;
} 375 375 }
376 376
//Check Down 377 377 //Check Down
if(dtDown<dtmin) 378 378 if(dtDown<dtmin)
{ 379 379 {
printf("During of ramp DOWN should be > %f s\n",dtmin*NumberPointsDown); 380 380 printf("During of ramp DOWN should be > %f s\n",dtmin*NumberPointsDown);
printf("Can't start the ramp\n"); 381 381 printf("Can't start the ramp\n");
return -1; 382 382 return -1;
} 383 383 }
384 384
if(dtDown>dtmax) 385 385 if(dtDown>dtmax)
{ 386 386 {
printf("During of ramp DOWN should be < %f\n",dtmax*NumberPointsDown); 387 387 printf("During of ramp DOWN should be < %f\n",dtmax*NumberPointsDown);
printf("Can't start the ramp\n"); 388 388 printf("Can't start the ramp\n");
return -1; 389 389 return -1;
} 390 390 }
391 391
392 392
//4 - Put word in register 393 393 //4 - Put word in register
394 394
395 395
//4.1 Limit register 396 396 //4.1 Limit register
uint32_t FTWRmin = rint((FreqMin/fclk)*pow(2.0,32.0)); 397 397 uint32_t FTWRmin = rint((FreqMin/fclk)*pow(2.0,32.0));
writeRegister(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence 398 398 writeRegister(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence
sendIOUpdate(f_dds); 399 399 sendIOUpdate(f_dds);
400 400
uint32_t FTWRmax = rint((FreqMax/fclk)*pow(2.0,32.0)); 401 401 uint32_t FTWRmax = rint((FreqMax/fclk)*pow(2.0,32.0));
writeRegister(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence 402 402 writeRegister(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence
sendIOUpdate(f_dds); 403 403 sendIOUpdate(f_dds);
404 404
405 405
//4.2 dfUP et dfDown 406 406 //4.2 dfUP et dfDown
double df_up = DeltaFreq/NumberPointsUp; 407 407 double df_up = DeltaFreq/NumberPointsUp;
double df_down = DeltaFreq/NumberPointsDown; 408 408 double df_down = DeltaFreq/NumberPointsDown;
409 409
uint32_t Word_df_up = rint(df_up*pow(2.0,32.0)/fclk); 410 410 uint32_t Word_df_up = rint(df_up*pow(2.0,32.0)/fclk);
uint32_t Word_df_down = rint(df_down*pow(2.0,32.0)/fclk); 411 411 uint32_t Word_df_down = rint(df_down*pow(2.0,32.0)/fclk);
412 412
writeRegister(fd,0x06,Word_df_up>>24&0xFF,Word_df_up>>16&0xFF,Word_df_up>>8&0xFF,Word_df_up&0xFF); //df_up 413 413 writeRegister(fd,0x06,Word_df_up>>24&0xFF,Word_df_up>>16&0xFF,Word_df_up>>8&0xFF,Word_df_up&0xFF); //df_up
sendIOUpdate(f_dds); 414 414 sendIOUpdate(f_dds);
writeRegister(fd,0x07,Word_df_down>>24&0xFF,Word_df_down>>16&0xFF,Word_df_down>>8&0xFF,Word_df_down&0xFF);//df_down 415 415 writeRegister(fd,0x07,Word_df_down>>24&0xFF,Word_df_down>>16&0xFF,Word_df_down>>8&0xFF,Word_df_down&0xFF);//df_down
sendIOUpdate(f_dds); 416 416 sendIOUpdate(f_dds);
417 417
418 418
//4.3 dtUp et dtDown 419 419 //4.3 dtUp et dtDown
420 420
uint16_t Word_dt_up = 0x0000; 421 421 uint16_t Word_dt_up = 0x0000;
uint16_t Word_dt_down = 0x0000; 422 422 uint16_t Word_dt_down = 0x0000;
423 423
Word_dt_up = rint(dtUp*fclk/24); 424 424 Word_dt_up = rint(dtUp*fclk/24);
Word_dt_down = rint(dtDown*fclk/24); 425 425 Word_dt_down = rint(dtDown*fclk/24);
426 426
writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt 427 427 writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt
sendIOUpdate(f_dds); 428 428 sendIOUpdate(f_dds);
429 429
//5 Start of the ramp 430 430 //5 Start of the ramp
431 431
writeRegister(fd,0x01,0x00,0x08,0x09,0x00); //rampe simple 432 432 writeRegister(fd,0x01,0x00,0x08,0x09,0x00); //rampe simple
sendIOUpdate(f_dds); 433 433 sendIOUpdate(f_dds);
return 0; 434 434 return 0;
435 435
436 436
437 437
return EXIT_SUCCESS; 438 438 return EXIT_SUCCESS;
439 439
} 440 440 }
441 441
442 442
//rampe continue de fréquence 443 443 //rampe continue de fréquence
int continueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown) 444 444 int continueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown)
{ 445 445 {
//calcul de N => N=DeltaF/df = DeltaT/dt 446 446 //calcul de N => N=DeltaF/df = DeltaT/dt
447 447
//1-fmax > fmin 448 448 //1-fmax > fmin
double DeltaFreq = FreqMax-FreqMin; 449 449 double DeltaFreq = FreqMax-FreqMin;
if(FreqMax<FreqMin) 450 450 if(FreqMax<FreqMin)
{ 451 451 {
printf("FreqMax should be > FreqMin\n"); 452 452 printf("FreqMax should be > FreqMin\n");
printf("Can't Start the ramp\n"); 453 453 printf("Can't Start the ramp\n");
return -1; 454 454 return -1;
} 455 455 }
456 456
//2- Calcul du nombre de points de la rampe 457 457 //2- Calcul du nombre de points de la rampe
int NumberPointsUp = DeltaFreq/dfUp; 458 458 int NumberPointsUp = DeltaFreq/dfUp;
int NumberPointsDown = DeltaFreq/dfDown; 459 459 int NumberPointsDown = DeltaFreq/dfDown;
460 460
//3- En déduire la valeur de dtUp et dtDown 461 461 //3- En déduire la valeur de dtUp et dtDown
double dtUp = DeltaTimeUp/NumberPointsUp; 462 462 double dtUp = DeltaTimeUp/NumberPointsUp;
double dtDown = DeltaTimeDown/NumberPointsDown; 463 463 double dtDown = DeltaTimeDown/NumberPointsDown;
464 464
double dtmin = 24/fclk; 465 465 double dtmin = 24/fclk;
double dtmax = dtmin*(pow(2.0,16.0)-1); 466 466 double dtmax = dtmin*(pow(2.0,16.0)-1);
467 467
//Check Up 468 468 //Check Up
if(dtUp<dtmin) 469 469 if(dtUp<dtmin)
{ 470 470 {
printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp); 471 471 printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp);
printf("Can't start the ramp\n"); 472 472 printf("Can't start the ramp\n");
return -1; 473 473 return -1;
} 474 474 }
475 475
if(dtUp>dtmax) 476 476 if(dtUp>dtmax)
{ 477 477 {
printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp); 478 478 printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp);
printf("Can't start the ramp\n"); 479 479 printf("Can't start the ramp\n");
return -1; 480 480 return -1;
} 481 481 }
482 482
//Check Down 483 483 //Check Down
if(dtDown<dtmin) 484 484 if(dtDown<dtmin)
{ 485 485 {
printf("During of ramp DOWN should be > %f s\n",dtmin*NumberPointsDown); 486 486 printf("During of ramp DOWN should be > %f s\n",dtmin*NumberPointsDown);
printf("Can't start the ramp\n"); 487 487 printf("Can't start the ramp\n");
return -1; 488 488 return -1;
} 489 489 }
490 490
if(dtDown>dtmax) 491 491 if(dtDown>dtmax)
{ 492 492 {
printf("During of ramp DOWN should be < %f\n",dtmax*NumberPointsDown); 493 493 printf("During of ramp DOWN should be < %f\n",dtmax*NumberPointsDown);
printf("Can't start the ramp\n"); 494 494 printf("Can't start the ramp\n");
return -1; 495 495 return -1;
} 496 496 }
497 497
498 498
//4 - Put word in register 499 499 //4 - Put word in register
500 500
501 501
//4.1 Limit register 502 502 //4.1 Limit register
uint32_t FTWRmin = rint((FreqMin/fclk)*pow(2.0,32.0)); 503 503 uint32_t FTWRmin = rint((FreqMin/fclk)*pow(2.0,32.0));
writeRegister(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence 504 504 writeRegister(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence
sendIOUpdate(f_dds); 505 505 sendIOUpdate(f_dds);
506 506
uint32_t FTWRmax = rint((FreqMax/fclk)*pow(2.0,32.0)); 507 507 uint32_t FTWRmax = rint((FreqMax/fclk)*pow(2.0,32.0));
writeRegister(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence 508 508 writeRegister(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence
sendIOUpdate(f_dds); 509 509 sendIOUpdate(f_dds);
510 510
511 511
//4.2 dfUP et dfDown 512 512 //4.2 dfUP et dfDown
double df_up = DeltaFreq/NumberPointsUp; 513 513 double df_up = DeltaFreq/NumberPointsUp;
double df_down = DeltaFreq/NumberPointsDown; 514 514 double df_down = DeltaFreq/NumberPointsDown;
515 515
uint32_t Word_df_up = rint(df_up*pow(2.0,32.0)/fclk); 516 516 uint32_t Word_df_up = rint(df_up*pow(2.0,32.0)/fclk);
uint32_t Word_df_down = rint(df_down*pow(2.0,32.0)/fclk); 517 517 uint32_t Word_df_down = rint(df_down*pow(2.0,32.0)/fclk);
518 518
writeRegister(fd,0x06,Word_df_up>>24&0xFF,Word_df_up>>16&0xFF,Word_df_up>>8&0xFF,Word_df_up&0xFF); //df_up 519 519 writeRegister(fd,0x06,Word_df_up>>24&0xFF,Word_df_up>>16&0xFF,Word_df_up>>8&0xFF,Word_df_up&0xFF); //df_up
sendIOUpdate(f_dds); 520 520 sendIOUpdate(f_dds);
writeRegister(fd,0x07,Word_df_down>>24&0xFF,Word_df_down>>16&0xFF,Word_df_down>>8&0xFF,Word_df_down&0xFF);//df_down 521 521 writeRegister(fd,0x07,Word_df_down>>24&0xFF,Word_df_down>>16&0xFF,Word_df_down>>8&0xFF,Word_df_down&0xFF);//df_down
sendIOUpdate(f_dds); 522 522 sendIOUpdate(f_dds);
523 523
524 524
//4.3 dtUp et dtDown 525 525 //4.3 dtUp et dtDown
526 526
uint16_t Word_dt_up = 0x0000; 527 527 uint16_t Word_dt_up = 0x0000;
uint16_t Word_dt_down = 0x0000; 528 528 uint16_t Word_dt_down = 0x0000;
529 529
Word_dt_up = rint(dtUp*fclk/24); 530 530 Word_dt_up = rint(dtUp*fclk/24);
Word_dt_down = rint(dtDown*fclk/24); 531 531 Word_dt_down = rint(dtDown*fclk/24);
532 532
writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt 533 533 writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt
sendIOUpdate(f_dds); 534 534 sendIOUpdate(f_dds);
535 535
//5 Start of the ramp 536 536 //5 Start of the ramp
537 537
writeRegister(fd,0x01,0x00,0x8e,0x29,0x00); //rampe triangulaire 538 538 writeRegister(fd,0x01,0x00,0x8e,0x29,0x00); //rampe triangulaire
sendIOUpdate(f_dds); 539 539 sendIOUpdate(f_dds);
return 0; 540 540 return 0;
541 541
542 542
543 543
return EXIT_SUCCESS; 544 544 return EXIT_SUCCESS;
545 545
} 546 546 }
547 547
//2-rampe d'amplitude 548 548 //2-rampe d'amplitude
549 549
int amplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown) 550 550 int amplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown)
{ 551 551 {
552 552
553 553
//calcul de N => N=DeltaF/df = DeltaT/dt 554 554 //calcul de N => N=DeltaF/df = DeltaT/dt
555 555
//1-Amax > Amin 556 556 //1-Amax > Amin
double DeltaAmp = AMax-AMin; 557 557 double DeltaAmp = AMax-AMin;
if(AMax<AMin) 558 558 if(AMax<AMin)
{ 559 559 {
printf("AMax should be > AMin\n"); 560 560 printf("AMax should be > AMin\n");
printf("Can't Start the ramp\n"); 561 561 printf("Can't Start the ramp\n");
return -1; 562 562 return -1;
} 563 563 }
564 564
565 565
//2- Calcul du nombre de points de la rampe 566 566 //2- Calcul du nombre de points de la rampe
int NumberPointsUp = DeltaAmp/dAUp; 567 567 int NumberPointsUp = DeltaAmp/dAUp;
int NumberPointsDown = DeltaAmp/dADown; 568 568 int NumberPointsDown = DeltaAmp/dADown;
569 569
//3- En déduire la valeur de dtUp et dtDown 570 570 //3- En déduire la valeur de dtUp et dtDown
double dtUp = DeltaTimeUp/NumberPointsUp; 571 571 double dtUp = DeltaTimeUp/NumberPointsUp;
double dtDown = DeltaTimeDown/NumberPointsDown; 572 572 double dtDown = DeltaTimeDown/NumberPointsDown;
573 573
double dtmin = 24/fclk; 574 574 double dtmin = 24/fclk;
double dtmax = dtmin*(pow(2.0,16.0)-1); 575 575 double dtmax = dtmin*(pow(2.0,16.0)-1);
576 576
//Check Up 577 577 //Check Up
if(dtUp<dtmin) 578 578 if(dtUp<dtmin)
{ 579 579 {
printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp); 580 580 printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp);
printf("Can't start the ramp\n"); 581 581 printf("Can't start the ramp\n");
return -1; 582 582 return -1;
} 583 583 }
584 584
if(dtUp>dtmax) 585 585 if(dtUp>dtmax)
{ 586 586 {
printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp); 587 587 printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp);
printf("Can't start the ramp\n"); 588 588 printf("Can't start the ramp\n");
return -1; 589 589 return -1;
} 590 590 }
591 591
//Check Down 592 592 //Check Down
if(dtDown<dtmin) 593 593 if(dtDown<dtmin)
{ 594 594 {
printf("During of ramp DOWN should be > %f s\n",dtmin*NumberPointsDown); 595 595 printf("During of ramp DOWN should be > %f s\n",dtmin*NumberPointsDown);
printf("Can't start the ramp\n"); 596 596 printf("Can't start the ramp\n");
return -1; 597 597 return -1;
} 598 598 }
599 599
if(dtDown>dtmax) 600 600 if(dtDown>dtmax)
{ 601 601 {
printf("During of ramp DOWN should be < %f\n",dtmax*NumberPointsDown); 602 602 printf("During of ramp DOWN should be < %f\n",dtmax*NumberPointsDown);
printf("Can't start the ramp\n"); 603 603 printf("Can't start the ramp\n");
return -1; 604 604 return -1;
} 605 605 }
606 606
607 607
608 608
//check if DeltaAmp is enouth 609 609 //check if DeltaAmp is enouth
double enouthUP=0.5*NumberPointsUp*100/4095; 610 610 double enouthUP=0.5*NumberPointsUp*100/4095;
double enouthDOWN=0.5*NumberPointsDown*100/4095; 611 611 double enouthDOWN=0.5*NumberPointsDown*100/4095;
612 612
int borneUP = rint(enouthUP); 613 613 int borneUP = rint(enouthUP);
int borneDown = rint(enouthDOWN); 614 614 int borneDown = rint(enouthDOWN);
615 615
if(DeltaAmp<=enouthUP) 616 616 if(DeltaAmp<=enouthUP)
{ 617 617 {
printf("The amplitude difference should be > %d\n, decrease Number Points for positive slope",borneUP); 618 618 printf("The amplitude difference should be > %d\n, decrease Number Points for positive slope",borneUP);
} 619 619 }
620 620
if(DeltaAmp<=enouthDOWN) 621 621 if(DeltaAmp<=enouthDOWN)
{ 622 622 {
printf("The amplitude difference should be > %d\n, decrease Number Points for negative slope",borneDown); 623 623 printf("The amplitude difference should be > %d\n, decrease Number Points for negative slope",borneDown);
} 624 624 }
625 625
626 626
//4 - Put word in register 627 627 //4 - Put word in register
628 628
629 629
//4.1 Limit register 630 630 //4.1 Limit register
uint32_t WordAmin = rint(AMin*4095/100); 631 631 uint32_t WordAmin = rint(AMin*4095/100);
uint32_t WordAmax= rint(AMax*4095/100); 632 632 uint32_t WordAmax= rint(AMax*4095/100);
633 633
writeRegister(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 634 634 writeRegister(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2
sendIOUpdate(f_dds); 635 635 sendIOUpdate(f_dds);
writeRegister(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 636 636 writeRegister(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0
sendIOUpdate(f_dds); 637 637 sendIOUpdate(f_dds);
638 638
639 639
//4.2 dAUP et dADown 640 640 //4.2 dAUP et dADown
641 641
uint32_t Word_dA_up = rint(dAUp*4095/100); 642 642 uint32_t Word_dA_up = rint(dAUp*4095/100);
uint32_t Word_dA_down = rint(dADown*4095/100); 643 643 uint32_t Word_dA_down = rint(dADown*4095/100);
644 644
writeRegister(fd,0x06,Word_dA_up>>24&0xFF,Word_dA_up>>16&0xFF,Word_dA_up>>8&0xFF,Word_dA_up&0xFF); //dA_up 645 645 writeRegister(fd,0x06,Word_dA_up>>24&0xFF,Word_dA_up>>16&0xFF,Word_dA_up>>8&0xFF,Word_dA_up&0xFF); //dA_up
sendIOUpdate(f_dds); 646 646 sendIOUpdate(f_dds);
writeRegister(fd,0x07,Word_dA_down>>24&0xFF,Word_dA_down>>16&0xFF,Word_dA_down>>8&0xFF,Word_dA_down&0xFF);//dA_down 647 647 writeRegister(fd,0x07,Word_dA_down>>24&0xFF,Word_dA_down>>16&0xFF,Word_dA_down>>8&0xFF,Word_dA_down&0xFF);//dA_down
sendIOUpdate(f_dds); 648 648 sendIOUpdate(f_dds);
649 649
650 650
//4.3 dtUp et dtDown 651 651 //4.3 dtUp et dtDown
652 652
uint16_t Word_dt_up = rint(dtUp*fclk/24); 653 653 uint16_t Word_dt_up = rint(dtUp*fclk/24);
uint16_t Word_dt_down = rint(dtDown*fclk/24); 654 654 uint16_t Word_dt_down = rint(dtDown*fclk/24);
655 655
writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt 656 656 writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt
sendIOUpdate(f_dds); 657 657 sendIOUpdate(f_dds);
658 658
//5 Start of the ramp 659 659 //5 Start of the ramp
660 660
writeRegister(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante 661 661 writeRegister(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante
//writeRegister(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue 662 662 //writeRegister(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue
sendIOUpdate(f_dds); 663 663 sendIOUpdate(f_dds);
664 664
return EXIT_SUCCESS; 665 665 return EXIT_SUCCESS;
} 666 666 }
667 667
int continueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown) 668 668 int continueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown)
{ 669 669 {
670 670
671 671
//calcul de N => N=DeltaF/df = DeltaT/dt 672 672 //calcul de N => N=DeltaF/df = DeltaT/dt
673 673
//1-Amax > Amin 674 674 //1-Amax > Amin
double DeltaAmp = AMax-AMin; 675 675 double DeltaAmp = AMax-AMin;
if(AMax<AMin) 676 676 if(AMax<AMin)
{ 677 677 {
printf("AMax should be > AMin\n"); 678 678 printf("AMax should be > AMin\n");
printf("Can't Start the ramp\n"); 679 679 printf("Can't Start the ramp\n");
return -1; 680 680 return -1;
} 681 681 }
682 682
683 683
//2- Calcul du nombre de points de la rampe 684 684 //2- Calcul du nombre de points de la rampe
int NumberPointsUp = DeltaAmp/dAUp; 685 685 int NumberPointsUp = DeltaAmp/dAUp;
int NumberPointsDown = DeltaAmp/dADown; 686 686 int NumberPointsDown = DeltaAmp/dADown;
687 687
//3- En déduire la valeur de dtUp et dtDown 688 688 //3- En déduire la valeur de dtUp et dtDown
double dtUp = DeltaTimeUp/NumberPointsUp; 689 689 double dtUp = DeltaTimeUp/NumberPointsUp;
double dtDown = DeltaTimeDown/NumberPointsDown; 690 690 double dtDown = DeltaTimeDown/NumberPointsDown;
691 691
double dtmin = 24/fclk; 692 692 double dtmin = 24/fclk;
double dtmax = dtmin*(pow(2.0,16.0)-1); 693 693 double dtmax = dtmin*(pow(2.0,16.0)-1);
694 694
//Check Up 695 695 //Check Up
if(dtUp<dtmin) 696 696 if(dtUp<dtmin)
{ 697 697 {
printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp); 698 698 printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp);
printf("Can't start the ramp\n"); 699 699 printf("Can't start the ramp\n");
return -1; 700 700 return -1;
} 701 701 }
702 702
if(dtUp>dtmax) 703 703 if(dtUp>dtmax)
{ 704 704 {
printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp); 705 705 printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp);
printf("Can't start the ramp\n"); 706 706 printf("Can't start the ramp\n");
return -1; 707 707 return -1;
} 708 708 }
709 709
//Check Down 710 710 //Check Down
if(dtDown<dtmin) 711 711 if(dtDown<dtmin)
{ 712 712 {
printf("During of ramp DOWN should be > %f s\n",dtmin*NumberPointsDown); 713 713 printf("During of ramp DOWN should be > %f s\n",dtmin*NumberPointsDown);
printf("Can't start the ramp\n"); 714 714 printf("Can't start the ramp\n");
return -1; 715 715 return -1;
} 716 716 }
717 717
if(dtDown>dtmax) 718 718 if(dtDown>dtmax)
{ 719 719 {
printf("During of ramp DOWN should be < %f\n",dtmax*NumberPointsDown); 720 720 printf("During of ramp DOWN should be < %f\n",dtmax*NumberPointsDown);
printf("Can't start the ramp\n"); 721 721 printf("Can't start the ramp\n");
return -1; 722 722 return -1;
} 723 723 }
724 724
725 725
726 726
//check if DeltaAmp is enouth 727 727 //check if DeltaAmp is enouth
double enouthUP=0.5*NumberPointsUp*100/4095; 728 728 double enouthUP=0.5*NumberPointsUp*100/4095;
double enouthDOWN=0.5*NumberPointsDown*100/4095; 729 729 double enouthDOWN=0.5*NumberPointsDown*100/4095;
730 730
int borneUP = rint(enouthUP); 731 731 int borneUP = rint(enouthUP);
int borneDown = rint(enouthDOWN); 732 732 int borneDown = rint(enouthDOWN);
733 733
if(DeltaAmp<=enouthUP) 734 734 if(DeltaAmp<=enouthUP)
{ 735 735 {
printf("The amplitude difference should be > %d\n, decrease Number Points for positive slope",borneUP); 736 736 printf("The amplitude difference should be > %d\n, decrease Number Points for positive slope",borneUP);
//return -1; 737 737 //return -1;
} 738 738 }
739 739
if(DeltaAmp<=enouthDOWN) 740 740 if(DeltaAmp<=enouthDOWN)
{ 741 741 {
printf("The amplitude difference should be > %d\n, decrease Number Points for negative slope",borneDown); 742 742 printf("The amplitude difference should be > %d\n, decrease Number Points for negative slope",borneDown);
//return -1; 743 743 //return -1;
} 744 744 }
745 745
746 746
//4 - Put word in register 747 747 //4 - Put word in register
748 748
749 749
//4.1 Limit register 750 750 //4.1 Limit register
uint32_t WordAmin = rint(AMin*4095/100); 751 751 uint32_t WordAmin = rint(AMin*4095/100);
uint32_t WordAmax= rint(AMax*4095/100); 752 752 uint32_t WordAmax= rint(AMax*4095/100);
753 753
writeRegister(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 754 754 writeRegister(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2
sendIOUpdate(f_dds); 755 755 sendIOUpdate(f_dds);
writeRegister(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 756 756 writeRegister(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0
sendIOUpdate(f_dds); 757 757 sendIOUpdate(f_dds);
758 758
759 759
//4.2 dAUP et dADown 760 760 //4.2 dAUP et dADown
761 761
uint32_t Word_dA_up = rint(dAUp*4095/100); 762 762 uint32_t Word_dA_up = rint(dAUp*4095/100);
uint32_t Word_dA_down = rint(dADown*4095/100); 763 763 uint32_t Word_dA_down = rint(dADown*4095/100);
764 764
writeRegister(fd,0x06,Word_dA_up>>24&0xFF,Word_dA_up>>16&0xFF,Word_dA_up>>8&0xFF,Word_dA_up&0xFF); //dA_up 765 765 writeRegister(fd,0x06,Word_dA_up>>24&0xFF,Word_dA_up>>16&0xFF,Word_dA_up>>8&0xFF,Word_dA_up&0xFF); //dA_up
sendIOUpdate(f_dds); 766 766 sendIOUpdate(f_dds);
writeRegister(fd,0x07,Word_dA_down>>24&0xFF,Word_dA_down>>16&0xFF,Word_dA_down>>8&0xFF,Word_dA_down&0xFF);//dA_down 767 767 writeRegister(fd,0x07,Word_dA_down>>24&0xFF,Word_dA_down>>16&0xFF,Word_dA_down>>8&0xFF,Word_dA_down&0xFF);//dA_down
sendIOUpdate(f_dds); 768 768 sendIOUpdate(f_dds);
769 769
770 770
//4.3 dtUp et dtDown 771 771 //4.3 dtUp et dtDown
772 772
uint16_t Word_dt_up = rint(dtUp*fclk/24); 773 773 uint16_t Word_dt_up = rint(dtUp*fclk/24);
uint16_t Word_dt_down = rint(dtDown*fclk/24); 774 774 uint16_t Word_dt_down = rint(dtDown*fclk/24);
775 775
writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt 776 776 writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt
sendIOUpdate(f_dds); 777 777 sendIOUpdate(f_dds);
778 778
//5 Start of the ramp 779 779 //5 Start of the ramp
780 780
//writeRegister(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante 781 781 //writeRegister(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante
writeRegister(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue 782 782 writeRegister(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue
sendIOUpdate(f_dds); 783 783 sendIOUpdate(f_dds);
784 784
return EXIT_SUCCESS; 785 785 return EXIT_SUCCESS;
} 786 786 }
787 787
788 788
//3-rampe de ĥase 789 789 //3-rampe de ĥase
790 790
int phaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown) 791 791 int phaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown)
{ 792 792 {
793 793
794 794
//calcul de N => N=Deltaphi/dphi = DeltaT/dt 795 795 //calcul de N => N=Deltaphi/dphi = DeltaT/dt
796 796
//1-phimax > phimin 797 797 //1-phimax > phimin
double DeltaPhi = PhiMax-PhiMin; 798 798 double DeltaPhi = PhiMax-PhiMin;
if(PhiMax<PhiMin) 799 799 if(PhiMax<PhiMin)
{ 800 800 {
printf("PhiMax should be > PhiMin\n"); 801 801 printf("PhiMax should be > PhiMin\n");
printf("Can't Start the ramp\n"); 802 802 printf("Can't Start the ramp\n");
return -1; 803 803 return -1;
} 804 804 }
805 805
806 806
//2- Calcul du nombre de points de la rampe 807 807 //2- Calcul du nombre de points de la rampe
int NumberPointsUp = DeltaPhi/dphiUp; 808 808 int NumberPointsUp = DeltaPhi/dphiUp;
int NumberPointsDown = DeltaPhi/dphiDown; 809 809 int NumberPointsDown = DeltaPhi/dphiDown;
810 810
printf("NumberPointsUp = %d\n",NumberPointsUp); 811 811 printf("NumberPointsUp = %d\n",NumberPointsUp);
printf("NumberPointsDown = %d\n",NumberPointsDown); 812 812 printf("NumberPointsDown = %d\n",NumberPointsDown);
813 813
//3- En déduire la valeur de dtUp et dtDown 814 814 //3- En déduire la valeur de dtUp et dtDown
double dtUp = DeltaTimeUp/NumberPointsUp; 815 815 double dtUp = DeltaTimeUp/NumberPointsUp;
double dtDown = DeltaTimeDown/NumberPointsDown; 816 816 double dtDown = DeltaTimeDown/NumberPointsDown;
817 817
double dtmin = 24/fclk; 818 818 double dtmin = 24/fclk;
double dtmax = dtmin*(pow(2.0,16.0)-1); 819 819 double dtmax = dtmin*(pow(2.0,16.0)-1);
820 820
//Check Up 821 821 //Check Up
if(dtUp<dtmin) 822 822 if(dtUp<dtmin)
{ 823 823 {
printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp); 824 824 printf("During of ramp UP should be > %f s\n",dtmin*NumberPointsUp);
printf("Can't start the ramp\n"); 825 825 printf("Can't start the ramp\n");
return -1; 826 826 return -1;
} 827 827 }
828 828
if(dtUp>dtmax) 829 829 if(dtUp>dtmax)
{ 830 830 {
printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp); 831 831 printf("During of ramp UP should be < %f\n",dtmax*NumberPointsUp);
printf("Can't start the ramp\n"); 832 832 printf("Can't start the ramp\n");
return -1; 833 833 return -1;