- Joined
- Nov 28, 2011
- Messages
- 8,393
Have you heard about comments? You use them throughout your program to describe what the program is doing. They are almost as important as the code itself because they enable other people to follow your logic, and they will also remind you of how the program works when you come back to it in six months.
So you have just the search coil connected between RC1 and RC2, with no capacitor across it to form a tuned circuit? Your code sets RC2 as an output and RC1 as an input? What does it do then? Does it generate a pulse on RC2 and measure how long it takes before RC1 changes?
I don't think you'll get any useful results doing that. Look at other metal detector designs. They ALL use the search coil as part of a tuned circuit in an oscillator. If you build an oscillator around the search coil, you could measure its frequency if you feed its output into a timer clock input. How you determine the frequency depends on what capabilities the timer(s) have. You might be able to use some kind of input capture. You might need to divide the oscillator frequency externally using something like a 74HC4040 and capture transitions from the divider. The PIC would need to be clocked from a crystal though, for accuracy and stability. If you really want to do the frequency detection with the PIC, that's what I would try next.
Try to understand how metal detectors work. Google metal detector schematic and click on the image results. For all the designs that aren't too basic, open the image in a new tab, then go through those tabs and go to the web page. You will find explanations for how the circuits work.
So you have just the search coil connected between RC1 and RC2, with no capacitor across it to form a tuned circuit? Your code sets RC2 as an output and RC1 as an input? What does it do then? Does it generate a pulse on RC2 and measure how long it takes before RC1 changes?
I don't think you'll get any useful results doing that. Look at other metal detector designs. They ALL use the search coil as part of a tuned circuit in an oscillator. If you build an oscillator around the search coil, you could measure its frequency if you feed its output into a timer clock input. How you determine the frequency depends on what capabilities the timer(s) have. You might be able to use some kind of input capture. You might need to divide the oscillator frequency externally using something like a 74HC4040 and capture transitions from the divider. The PIC would need to be clocked from a crystal though, for accuracy and stability. If you really want to do the frequency detection with the PIC, that's what I would try next.
Try to understand how metal detectors work. Google metal detector schematic and click on the image results. For all the designs that aren't too basic, open the image in a new tab, then go through those tabs and go to the web page. You will find explanations for how the circuits work.