logic to generate variable frequency output.

Discussion in 'Embedded Systems and Microcontrollers' started by bilal sheikh, Mar 20, 2015.

  1. bilal sheikh

    Thread Starter New Member

    Jan 21, 2015
    22
    0
    hello all, recently i am working on a project that is variable frequency drive. i am using pic microcontroller for the programming purpose.in the programming section, i have one sine look up table and have to generate various such tables during run time(each table corresponds to a particular frequency).
    now i want a logic that can generate various look-up tables for me from one table during run time. for sample purpose, i am posting to tables here, one for 50hz output frequency and other for 10hz output frequency. if anyone can help, kindly reply.
    fiftyyy=[0, 2, 3, 5, 7, 8, 10, 11, 13, 15, 16, 17, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31, 32, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33, 32, 31, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 20, 19, 17, 16, 15, 13, 11, 10, 8, 7, 5, 3, 2];


    ten=[0, 9, 17, 26, 34, 42, 51, 59, 67, 74, 82, 89, 97, 104, 110, 117, 123, 129, 135, 140, 145, 149, 153, 157, 161, 164, 167, 169, 171, 172, 173, 174, 174, 174, 173, 172, 171, 169, 167, 164, 161, 157, 153, 149, 145, 140, 135, 129, 123, 117, 110, 104, 97, 89, 82, 74, 67, 59, 51, 42, 34, 26, 17, 9];


    i have fifty such tables but i just can use one table as static memory of the program, all other tables have t0 be generated during run time. kindly help if u can.
     
  2. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    Surely you need only one table, regardless of frequency? Just change the table read rate to vary frequency.
     
  3. bilal sheikh

    Thread Starter New Member

    Jan 21, 2015
    22
    0
    well, thanks for ur rply, i need a different table for each and every frequency, however , i can only define one table in the program. rest of the tables are to be generated during run time.
     
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    What Alec_t suggested is the normal approach, though you'd need to modify your table.

    Is there a particular reason you want to generate a whole new table on the fly? By using that approach, you are severely limiting your maximum frequency...
     
  5. bilal sheikh

    Thread Starter New Member

    Jan 21, 2015
    22
    0
    thank u for ur valuable suggestions, can u further suggest what should i do than ? to vary frequency using a pic18f4431, u had to control two FSRs
    1) PR2 register (i have controlled it using adc, any value can be generating by reading output of an adc)
    2) duty cycle register, ( ccpr1 ) for which look-up table should be generated (i am stuck on it).
    can u suggest something ?
     
  6. bilal sheikh

    Thread Starter New Member

    Jan 21, 2015
    22
    0
    sorry but i m not getting ur point, can u please elaborate ? i am duffer, thank u 4 ur help :)
     
  7. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Typically, you would set up a single period of your waveform in a lookup table with the rate at which you read and update the output is how you vary signal frequency.

    I did, however, find this article talking about doing the calculation on the fly.
     
  8. jjw

    Member

    Dec 24, 2013
    173
    31
    Google DDS ( direct digital synthesizer)
    With a Pic you can make a sine up to a few tens kHz with a resolution better than 1Hz and with only one sine table.
    AVR dds generator: http://www.myplace.nu/avr/minidds/
     
    Last edited: Mar 22, 2015
    bilal sheikh likes this.
Loading...