View previous topic :: View next topic |
Author |
Message |
sifirzero1
Joined: 14 Dec 2022 Posts: 43
|
Metal detector |
Posted: Wed Dec 14, 2022 4:00 am |
|
|
hello metal detector circuit. 19kh frequency is received from the 5th leg. this is the frequency shift working logic. In frequency shift, sound is heard from the 7th leg buzzer.
Can you write the code of this circuit? thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Wed Dec 14, 2022 4:17 am |
|
|
One word answer.
NO....
This is a forum where we will try to help _you_ to write code for
things. Learn to code, post your code, and we will try to help you.
There are people here who will write code for you, but they will charge
commercial rates to do it. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Dec 14, 2022 6:33 am |
|
|
While I can write the code, I agree with Mr. T , you need to try and show us YOUR code. Then we can help.
The BIG problem with just supplying you my code, is that I do not have your hardware, so I cannot test my code. There will be necessary code changes depending on PCB layout, component selection, actual 'loop' construction, etc.
It's like asking someone to paint your car 'black'. when you get it back ,it's not the ' black' you wanted. Either too much brown, not enough blue, too little metallic, too shiny,.......
Where ever you got the schematic from, that website, probably has code.
THAT would be the first place to start,even if it's in another form of C or Assembler.
BTW...if this unit is to be portable ( battery operation ), there are far better voltage regulators than the '7805'. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Wed Dec 14, 2022 6:53 am |
|
|
I must admit, looking at the circuit, I can't see how you would make the
coil oscillate with the circuit as posted. You normally either have an external
transistor oscillator, or you have to use the CLKIN/CLKOUT pins to give
the oscillator. With the pin pair shown, I can't think of a way to make
this work.
Actually I can. The circuit is designed to use the comparator to form
the resonator. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Dec 14, 2022 7:50 am |
|
|
curious too... Google to the rescue, sort of....
https://www.youtube.com/watch?v=kwgxbik17NY
I haven't listened to it, or downloaded the code..
what caught my eye was the original PSU is +-3volts NOT +5 only..
Have to wonder why the poster didn't just download the supplied HEX code?
If he did, he could 'reverse engineer' the Assembler and create CCS C code.
Jay |
|
|
sifirzero1
Joined: 14 Dec 2022 Posts: 43
|
|
Posted: Wed Dec 14, 2022 8:04 am |
|
|
temtronic wrote: | curious too... Google to the rescue, sort of....
https://www.youtube.com/watch?v=kwgxbik17NY
I haven't listened to it, or downloaded the code..
what caught my eye was the original PSU is +-3volts NOT +5 only..
Have to wonder why the poster didn't just download the supplied HEX code?
If he did, he could 'reverse engineer' the Assembler and create CCS C code.
Jay |
Can anyone do reverse engineering?
hex code ok. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Wed Dec 14, 2022 8:25 am |
|
|
You are missing the key point.
This is a _help with CCS C programming_ forum, not a 'do things for free'
forum.
If you want to reverse engineer the hex code so you can modify it, you
need to do this yourself.
Honestly though much simpler just to learn to program and do it yourself.
Basic setup comparator to form the oscillator. Use the comparator output
to feed a timer. Use Timer0, and just record the instruction cycles with
Timer1, when T0 overflows. This is a direct measurement of the period
of the inductor oscillator.
If you want the original code, talk to the original author. He'll probably
sell it to you for less than you could get it any other way.
Last edited by Ttelmah on Wed Dec 14, 2022 8:39 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Dec 14, 2022 8:38 am |
|
|
The metal detector code IS 'HEX' code, you simply download it into the PIC so no need to 'reverse engineer', as the program is there.
It's fairly easy to reverse engineer that code though .
That PIC only has 35+- instructions, in the back of the datasheet, so you 'play PIC' and decode the HEX file,removing line numbers and such.
You will of course end up with Assembler and NOT 'C' code.
Now once 'disassembled', you can create C code that compiles into the Assembler code that's in the HEX file.
At the end of the day, you'll have a wealth of knowledge on how a PIC actually works ! |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Wed Dec 14, 2022 8:50 am |
|
|
temtronic wrote: | ...At the end of the day, you'll have a wealth of knowledge on how a PIC actually works ! |
I suspect that that is the last thing he wants. |
|
|
sifirzero1
Joined: 14 Dec 2022 Posts: 43
|
|
Posted: Wed Dec 14, 2022 9:41 am |
|
|
newguy wrote: | temtronic wrote: | ...At the end of the day, you'll have a wealth of knowledge on how a PIC actually works ! |
I suspect that that is the last thing he wants. |
author :a metal detector is mentioned in a controller that works on the principle of measuring the loop tuning frequency under external influence. The metal detector is parametric. These are. It measures the change in parameters of the oscillating circuit during the search. Therefore, it is quite difficult to detect a useful signal against the background of strong interference factors. For the same reason, the sensitivity "USSR for 5 kopecks" (in Runet such a target is used as a standard) does not exceed the diameter of the search coil. But despite all the shortcomings, such a metal detector has one undeniable advantage - the simplicity of both the electronic unit itself and the search coil. Unlike its more powerful brethren, this little one assembles in minutes and requires no adjustments. Everything necessary happens inside the controller at the software level. Unlike the prototype, my metal detector has even less detail. There is no separate generator - its functions fell on the shoulders of the controller. Of the conditions necessary for the normal operation of the Kid-FM, there is only a pair of capacitors with good thermal stability and a properly constructed coil. The second responsible node is the search coil. Its inductance together with the capacitors forms a parallel oscillating circuit at 19 kHz. If using 100nF loop capacitors , loop inductance should be about 1250µH . I say all this in case you want to upgrade the search node. It works fine without any changes. as a pinpointer (95 turns PEL 0.1-0.18 mm coil wound on a 70 mm diameter glass beer bottle) or as a beach (or inspection) (55 turns PEL 0.1 wound on a 180 mm mandrel) -0.18mm coil). In both cases, after winding, you need to fix the wire with a thread and wrap the coil with aluminum foil to fry the meat. This will be a static screen. There is a blank on the screen in the results area. Run a tinned wire along the length of the screen and solder its end to the "Kid-FM" "ground". If this is not done, the frequency of the circuit will change from approaching hands or any object due to parasitic capacitance. |
|
|
sifirzero1
Joined: 14 Dec 2022 Posts: 43
|
|
Posted: Wed Dec 14, 2022 12:09 pm |
|
|
Code: | #include<12f683.h>
#fuses HS,WDT,MCLR,BROWNOUT
#use delay(clock=20m)
#INT_TIMER1
void kesme()
{
set_timer1(65274);
output_toggle(pin_a2);
}
void main()
{
set_timer1(65274);
setup_timer_1(t1_internal | t1_div_by_1);
enable_interrupts(int_timer1);
enable_interrupts(global);
setup_comparator(A1_VR);
setup_vref (VREF_LOW | 3);
while(true)
{
if(c1out== 0)
{
output_high(pin_a0);
delay_ms(VREF_LOW | 3);
output_low(pin_a0);
delay_ms(VREF_LOW | 3);
}
else
{
output_high(pin_a0);
delay_ms(VREF_LOW | 4);
output_low(pin_a0);
delay_ms(VREF_LOW | 4);
}
}
} |
19khz i found the frequency but how do i set the offset |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Dec 14, 2022 12:56 pm |
|
|
you really need to add ;comments at the end of each line of code
so we can try to understand what you're doing.
also helps to define pins as to their function...
instead of pin_a2 write LED ( or whatever it's purpose is ).
or this..
setup_vref (VREF_LOW | 3);
doesn't look correct,but if commented might be correct ?
and you've changed the PIC type from a 629 to a 683, have to ask why ? |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Wed Dec 14, 2022 3:11 pm |
|
|
Change to 683 might be because there is code floating around for that chip |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Dec 15, 2022 7:33 am |
|
|
curious as to where the schematic and code is from...
really should post where you're getting it....
one site's program uses the WDT as the 'timing reference' !
since I have a sheet of freezing rain coming down, today is an 'indoor' day.... |
|
|
sifirzero1
Joined: 14 Dec 2022 Posts: 43
|
|
Posted: Thu Dec 15, 2022 7:35 am |
|
|
temtronic wrote: | curious as to where the schematic and code is from...
really should post where you're getting it....
one site's program uses the WDT as the 'timing reference' !
since I have a sheet of freezing rain coming down, today is an 'indoor' day.... |
https://t.co/qBSy52Q9IP |
|
|
|