i am working on a project involving the CN-0349 and therefore the AD5934 with a Raspberry Pi Model 3. I already did some tests, which were working fine.
My main problem is to get the right frequency parameters to the AD5934. The data sheet states (page 4), that the maximum clock speed is somewhere around 16 MHz, with a frequency range from 1 kHz to 100 kHz. I tried to use the equations on page 13 and 21 to calculate the code to send to the AD5934. Using the exact same values (start frequency 30 kHz, 10 Hz increment, 150 steps) used on page 13, everything works fine. But i can't seem to go below 25 kHz. Only the start frequency code seems to break my python code. After sending wrong(?) code to the AD5934, the status register only shows no valid data/dft not complete. The only way to get valid data again is to reboot the CN-0349.
Now i already tried to check if something with the equation might be wrong. I checked the baudrate of the raspberry pi(400 kHz) and changed the MCLK in my formula, only to get errors on every try. The start frequency and other parameters do not seem to matter anymore. After changing MCLK back to 16 MHz in the equation (Raspi still 400 kHz), it works again in the range described above (30 kHz +- 5 kHz).
Since many sources state the raspberry pi baudrate is 400 kbps, not 400 kHz and i could not find any I2C bus baudrates of 16 MHz, mabye my understanding of these frequencies/speeds might be wrong? Is there a vaild way to get the baudrate in Hz? Did someone have similar problems with the frequency parameters?
This might not be part of my problem, but i do not understand where the 16 in the equation comes from. Is it derived from the 16 MHz? Do i need to change it with a different MCLK or is it a constant?
I would be very grateful for any help!
All formulas in the datasheet refer to MCLK frequency that it coming to the AD5934 chip from the clock generator U6. It has nothing to do with the I2C interface clock of 400KHz.
Not sure what could be breaking your python code – putting 400KHz instead of MCLK frequency shouldd result in erroneous frequency codes, but should not break the execution. If this could be of help, here is a reference to some Python code for the AD5933 you can look at, especially lines 159 and 160. There is a bit of a difference between formulas for the AD5933 and AD5934: for the AD5934 you need to replace “4” with “16”. I would also recommend using “round” piror to “int”, although the difference is quite miniscule:
min = int(round((min / (self.clk / 16)) * pow(2, 27)))
freq_inc = int(round((freq_inc / (self.clk / 16)) * pow(2, 27)))
Also the AD5934 does not have internal oscillator, so instead of “self.clk” it is necessary to use the frequency of your external U6 oscillator, which is 16000000Hz. Make sure your desired output frequency and MCLK frequency are in the same units, say, Hz.
thanks for the fast reply! I will check out the python code you sent me today, maybe i can figure out what's wrong with my own.
I checked the CN-0349 circuit note again for the U6 oscillator. According to figure 1, the oscillator is the FXO-HC536R-1, which has a frequency of ~1MHz accoding to data sheets. Is the oscillator on the CN-0349 board actually the FXO-HC536R-16, which has 16 MHz?
Yes, FXO-HC536R-1 is 1MHz. From your original message I assumed that U6 you had on your board was FXO-HC536R-16. So in those python statements “self.clk” should be 1MHz.
I have tried the new formula and checked it multiple times. I also checked the registers 0x82 to 0x89. All of them have to right values programmed to them. So i checked other threads with similar problems, but the only answer i could find was to deassert the reset bit at Reg_Address 0x81. I did that too, but had the same results.
Is there anything i am missing? I am following the steps from the AD5934 data sheet and compared my code to the code you sent me. It's pretty much the same thing, except lines 162 to 168, where the values are programmed to different registers from the data sheet. But it seems to me thats just a mistake.
I also used another CN0349. Still the same results. Im pretty stuck and dont know what to try anymore. Everything works fine until i programm a value to the Start frequency register.
So the register has data already in it after power up (obviously). I checked the values and calculated the value for the start frequency using 16 MHz and 1 MHz. I get 89355 for 16 MHz and 5585 for 1MHz.
values of the registers : 0x82 - 182 0x83 - 255 0x84 - 251
Can someone please verify these values? If i can not get the frequency parameters to work, i need to at least get the measurement frequency to fully describe my experiments.