Read ADC for specified timw

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

cross mob
Anonymous
Not applicable

 Hello,

   

I was wanting to set up an ADC to continue to read for about 48 MS. My ADC is running at 8Mhz, how many times would i need to read my adc? How long does it take for my adc to run?

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A single conversion will take 160µs at 6.25ksps when clocking with 8MHz, so within 48ms you may get 300 ADC readings.

   

 

   

Bob

View solution in original post

0 Likes
28 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A little bit too few information: What kind of ADC? DelsSig, ADCInc) How many bits? what are the exact settings? As far as I remember there was a formula to calculate the conversion time for an ADC in the datasheet. Can you post your complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.



Bob
 

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Thanks, I added my project so everyone can see my settings better

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A single conversion will take 160µs at 6.25ksps when clocking with 8MHz, so within 48ms you may get 300 ADC readings.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Thanks, That example helped me understand how to use the formula bettr.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are always welcome!

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

If you only need one reading ever 48 mS consider setting a timer

   

for 48 mS and issuing an interrupt at the end of the period to take

   

a reading. That way you don't eat up a lot of MIPS doing nothing but

   

reading an A/D and ignoring its results for the 48 mS period.

   

 

   

In fact only start the A/D at the end of the 48 mS period and take a

   

reading, save power.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Does anyone know how I'd be able to figure out the conversion to get it as a voltage?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Your reference is set to Vdd/2 +/- Vdd/2.

   

 

   

Your converter is set to 8 bits, unsigned.

   

 

   

So Vx = ( AtoDcount value * 5V ) / 256

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

I may be wrong, but I'm under the assumption that the ADC has an interrupt. I am running this ADC fro 48ms which I do about 6 times. Is it possible to run something that happens every 2ms to interrupt the ADC? Like if I were to poll the status of a button.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

ADCINC_1INT.asm this file has a place where user code can be entered

   

to be part of the ADC interrupt handler.

   

 

   

You could do an ISR on the button and simply call the stop / restart on the

   

ADC.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

I need to do similar things for a couple others as well but only in certain conditions. I was planning on having a couple timers I would Start and Stop with interupts. Would placing my timer's ISR jumps higher in the vector table, like in the following link, interrupt the adc since it has Higher priority?

   

http://www.cypress.com/?docID=47681

   

Thanks,

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

From the ap note -

   

 

   

0 Likes
Anonymous
Not applicable

Thanks!

   

Also I forgot to ask, what is the AtoDcount value in...

   

 

   

Vx = ( AtoDcount value * 5V ) / 256

   

 

   

PulseWidth? 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

What pulsewidth ? Are you trying to make a V to PW converter ?

   

Or trying to control LED brightness with V ?

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 on the ADC

0 Likes
Anonymous
Not applicable

 I'm trying to do the conversion for Volts and wanted to know what value I had to put in for the formula

   

      

Vx = ( AtoDcount value * 5V ) / 256

   

 

   

After reading the ADC

0 Likes
Anonymous
Not applicable

 I'm sorry, I think I understand now, the AtoDcount is what comes from the ADC

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Thats correct.

   

 

   

Some ref material -

   

 

   

    

   

          

                                                                                                                         

http://www.cypress.com/?rID=2843     AN2096 - PSoC® 1 - Using the ADCINC ADC

http://www.cypress.com/?rID=2641     AN2239 - PSoC® 1 - Selecting The Right ADC

AN2226 - PSoC® 1 - Using Correlated Double Sampling to Reduce Offset, Drift, and Low Frequency Noise

05/08/2014

AN2099 - PSoC® 1, PSoC 3, PSoC 4, and PSoC 5LP - Single-Pole Infinite Impulse Response (IIR) Filters

05/26/2014

AN2095 - Algorithm - Logarithmic Signal Companding - Not Just a Good Idea - It Is μ-Law

01/05/2015

AN2219 - PSoC® 1 Selecting Analog Ground and Reference

03/20/2014

   

 

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Dana you posted earlier:

   

 

   

"If you only need one reading ever 48 mS consider setting a timer

   

for 48 mS and issuing an interrupt at the end of the period to take

   

a reading. That way you don't eat up a lot of MIPS doing nothing but

   

reading an A/D and ignoring its results for the 48 mS period.

   

 

   

In fact only start the A/D at the end of the 48 mS period and take a

   

reading, save power.

   

 

   

Regards, Dana."

   

 

   

Since I have a task every 3.5 miliseconds to oscilate an led,          the adc is causing this task not to happen in a timely manner.    

   

so this is interrupting the ADC and giving bad values

   

 

   

What kind of timer would I use, a sleep timer, or just a regular timer?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

It might help if you give an overall description of what you are trying to

   

do. For example at the press of a button I will take a reading of V and

   

if it exceeds 2.54 V then I will flash an LED at a rate of 1 flash/sec.

   

 

   

Something like that, I get the feeling we may be giving you bad advice

   

and wasting PSOC resources w/o knowing what the overall design goas

   

are.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 In order for an external latch to be activated I must invert a digital signal (which ends up at an led) every 3.55ms. In the main while loop I am reading the ADC from 6 different signals coming from an external analog MUX. I need to update out led signals based on these readings. Please let me know if I need to explain further

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

 In order for an external latch to be activated I must invert a digital signal (which ends up at an led) every 3.55ms. In the main while loop I am reading the ADC from 6 different signals coming from an external analog MUX. I need to update out led signals based on these readings. Please let me know if I need to explain further

   

 

   

So I read this as three different processes -

   

 

   

1) An external digital signal is routed, inverted, to an LED. I will sample the

   

pin (input) every 3.55 mS and drive the LED with inverted logic from input

   

pin.

   

 

   

2) The latch gets activated by just ther inversion of an input signal ? The

   

latch is driving what ?

   

 

   

3) Main loop, I read 6 different inputs, at 8 bits, and do what to the LEDs that

   

I am driving in 1) ? Turn them off/on at a value, modulate their brightness at

   

a value......? This loop is independent of the operation in 1) ?

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Let me try wording better.

   

- LED_1 has to be sent out turning on and off at 3.55ms to activate the Latch. This latch allows the other LEDs to be able to turn on.

   

- Seperate from LED_1 I read Analog readings from sensors in which I know what LEDs to turn on, for example if reading one is between 2 and 3 volts (not real example) then the LED_2 should come on. And so on for LED_3 ...5

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

 Let me try wording better.

   

- LED_1 has to be sent out turning on and off at 3.55ms to activate the Latch. This latch allows the other LEDs to be able to turn on.

   

- Seperate from LED_1 I read Analog readings from sensors in which I know what LEDs to turn on, for example if reading one is between 2 and 3 volts (not real example) then the LED_2 should come on. And so on for LED_3 ...5

   

 

   

1) So latch is updated at 3.55 mS intervals. Why external latch, not just PSOC port pins ? Is it

   

becuse latch drives a lot of power ?

   

 

   

2) Based on V readings each latch bit, corresponding to an LED, gets updated when 1) occurs.

   

 

   

So I would use a timer. Route the timer Tc out to the latch via a pin. That pulses the latch

   

pin high then low, trasfering inputs to the latch to its outputs. Set timer to give you 3.55 mS,

   

and its compare value to half the period value (that just gives a compare out (if you choose

   

to use it for something else) of a 50% duty cycle.

   

 

   

Two I would take concurrently A/D readings, at whatever resolution/rate you want, and test for specific

   

LED voltage on/off points, and set a PSOC port(s) of pins that are routed as latch inputs to the bit values

   

that will get updated when 1) occurs for each LED or bit.

   

 

   

That sound right ?

0 Likes
Anonymous
Not applicable

 Yes, and the reason for the latch is I'm replacing an older chip on a custom board. My main problem lies when the timer interupts to invert at 3.55ms and the adc is running in the while loop

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Turn your audio on.

   

 

   

www.dropbox.com/s/l5ylpwt9x4mhzdb/Ryan.wav

0 Likes
Anonymous
Not applicable

 Could you explain further what you mean by turn your audio on?

0 Likes
Anonymous
Not applicable

 I think I already have the timer implemented like you described, I will try some things and then reach out again with a schematic and diagram of whats happening

   

Thanks!

0 Likes