Announcement

Collapse
No announcement yet.

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


            • #21
              I'm now trying to change the circuit to use a NMOS coil switch like an IRF840. I changed all the power supply and now VB+ is the ground. I'm powering the STM32 board from -5V of the 79l05 regulator connected to STM32 ground and circuit ground (VB+) connected to the STM32 5v pin. Until the preamp all seems to work ok, but now I have a problem: the STM32 3.3V outputs, when referenced to the main circuit ground (VB+) are not measuring the correct voltage and this causes problems with the ADC readings (VREF), etc. Is there any other way of properly powering the STM32 with 5v and share the same ground? Thanks.

              I'm using the following power supply schematic:

              Comment


              • #22
                Would it work by powering the STM32 from the 78L05 instead of the 79L05, using the VB+ as the STM32 ground and the main circuit ground? You could use an extra 78L05 if the STM introduces noise

                Comment


                • #23
                  Hi Cristian.
                  I'm using this schematic in my project, and it works very well. My ESP32 is also powered between GND (+BATT) and -3.3V.​
                  Attached Files

                  Comment


                  • #24
                    Originally posted by cristiano.sar View Post
                    I'm now trying to change the circuit to use a NMOS coil switch like an IRF840. I changed all the power supply and now VB+ is the ground. I'm powering the STM32 board from -5V of the 79l05 regulator connected to STM32 ground and circuit ground (VB+) connected to the STM32 5v pin. Until the preamp all seems to work ok, but now I have a problem: the STM32 3.3V outputs, when referenced to the main circuit ground (VB+) are not measuring the correct voltage and this causes problems with the ADC readings (VREF), etc. Is there any other way of properly powering the STM32 with 5v and share the same ground? Thanks.

                    I'm using the following power supply schematic:
                    Hello, Christian.
                    This circuit does not provide power to the processor chip.

                    Click image for larger version

Name:	image_58275.jpg
Views:	362
Size:	33.2 KB
ID:	438402

                    Comment


                    • #25
                      I am back again with this project. I'm now trying to use the GS5 lite from Eduardo power supply, with a LM337 regulator from -12v to provide -3,3v to power my STM32f407vet6 dev board and I am wiring it from -3,3v and GND.
                      The Stm32 board powers up, but does not run the program, it seems like it stays at programming state or something like that.
                      Below is the schematic of the STM32f407vet6 :

                      STM32F407VET6_schematic.pdf

                      Someone has an idea of how to solve that? May be the problem is that it is a dev board (should I try another)?

                      Thank you!

                      Comment


                      • #26
                        Originally posted by cristiano.sar View Post
                        I am back again with this project. I'm now trying to use the GS5 lite from Eduardo power supply, with a LM337 regulator from -12v to provide -3,3v to power my STM32f407vet6 dev board and I am wiring it from -3,3v and GND.
                        The Stm32 board powers up, but does not run the program, it seems like it stays at programming state or something like that.
                        Below is the schematic of the STM32f407vet6 :

                        [ATTACH]n444572[/ATTACH]

                        Someone has an idea of how to solve that? May be the problem is that it is a dev board (should I try another)?

                        Thank you!
                        are you trying to run the board from -3.3 volts ... that reads as minus 3.3 volts ??? It will most probably blow up.

                        Comment


                        • #27
                          Originally posted by moodz View Post

                          are you trying to run the board from -3.3 volts ... that reads as minus 3.3 volts ??? It will most probably blow up.
                          I am running the 3.3v pin of the board connected to my circuit ground (+VB) and the GND of the board to the -3.3v of the circuit regulator (LM337) so the board sees 3.3v.

                          Comment


                          • #28
                            thats fine but the logic levels will be wrong for the programmer which wont be connected like that.

                            Comment


                            • #29
                              Originally posted by moodz View Post
                              thats fine but the logic levels will be wrong for the programmer which wont be connected like that.
                              Thank you, what you suggest me to do? Is there any other option to power the stm32 board in another way in a circuit like that (where we used VB+ as GND)?

                              Comment


                              • #30
                                There are 2 ways to deal with this, I have used both.

                                1. Disconnect the power supply to the board, then connect the programmer and allow the programmer to power the board with +3.3V and ground. When programming is done, disconnect the programmer and then apply the -3.3V power supply. This method means you cannot use a run-time debugger.

                                2. Use a galvanic isolating USB cable to drive the programmer. This will provide DC isolation so that you can power the micro from -3.3V and still program and debug.

                                Comment

                                Working...
                                X