Post Go back to editing

AD5941 Waveform Generator Configuration

Category: Software
Product Number: AD5941

Hello to everyone,

I am programming AD5941 and have successfully set up the high speed ADC together with low power DAC, now I want to activate the waveform generator.

The goal is to produce a sinus wave with adjustable frequency, phase, DC offset and amplitude.

After reading the datasheet I know that first I have to set up the wave parameters in WGFCW, WGPHASE, WGOFFSET and WGAMPLITUDE registers, then change the wave type to sinusoid in WGCON register, finally enable the generator in AFECON register.

Now I have 2 problems:

1. Is there any other configuration I missed?

2. Which switches I have to close, in order to route the wave output to the desired pin (for example, AIN1 and AIN0) ?

Sincerely,

Yongkun

  • Hi  ,

    We will look into this. I will contact the product owner and get back to you.

    Regards,

    JC

  • Hi,

    You may go through the example code here: ad5940-examples/Impedance.c at master · analogdevicesinc/ad5940-examples · GitHub

    where waveform generator, HSTIA, LPDAC and corresponding switches are configured.

    Code snippet:

    HsLoopCfg.HsTiaCfg.HstiaCtia = 31; /* 31pF + 2pF */
    HsLoopCfg.HsTiaCfg.HstiaDeRload = HSTIADERLOAD_OPEN;
    HsLoopCfg.HsTiaCfg.HstiaDeRtia = HSTIADERTIA_OPEN;
    HsLoopCfg.HsTiaCfg.HstiaRtiaSel = AppIMPCfg.HstiaRtiaSel;

    HsLoopCfg.SWMatCfg.Dswitch = AppIMPCfg.DswitchSel;
    HsLoopCfg.SWMatCfg.Pswitch = AppIMPCfg.PswitchSel;
    HsLoopCfg.SWMatCfg.Nswitch = AppIMPCfg.NswitchSel;
    HsLoopCfg.SWMatCfg.Tswitch = SWT_TRTIA|AppIMPCfg.TswitchSel;

    HsLoopCfg.WgCfg.WgType = WGTYPE_SIN;
    HsLoopCfg.WgCfg.GainCalEn = bTRUE;
    HsLoopCfg.WgCfg.OffsetCalEn = bTRUE;

    HsLoopCfg.WgCfg.SinCfg.SinFreqWord = AD5940_WGFreqWordCal(sin_freq, AppIMPCfg.SysClkFreq);
    HsLoopCfg.WgCfg.SinCfg.SinAmplitudeWord = (uint32_t)(AppIMPCfg.DacVoltPP/800.0f*2047 + 0.5f);
    HsLoopCfg.WgCfg.SinCfg.SinOffsetWord = 0;
    HsLoopCfg.WgCfg.SinCfg.SinPhaseWord = 0;
    AD5940_HSLoopCfgS(&HsLoopCfg);

  • Hi Akila,

    thank you for the answer!

    I notice that in the examples the wave generator is used together with internal TIA to execute an impedance measurement. Is it possible to use an external TIA? In my case the internal TIA can not fufill my need.

    Best regards,

    Yongkun

  • Yes.

    For example, if the waveform excitation must be given across AIN2 and AIN3, and if the +ve and -ve outputs from your external TIA can be connected to AIN0 and AIN1, 

    then voltage output from your external TIA can be measured by configuring as below:

    HsLoopCfg.SWMatCfg.Dswitch = SWD_AIN2;
    HsLoopCfg.SWMatCfg.Pswitch = SWP_AIN2;
    HsLoopCfg.SWMatCfg.Nswitch = SWN_AIN3 ;
    HsLoopCfg.SWMatCfg.Tswitch = SWT_AIN3;
    
    HsLoopCfg.WgCfg.WgType = WGTYPE_SIN;
    HsLoopCfg.WgCfg.GainCalEn = bTRUE;
    HsLoopCfg.WgCfg.OffsetCalEn = bTRUE;
    
    HsLoopCfg.WgCfg.SinCfg.SinFreqWord = 50000;
    HsLoopCfg.WgCfg.SinCfg.SinAmplitudeWord = 100.0;
    HsLoopCfg.WgCfg.SinCfg.SinOffsetWord = 0;
    HsLoopCfg.WgCfg.SinCfg.SinPhaseWord = 0;
    AD5940_HSLoopCfgS(&HsLoopCfg);
    
    
    
    AD5940_ADCMuxCfgS(ADCMUXP_AIN0, ADCMUXN_AIN1);
    
    AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_SINC2NOTCH, bTRUE);
    AD5940_Delay10us(16*25);
    AD5940_AFECtrlS(AFECTRL_ADCCNV, bTRUE); /* Start ADC convert*/
    AD5940_Delay10us(WaitClks);
    timeout = 0;
    while (!(AD5940_INTCTestFlag(AFEINTC_1, AFEINTSRC_SINC2RDY))) ;
    
    AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
    afeResult = AD5940_ReadAfeResult(AFERESULT_SINC2);
    AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_ADCCNV|AFECTRL_SINC2NOTCH, bFALSE); /* Stop ADC */
    measured_voltage = AD5940_ADCCode2Volt(afeResult&0xffff, ADCPGA_1, 1.82);

     

  • Hi Akila,

    thank you for the answer!

    However, I have been trying for this whole week and the AD5941 just wont output the AC signal I want.

    I then tried to write directly to the DAC, in order to test its functionality, and things went strange:

    no matter which value I wrote to HSDACDAT register, N node is fixed at 1.8V and N node is less than 0.1V. However, when I tried to measure the voltage between them, the result is again less than 0.1V.

    Could you please give me some tips? I put some of my settings here:

    In AFECON, all DAC references are enabled; DAC, excitation amplifier and buffer are enabled.

    Power and clock related registers are left default.

    P node at AIN1 (D2 and P2 switches are closed), N node at AIN2 (N3 and T3 switches are closed).

    HSDACCON is left default.

    Thank you in advance for the help!

    Sincerely,

    Yongkun

  • Could you monitor the signals around the external TIA: inputs and outputs of the TIA and check if they are as expected.

    Once the desired outputs from TIA occur at AIN0 and AIN1, ADC will measure and give the voltage.

  • Hi Akila,

    actually I am only tuning the DAC, the TIA is not yet plugged into the system.

    In waveform generator mode there is no output, in direct writing mode the P node is nearly 0V and N node is fixed 1.8V.

    On the oscilloscope there is only white noise.

    Best regards,

    Yongkun

  • Hi,

    Could you just connect a resistor across AIN2 and AIN3 and check the voltage across it.

  • Hi Akila,

    the last chip was damaged, I used a new chip and did what you said.

    The voltages across the resistor is still almost zero, and the absolute voltage at each pin varies, sometimes within 1V but sometimes near 3V.

    Is there any way I can further analyze the problem?

    Thanks,

    Yongkun