Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: VLF i metal detetor based on teensy audio board

  1. #1
    Junior Member
    Join Date
    Jul 2021
    Posts
    8

    VLF i metal detetor based on teensy audio board

    Hi everyone, i'm building vlf meta detector with a frequency of 10khz, i want to use the signal generated by the audio board in the tx coil with an amplifier, and the MIC input of the board to analyze the signal in the rx coil.
    maybe if necessary I'll put an amplifier between the rx coin and the teensy.
    I already have a teensy 4.0 with the board rev.d, I was thinking to use that for this project to take advantage of the many commands for the signal analysis already programmed.
    This type of project if feasible with this board or there are simpler and effective ways to achieve this? I'm worried about the rx coil receiving more than 3.6v, so I maybe will use a separate ADC to have a better reading.

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,229
    I guess that's perfectly possible - you'd need to ensure suitable scaling of the received signal to the right level for best sensitivity without clipping too readily.

  3. #3
    Junior Member
    Join Date
    Jul 2021
    Posts
    8
    Thank you for your answer.
    One more thing, if I use the waveform function, with sinusoidal wave what is the maximum frequency? I tried with my oscilloscope but after 22kHz, the wave was pulsing, there are some ways to increment this limit to maybe achieve 40/50kHz? I can create a 60kHz Square wave with a normal pin and the tone function, but the sinusoidal is more suitable for my application,

  4. #4
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,229
    Since the system samples at 44100Hz, 22kHz is indeed the maximum frequency supported by the Audio library, in its out-of-the-box configuration. Increasing this is possible, there are various threads around about this.

  5. #5
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    507
    Hi,

    Below is part of the code I am using in the batdetector. This allows you to set the sampling frequency a lot higher (we have tested/used this up to 384K).


    // https://forum.pjrc.com/threads/65225...%2C+true%29%3B
    Code:
    #include <utility/imxrt_hw.h>
    bool setI2S_freq(int freq)
      {
      // PLL between 27*24 = 648MHz und 54*24=1296MHz
      int n1;
      if (freq > 8000)
        {
        n1 = 4; //SAI prescaler 4 => (n1*n2) = multiple of 4  based on Frank Boesings code
        }
      else
        {
        n1 = 8;
        }
    
      int n2 = 1 + (24000000 * 27) / (freq * 256 * n1);
    
      double C = ((double)freq * 256 * n1 * n2) / 24000000;
      int c0 = C;
      int c2 = 10000;
      int c1 = C * c2 - (c0 * c2);
      set_audioClock(c0, c1, c2, true);
      CCM_CS1CDR = (CCM_CS1CDR & ~(CCM_CS1CDR_SAI1_CLK_PRED_MASK | CCM_CS1CDR_SAI1_CLK_PODF_MASK)) | CCM_CS1CDR_SAI1_CLK_PRED(n1 - 1) // &0x07
        | CCM_CS1CDR_SAI1_CLK_PODF(n2 - 1);                                                                                // &0x3f
      return true;
      }

    And you can set a sine like this (sine_HT is a AudioSynthWaveformSine)

    Code:
    void set_freq_Oscillator(int freq)
      {
      // audio lib thinks we are still in 44118sps sample rate therefore we have to scale the frequency of the local oscillator
      // in accordance with the REAL sample rate
      freq_Oscillator = (freq) * (AUDIO_SAMPLE_RATE_EXACT / SR_real);
       
      if (freq_Oscillator > 22000)
        {
        freq_Oscillator = 22000;
        osc_frequency = freq_Oscillator * (SR_real / AUDIO_SAMPLE_RATE_EXACT) ;
        }
      
      sine_HT.frequency(freq_Oscillator);
      
    
      } //

    cheers
    Cor

  6. #6
    Junior Member
    Join Date
    Jul 2021
    Posts
    8
    Thank you for this overclock, I saw your bat detector during my searches but didn't realize that I can also generate a faster waveform.
    One more thing, I have to calculate the out of phase between my Rx coil and Tx coil, maybe will use logic gates, but there is a more effective way to get his information?
    I'm waiting for some components to arrive, but if this is a functional project I'll post my code and some more info.
    Thanks for the help!

  7. #7
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,229
    Just feed an attenuated sample of the TX coil to the other channel and you can compare the phases between channels perhaps?

  8. #8
    Junior Member
    Join Date
    Jul 2021
    Posts
    8
    markT, i need to know with some precision the angle of shift, if I can access the real time data of the current amplitude, bot synthetized and received, I can use some iterative math to know the timing of the peak, with this I can identify the phase shift.

    CorBee the code you posted(for the sine_ht) has to be put in the library's files? thanks
    Last edited by Xarin94; 10-03-2021 at 06:24 PM. Reason: Error correction

  9. #9
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    507
    Hi,

    The sine_HT is using a part of the audio library, you only need to declare

    AudioSynthWaveformSine sine_HT;

    cheers
    Cor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •