Multiplying with 11 using PIC


+ Reply to Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2015
    Posts
    14

    Default Multiplying with 11 using PIC

    Hi
    Anyone can help about the following task.
    Have to multiply input frequency by 11.
    The input frequency range is from 1 Hz to 1 MHz.
    Output frequency has to be from 11 Hz to 11 Mhz.
    Input frequency is coming in time frames of 5 minutes to PIC input stochastically.Means for instance first freq. is 1 KHz and lasts for 5 minutes, after that come second freq. for instance 2 KHz which lasts 5 minutes, then come third freq. 950 KHz etc. etc.
    That means first PIC have to measure input frequency, recognize if it has changed to the new value, and sent to output the present frequency multiplied by 11.
    Much gratefull for any suggestion of which PIC to use for that and how to solve the problem. (16F628A with 20 MHz resonator, PIC16F1455 with 48 MHz osc., PIC18F13K22 with 64 MHz osc. ) ?
    If you can post some code for that the better.
    Have PBP3 Gold edition.
    Thanks

  2. #2

    Default Re: Multiplying with 11 using PIC

    ...and sent to output the present frequency multiplied by 11.
    What do you mean by this?

    Do you want the pic to generate a square wave output from 11Hz to 11MHz on an output pin?

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,361

    Default Re: Multiplying with 11 using PIC

    What sort of resolution are we talking about and how much jitter can you tolerate (ie how "clean" must the output signal be)?

    I would think that your best bet is to use a PIC that has a 20bit NCO-peripheral. 18F25K42 is one such device. If you don't know how DDS frequency generation works make sure to read up on that in order to determine if it'll fit your application.

    If DDS works but the NCO won't live up to requirements you might be able to use an external DDS-chip with a higher base frequency and/or higher resolution and use the PIC to control that chip.

    /Henrik.

  4. #4
    Join Date
    Apr 2014
    Location
    Northeast
    Posts
    390

    Default Re: Multiplying with 11 using PIC

    Please feel free to correct any faulty assumptions.

    First realize that to multiply a frequency by 11, you are dividing a time frame by 11.

    What does your frequency input look like? Is it a perfect square wave (50% duty cycle), an irregular square wave (!=50% DC), a sine wave?

    Assuming a square wave input, try using CCP1 in Capture Mode to measure the time frame of one Gate (low-high starts Capture, high-low stops it). Use CCP2 with the same source clock and divide that time frame and plug it into PWM at 50% DC.

    If your input is sine wave, you might need to use a Comparator to mark low-high and high-low transitions, then feed that into your CCP1.

    If you have an irregular square wave input, you need to measure low-high to low-high period.

    If your input frequency is extremely long (like 1 Hz), you may need a Signal Measurement Timer with 24 bits to measure the input period time. Keeping the clocks the same for measuring input and for your output means you just run the math (input period / 11 = output period).

    I hope this gives you ideas.

  5. #5
    Join Date
    Sep 2015
    Posts
    14

    Default Re: Multiplying with 11 using PIC

    Reply to mpgmike
    In private correspondence with Mr. Henrik the conclusion is that solution with NCO, and PIC working on 64MHz clock would not be the solution.
    Referring to your idea to measure time frame of the input to PIC which has to be multiplied by 11 – if we consider the 1MHz input (1 usec time frame) and 64MHz PIC oscillator clock.Then we have do divide 1 usec /11 and generate output on the base of 64MHz clock.Could you predict what the accuracy should be for 11 MHz output.
    Pic which works on 64MHz and have 2 CCP is PIC18(L)F24/25K40
    Input is square wave with not exactly 50% duty cycle.

    Reply to tumbleweeed
    Yes, PIS has to generate thesquare wave output from 11 Hz to 11 MHz on an output pin.
    Thanks

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    1,918

    Default Re: Multiplying with 11 using PIC

    Then we have do divide 1 usec /11 and generate output on the base of 64MHz clock.Could you predict what the accuracy should be for 11 MHz output.
    you could work it out

    @64 mHz the pic executes 1 instruction every 62.5 nano seconds
    to toggle a pin @11 mHz thats twice every 91 nano seconds , you don't have even 1 inst period to work with

    accuracy approx 0%

    i can't work it out in my head but CCP is unlikely to get there either,

    your going to need a bigger boat
    This is more entertaining than Free to Air TV

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    1,918

    Default Re: Multiplying with 11 using PIC

    the closest i get to 11 meg in mcc for a pwm module is 8meg next step down is 5.33 meg next up 16 meg
    Name:  Untitled.jpg
Views: 29
Size:  80.0 KB
    Name:  Untitled.png
Views: 31
Size:  24.7 KB
    Last edited by richard; - 17th October 2021 at 11:33.
    This is more entertaining than Free to Air TV

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,361

    Default Re: Multiplying with 11 using PIC

    Off list I tried to get Mike to put some sort of number on the needed frequency resolution and allowable jitter. I got neither. I tried to explain how the NCO works and he determined it wasn't up to the task. I did some experiments with the 18F57Q43 running at 64MHz and I'll post some images showing the output of the NCO.

    Name:  SDS2104X Plus_PNG_4.png
Views: 30
Size:  75.5 KB

    Name:  SDS2104X Plus_PNG_3.png
Views: 29
Size:  75.0 KB

    Here we can see how the NCO generates an average frequency of 7.619MHz (as evident by the frequency counter in the top right corner). But when looking closely we can see that MOST of the time (as shown by the "warm" trace) the actual frequency is 7.936MHz and occationally (as shown by the "cold" trace) it's 6.309MHz. The NCO "dithers" between these two frequencies so that, over time, the average frequency is 7.619MHz.

    I tried to squeeze 11MHz out of it but it won't do it, runt pulses and all sorts of weird looking stuff - some of which most likely comes from the setup and probing.

    I still think something like an AD9850 with proper filtering on the output, and then turning that signal back to digital might work.

  9. #9
    Join Date
    Sep 2015
    Posts
    14

    Default Re: Multiplying with 11 using PIC

    Hi Richard , Hi Henrik
    You enormously help me in solving to approach to the task on the right way by conclusion that neither CCP or NCO should not lead to the solving of the problem.
    As one solution I shall try is to solve it with PLL – CD74HC4046A.Here the PIC should be used to detect input frequency and accordingly to switch on or off elements in VCO low pass filter to obtain the input frequency range from 1 Hz to 1 MHz.The multiplication should be realized by 11 time divider in between VCO output and Comparator Input of CD74HC4046A.
    I ordered the chips accordingly and it will take some time to get it and then I shall make the test.

  10. #10

    Default Re: Multiplying with 11 using PIC

    what came to my mind first for that was PLL..... phase-locked-loop that does exact frequency multiplication using divide by N as the multiplier. One problem would be the 'dynamic range' of 1 million for the 11 to 11MHZ. The PIC could switch in 1 of 2 or 3 PLL's for workable operating ranges.

    Just saw previous post with PLL

  11. #11
    Join Date
    Sep 2015
    Posts
    14

    Default Re: Multiplying with 11 using PIC

    Do not understand exactly what do you mean by sentence : "The PIC could switch in 1 of 2 or 3 PLL's for workable operating ranges."
    My idea is that PIC should detect the frequency frame in which PPL will be locked.For instance the first frame will be 1 Hz to 20 Hz, the second from 20 Hz to 200 Hz, third from 200 Hz to 2000 Hz, etc.Means PIC will detect the input frequency coming to PIC input pin (and also to PLL) which have to be multiplied by 11, and accordingly will switch the right low pass filter into VCO input.The input frequency will change in value every 5 minutes.
    So idea is to switch elements in low pass filter in PLL, not to switch the whole PLL's.

Similar Threads

  1. pass pic basic pro pic from pic 16f877a to pic 16f887
    By joseluisatmega8 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 12th February 2020, 16:17
  2. High Speed Serial Comm PC - PIC and PIC - PIC
    By manumenzella in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 16th January 2007, 21:55
  3. Multiplying large numbers
    By jhonea1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 14th April 2006, 17:41

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts