- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to work with Sigma-Delta ADC in single-sample mode for 16 bit in PSoC 5. I am testing my ADC by feeding it with 20Hz sine wave. This sine wave is generated by waveform DAC.
For 60 samples at sampling interval of 5 milli-sec about 6 peaks are expected from the ADC output [(60 *5ms)/50ms =6]. However I see 9 peaks when the raw ADC samples are plotted. I have attached the screenshot of the same.
Note :- I have checked the waveform DAC on the oscilloscope and 20Hz was observed.
Am I doing something wrong here ?
I am also attaching the project bundle.
My main.c looks something like this:
#define NO_SAMPLES 60
#define SAMPLING_INTERVAL_MS 5
#include <project.h>
#include<ADC_DelSig_1.h>
uint8 count=0;
int32 samples[NO_SAMPLES];
int main()
{
CyGlobalIntEnable; /* Enable global interrupts. */
WaveDAC8_1_Start();
ADC_DelSig_1_Start();
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
for(count =0; count<NO_SAMPLES;count++)
{
ADC_DelSig_1_StartConvert();
if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_WAIT_FOR_RESULT)!=0)
{
samples[count]=ADC_DelSig_1_GetResult32();
}
ADC_DelSig_1_StopConvert();
CyDelay(SAMPLING_INTERVAL_MS);
}
}
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you need exact timing, start your conversion based on a timer (via ISR). The way you are doing it now your delay is 5ms+time_for(conversion)+time_for(start_convert)+time_for(read_result)+time_for(stop_convert).
If you want to test this, toogle a pin with each _GetResult and maybe _StartConvert, and check their timing with the scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your waveDAC frequency is 20kHz, your ADC sampling rate is only 200Hz (to be more precise about 150Hz). So what do you expect to see???
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"Aliasing" is the answer 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wavedac frequency is 20Hz not 20Khz. So I do not think aliasing would be an issue here.My concern is why am I not getting 5ms(200Hz) as the sampling frequency? Why is there so much deviation ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, misread. It takes 2.18 ms after StartConvert() until a sample is ready, then you wait another 5 ms using CyDelay(). So there is no aliasing possible. When you want to measure in equal time slices I would suggest using a hardware trigger (timer) for the ADC soc signal and a high conversion rate (5 -10ksps). You even might use the eoc signal to trigger an interrupt that reads out the converted value (no waiting needed).
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content