Announcement

Collapse
No announcement yet.

STM32 controlled PI detector

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

  • #16
    Thank you, thats what Im doing but I have found there was so much noise captured by the coil, so the sound was very strange. Today I made another vídeo with the coil in another position and now the sound is a little better but still needs adjustments like low pass filtering and amplification.
    Here is the today video:
    https://youtube.com/shorts/GU6jh5dMW...dzpqH943aGw2OS

    Thanks !

    Comment


    • #17
      Now I need to implement a subtractive ground balance digitally.

      I have 3 sample windows triggered by timers to open a CD4066:
      - main at 10us
      - gb at 25us
      - efe at 200us

      Values are independently integrated with analog circuitry and captured by the ADC at the precise timings.

      I added a push button that when pressed, I capture samples of the gb window, average them and store them in a variable named "gb_baseline".

      Then, I have a function "detect_metal" in which I need to make the detection logic.
      I have read about subtractive ground balance in the ITMD book.

      Can you help me implement that in the code? What I'm doing now, is the following, anyway I can't see any difference in target detection, ground exclusion:

      Code:
      void detect_metal(void) {
          static int16_t corrected_values[5] = {0};
          static uint8_t index = 0;
          // subtract captured gb_baseline and efe sample so we can have a "clean" target signal
          target_signal = (int16_t)(adc_main_sample - gb_baseline);
          target_signal = (int16_t)(target_signal - adc_efe_sample);
          corrected_values[index] = target_signal;
          index = (index + 1) % 5;
          // average 5 stored samples
          int16_t avg = (corrected_values[0] + corrected_values[1] + corrected_values[2] +
          corrected_values[3] + corrected_values[4]) / 5;
          // calculate a frequency for the VCO
          base_freq = 1 + (800 * avg) / SIGNAL_MAX;
          // limits VCO frequencies
          if (base_freq < 200) {
              base_freq = 200;
          }
          if (base_freq > 3000) {
              base_freq = 3000;
          }
          // updates VCO
          update_pwm_frequency(base_freq);
      }​
      I'm using a small hot rock (tygers eye rich in iron) or a batch (100gr) of magnetite crystals to simulate a mineralized ground.
      For EFE I'm using a large speaker magnet at about 1meter from the coil (not sure if this is a good way to test it).
      I'm using a small 10cm coil as you can see in the videos.

      Thanks.

      Comment


      • #18
        // average 5 stored samples
        int16_t avg = (corrected_values[0] + corrected_values[1] + corrected_values[2] +
        corrected_values[3] + corrected_values[4]) / 5;​
        Are you sure that int16_t avg won't overflow ? => int32_t avg ?

        int16_t avg can be negative =>
        base_freq = 1 + (800 * avg) / SIGNAL_MAX;
        base_freq can be negative too.
        Should you take the absolute value instead ?

        Comment


        • #19
          Thank you. Yes, there was a chance of overflows, I fixed that and also made some improvements about GB subtraction that geocash1 sent to me and now it works. The audio in the video is from high impedance headphones. Now there is also much less noise because Im using batteries instead of previously switching PS.
          video, sharing, camera phone, video phone, free, upload

          Comment


          • #20
            Congratulations on evolving your project Cristiano , the ground balance seems to have worked very well.

            Comment

            Working...
            X