logic to generate variable frequency output.

Thread Starter

bilal sheikh

Joined Jan 21, 2015
22
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.
 

Alec_t

Joined Sep 17, 2013
14,280
i have one sine look up table and have to generate various such tables during run time(each table corresponds to a particular frequency).
Surely you need only one table, regardless of frequency? Just change the table read rate to vary frequency.
 

Thread Starter

bilal sheikh

Joined Jan 21, 2015
22
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.
 

tshuck

Joined Oct 18, 2012
3,534
[...]i need a different table for each and every frequency[...]
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...
 

Thread Starter

bilal sheikh

Joined Jan 21, 2015
22
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...
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 ?
 

tshuck

Joined Oct 18, 2012
3,534
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.
 
Top