View previous topic :: View next topic |
Author |
Message |
kamol
Joined: 02 Dec 2007 Posts: 33
|
Posted: Sun Nov 13, 2011 6:37 am Post subject: PWM releted |
|
|
Dear all,
please some one make me clear about Compare1a,Compare1b and Pwm1a, Pwm1b.
defining value for Compare1a and Pwm1a same thing?
regards,
Kamol |
|
Back to top |
|
|
kamol
Joined: 02 Dec 2007 Posts: 33
|
Posted: Mon Nov 14, 2011 4:48 am Post subject: |
|
|
please replay some one |
|
Back to top |
|
|
Visovian
Joined: 31 Oct 2007 Posts: 584 Location: Czech
|
Posted: Mon Nov 14, 2011 6:51 am Post subject: |
|
|
Quote: | defining value for Compare1a and Pwm1a same thing?
| Yes.
From help CONFIG TIMER1:
Quote: | 'to set the PWM registers, just assign a value to the compare A and B registers
Compare1a = 100
Compare1b = 200
'Or for better reading :
Pwm1a = 100
Pwm1b = 200 |
|
|
Back to top |
|
|
kamol
Joined: 02 Dec 2007 Posts: 33
|
Posted: Tue Nov 15, 2011 4:43 am Post subject: |
|
|
can any one post a timer configuration for 50Hz pwm with 8Mhz and 16Mhz crystal. |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Tue Nov 15, 2011 8:00 am Post subject: |
|
|
You will have to do a bit of low level math work yourself.
If you want to do a 50 Hz PWM then it is not possible with the clock frequencies you mention and the ready made PWM commands at a high resolution (16 bit).
The Frequency depends on the ability to do a full cycle of the required F. at a certain prescale and clock at a certain resolution (8 or 16 bit timer) and the required resolution.
The available clock prescales determine the resolution.
The best way to start: determine the required resolution. Then set the prescale depending on that and use the suitable timer to switch the output depending on the count compare.
For 50 Hz you can even use an RTC interrupt (with frequency output) to have a perfect frequency base and use the timer interrupt for the PWM.
If you search the forum, there are many samples available.
BTW this is the wrong section of the forum to post you request.
Hubert |
|
Back to top |
|
|
kamol
Joined: 02 Dec 2007 Posts: 33
|
Posted: Wed Nov 16, 2011 5:28 am Post subject: |
|
|
it is possible to do Phase and frequency Correct PWM with bascom? |
|
Back to top |
|
|
kamol
Joined: 02 Dec 2007 Posts: 33
|
Posted: Thu Nov 17, 2011 4:36 am Post subject: |
|
|
please response some one |
|
Back to top |
|
|
kamol
Joined: 02 Dec 2007 Posts: 33
|
Posted: Sun Nov 20, 2011 4:41 am Post subject: |
|
|
no one replaied |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Sun Nov 20, 2011 7:23 am Post subject: |
|
|
Nobody replies because the information you are looking for is readily available in the HELP files and the Atmel data sheet of the controller in question.
Bascom can write and read to any register, therefore Bascom can do it. The question shoud read: Can you (IN YOUR CASE "I") do it?
In this case you have to do the learning yourself.
This is not a teaching and make it easy forum... it is a help forum.
Especially this section of the forum is for HELP IF YOU HAVE PROBLEMS WITH YOUR CODE that you post here.
In the previous answer I mentioned it to you but there seems to be some ignorance involved (and you are not the only one).
You find the answer in the timer section of the data sheet.
Mark Alberts seems to be very tolerant of wrongly posted questions, try to keep it in the correct section.
Hubert |
|
Back to top |
|
|
sunnyiut
Joined: 27 Nov 2011 Posts: 3 Location: Dhaka, Bangladesh
|
Posted: Sun Nov 27, 2011 7:32 pm Post subject: pwm related |
|
|
Quote: | ##defining value for Compare1a and Pwm1a same thing? |
--> yes, by defining the COMPARE value, u r just setting up the PWM register
Quote: | ##it is possible to do Phase and frequency Correct PWM with bascom? |
--> u can generate pretty much precise PWM with variable duty cycle and frequency - with BASCOM
Quote: | ##can any one post a timer configuration for 50Hz pwm with 8Mhz and 16Mhz crystal. |
--> I don't know about the uC u r using and also the timer inside. I am gonna take AtMega32 uC and TIMER1 for generating PWM here.
First of all u need know how to calculate PWM for AtMega32. Not going for detail, just the basic only---
the equation is
PWM FREQUENCY = {Frequency of crystal osc/(N*256)}
'256' represents 8bit PWM, N = Prescale value (can be 1,8,64,256,1024)
Now think a little bit - as u have mentioned ur crystal frequencies - 8 and 16MHz, its not possible to get 50Hz PWM according to the above mentioned formula. In this case u need a crystal of 3.2768MHz [considering N=256]. I know its not available in local market.
What I can suggest u is that - if u can change the PWM frequency a little [i.e. 54.6 Hz]. In that case u r crystal will be of 3.579MHz, which is available. |
|
Back to top |
|
|
sunnyiut
Joined: 27 Nov 2011 Posts: 3 Location: Dhaka, Bangladesh
|
Posted: Sun Nov 27, 2011 7:44 pm Post subject: pwm related |
|
|
Timer1 configuration for Atmega32, where-
PWM frequency = 54.6Hz
Prescale = 256
PWM = 8bit PWM
Crystal = 3.579MHZ [external]
___________________________________________
Config Timer1 = Pwm , Pwm = 8 , Prescale = 256 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down
....
....
Start Timer1
Pwm1a = 128 'gives u 50% duty cycle
....
....
___________________________________________
i have registered in this forum just to reply ur post - donno whether u have found it helpful or not - keep in touch |
|
Back to top |
|
|
kamol
Joined: 02 Dec 2007 Posts: 33
|
Posted: Mon Nov 28, 2011 4:58 am Post subject: |
|
|
Dear sunnyiut,
thnaks for your replay. As you are Bangladeshi better to touch with you.
how can I keep touch with you?
thanks
Kamol |
|
Back to top |
|
|
sunnyiut
Joined: 27 Nov 2011 Posts: 3 Location: Dhaka, Bangladesh
|
Posted: Mon Nov 28, 2011 4:25 pm Post subject: pwm related |
|
|
was that helpful for u?
if u have any query feel free to mail me. i'll try my best to share with u, whatever i know.
email id --> sunnyiut@gmail.com |
|
Back to top |
|
|
kamol
Joined: 02 Dec 2007 Posts: 33
|
Posted: Tue Nov 29, 2011 5:49 am Post subject: |
|
|
it was very helpful for me. I have send you a mail. please see the mail... |
|
Back to top |
|
|
|