Frequency Conversion Circuit
Frequency Conversion Circuit
(OP)
Hello,
I am trying to design a circuit capable of dividing a 70Hz - 5.7kHz square wave signal down to a 1Hz - 1kHz square wave signal. The exact output frequency must be adjustable.
I am currently working with a PIC16F631 chip and had some luck with low frequencies <300Hz using if statements and counting the input pulse. extremely simplified the code was:
if input on, run timer
if input off, stop timer
multiply timer value by x to get y
switch output every y
I then tried using the interrupts built into the chip but the results ended up worse than with the if statements.
I am not an electronics guy and have zero experience in designing circuits. Is the PIC chip even a good architecture for me to be attempting this on? I am not stuck with the PIC, I just chose it because it looked simple and I could program it in C. Is there anything pre-built out there that can accomplish what I am trying to do? Any help would be welcome.
I am trying to design a circuit capable of dividing a 70Hz - 5.7kHz square wave signal down to a 1Hz - 1kHz square wave signal. The exact output frequency must be adjustable.
I am currently working with a PIC16F631 chip and had some luck with low frequencies <300Hz using if statements and counting the input pulse. extremely simplified the code was:
if input on, run timer
if input off, stop timer
multiply timer value by x to get y
switch output every y
I then tried using the interrupts built into the chip but the results ended up worse than with the if statements.
I am not an electronics guy and have zero experience in designing circuits. Is the PIC chip even a good architecture for me to be attempting this on? I am not stuck with the PIC, I just chose it because it looked simple and I could program it in C. Is there anything pre-built out there that can accomplish what I am trying to do? Any help would be welcome.





RE: Frequency Conversion Circuit
http://www.ti.com/lsds/ti/analog/clocksandtimers/c...
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Frequency Conversion Circuit
I have looked at stuff like that before. The problem is I need to divide by weird numbers like 8.533. not just multiples of 2.
RE: Frequency Conversion Circuit
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Frequency Conversion Circuit
RE: Frequency Conversion Circuit
I will look into the frequency-voltage-frequency idea.
RE: Frequency Conversion Circuit
"The exact output frequency must be adjustable."
However, this may not be doable, depending on what resolution/accuracy you are requiring
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Frequency Conversion Circuit
Thanks for your help.
RE: Frequency Conversion Circuit
Recently I've been playing with Arduino boards and a popular AD9850 DDS board. These things are cheap as chips, and can be tiny (Arduino Nano). If your requirements for tracking were loose, it might be possible to do this in software. Measure F(in), do the math, adjust F(out). The limitation would be the update loop rate. Using clever programming tricks, it could be better than once per second - maybe...
Another approach worth checking is to switch your thinking from the frequency domain (Hz) to the period domain (us). There may be a simple and tight algorithm of counting pulses and then interpolating the fractional part, and then transitioning the output on a calculated schedule. If you're lucky, maybe 30 lines of tight code (?).
RE: Frequency Conversion Circuit
The Arduino includes a "tone(pin, frequency)" instruction, apparently programmable to the nearest Hz. Disclaimer - I've not used that feature yet; I'm not aware of any limitations.
I wonder if you could measure the input period (typically faster than measuring frequency), use a look up table, and update the appropriate tone output. Might be just a few lines of code inside the main loop.
If you change the division ratio, recalculate the table.
Obviously you can also recreate this using whatever board you have at hand.
RE: Frequency Conversion Circuit
I am currently counting pulse width not frequency. I am taking the input pulse length, multiplying it by a number (this only needs to be set once but varies depending on application) and then outputting the new pulse length. It worked really well up to 300Hz then it fell on it's face.
I spent sometime yesterday looking at frequency to voltage converters and am now thinking that might be a simpler solution.
RE: Frequency Conversion Circuit
Another consideration, since you mention it working at lower frequencies, is number overflow versus the counter resolution. You could be running into numbers that are simply too large when trying to count higher frequencies and this would appear as random garbage output when in fact it is the low order bits of your result.
Personally, I would suggest using a better processor for the job, such as one of the TI's mentioned as they operate at a clock rate MUCH higher than a PIC and have built in hardware for measuring input pulses as well, generating output via a PLL, and the math resources necessary to do the frequency conversion. A smaller TI DSP, eg 28x series, won't cost you anymore than a PIC either.
RE: Frequency Conversion Circuit
That's what the rate multiplier/divider chips from the TI site do.
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Frequency Conversion Circuit
Also, the method of reading the input to determine whether or not to start the clock the way you are doing is called "polling". It can result in a good bit of jitter in the output signal, since your clock value now has an +/- error range as large as that section of code takes to execute(twice).
Have you determined a spec for how much error you can have on the output signal? In terms of jitter, duty cycle errors(does it need to reproduce the same duty cycle as the input?), error in frequency scaling, etc.
Will your electronics need to go through any sort of compliance testing, in your products?
RE: Frequency Conversion Circuit
I was thinking I may run into a problem like that. Indeed I encounter more problems when I try to multiply the pulses as opposed to just moving the registers from the input to the output.
The pulse widths get smaller as the frequency increases. I don't see this being a problem.
I don't see anything there that will solve my issue. Although that is probably due to me not knowing exactly what I am looking for/at.
I need the output to be as similar to the input as possible. There is just environmental testing the products need to go through. I am not trerribly worried about it at this point. I need this in a semi-working state before I even think about moving forward.
RE: Frequency Conversion Circuit
PLL MULTIPLIER/DIVIDER DEFINITION
At a given input frequency (fIN), the output frequency (fOUT) of the CDCE949/CDCEL949 can be calculated by:
where ƒOUT = (ƒIN/Pdiv) * (N/M)
M (1 to 511) and N (1 to 4095) are the multiplier/divider values of the PLL;
Pdiv (1 to 127) is the output divider.
I suggest that you find an EE to do this.
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Frequency Conversion Circuit
I agree. Unfortunately I am the one who has to do this.
The datasheet sates that in PLL mode the minimum frequency input is 8MHz. Unless I am missing something, this will not work for me as I am working in the Hz and kHz range. Regardless I did order a couple in to play with, so if there is a work around for this I would love to know.
RE: Frequency Conversion Circuit
RE: Frequency Conversion Circuit
Alternately, your original approach would still seem to be viable. The chip is single-cycle instructions at 200 ns/instruction cycle, which is 877 instructions/ period of your fastest input. You need to find out why your code is so slow. I know the answer to that, actually, which is WHY ARE YOU DOING THE SAME MULTIPLICATION AND DIVISION EVERY INPUT CYCLE? Do you really need infinite resolution? Why not use a lookup table? Even then, a simple FPGA could do pre-processing to lessen any burdens on the PIC.
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Frequency Conversion Circuit
I am not using a D/A. The output frequency is created simply by turning the output pin on and off quickly. I also do not have a debugger, which may have helped me.
It seemed to be the simplest solution at the time. I could probably get away with a refresh rate of about 2Hz or so. A lookup table might be something to look into. Any way to get math out of the program should help me.
RE: Frequency Conversion Circuit
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers