ADC_SAR - Time between samples

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Tranzystomator
Level 1
Level 1
5 questions asked 10 sign-ins 5 replies posted

Hi,

I use ADC_SAR but I can't find how can I get the time between samples. Maybe someone can help?

0 Likes
1 Solution
DennisS_46
Employee
Employee
100 sign-ins 50 likes received 50 solutions authored

If you have a scope . . .
In the SAR configuration screen, enable the end-of-scan (EOS) output

DennisS_46_0-1670975859755.png

Route this signal to a pin.

DennisS_46_2-1670975983253.png

The output is one clock wide, you can measure the time delay with your scope.
The fastest sample rate is clock rate / 18. 
12 MHz clock yields 666666 samples per second, 1.5 usec between samples.
18 MHz clock yields 1000000 samples per second, 1 usec between samples, this is the maximum rate.
Adjust the sample rate by adjusting the clock to the SAR.
---- Dennis

 

View solution in original post

0 Likes
8 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted
Tranzystomator,

That should be easy to determine.
If you open the ADC_SAR configuration tool it will have two fields you can change to determine the conversion time.
Len_CONSULTRON_0-1668725447707.png

 

The two fields are in the RED boxes "Resolution (bits):" and "Conversion rate (SPS):"

Basically the more bits you want to use the slower the allowed conversion rate.

Once the resolution is selected you can change the desired conversion rate.   If a RED ! shows up next to the field, you will be told the value selected is not valid.  Hovering over the RED ! informs you of the valid values for the range.

Once you select the resolution and the desired conversion rate, the "Actual conversion rate (SPS):" in GREEN will be the actual rate.  1/actual rate = time between conversions.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
Tranzystomator
Level 1
Level 1
5 questions asked 10 sign-ins 5 replies posted

Hi, 

But I can’t find that variable in code. I mean the green one.

Second things is that, I’ve noticed is when I change the sampling rate,  total amount of samples doesn’t change. It’s still the same. 

For example I’ve set the conversion rate to minimum, then I sent the data by USB to PC. I put the data to a chart. Then I change the converion rate to the maximum, I did the same step and the result is the same chart. Signal should change because of  changing the conversion rate. No samples were missing. 

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Tranzystomator,

You may find basic oscilloscope demo here:

Basic oscilloscope demo using ADC_SAR and KIT-059

The sampling rate can be changed by updating the external clock divider (Clock_SetDivider(new_value);) or, in case of free-running ADC, by the method explained by the Len. 

0 Likes
Tranzystomator
Level 1
Level 1
5 questions asked 10 sign-ins 5 replies posted

But I asked how can I get this value in code. But you answer me how can I set this value. 😞

0 Likes

Tranzystomator,

Infineon could have supplied the conversion rate value as a float value in a #define but they chose not.

In general, take the input clock frequency to the SAR and divide by 18.  This appears to be the conversion rate calculation.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
DennisS_46
Employee
Employee
100 sign-ins 50 likes received 50 solutions authored

Tranzystomator:
There are two ways (at least) to set the ADC sample rate.
1. Pick a clock rate and adjust the sample delay to get the rate that you want.
2. Set up a timing circuit (typically using a PWM) and use the PWM output to trigger
the external start convert (SOC) input. In this case you use a single shot trigger

DennisS_46_0-1669747581337.png

I prefer this method because it gives me absolute control of sample rate without having to juggle
around with internal sampling delays.
---- Dennis Seguine, PSoC Applications Engineer

 

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

As we usually would like to sample ADC in a unformed time,

so setting the sample rate probably provide us the max time for that resolution.

I tried to measure the sampling time using a hard ware time like below

using my CY8CKIT-059.

Schematic

002-schematic.JPG

Pins

003-Pins.JPG

Tera Term log

001_TeraTerm_log.JPG

I'm not sure how accurate this measurement,

but I hope that at least it gives us some reference.

moto

 

0 Likes
DennisS_46
Employee
Employee
100 sign-ins 50 likes received 50 solutions authored

If you have a scope . . .
In the SAR configuration screen, enable the end-of-scan (EOS) output

DennisS_46_0-1670975859755.png

Route this signal to a pin.

DennisS_46_2-1670975983253.png

The output is one clock wide, you can measure the time delay with your scope.
The fastest sample rate is clock rate / 18. 
12 MHz clock yields 666666 samples per second, 1.5 usec between samples.
18 MHz clock yields 1000000 samples per second, 1 usec between samples, this is the maximum rate.
Adjust the sample rate by adjusting the clock to the SAR.
---- Dennis

 

0 Likes