- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Solved! Go to Solution.
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A single conversion will take 160µs at 6.25ksps when clocking with 8MHz, so within 48ms you may get 300 ADC readings.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A single conversion will take 160µs at 6.25ksps when clocking with 8MHz, so within 48ms you may get 300 ADC readings.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, That example helped me understand how to use the formula bettr.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are always welcome!
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does anyone know how I'd be able to figure out the conversion to get it as a voltage?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From the ap note -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!
Also I forgot to ask, what is the AtoDcount value in...
Vx = ( AtoDcount value * 5V ) / 256
PulseWidth?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What pulsewidth ? Are you trying to make a V to PW converter ?
Or trying to control LED brightness with V ?
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
on the ADC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm sorry, I think I understand now, the AtoDcount is what comes from the ADC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 |
03/20/2014 |
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you explain further what you mean by turn your audio on?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!