Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[SOLVED] V/F control help in frequency control

Status
Not open for further replies.

abc_de

Full Member level 4
Joined
Jan 9, 2014
Messages
200
Helped
11
Reputation
22
Reaction score
11
Trophy points
18
Location
Ludhiana ਪੰਜਾਬ
Activity points
1,375
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
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,372
Helped
4,727
Reputation
9,469
Reaction score
4,496
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,634
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.
 

abc_de

Full Member level 4
Joined
Jan 9, 2014
Messages
200
Helped
11
Reputation
22
Reaction score
11
Trophy points
18
Location
Ludhiana ਪੰਜਾਬ
Activity points
1,375
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
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,372
Helped
4,727
Reputation
9,469
Reaction score
4,496
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,634
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.
 

abc_de

Full Member level 4
Joined
Jan 9, 2014
Messages
200
Helped
11
Reputation
22
Reaction score
11
Trophy points
18
Location
Ludhiana ਪੰਜਾਬ
Activity points
1,375
hello
i am sure cro gives accurate result. also cross check with transformer out put
its really arround 35hz :(
 

abc_de

Full Member level 4
Joined
Jan 9, 2014
Messages
200
Helped
11
Reputation
22
Reaction score
11
Trophy points
18
Location
Ludhiana ਪੰਜਾਬ
Activity points
1,375
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.
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,372
Helped
4,727
Reputation
9,469
Reaction score
4,496
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,634
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.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top