Jump to content

External analog i/p to XADC


T106A81

Recommended Posts

Hiii,

 I am trying to convert a sine wave into digital signal with XADC using  Zynq-7010 (XC7Z010) board but i am not getting any output. I tried so many tutorials. Anyone please help me....

I used Axi-lite interface and vp and vn as input, i tried with aux 2 channel also. i gave 1 Vpp sine wave with 1kh frequency. i want to read it on the terminals. I used XADC in single channel mode. I can able to read the on chip temp and voltages but i am not getting how i can enable the external analog input.  I used as the following code and design

#include <stdio.h>
#include "xsysmon.h"
#include "xparameters.h"
#include "xil_io.h"

#include "xil_types.h"
#include "platform.h"

#define SYSMON_DEVICE_ID   XPAR_SYSMON_0_DEVICE_ID
#define XSysMon_RawToExtVoltage(AdcData)                    \
    ((((float)(AdcData))* (1.0f))/65536.0f)
#define XSM_CFR0_DU_MASK    0x0800  /**< Bipolar/Unipolar mode */

#define XSM_VPVN_OFFSET         (XSM_IP_OFFSET + 0x20C)
                    /**< ADC out of VP/VN       */

static XSysMon SysMonInst;
int SysMonFractionToInt(float FloatNum);


int main()
{
u16 ExtVolRawData;
    float ExtVolData;
int xStatus;
XSysMon_Config *SysMonConfigPtr;
XSysMon *SysMonInstPtr = &SysMonInst;
//static int incr_size = 0x0;
//volatile static int VN_OFFSET_VALUE     = 0x7fff;      //- Offset value for XADC's VN
init_platform();
print("Hello World\n\r");


//----------------------------------------------------------------------- SysMon Initialize
SysMonConfigPtr = XSysMon_LookupConfig(SYSMON_DEVICE_ID);
if(SysMonConfigPtr == NULL) printf("LookupConfig FAILURE\n\r");
xStatus = XSysMon_CfgInitialize(SysMonInstPtr, SysMonConfigPtr,SysMonConfigPtr->BaseAddress);
if(XST_SUCCESS != xStatus) printf("CfgInitialize FAILED\r\n");


// Disable the channel sequencer. The documentation states that we should do this

XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SAFE);


//Enable the Channel Sequencer in continuous sequencer cycling mode.
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_CONTINPASS);


// Wait till the End of Sequence occurs
XSysMon_GetStatus(SysMonInstPtr);  /* Clear the old status */

 //set the INPUT enables.
XSysMon_SetSeqInputMode(SysMonInstPtr, XSM_SEQ_CH_VPVN);


//set the SINGLE CHAN enables.
XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SINGCHAN);

while(1)
{

    ExtVolRawData = XSysMon_GetAdcData(SysMonInstPtr,XSM_CH_VPVN); //Read the external Vpn Data
    ExtVolData = XSysMon_RawToExtVoltage(ExtVolRawData);
    printf("The Current VpVn is %0d.%03d Volts. \r\n", (int)(ExtVolData), SysMonFractionToInt(ExtVolData));

usleep(500000); //wait 500ms
}
return 0;
}
//----------------------------------------------------------------------------------------------
int SysMonFractionToInt(float FloatNum)
{
float Temp;
Temp = FloatNum;
if (FloatNum < 0) {
Temp = -(FloatNum);
}
return( ((int)((Temp -(float)((int)Temp)) * (1000.0f))));
}

 

I am getting output as

The Current VpVn is 0.001 Volts.  with the sine input of 1Vpp at 1 KHZ

 

 

design.jpg

Link to comment
Share on other sites

Hi @T106A81

What board are you using, Cora or Zybo? External pins may be connected to different aux channels depending on the board - VP/VN should be the same for either, but there might be some other IP configuration changes to apply. For tutorials, the Cora XADC demo is the only one Digilent provides that uses the XADC with an AXI interface: https://digilent.com/reference/programmable-logic/cora-z7/demos/xadc.

Thanks,

Arthur

 

Link to comment
Share on other sites

The Edge Zynq isn't a Digilent product, so I am less able to help. Check the Analog Input section of their manual: https://allaboutfpga.com/edge-zynq-soc-fpga-development-board-user-manual/#AnalogInput. I can't find a schematic to see what VP/VN is connected to, but you likely need to be using aux channels 2 and 10 instead, through the XADC sequencer. The aforementioned Cora demo sets up a set of channels to be sequenced through, the Xadc_Init implementation may be of some help: https://github.com/Digilent/Cora-Z7-SW/blob/d35d836848fed00dec917ff0784f6232862220f5/src/Cora-Z7-10-XADC_SW/src/main.c

Thanks,

Arthur

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...