Hello everyone,
I would like to use two different PWM frequencies in one project. I'm using the Arduino NANO. From pin 3 I will use the 100 HZ frequency and from pin 9 200 HZ frequency.
My project is a robot that drives from one place to another place using this two modulation frequencies. The project have to work in this both frequencies but in order to chose the specific frequency in real time the requirement is to do it without changing the software.
Thanks' in advance.
1. Fig-1 says that you are going to generate 100 Hz at DPin-3 using 8-bit TC2 and 200 Hz at DPin-9 using 16-bit TC1.
Figure-1:
2. Let us choose Mode-14 for TC1 to genertae 200 Hz Fast PWM at DPin-9.
Figure-2:
3. The frequency equation for the single slope Fast PWM signal of Stp-2 is:
fpwm = sysClk/(N*(1+TOP))
where:
sysClk = MCU Clock = 16 000 000 Hz
TOP = Contnet of ICR1 Register to detrmine (regulate) 200 Hz PWM frequency
N = TC1 Clock Prescaler (choose suitable one) from Fig-3 to get 200 Hz.
Figure-2:
4. Based on the above information, write some codes to load appropriate values into TCCR1A, TCCR1B, and ICR1 Registers to generate 200 Hz PWM signal at DPin-9.
Figure-3:
5. The duty cycle of the PWM signal can be regulated using OCR1A Register.
Please clarify which Arduino board you are using, bearing in mind the forum category in which you have posted your question
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.