ADC Help

Hi Guys,

I could use some help understanding Analog Digital Converters. I've read a number of articles which helps somewhat.

I want to measure the peak amplitude and duration of a non repetitive signal from a transducer. Ideally as a pair of numbers on a four digit LCD display.

Looking at the signal on a scope gets me around 500mv pp maximum and a frequency of 5.500 Khz lasting for five or six cycles.

Looking at specs for various ADC's suggests that I would need to have a sample rate of twice the maximum expected frequency or around 10ksp. Something to do with "Shannon Nyquist"!

Since I want to measure the signal duration I would need to be able to trigger the start of sampling and store the result. I have no idea how to obtain a trigger signal.

What type of ADC should I be looking at ? I now have so many data sheets from various manufacturers that I need to narrow the field considerably.

I have also been looking at "PIC" to see if there are any useful ideas there without much luck. It seems that I would have to learn how to program these to get something useful.

Thanks in advance for any help.

--
Best Regards:
                     Baron.
Reply to
Baron
Loading thread data ...

You might want to amplify that a bit more.

Yeah, that's the theory. The reality is that if you want any real idea of the shape of the signal, you would want to sample it much more often than that.

What I would do is use an op-amp to pump up the signal till it's clipping. If that gives you false triggers on noise, then you could follow that stage with a comparator.

That's pretty much true with any microcontroller (excepting things like the picaxe and the like). If I wanted tens of thousands of samples per second, I'd probably use something larger/faster than a PIC. My new favorite tinker-toy micro is the ARM LPC2xxx. It can easily meet your requirements using the built in ADC. I don't have a clue as to what to recommend for a stand-alone ADC, there are approximately an infinite number of parts from which to choose.

Reply to
Anthony Fremont

If the 5.5Khz is a constant? Then what you're looking at is a simple burst of square wave that may have variant amplitude that represents the value ? What I would do is not use a ADC converter for this. The signal would simply be referenced to drive a PWM circuit. this pulse would vary it's width to an input pin of a uC to indicate voltage level. You would create a DC component from the 5.5khz pulse that only leaves you a DC level proportional to the amplitude of the pulse that drives the PWM circuit. The code in the uC would use the Peak value reading for it's final reading in the burst converted to PWM.

The PWM converter can be done using a dual op-amp or comparator. One unit as a triangle generator, the other as a comparator to pass the triangle pulse to the uC which will translate to a PWM.

--
"I'd rather have a bottle in front of me than a frontal lobotomy"

http://webpages.charter.net/jamie_5"
Reply to
Jamie

Hi Jamie,

That is something that I am going to have to check. I just looked at the scope timebase and made an assumption that the frequency was constant.

I find your comments interesting! Although the technique you describe is not familiar to me, I would like more information that would help me understand it.

--
Best Regards:
                     Baron.
Reply to
Baron

The input signal is a sinusoid. Jamie asked if it was a constant frequency, that I will have to check that out. I don't think that it would matter since I only need amplitude and duration.

A simple op-amp would certainly give me a bigger signal to play with. What sort of output voltage would you suggest ?

Yes that is what I have discovered. My problem with ADC's is seeing the wood for the trees. There's a lot of trees....

--
Best Regards:
                     Baron.
Reply to
Baron

If you are going to use a microcomputer, you might consider one that has enough analog stuff to do most of it, like the Cypress PSoC. It has built-in analog resources that can be used as A/Ds, amplifiers and comparators. Sample rates in excess of 10 kHz can be achieved at 10 bits or more. You can get a start-up kit that can be programmed from a PC for less than $100 that has an LCD display attached. It has 32k flash memory and 2k static ram. If you have the resources (time, power consumption, memory) it might be good to digitize continuously, storing the results in a circular buffer, while waiting for a good trigger; when a trigger is recognized, some contents of the buffer before the trigger time are still available as data. That way, you can take enough time to get a clean trigger without risking losing data. I don't see how you can avoid learning to do some programming to do the job, but it's way easier if you can get an example program running, and gradually modify it to do what you want. It will be a problem to get the peak value of a short burst of 5.5 kHz with an A/D, unless it is running very fast. If you use an external peak detector (a simple analog circuit), you can reset it with a signal from the micro at a fixed time after trigger detection.

--
John
Reply to
John O'Flaherty

formatting link
check there for the basic operations of the PWM circuit theory.

using comparators/op-amps allows you to have a 0..100% duty cycle pulse that can translate to a scale of 0..100% in your uC. You can go one step better and have the uC generate a square pulse as the reference to the Op-amp for the carrier frequency. Using this from the uC and the uC using that as the internal reference makes for a more stable resolve. Only the RC time constant externally would be in question to the op-amp tailoring network.

The uC would use a INT service routine on the raising edge of the PWM that simply zero's a hardware counter or takes a reading of a free running wrap around counter, the falling edge would then be used for the time reading.

You can program the interrupt for edge level triggering so that you can use the same handler for the low/high state of the PWM signal. you only need to reference the IO input to determine the state, mean while, your uC could be doing other things like scanninng a global variable that is being updated via the interrupt handler (ISR).

You need to check in more detail as to what is really happening as the transducer is acquiring data at different conditions for a proper design assessment. I find having a data logger via the computer from the scope works well so that you can scroll back and look.

You may want evaluate the choices of processors to use verses your level of project. from your prior post, I would say using a serial type LCD display and a modern PIC will do it for you.

--
"I'd rather have a bottle in front of me than a frontal lobotomy"

"Daily Thought:

http://webpages.charter.net/jamie_5"
Reply to
Jamie

Hi John,

I'm in the UK so I'll bet that the $ changes to a £ over here. Having said that its just a hobby project. I don't mind spending $100 if its going to get me where I want to go.

I agree. Program examples would certainly help. I did have a hunt around "Microchips" PIC examples but didn't find anything that made a lot of sense.

I need to check if the frequency varies. I realise that I made a bad assumption there.

I'll have a look at the Cypress kit though.

--
Best Regards:
                     Baron.
Reply to
Baron

More like, the reality is that the maximum frequency a naive designer expects is significantly less than the maximum frequency you need to pass.

In the OP's case he's trying to capture a datum that's very much a time- domain thing, rather than a frequency-domain thing -- so rather than trying to set the sample rate using Nyquist, he should probably do it by sketching the signal he wants to capture, then sketching the sampling instants, and figure it out from there.

formatting link

I suspect that sampling fast and having a processor puzzle over the results may end up with a bigger, more expensive system than the simple amplifier/comparator that you suggested -- but it can be hard to say.

--
Tim Wescott
Control systems and communications consulting
http://www.wescottdesign.com

Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott
Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

Hi Guys,

I asked for some help a little while ago about ADC's Many thanks to all those who responded with wise words. I now find that I have another issue to understand regarding SPI interfaces. Whilst Google & Wikipedia tell me what the interface is and some theory about what it does, it doesn't help me with implementing an interface.

I don't know whether a PIC would work and if it did how to control or program one to do what I want. I haven't been able to find anything on the "Microchip" website that helps me. Although I did find some web tutorials on PIC programming.

--
Regards:
              Baron.
Reply to
Baron

Of course a PIC would work. You have the choice of a hardware SPI master, that is something like a UART, you just write a few registers and the hardware pumps out the bits, or you "bit bang" the code yourself, meaning you write code that implements the protocol and sends out each bit. PICs come in an overwhelming variety of flavors. Choose wisely! It's a lot easier than it sounds, but I'm guessing you've never done any of this? At least you have a concrete goal and did some reading already. This is good. The next step is you telling us what your experience is, have you ever programmed anything? Written a batch file? Where are you coming from? Do you understand the basics of a CPU? That's it's nothing more than taking a number *here*, doing something with it, and putting it

*there*, very very quickly?
Reply to
a7yvm109gf5d1

I've done bits and pieces over the past 40 odd years but nothing like this. Its very much a hobbyist project involving self education and modern technology. Linking Electronics, computing and programming seems to be a good combination. Its just finding the right bits :-) If you know what I mean.

--
Best Regards:
                     Baron.
Reply to
Baron

A PIC works absolutely fine but there is no "standard" to work to. Each ADC maker will implement the serial mechanism differently. Only common factor is that the micro needs to take one of it's pins high then low, to act a 'clock' and for another pin to read the resulting ADC data bit, (or even sending a few data bits to the ADC to set up it's internals). You may also have to allocate a third pin to act as an 'ADC chip enable'. The programming of said ADC items must be done entirely with the ADC datasheet timing diagrams in front of you. Beware also that these serial ADC datasheets, mostly seem written by lunatics. What should basically only be a few lines of simple description can end up as 6 pages of obtuse timing diagrams. Worry not!. Main thing is to jump in there and give it a go. Make the mistakes and try again. (you'll find no help on the net). After you've succeeded with your first serial ADC all the rest will be passe.

Below is an arbitrary copy/paste of some PIC code I did to run a particular ADC in a particular manner in a particular product. Main thing to note is all the 'pin high then low' repetitions, as each data bit is collected. There was only about an hour's work there but was premised on having lost the will to live on a number of earlier run-ins with serial ADCs.

get_one_adc_reading: '48.4uS at 10M clock. AD7680 16bit serial chip '16 bits to the "adcreading", 2byte register PORTA.2 = 0 'CS to low (= enable conversion) PORTA.1 = 0 'then send 3 clocks to ignore 3 leading zeroes PORTA.1 = 1 PORTA.1 = 0 PORTA.1 = 1 PORTA.1 = 0 PORTA.1 = 1 PORTA.1 = 0 '4th clock

PORTA.1 = 1 adcreading.15 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.14 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.13 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.12 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.11 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.10 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.9 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.8 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.7 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.6 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.5 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.4 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.3 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.2 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.1 = PORTA.0 'read data PORTA.1 = 0 PORTA.1 = 1 adcreading.0 = PORTA.0 'read data PORTA.1 = 0 '20th clock. maybe terminate here PORTA.1 = 1 '4 trailing zeroes

PORTA.1 = 0 PORTA.1 = 1

PORTA.1 = 0 PORTA.1 = 1

PORTA.1 = 0 PORTA.1 = 1

PORTA.1 = 0 PORTA.1 = 1

PORTA.2 = 1 'CS back to high, ready for next conversion start. Return deactivate_adc:

PORTA.1 = 1 'clock high PORTA.2 = 1 'CS high Return

Reply to
john jardine

Sounds good. Did you get the PIC MPLAB development thingy?

formatting link
You can try stuff out and simulate it.

Try to find a print magazine called "Make", it's a good read.

formatting link

How's your boolean logic, BTW?

Reply to
a7yvm109gf5d1

[...]

Do you really need it that fast? The PIC has a shift command, so you could use a loop. The AD7680 samples up to 100 kSPS, which means your 48.4us would be too slow anyway to read it at full speed. Better use a PIC with hardware SPI.

BTW: in which language do you've written your program? PORTA.1 etc. looks like C bitfields, but then the "'" comments are not C.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

Actually the PIC Microprogram Development System should be here on Monday.

formatting link

I belive that all that stuff comes in the kit I ordered.

I'll have a look at that. Thanks.

Er.... 1&1=1 Stuff ? Just kidding I looked up some of that quite a while ago. It was covered in one of the tutorials for the PIC that I read.

--
Best Regards:
                     Baron.
Reply to
Baron

That explains why I can't find anything understandable.

Just dealing with the clock. Does the micro drive the ADC or is it the other way round ? Or is each clocked independently ?

Yes I have discovered that! Those timing diagrams don't make easy understanding.

What I have done so far is to sketch out a number of boxes and written in them what I expect each one to do and its input/outputs into the next box.

Hey! Code I can understand. Thanks.

--
Best Regards:
                     Baron.
Reply to
Baron

Which PIC would have SPI ?

For information the ADC I am playing with is the LTC1286CN8.

--
Best Regards:
                     Baron.
Reply to
Baron

Many ADC and other chips supports the SPI protocol, which is very simple. Take a look at Wikipedia:

formatting link

There are 4 modes, depending on the phase and polarity. With better microcontrollers and bigger chips, like ARM processors, you just specify the mode, set the chip select and the CPU does the rest, while your program can do other things instead of being busy with bit banging the ADC.

Usually the microcontroller drives the clock.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Reply to
Frank Buss

I did have a look at that the other day, but it didn't make too much sense. I'll go back and have another read at it.

Thanks.

--
Best Regards:
                     Baron.
Reply to
Baron

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.