Blame view
src/ad9915.c
28.5 KB
dfa91a3bc libad9915 : add i... |
1 2 3 4 5 6 7 8 9 |
/* SPI : initialisation du dds et communication SPI */ #include"ad9915.h" #include "spi.h" #include "ddsFreq.h" #define debug //fonction reset |
41fb442f6 ad9915.c et ad991... |
10 |
void sendReset(int f_dds) |
dfa91a3bc libad9915 : add i... |
11 |
{ |
e41d5220b ad9915.c : nettoy... |
12 |
write(f_dds,"2",1); |
dfa91a3bc libad9915 : add i... |
13 14 15 |
} //fonction ioupdate |
41fb442f6 ad9915.c et ad991... |
16 |
void sendIOUpdate(int f_dds) |
dfa91a3bc libad9915 : add i... |
17 |
{ |
e41d5220b ad9915.c : nettoy... |
18 |
write(f_dds,"1",1); |
dfa91a3bc libad9915 : add i... |
19 20 21 |
} //fonction write register |
41fb442f6 ad9915.c et ad991... |
22 |
void writeRegister (int fd, unsigned char addr, unsigned char d3, unsigned char d2, unsigned char d1, unsigned char d0) |
dfa91a3bc libad9915 : add i... |
23 24 25 26 27 28 29 30 31 32 33 34 |
{ unsigned char tx[5]={0}; tx[0]=addr; tx[1]=d3; tx[2]=d2; tx[3]=d1; tx[4]=d0; //spi_put_multiple envoie le vecteur dans cet ordre //[tx0]-[tx1]-[tx2] -> adresse->bit poids Fort->bit poids faible spi_put_multiple(fd,tx,5,NULL,0); } |
09ecc607d mise a jour avec ... |
35 36 |
//fonction read register |
41fb442f6 ad9915.c et ad991... |
37 |
void readRegister (int fd,unsigned char addr, uint32_t *readword) |
09ecc607d mise a jour avec ... |
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
{ unsigned char tx[1] = {0}; unsigned char rx[4] = {0}; addr = addr|0x80;//instruction byte for the read : 1000 0000 | byte_adress tx[0]=addr; spi_put_multiple(fd,tx,1,rx,4); //printf("TX:%x RX:%x %x %x %x ",tx[0],rx[0],rx[1],rx[2],rx[3]); *readword = 0x00000000; *readword = *readword|(rx[0]<<24); *readword = *readword|(rx[1]<<16); *readword = *readword|(rx[2]<<8); *readword = *readword|rx[3]; } //fonction read register |
41fb442f6 ad9915.c et ad991... |
54 |
void readRegisterIni (int fd, unsigned char addr) |
09ecc607d mise a jour avec ... |
55 56 57 58 59 60 61 62 |
{ unsigned char tx[1] = {0}; unsigned char rx[4] = {0}; addr = addr|0x80; tx[0]=addr; spi_put_multiple(fd,tx,1,rx,4); printf("TX:%x RX:%x %x %x %x ",tx[0],rx[0],rx[1],rx[2],rx[3]); |
41fb442f6 ad9915.c et ad991... |
63 |
// sendIOUpdate (f_dds); //Send the update to set the control registers |
09ecc607d mise a jour avec ... |
64 65 |
} |
dfa91a3bc libad9915 : add i... |
66 |
//initialisation du dds |
41fb442f6 ad9915.c et ad991... |
67 |
void initializeDDS (int fd, int f_dds) |
dfa91a3bc libad9915 : add i... |
68 |
{ |
41fb442f6 ad9915.c et ad991... |
69 70 71 72 73 74 75 76 77 78 79 |
sendReset(f_dds); writeRegister(fd,CFRAddress[0],CFR1Start[0], CFR1Start[1], CFR1Start[2], CFR1Start[3]); sendIOUpdate (f_dds); //Send the update to set the control registers writeRegister(fd,CFRAddress[1], CFR2Start[0], CFR2Start[1], CFR2Start[2], CFR2Start[3]); sendIOUpdate (f_dds); writeRegister(fd,CFRAddress[2], CFR3Start[0], CFR3Start[1], CFR3Start[2], CFR3Start[3]); sendIOUpdate (f_dds); writeRegister(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]); sendIOUpdate (f_dds); writeRegister(fd,USR0Address, 0xA2, 0x00, 0x08, 0x00); sendIOUpdate (f_dds); |
dfa91a3bc libad9915 : add i... |
80 81 82 |
} //calibration du dac |
41fb442f6 ad9915.c et ad991... |
83 |
void calibrateDAC (int fd, int f_dds) |
dfa91a3bc libad9915 : add i... |
84 |
{ |
41fb442f6 ad9915.c et ad991... |
85 86 87 88 |
writeRegister(fd,CFRAddress[3], DACCalEnable[0], DACCalEnable[1], DACCalEnable[2], DACCalEnable[3]); sendIOUpdate (f_dds); writeRegister(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]); sendIOUpdate (f_dds); |
dfa91a3bc libad9915 : add i... |
89 90 |
} |
41fb442f6 ad9915.c et ad991... |
91 |
void modulusSetup(int fd, int f_dds) |
dfa91a3bc libad9915 : add i... |
92 |
{ |
41fb442f6 ad9915.c et ad991... |
93 |
writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x0a); //OSK enable //0x08 |
41fb442f6 ad9915.c et ad991... |
94 95 96 |
sendIOUpdate (f_dds); writeRegister(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp sendIOUpdate (f_dds); |
dfa91a3bc libad9915 : add i... |
97 98 |
} |
41fb442f6 ad9915.c et ad991... |
99 |
void basicSetup(int fd, int f_dds,uint16_t ampWord, uint16_t phaseWord) |
dfa91a3bc libad9915 : add i... |
100 |
{ |
41fb442f6 ad9915.c et ad991... |
101 102 103 104 |
writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x08); //OSK enable sendIOUpdate (f_dds); writeRegister(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp sendIOUpdate (f_dds); |
e41d5220b ad9915.c : nettoy... |
105 |
writeRegister(fd,0x04,0x19, 0x99, 0x99, 0x99); //ftw |
41fb442f6 ad9915.c et ad991... |
106 |
sendIOUpdate (f_dds); |
e41d5220b ad9915.c : nettoy... |
107 |
writeRegister(fd,0x05,0xC0, 0x00, 0x00, 0x00); //A |
41fb442f6 ad9915.c et ad991... |
108 |
sendIOUpdate (f_dds); |
e41d5220b ad9915.c : nettoy... |
109 |
writeRegister(fd,0x06,0x00, 0x00, 0x00, 0x05); //B |
41fb442f6 ad9915.c et ad991... |
110 |
sendIOUpdate (f_dds); |
e41d5220b ad9915.c : nettoy... |
111 |
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) |
41fb442f6 ad9915.c et ad991... |
112 |
sendIOUpdate (f_dds); |
dfa91a3bc libad9915 : add i... |
113 114 115 116 |
} void setFreqMM(int fd, int f_dds, unsigned int ftw, unsigned int A, unsigned int B) { |
41fb442f6 ad9915.c et ad991... |
117 118 119 120 121 122 |
writeRegister(fd,0x04,ftw>>24&0xFF, ftw>>16&0xFF, ftw>>8&0xFF, ftw&0xFF); //ftw sendIOUpdate(f_dds); writeRegister(fd,0x05,A>>24&0xFF,A>>16&0xFF, A>>8&0xFF, A&0xFF); //A sendIOUpdate(f_dds); writeRegister(fd,0x06,B>>24&0xFF,B>>16&0xFF, B>>8&0xFF, B&0xFF); //B sendIOUpdate(f_dds); |
dfa91a3bc libad9915 : add i... |
123 124 125 126 |
} void setAmpPhaseWord(int fd, int f_dds,unsigned int phaseAmpWord) { |
41fb442f6 ad9915.c et ad991... |
127 128 |
writeRegister(fd,0x0c, phaseAmpWord>>24&0xFF, phaseAmpWord>>16&0xFF,phaseAmpWord>>8&0xFF,phaseAmpWord&0xFF); // amp (12b) ph(16) sendIOUpdate(f_dds); |
dfa91a3bc libad9915 : add i... |
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
} int openAndSetDdsFreq( char * device, char * gpio_update, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord) { #ifdef debug printf("device=%s\tgpio_update=%s\tf_clk=%e\tf_out=%e\tampWord=%d\tphaseWord=%d ",device,gpio_update,f_clk,f_out,ampWord,phaseWord); #else printf("device=%s\tgpio_update=%s\tf_clk=%e\tf_out=%e\tampWord=%d\tphaseWord=%d ",device,gpio_update,f_clk,f_out,ampWord,phaseWord); int fd=configureSpi(device); //ex #define FILENAME2 "/dev/spidev0.0" printf("fd(funct)=%d ",fd); setMode(fd,SPI_MODE_0); if (fd <= 0){ printf("ERREUR : ouverture périphérique SPI %s ",device); return EXIT_FAILURE; } int f_dds=open(gpio_update,O_RDWR); //ex #define UPDATE2 "/sys/dds/gpio24/updateOn" printf("f_dds(funct)=%d ",f_dds); if (f_dds <= 0){ printf("ERREUR : ouverture ");printf(gpio_update);printf(" "); printf("Chargez le module ddsIOupdateX "); return EXIT_FAILURE; } setddsFreq(fd,f_dds,f_out,f_clk); //debug phaseWord = 0x0000; ampWord=0x0FFF; uint32_t phaseAmpWord = phaseWord | ampWord<<16; setAmpPhaseWord(fd, f_dds, phaseAmpWord); #endif return EXIT_SUCCESS; } int setDdsFreqFull ( int fd, int f_dds, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord) { setddsFreq(fd,f_dds,f_out,f_clk); #ifdef debug phaseWord = 0x0000; ampWord=0x0FFF; #endif uint32_t phaseAmpWord = phaseWord | ampWord<<16; setAmpPhaseWord(fd, f_dds, phaseAmpWord); return EXIT_SUCCESS; } |
41fb442f6 ad9915.c et ad991... |
184 |
void sendCtrlUp(int fp) |
09ecc607d mise a jour avec ... |
185 |
{ |
e41d5220b ad9915.c : nettoy... |
186 187 |
//pente positive write(fp,"0",1); |
09ecc607d mise a jour avec ... |
188 189 |
} |
41fb442f6 ad9915.c et ad991... |
190 |
void sendCtrlDown(int fp) |
09ecc607d mise a jour avec ... |
191 |
{ |
e41d5220b ad9915.c : nettoy... |
192 193 |
//pente negative write(fp,"2",1); |
09ecc607d mise a jour avec ... |
194 195 |
} |
41fb442f6 ad9915.c et ad991... |
196 |
void sendHold(int fp) |
09ecc607d mise a jour avec ... |
197 |
{ |
e41d5220b ad9915.c : nettoy... |
198 199 |
//rampe bloquee write(fp,"1",1); |
09ecc607d mise a jour avec ... |
200 201 |
} |
41fb442f6 ad9915.c et ad991... |
202 |
void sendUnhold(int fp) |
09ecc607d mise a jour avec ... |
203 |
{ |
e41d5220b ad9915.c : nettoy... |
204 205 |
//rampe debloquee write(fp,"3",1); //reset |
09ecc607d mise a jour avec ... |
206 207 208 209 210 211 212 213 |
} int testRampFreq(int fd, int f_dds, int fp) { //3-Rampe de pente positive + debloquage |
41fb442f6 ad9915.c et ad991... |
214 215 |
sendCtrlDown(fp);//rampe up sendUnhold(fp); |
09ecc607d mise a jour avec ... |
216 |
|
41fb442f6 ad9915.c et ad991... |
217 |
sendReset(f_dds); |
09ecc607d mise a jour avec ... |
218 219 220 |
//Initialize_DDS (fd, f_dds); //0- paramètre de bases |
41fb442f6 ad9915.c et ad991... |
221 222 223 |
writeRegister(fd,0x00,0x00,0x01,0x01,0x0a);//OSKenable+Read&write sendIOUpdate(f_dds); readRegisterIni(fd,0x00); |
09ecc607d mise a jour avec ... |
224 |
|
41fb442f6 ad9915.c et ad991... |
225 226 227 |
writeRegister(fd,0x01,0x00, 0x00, 0x09, 0x00); // enable amp ramp sendIOUpdate(f_dds); readRegisterIni(fd,0x00); |
09ecc607d mise a jour avec ... |
228 |
|
09ecc607d mise a jour avec ... |
229 |
|
41fb442f6 ad9915.c et ad991... |
230 231 232 233 |
writeRegister(fd,0x0b,0x02,0xd0,0xe5,0x60);//mot de frequence sendIOUpdate(f_dds); writeRegister(fd,0x0c,0x0F,0xFF,0x00,0x00); //mot de amp et de phase : amp max, phase nulle sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
234 235 236 237 238 |
printf("Les mots de frequences, d'amplitudes et de phases sont envoyes "); printf("Lecture registre de frequence: 0x0b "); |
41fb442f6 ad9915.c et ad991... |
239 |
readRegisterIni(fd,0x0b); |
09ecc607d mise a jour avec ... |
240 241 |
printf("Lecture registre de amp et phase: 0x0c "); |
41fb442f6 ad9915.c et ad991... |
242 |
readRegisterIni(fd,0x0c); |
09ecc607d mise a jour avec ... |
243 |
|
e41d5220b ad9915.c : nettoy... |
244 |
calibrateDAC (fd,f_dds); |
09ecc607d mise a jour avec ... |
245 246 247 248 249 250 251 |
printf(" ----------------------- "); |
09ecc607d mise a jour avec ... |
252 253 254 255 256 |
return EXIT_SUCCESS; } //---------------rajout 8/1 |
41fb442f6 ad9915.c et ad991... |
257 |
int putAmpWord(int fd, int f_dds, double amplitude) |
09ecc607d mise a jour avec ... |
258 259 260 261 262 263 264 |
{ uint16_t PhaseWord = 0x0000; uint16_t AmpWord = 0x0000; uint32_t ReadPhaseAmpWord=0x00000000; AmpWord = rint(amplitude*(pow(2.0,12.0)-1)/100); |
41fb442f6 ad9915.c et ad991... |
265 |
readRegister(fd,0x0c,&ReadPhaseAmpWord); |
09ecc607d mise a jour avec ... |
266 267 268 |
PhaseWord = ReadPhaseAmpWord&0xFFFF; |
41fb442f6 ad9915.c et ad991... |
269 270 |
writeRegister(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
271 272 273 274 275 |
return 0; } |
41fb442f6 ad9915.c et ad991... |
276 |
int putPhaseWord(int fd, int f_dds, double phase) |
09ecc607d mise a jour avec ... |
277 |
{ |
e41d5220b ad9915.c : nettoy... |
278 279 |
//uint16_t PhaseWord = 0x0000; //uint16_t AmpWord = 0x0000; |
09ecc607d mise a jour avec ... |
280 281 |
uint32_t ReadPhaseAmpWord=0x00000000; |
e41d5220b ad9915.c : nettoy... |
282 |
uint16_t PhaseWord = rint(phase*(pow(2.0,16.0)-1)/360); |
09ecc607d mise a jour avec ... |
283 |
|
41fb442f6 ad9915.c et ad991... |
284 |
readRegister(fd,0x0c,&ReadPhaseAmpWord); |
09ecc607d mise a jour avec ... |
285 |
|
e41d5220b ad9915.c : nettoy... |
286 |
uint16_t AmpWord = ReadPhaseAmpWord>>16&0xFFFF; |
09ecc607d mise a jour avec ... |
287 |
|
41fb442f6 ad9915.c et ad991... |
288 289 |
writeRegister(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
290 291 292 293 |
return 0; } |
41fb442f6 ad9915.c et ad991... |
294 |
int putFrequencyWord(int fd, int f_dds, double fclk,double fout)//Attention uniquement valable pour fclk = 1 GHz |
09ecc607d mise a jour avec ... |
295 296 |
{ |
e41d5220b ad9915.c : nettoy... |
297 298 |
//uint32_t FTWR = 0x00000000; uint32_t FTWR = rint((fout/fclk)*pow(2.0,32.0)); |
41fb442f6 ad9915.c et ad991... |
299 300 |
writeRegister(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
301 302 303 304 305 |
return 0; } |
41fb442f6 ad9915.c et ad991... |
306 |
int putFrequencyAmpPhaseWord(int fd, int f_dds, double fout, double fclk,double amp, double phase)//n'existe pas dans le mode profile enable |
09ecc607d mise a jour avec ... |
307 308 |
{ |
e41d5220b ad9915.c : nettoy... |
309 |
//uint32_t FTWR = 0x00000000; |
09ecc607d mise a jour avec ... |
310 |
|
e41d5220b ad9915.c : nettoy... |
311 |
uint32_t FTWR = rint((fout/fclk)*pow(2.0,32.0)); |
09ecc607d mise a jour avec ... |
312 |
|
41fb442f6 ad9915.c et ad991... |
313 |
writeRegister(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence |
09ecc607d mise a jour avec ... |
314 |
|
41fb442f6 ad9915.c et ad991... |
315 |
sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
316 |
|
41fb442f6 ad9915.c et ad991... |
317 318 |
putPhaseWord(fd,f_dds,phase); putAmpWord(fd,f_dds,amp); |
09ecc607d mise a jour avec ... |
319 320 321 322 323 |
return 0; } |
41fb442f6 ad9915.c et ad991... |
324 |
int initialisationProfileMode (int fd,int f_dds) |
09ecc607d mise a jour avec ... |
325 326 |
{ |
41fb442f6 ad9915.c et ad991... |
327 328 329 330 331 332 333 334 335 336 337 |
sendReset(f_dds); //les registres sont maintenant par defaut writeRegister(fd,0x00,0x00,0x01,0x01,0x0a); //OSK+SDIO input only//ok sendIOUpdate(f_dds); writeRegister(fd,0x01,0x00,0x80,0x09,0x00); // profile mode enable very important sendIOUpdate(f_dds); writeRegister(fd,0x02,0x00,0x00,0x19,0x1c); // default sendIOUpdate(f_dds); writeRegister(fd,0x03,0x01,0x05,0x21,0x20); // calibration 1/2 :enable sendIOUpdate(f_dds); writeRegister(fd,0x03,0x00,0x05,0x21,0x20); // calibration 2/2 :desenable sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
return 0; } //------------------- FIN RAJOUT 8/1 //-------------------------FONCTIONS RAMPES HARDWARE //1-rampe de frequence //rampe simple de fréquence |
41fb442f6 ad9915.c et ad991... |
352 |
int frequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown) |
09ecc607d mise a jour avec ... |
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
{ //calcul de N => N=DeltaF/df = DeltaT/dt //1-fmax > fmin double DeltaFreq = FreqMax-FreqMin; if(FreqMax<FreqMin) { printf("FreqMax should be > FreqMin "); printf("Can't Start the ramp "); return -1; } //2- Calcul du nombre de points de la rampe int NumberPointsUp = DeltaFreq/dfUp; int NumberPointsDown = DeltaFreq/dfDown; //3- En déduire la valeur de dtUp et dtDown double dtUp = DeltaTimeUp/NumberPointsUp; double dtDown = DeltaTimeDown/NumberPointsDown; double dtmin = 24/fclk; double dtmax = dtmin*(pow(2.0,16.0)-1); //Check Up if(dtUp<dtmin) { printf("During of ramp UP should be > %f s ",dtmin*NumberPointsUp); printf("Can't start the ramp "); return -1; } if(dtUp>dtmax) { printf("During of ramp UP should be < %f ",dtmax*NumberPointsUp); printf("Can't start the ramp "); return -1; } //Check Down if(dtDown<dtmin) { printf("During of ramp DOWN should be > %f s ",dtmin*NumberPointsDown); printf("Can't start the ramp "); return -1; } if(dtDown>dtmax) { printf("During of ramp DOWN should be < %f ",dtmax*NumberPointsDown); printf("Can't start the ramp "); return -1; } //4 - Put word in register //4.1 Limit register uint32_t FTWRmin = rint((FreqMin/fclk)*pow(2.0,32.0)); |
41fb442f6 ad9915.c et ad991... |
422 423 |
writeRegister(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
424 425 |
uint32_t FTWRmax = rint((FreqMax/fclk)*pow(2.0,32.0)); |
41fb442f6 ad9915.c et ad991... |
426 427 |
writeRegister(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
428 429 430 431 432 433 434 435 436 |
//4.2 dfUP et dfDown double df_up = DeltaFreq/NumberPointsUp; double df_down = DeltaFreq/NumberPointsDown; 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); |
41fb442f6 ad9915.c et ad991... |
437 438 439 440 |
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); 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); |
09ecc607d mise a jour avec ... |
441 442 443 444 445 446 447 448 449 450 |
//4.3 dtUp et dtDown uint16_t Word_dt_up = 0x0000; uint16_t Word_dt_down = 0x0000; Word_dt_up = rint(dtUp*fclk/24); Word_dt_down = rint(dtDown*fclk/24); |
41fb442f6 ad9915.c et ad991... |
451 452 |
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); |
09ecc607d mise a jour avec ... |
453 454 455 |
//5 Start of the ramp |
41fb442f6 ad9915.c et ad991... |
456 457 |
writeRegister(fd,0x01,0x00,0x08,0x09,0x00); //rampe simple sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
458 459 460 461 462 463 464 465 466 467 |
return 0; return EXIT_SUCCESS; } //rampe continue de fréquence |
41fb442f6 ad9915.c et ad991... |
468 |
int continueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown) |
09ecc607d mise a jour avec ... |
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
{ //calcul de N => N=DeltaF/df = DeltaT/dt //1-fmax > fmin double DeltaFreq = FreqMax-FreqMin; if(FreqMax<FreqMin) { printf("FreqMax should be > FreqMin "); printf("Can't Start the ramp "); return -1; } //2- Calcul du nombre de points de la rampe int NumberPointsUp = DeltaFreq/dfUp; int NumberPointsDown = DeltaFreq/dfDown; //3- En déduire la valeur de dtUp et dtDown double dtUp = DeltaTimeUp/NumberPointsUp; double dtDown = DeltaTimeDown/NumberPointsDown; double dtmin = 24/fclk; double dtmax = dtmin*(pow(2.0,16.0)-1); //Check Up if(dtUp<dtmin) { printf("During of ramp UP should be > %f s ",dtmin*NumberPointsUp); printf("Can't start the ramp "); return -1; } if(dtUp>dtmax) { printf("During of ramp UP should be < %f ",dtmax*NumberPointsUp); printf("Can't start the ramp "); return -1; } //Check Down if(dtDown<dtmin) { printf("During of ramp DOWN should be > %f s ",dtmin*NumberPointsDown); printf("Can't start the ramp "); return -1; } if(dtDown>dtmax) { printf("During of ramp DOWN should be < %f ",dtmax*NumberPointsDown); printf("Can't start the ramp "); return -1; } //4 - Put word in register //4.1 Limit register uint32_t FTWRmin = rint((FreqMin/fclk)*pow(2.0,32.0)); |
41fb442f6 ad9915.c et ad991... |
538 539 |
writeRegister(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
540 541 |
uint32_t FTWRmax = rint((FreqMax/fclk)*pow(2.0,32.0)); |
41fb442f6 ad9915.c et ad991... |
542 543 |
writeRegister(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
544 545 546 547 548 549 550 551 552 |
//4.2 dfUP et dfDown double df_up = DeltaFreq/NumberPointsUp; double df_down = DeltaFreq/NumberPointsDown; 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); |
41fb442f6 ad9915.c et ad991... |
553 554 555 556 |
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); 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); |
09ecc607d mise a jour avec ... |
557 558 559 560 561 562 563 564 565 566 |
//4.3 dtUp et dtDown uint16_t Word_dt_up = 0x0000; uint16_t Word_dt_down = 0x0000; Word_dt_up = rint(dtUp*fclk/24); Word_dt_down = rint(dtDown*fclk/24); |
41fb442f6 ad9915.c et ad991... |
567 568 |
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); |
09ecc607d mise a jour avec ... |
569 570 571 |
//5 Start of the ramp |
41fb442f6 ad9915.c et ad991... |
572 573 |
writeRegister(fd,0x01,0x00,0x8e,0x29,0x00); //rampe triangulaire sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
574 575 576 577 578 579 580 581 582 583 |
return 0; return EXIT_SUCCESS; } //2-rampe d'amplitude |
41fb442f6 ad9915.c et ad991... |
584 |
int amplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown) |
09ecc607d mise a jour avec ... |
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
{ //calcul de N => N=DeltaF/df = DeltaT/dt //1-Amax > Amin double DeltaAmp = AMax-AMin; if(AMax<AMin) { printf("AMax should be > AMin "); printf("Can't Start the ramp "); return -1; } //2- Calcul du nombre de points de la rampe int NumberPointsUp = DeltaAmp/dAUp; int NumberPointsDown = DeltaAmp/dADown; //3- En déduire la valeur de dtUp et dtDown double dtUp = DeltaTimeUp/NumberPointsUp; double dtDown = DeltaTimeDown/NumberPointsDown; double dtmin = 24/fclk; double dtmax = dtmin*(pow(2.0,16.0)-1); //Check Up if(dtUp<dtmin) { printf("During of ramp UP should be > %f s ",dtmin*NumberPointsUp); printf("Can't start the ramp "); return -1; } if(dtUp>dtmax) { printf("During of ramp UP should be < %f ",dtmax*NumberPointsUp); printf("Can't start the ramp "); return -1; } //Check Down if(dtDown<dtmin) { printf("During of ramp DOWN should be > %f s ",dtmin*NumberPointsDown); printf("Can't start the ramp "); return -1; } if(dtDown>dtmax) { printf("During of ramp DOWN should be < %f ",dtmax*NumberPointsDown); printf("Can't start the ramp "); return -1; } //check if DeltaAmp is enouth double enouthUP=0.5*NumberPointsUp*100/4095; double enouthDOWN=0.5*NumberPointsDown*100/4095; int borneUP = rint(enouthUP); int borneDown = rint(enouthDOWN); if(DeltaAmp<=enouthUP) { printf("The amplitude difference should be > %d , decrease Number Points for positive slope",borneUP); |
09ecc607d mise a jour avec ... |
664 665 666 667 668 669 |
} if(DeltaAmp<=enouthDOWN) { printf("The amplitude difference should be > %d , decrease Number Points for negative slope",borneDown); |
09ecc607d mise a jour avec ... |
670 671 672 673 674 675 676 677 678 679 |
} //4 - Put word in register //4.1 Limit register uint32_t WordAmin = rint(AMin*4095/100); uint32_t WordAmax= rint(AMax*4095/100); |
41fb442f6 ad9915.c et ad991... |
680 681 682 683 |
writeRegister(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 sendIOUpdate(f_dds); writeRegister(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
684 685 686 687 688 689 690 |
//4.2 dAUP et dADown uint32_t Word_dA_up = rint(dAUp*4095/100); uint32_t Word_dA_down = rint(dADown*4095/100); |
41fb442f6 ad9915.c et ad991... |
691 692 693 694 |
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); 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); |
09ecc607d mise a jour avec ... |
695 696 697 698 699 700 701 |
//4.3 dtUp et dtDown uint16_t Word_dt_up = rint(dtUp*fclk/24); uint16_t Word_dt_down = rint(dtDown*fclk/24); |
41fb442f6 ad9915.c et ad991... |
702 703 |
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); |
09ecc607d mise a jour avec ... |
704 705 706 |
//5 Start of the ramp |
41fb442f6 ad9915.c et ad991... |
707 708 709 |
writeRegister(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante //writeRegister(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
710 711 712 713 |
return EXIT_SUCCESS; } |
41fb442f6 ad9915.c et ad991... |
714 |
int continueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown) |
09ecc607d mise a jour avec ... |
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 |
{ //calcul de N => N=DeltaF/df = DeltaT/dt //1-Amax > Amin double DeltaAmp = AMax-AMin; if(AMax<AMin) { printf("AMax should be > AMin "); printf("Can't Start the ramp "); return -1; } //2- Calcul du nombre de points de la rampe int NumberPointsUp = DeltaAmp/dAUp; int NumberPointsDown = DeltaAmp/dADown; //3- En déduire la valeur de dtUp et dtDown double dtUp = DeltaTimeUp/NumberPointsUp; double dtDown = DeltaTimeDown/NumberPointsDown; double dtmin = 24/fclk; double dtmax = dtmin*(pow(2.0,16.0)-1); //Check Up if(dtUp<dtmin) { printf("During of ramp UP should be > %f s ",dtmin*NumberPointsUp); printf("Can't start the ramp "); return -1; } if(dtUp>dtmax) { printf("During of ramp UP should be < %f ",dtmax*NumberPointsUp); printf("Can't start the ramp "); return -1; } //Check Down if(dtDown<dtmin) { printf("During of ramp DOWN should be > %f s ",dtmin*NumberPointsDown); printf("Can't start the ramp "); return -1; } if(dtDown>dtmax) { printf("During of ramp DOWN should be < %f ",dtmax*NumberPointsDown); printf("Can't start the ramp "); return -1; } //check if DeltaAmp is enouth double enouthUP=0.5*NumberPointsUp*100/4095; double enouthDOWN=0.5*NumberPointsDown*100/4095; int borneUP = rint(enouthUP); int borneDown = rint(enouthDOWN); if(DeltaAmp<=enouthUP) { printf("The amplitude difference should be > %d , decrease Number Points for positive slope",borneUP); //return -1; } if(DeltaAmp<=enouthDOWN) { printf("The amplitude difference should be > %d , decrease Number Points for negative slope",borneDown); //return -1; } //4 - Put word in register //4.1 Limit register uint32_t WordAmin = rint(AMin*4095/100); uint32_t WordAmax= rint(AMax*4095/100); |
41fb442f6 ad9915.c et ad991... |
812 813 814 815 |
writeRegister(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 sendIOUpdate(f_dds); writeRegister(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
816 817 818 819 820 821 822 |
//4.2 dAUP et dADown uint32_t Word_dA_up = rint(dAUp*4095/100); uint32_t Word_dA_down = rint(dADown*4095/100); |
41fb442f6 ad9915.c et ad991... |
823 824 825 826 |
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); 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); |
09ecc607d mise a jour avec ... |
827 828 829 830 831 832 833 |
//4.3 dtUp et dtDown uint16_t Word_dt_up = rint(dtUp*fclk/24); uint16_t Word_dt_down = rint(dtDown*fclk/24); |
41fb442f6 ad9915.c et ad991... |
834 835 |
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); |
09ecc607d mise a jour avec ... |
836 837 838 |
//5 Start of the ramp |
41fb442f6 ad9915.c et ad991... |
839 840 841 |
//writeRegister(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante writeRegister(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
842 843 844 845 846 847 848 |
return EXIT_SUCCESS; } //3-rampe de ĥase |
41fb442f6 ad9915.c et ad991... |
849 |
int phaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown) |
09ecc607d mise a jour avec ... |
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
{ //calcul de N => N=Deltaphi/dphi = DeltaT/dt //1-phimax > phimin double DeltaPhi = PhiMax-PhiMin; if(PhiMax<PhiMin) { printf("PhiMax should be > PhiMin "); printf("Can't Start the ramp "); return -1; } //2- Calcul du nombre de points de la rampe int NumberPointsUp = DeltaPhi/dphiUp; int NumberPointsDown = DeltaPhi/dphiDown; printf("NumberPointsUp = %d ",NumberPointsUp); printf("NumberPointsDown = %d ",NumberPointsDown); //3- En déduire la valeur de dtUp et dtDown double dtUp = DeltaTimeUp/NumberPointsUp; double dtDown = DeltaTimeDown/NumberPointsDown; double dtmin = 24/fclk; double dtmax = dtmin*(pow(2.0,16.0)-1); //Check Up if(dtUp<dtmin) { printf("During of ramp UP should be > %f s ",dtmin*NumberPointsUp); printf("Can't start the ramp "); return -1; } if(dtUp>dtmax) { printf("During of ramp UP should be < %f ",dtmax*NumberPointsUp); printf("Can't start the ramp "); return -1; } //Check Down if(dtDown<dtmin) { printf("During of ramp DOWN should be > %f s ",dtmin*NumberPointsDown); printf("Can't start the ramp "); return -1; } if(dtDown>dtmax) { printf("During of ramp DOWN should be < %f ",dtmax*NumberPointsDown); printf("Can't start the ramp "); return -1; } |
09ecc607d mise a jour avec ... |
922 923 924 925 926 927 928 929 930 931 932 |
//4.1 Limit register uint32_t WordPhimin = rint(PhiMin*65535/360); uint32_t WordPhimax= rint(PhiMax*65535/360); printf("WordPhimin = %.32x ",WordPhimin); printf("WordPhimax = %.32x ",WordPhimax); |
41fb442f6 ad9915.c et ad991... |
933 934 935 936 |
writeRegister(fd,0x04,WordPhimin>>24&0xFF,WordPhimin>>16&0xFF,WordPhimin>>8&0xFF,WordPhimin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 sendIOUpdate(f_dds); writeRegister(fd,0x05,WordPhimax>>24&0xFF,WordPhimax>>16&0xFF,WordPhimax>>8&0xFF,WordPhimax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
937 938 939 940 |
//4.2 dphiUP et dphiDown |
09ecc607d mise a jour avec ... |
941 942 943 944 945 946 947 948 |
uint32_t Word_dphi_up = rint(dphiUp*(65535/360)); uint32_t Word_dphi_down = rint(dphiDown*(65535/360)); printf("Word_dphi_up = %.32x ",Word_dphi_up); printf("Word_dphi_down = %.32x ",Word_dphi_down); |
09ecc607d mise a jour avec ... |
949 |
|
41fb442f6 ad9915.c et ad991... |
950 951 952 953 |
writeRegister(fd,0x06,Word_dphi_up>>24&0xFF,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up&0xFF); //dA_up sendIOUpdate(f_dds); writeRegister(fd,0x07,Word_dphi_down>>24&0xFF,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down&0xFF);//dA_down sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
954 955 956 957 958 959 960 |
//4.3 dtUp et dtDown uint16_t Word_dt_up = rint(dtUp*fclk/24); uint16_t Word_dt_down = rint(dtDown*fclk/24); |
41fb442f6 ad9915.c et ad991... |
961 962 |
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); |
09ecc607d mise a jour avec ... |
963 964 965 |
//5 Start of the ramp |
41fb442f6 ad9915.c et ad991... |
966 967 |
writeRegister(fd,0x01,0x00,0x18,0x09,0x00); //rampe simple montante sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
968 969 970 971 |
return EXIT_SUCCESS; } |
41fb442f6 ad9915.c et ad991... |
972 |
int continuePhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown) |
09ecc607d mise a jour avec ... |
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
{ //calcul de N => N=Deltaphi/dphi = DeltaT/dt //1-phimax > phimin double DeltaPhi = PhiMax-PhiMin; if(PhiMax<PhiMin) { printf("PhiMax should be > PhiMin "); printf("Can't Start the ramp "); return -1; } //2- Calcul du nombre de points de la rampe int NumberPointsUp = DeltaPhi/dphiUp; int NumberPointsDown = DeltaPhi/dphiDown; printf("NumberPointsUp = %d ",NumberPointsUp); printf("NumberPointsDown = %d ",NumberPointsDown); //3- En déduire la valeur de dtUp et dtDown double dtUp = DeltaTimeUp/NumberPointsUp; double dtDown = DeltaTimeDown/NumberPointsDown; double dtmin = 24/fclk; double dtmax = dtmin*(pow(2.0,16.0)-1); //Check Up if(dtUp<dtmin) { printf("During of ramp UP should be > %f s ",dtmin*NumberPointsUp); printf("Can't start the ramp "); return -1; } if(dtUp>dtmax) { printf("During of ramp UP should be < %f ",dtmax*NumberPointsUp); printf("Can't start the ramp "); return -1; } //Check Down if(dtDown<dtmin) { printf("During of ramp DOWN should be > %f s ",dtmin*NumberPointsDown); printf("Can't start the ramp "); return -1; } if(dtDown>dtmax) { printf("During of ramp DOWN should be < %f ",dtmax*NumberPointsDown); printf("Can't start the ramp "); return -1; } |
09ecc607d mise a jour avec ... |
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 |
//4 - Put word in register //4.1 Limit register uint32_t WordPhimin = rint(PhiMin*65535/360); uint32_t WordPhimax= rint(PhiMax*65535/360); printf("WordPhimin = %.32x ",WordPhimin); printf("WordPhimax = %.32x ",WordPhimax); |
41fb442f6 ad9915.c et ad991... |
1059 1060 1061 1062 |
writeRegister(fd,0x04,WordPhimin>>24&0xFF,WordPhimin>>16&0xFF,WordPhimin>>8&0xFF,WordPhimin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 sendIOUpdate(f_dds); writeRegister(fd,0x05,WordPhimax>>24&0xFF,WordPhimax>>16&0xFF,WordPhimax>>8&0xFF,WordPhimax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
1063 1064 1065 1066 |
//4.2 dphiUP et dphiDown |
09ecc607d mise a jour avec ... |
1067 1068 1069 1070 1071 1072 1073 1074 |
uint32_t Word_dphi_up = rint(dphiUp*(65535/360)); uint32_t Word_dphi_down = rint(dphiDown*(65535/360)); printf("Word_dphi_up = %.32x ",Word_dphi_up); printf("Word_dphi_down = %.32x ",Word_dphi_down); |
41fb442f6 ad9915.c et ad991... |
1075 1076 1077 1078 |
writeRegister(fd,0x06,Word_dphi_up>>24&0xFF,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up&0xFF); //dA_up sendIOUpdate(f_dds); writeRegister(fd,0x07,Word_dphi_down>>24&0xFF,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down&0xFF);//dA_down sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
1079 1080 1081 1082 1083 1084 1085 |
//4.3 dtUp et dtDown uint16_t Word_dt_up = rint(dtUp*fclk/24); uint16_t Word_dt_down = rint(dtDown*fclk/24); |
41fb442f6 ad9915.c et ad991... |
1086 1087 |
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); |
09ecc607d mise a jour avec ... |
1088 1089 1090 |
//5 Start of the ramp |
41fb442f6 ad9915.c et ad991... |
1091 1092 |
writeRegister(fd,0x01,0x00,0x9E,0x29,0x00); //rampe simple montante sendIOUpdate(f_dds); |
09ecc607d mise a jour avec ... |
1093 1094 1095 1096 1097 1098 1099 |
return EXIT_SUCCESS; } //-------------------------FIN FONCTIONS RAMPES HARDWARES |
09ecc607d mise a jour avec ... |
1100 1101 |
|
dfa91a3bc libad9915 : add i... |
1102 1103 1104 1105 1106 1107 |
int receiveParameterFromPythonServer(char * device, double f_clk, double f_out){ printf("receiveParameterFromPythonServer::device=%s\tf_clk=%e\tf_out=%e ",device,f_clk,f_out); return 0; } |