Hi Jim, Unfortunately, the code for the counter is back home on my workbench computer (I am at university right now). I can't get the actual code for you for about a week. I might be able to dig up an uncommented intermediate version sooner, but I couldn't be sure it works. Let me know if you still want it. I wrote the code myself, it isn't based on any Mchip app note directly. However, I am using the brilliant idea (whose origin I don't know) of using the prescaler and reading it's contents by pulsing the TMR0 input pin by using an additional PIC pin. (I can explain this better if you are not familiar with it). The code operates in three ranges: 0Hz to 64KHz, 65KHz to 640KHz, and 650KHz to 65MHz (but it isn't really capable of reading a signal that fast). The sampling (gate) delay for each range is as follows: 1 second, 100ms, and 1ms. The autoranging works by first checking at the upper range. If the result is too small (i.e. below 650 counts), it tries the next range down. It does the same procedure,and switches to the lowest range if necessary. My guess is that this isn't really what you want,since you are concentrating on slow waveforms (2KHz to 4Khz). It seems to me that you want to to period measurement. To do that effectively, you should set up TMR0 to clock on internal interrupt cycles,and to interrupt on port change. In the interrupt handler, you can have a second variable that you increment,to extend the range of TMR0. Then,to detect rising and falling edges of the waveform, you might be able to additionally use interrupt on port pin change, or just poll in your main loop. This way, you should be able to get very accurate period measurement by just waiting a few periods of the wave and averaging their results together. If there isn't too much jitter in your input signal, you should be able to get the period to >16 bits accuracy in only a few ms. At 01:24 PM 10/17/99 -0500, you wrote: >Sean, > >I read this post and wanted to ask you about the frequency counter portion >of your project. >I need to measure a frequency range of about 2 Khz to 4 Khz to as small a >resolution as >possible, while still sampling as fast as possible. I see your frequency >counter goes down >to 15 Hz. What I wanted to ask you is what is your sampling period at the >low frequency end >of the range? And is the software based on an Ap Note from Microchip, or >is it one of your >own? Laso, do you perform any floating point math? And if so, what >routines are you using? >I'd appreciate it if you would enlighten me and possibly share your software >for the counter >portion of your project. Please RSVP > > >Thanks and Regards, > > >Jim >-----Original Message----- >From: Sean H. Breheny >To: PICLIST@MITVMA.MIT.EDU >Date: Sunday, October 17, 1999 12:59 PM >Subject: Re: RF High-Isolation Switches > > >>Hi all, >> >>Thanks for the help on the switches. I think I will use Mike Keitz's >>suggestion (given to me in a private reply), to use a DPDT switch (which I >>think will fit into the hole already drilled in the case). >> >>The actual application is a frequency counter and function gen in one case. >>You can switch the source of the freq. counter between the ext. input and >>the function gen. Because the function gen needs to operate even when the >>counter is connected, I cannot simply ground the function gen to isolate it >>from the counter. SO, the DPDT switch will allow me to connect the gen to >>the counter indirectly,and ground the indirect line when not in use. >> >>The frequency range is from 3Hz to 16Mhz. I can't work in a 50ohm >>environment because the amp input needs to be high impedance, so that it >>won't affect the external circuit that it is measuring. The function gen >>output is 50 ohms, however. >> >>BTW, to those who remember the thread on using 7404's as linear amplifiers, >>which was months ago, I finally did get it to work by using 74HCU04's,so >>yes,the answer was unbuffered gates,in addition to NOT using gates with >>adjacent pins (i.e., when using more than one on the same chip, skip a gate >>inbetween,and ground its input). >> >>When I have some pictures and schematics to show, I will put it up on my >>web page. Originally, I planned on including a dual channel power supply in >>the same case. I ended up building it separately,and it is also completed >>and should be documented on my page in the not-too-distance future. >> >>Thanks to all, >> >>Sean >> >> >> >>| >>| Sean Breheny >>| Amateur Radio Callsign: KA3YXM >>| Electrical Engineering Student >>\--------------=---------------- >>Save lives, please look at http://www.all.org >>Personal page: http://www.people.cornell.edu/pages/shb7 >>mailto:shb7@cornell.edu ICQ #: 3329174 > | | Sean Breheny | Amateur Radio Callsign: KA3YXM | Electrical Engineering Student \--------------=---------------- Save lives, please look at http://www.all.org Personal page: http://www.people.cornell.edu/pages/shb7 mailto:shb7@cornell.edu ICQ #: 3329174