[SOLVED] V/F control help in frequency control

Status
Not open for further replies.

abc_de

Full Member level 5
Joined
Jan 9, 2014
Messages
243
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Location
Ludhiana ਪੰਜਾਬ
Activity points
2,939
hello i am working on an900 code but i am not getting exact frequency from formula as mention in an900 app note

formula is
CALCULATING TIMER0 RELOAD VALUE

imer0 Reload Value = FFFFh –[(FOSC/4)/(2 • (sine table entries – 1)) × Timer0 prescaler value × f]

but i am getting 35hz even i am compute the equation for 50hz

thanks in advance
 

Check you have Timer0 configured in 16-bit mode. It can be set to 8-bit or 16-bit. If you use that calculation in 8-bit mode you will get the wrong result.

Brian.
 

hello
i am using pic18f4431, timer0 is configured in 16bit mode
1) FOSC = 8mhz ,
2) Timer0 prescaler value =4
3) sine table entries=32
4) f=50hz


according to equation it gives 161 counts timer0 load value 65374

- - - Updated - - -

which is correct i have checked it in this way

internal clock = 8MHZ/4=2MHZ

internal clock frequency 1/2MHZ = 0.0000005 SEC


timer0 roll over time= 0.0000005 x 161 x 4=0.000322 sec

total time to cover 62 sine entries
0.000322 x 62 =0.019964 sec

hence frequency = 1/(0.019964) = 50.90HZ

but i have check my output on CRO it gives 35.5HZ around
please support me thank you
 

Your math seems fine. A CRO isn't the best instrument for measuring frequency, are you sure it is accurate? Can you use a frequency counter or alternatively, if you have a dual trace CRO, can you apply 50Hz AC from a mains transformer to the second trace and see if they align about once per second?

Brian.
 

hello
i am sure cro gives accurate result. also cross check with transformer out put
its really arround 35hz
 

hello Betwixt
i am very thankful for your support.
i just simulate my source code in MPLAB SIM debugger then i found so much time has been wasted in ISR Routine which was actual cause of lack in frequency 36HZ.
after that i have minimize my code so that CPU could not waste too much time in ISR. then i got desire frequency not highly accurate like 49 HZ at 50 HZ
I am very thankful for you support.
if you want to study my code then i can post it.
 

Well done.
Always try to keep processing inside an ISR to a minimum.
Please don't post your code - I'm already up to my neck in work :lol:

Brian.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…