Announcement

Collapse
No announcement yet.

Direct I/Q demodulation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Originally posted by scrungy_doolittle View Post
    No you are wrong there. 60 hz is 16.666 ms i.e. (1/60 ) * 1000=16.666 at 15000 hz you have (1/15000)*1000 = .066 milliseconds. that is a full cycle. divide that by 360 and you get 1.185 10-4 milliseconds per degree. .00018 milliseconds. That is .18 usec per degree. so sampling 1 cycle at .18 usec, 16 bit resolution, it would take all of 2*360 = 720 bytes. It takes more memory to do slower
    frequencies. You fundamentally mis-understand frequency. You are giving the amount of memory to digitize 15,000 cycles. We only need to digitzed a maximum of 10 to get 10x over sampling.
    Taking one sample every 0.18uSec needs your ADC to run at 1/(0.18*10^-6) Hz = 5.55MS/s, this fills up your buffer of 360 samples in 360*0.18uS = 64.80uS no?

    Comment


    • #32
      Originally posted by sled View Post
      Taking one sample every 0.18uSec needs your ADC to run at 1/(0.18*10^-6) Hz = 5.55MS/s, this fills up your buffer of 360 samples in 360*0.18uS = 64.80uS no?

      For IQ demod Mr Nyquist says you have to sample a minimum of twice the highest frequency ( ie 2 "I" samples and 2 "Q" samples) for every cycle. So the sample frequency for 15 Khz is 30 Khz. The I and Q samples are separated in time by 90 degrees. There is no need to sample more than this per cycle. Gather up sufficient samples ( eg 1024 ) and then do an FFT / DFT .. this will give amplitude and phase.

      Click image for larger version

Name:	NYQUIST.JPG
Views:	1
Size:	62.2 KB
ID:	347589

      Click image for larger version

Name:	IQ.png
Views:	1
Size:	250.3 KB
ID:	347590

      The AD5933 does all this in one chip .... ;-)

      Click image for larger version

Name:	AD5933.JPG
Views:	1
Size:	70.4 KB
ID:	347591

      and you can get it on a little pcb here ... http://store.digilentinc.com/pmod-ia...ance-analyzer/

      Even though it is classed as an "impedance analyzer" ... it makes a superb dsp engine for a discrim detector.

      Comment


      • #33
        Originally posted by sled View Post
        Taking one sample every 0.18uSec needs your ADC to run at 1/(0.18*10^-6) Hz = 5.55MS/s, this fills up your buffer of 360 samples in 360*0.18uS = 64.80uS no?
        yes and no. To get 1 sample every degree, yes. That is why the 10 msample per second. ADC works. Now, do you need all of that? Well no.
        But what it does let you do, if you sample the input as well, is determine the phase shift trivially. Use a buffer that can hold two cycles. In the transmit buffer, find the first 0 value. whatever that
        index is, becomes index 0 for the receive buffer. So if the transmit buffer hits a 0 at index 29 in the buffer, then you find the first zero in the receive buffer, and the difference in the index give you your phase shift directly in degrees.

        Comment


        • #34
          Originally posted by moodz View Post
          For IQ demod Mr Nyquist says you have to sample a minimum of twice the highest frequency ( ie 2 "I" samples and 2 "Q" samples) for every cycle. So the sample frequency for 15 Khz is 30 Khz. The I and Q samples are separated in time by 90 degrees. There is no need to sample more than this per cycle. Gather up sufficient samples ( eg 1024 ) and then do an FFT / DFT .. this will give amplitude and phase.

          [ATTACH]38472[/ATTACH]

          [ATTACH]38473[/ATTACH]
          you're correct of course. However if we oversample,exactly four times the TX frequency we can drop the mixer and sin/cos local oscillator because the samples are already 90 degrees apart. This makes the implementation trivial, oversampling by a factor of 4, collecting 2048 samples over DMA, gives me an interrupt every 32mS with 1024 I and 1024 Q samples, interleaved in an array. This gives me 32mS to process the batch while the DMA continues to fill up my buffer in the background.

          Comment


          • #35
            Originally posted by scrungy_doolittle View Post
            yes and no. To get 1 sample every degree, yes. That is why the 10 msample per second. ADC works. Now, do you need all of that? Well no.
            But what it does let you do, if you sample the input as well, is determine the phase shift trivially. Use a buffer that can hold two cycles. In the transmit buffer, find the first 0 value. whatever that
            index is, becomes index 0 for the receive buffer. So if the transmit buffer hits a 0 at index 29 in the buffer, then you find the first zero in the receive buffer, and the difference in the index give you your phase shift directly in degrees.
            Couldn't this be done using the op-amp as comparator to detect the zero crossing, triggering an interrupt and then look up at what angle the transmitter is at?

            Comment


            • #36
              AD5933. Nice chip. I think I'll propose using that in one of the medical devices I work on.
              It looks to me like this chip can generate the excitation frequency as well. Could it be as simple, as using this chip to generate the frequency, and feeding the resulting signal from the coil into the input, and then just reading the results directly over the I2C bus at 400,000 bits per second. I'd be happier if it were SPI, even though I hate SPI, it at lest will read much faster. I don't see how one would be able to track the data in real time, by reading the I2C at 400,000 bits per second....

              So how does I and R (imaginary and real) relate to the X and Y channels or the X and R if you will.

              Comment


              • #37
                Originally posted by scrungy_doolittle View Post
                AD5933. Nice chip. I think I'll propose using that in one of the medical devices I work on.
                It looks to me like this chip can generate the excitation frequency as well. Could it be as simple, as using this chip to generate the frequency, and feeding the resulting signal from the coil into the input, and then just reading the results directly over the I2C bus at 400,000 bits per second. I'd be happier if it were SPI, even though I hate SPI, it at lest will read much faster. I don't see how one would be able to track the data in real time, by reading the I2C at 400,000 bits per second....

                So how does I and R (imaginary and real) relate to the X and Y channels or the X and R if you will.
                I think it should be fast enough to do it in real time, the phase/amplitude change with the sweep speed of the coil over ground, i.e a few Hz.

                it's a really nice chip, the PGA allows to increase the dynamic range on demand. With a switch on the receive and transmit end we could characterize the TX and RX coil and adjust the parameters, a detector that could work with many existing coils like plug and play. Question is whether 12bits are enough

                Comment


                • #38
                  Originally posted by scrungy_doolittle View Post
                  So how does I and R (imaginary and real) relate to the X and Y channels or the X and R if you will.
                  X = X = I
                  Y = R = Q

                  Comment


                  • #39
                    ...a PC soundcard could do the TX and IQ RX ... try the audio tools from here ... I set the PC to internal sound loop using stereomix ... http://www.satsignal.eu/software/audio.html .

                    You dont have to register the tools to use them .... great for basic experiments ... see how the phase and amplitude varies on the vector scope ... compare response of capacitor / inductor and resistor ....

                    A real detector would require you to write code ;-) .....

                    Click image for larger version

Name:	DT.JPG
Views:	1
Size:	323.8 KB
ID:	347592

                    Comment


                    • #40
                      Really great tools to play with, thanks moodz.

                      Comment


                      • #41
                        .... this application note from Microchip makes development of an IQ TX / RX sampler easier than falling off a log ... http://ww1.microchip.com/downloads/e...tes/01115A.pdf

                        Particularly because the fully documented source code is available also.

                        Comment


                        • #42
                          Originally posted by moodz View Post
                          .... this application note from Microchip makes development of an IQ TX / RX sampler easier than falling off a log ... http://ww1.microchip.com/downloads/e...tes/01115A.pdf

                          Particularly because the fully documented source code is available also.
                          Yep they use the trick with 4x oversampling, I'm implementing on my STM32 at the moment. The trade-off is that the timers must be in-sync and frequency resolution is limited.

                          What I do at the moment:

                          - Full sine wave table with 4096 entries, 16bit
                          - 32-bit phase accumulator for DDS
                          - Calculate phase increment for desired frequency
                          - Double buffer for RX and TX to hold samples for about 10ms (= 5ms double buffered)
                          - Configure ADC at 5.33MS/s with hardware oversampling, i.e samples are accumulated in hardware, using a 64x oversampling gives me 83kS/s maximum sample rate at 15bit.
                          - Configure DMA for both DAC and ADC in cycle mode with interrupt on half-full / half-empty
                          - Configure Timer3 to trigger at exactly four times the sampling frequency, starting both a ADC and DAC conversion simultaneously
                          - In half-full/half-empty interrupt (occurs at a rate of ~200Hz, every 5ms):
                          - I fill the DAC buffer with sine values (DDS)
                          - I get the RX samples in an array, interleaved - i.e samples[even_index] = I_i and samples[odd_index] = Q_i
                          - I downsample the I, Q values
                          - Write values to PC over UART for debugging

                          That's my goal for the moment, still missing the pre-amp and coil driver, only function generator + oscilloscope hooked up.
                          The tricky part is to find optimal values for the TX frequency, so that I can configure the timer to trigger at 4x the TX frequency (prescaler, period).

                          Not sure how much I gain by this batch processing, maybe a simple interrupt at 4x TX frequency would work fine too.

                          If somebody is interested in the hardware oversampling: http://www.st.com/content/ccc/resour...Analog_ADC.pdf

                          Comment


                          • #43
                            sounds reasonable, depending on how close to the zero crossing it triggers. I can see a problem with weak signals triggering it at the wrong time. I work with a medical device, where I have a simple zero crossing circuit that does this for a damped sinusoidal wave form. The problem is that the zero crossing is offset from where it actually occurs. You need to trim it. And we don't. In my case, I am just interested in the time between zero crossings, so it works.
                            In this case, one would probably want to use a DAC to be able to tweak the opamp comparator threshold. With the PIC24 gc010 having three built in comparators, and two opamps, it would be easy.
                            The comparator can trigger an interrupt directly. If your sinewave table has 360 values in it, then I believe this would work.

                            Comment


                            • #44
                              Thank you Carl. That makes everything else make sense.
                              So the real part is the same as the Y, or resistive channel? or is q the real part.
                              Lets redo that with the following notional differences.
                              r = resistive channel
                              R= real part of the number from the AD5933.
                              Would it be:
                              Y=r=Q or Y=R=Q
                              Q=quadrant
                              I=in-phase
                              i=imaginary.
                              how do these relate?
                              The ADC5933 produces a "real" value and an "imaginary" value. How do these relate to X,Y,r,I,Q

                              Comment


                              • #45
                                Originally posted by scrungy_doolittle View Post
                                Thank you Carl. That makes everything else make sense.
                                So the real part is the same as the Y, or resistive channel? or is q the real part.
                                Lets redo that with the following notional differences.
                                r = resistive channel
                                R= real part of the number from the AD5933.
                                Would it be:
                                Y=r=Q or Y=R=Q
                                I found a good explanation from minelab here: https://www.minelab.com/__files/f/11...S_&_THEORY.pdf

                                Comment

                                Working...