PDA

View Full Version : 12f657 programming question



puggy
- 8th October 2004, 07:19
i am currently trying to use the 12f675 pic in a metal detector that im building for a senior design class. i want the pic to output a constant 10 khz signal that never stops. also i want it to handle the data aquistion. to be more specific it needs to perform an a/d conversion and then analyize that signal to determine if metal has been detected and if so how strong is the signal so we might be able to figure out what we found. lastly i need to be able to output a signal that can change frequency depending on the data analysis (the different frequencies will be used to make different sounds so we know the strength of the signal so for instance the higher freq means the better the signal)

so far i have got the 10 khz signal to output by flashing a pin. that was no problem. but this is running in a continuous loop that cant be stopped so that the metal detector will continue to operate. so while this 10 khz signal is being produced i have to do all my data analysis which i think i can do at the same time by using those instructions as part of the delay used in creating the 10 khz signal. however if i can do this how do i output the other signal that will be used to produce a sound. i dont think i can have to different loops running continuously creating different freqencies. i think it would be easier if there was a way to use the clkout in gpio4 and just have that output a square wave and just set up conditions to determine what freq it should output but i dont know how to get the clkout to work or if i can even do that with this chip

do i need to use more than one pic for this

do i need to possible get a different pic that would be better suitable for this problem and if so which one

or does anyone have any suggestions or tips on how i can solve this problem using the one pic i have.

Melanie
- 8th October 2004, 11:28
CLKOUT from any PIC will give you the Oscillator Frequency. If you're running on internal oscillator, that's probably going to be 4MHz. Not too handy I guess for you, BUT, if you put it through a divider (eg 4020) you can get either 15.6kHz (divide by 8) or 7.8kHz (divide by nine). That saves you the bother of having to generate a constant frequency. To work out how to set the configuration fuses for CLKOUT on any PIC, read the FAQ...

http://www.picbasic.co.uk/forum/showthread.php?s=&threadid=543

Because you need to do other things besides generating a tone, you have two additional alternatives over and above what I suggested above...

1. Chose a PIC with Hardware PWM as well as ADC's... 16F872, 16F876 etc immediately spring to mind, but there are heaps of others... the PWM can then be your constant frequency output.

2. Have your 10kHz generated by background interrupts... tricky (but quite achieveable) with PICBasic, especially if you also need to devote significant foreground time to other tasks.

It all depends on your skill level and how you want to proceed. You can do it all in a 12F675... actually, it's such a simple application, you probably could do it in a PIC10F series... but if you're a bit shaky with attempting some creative programing, then go for option 1.

mister_e
- 8th October 2004, 17:14
Hi puggy,
My suggestion for developpement is of course a flash device such the 16F87x serie but for the end project PIC16c712.

PIC16C712 have 1 PWM (for your 10KHZ tone ), 4 channel ADC and 1k of program memory (wich it's really enough for your needs).

O.k these are not really the most cost price efficient but they have what you want to do your project fast.

regards.

mister_e
- 8th October 2004, 17:28
Hi again,
after a visit to microchip web site i discover PIC12F683 wich have 1 PWM + 4 ADC. It's also supported by PicBasic Pro V 2.45. So i think that's the most suitable for your application.

have a look to this
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010115

They are available for cheap on Newark web site.

regards