Hello,
I want a PWM frequency of 4.1KHz. I am using Flowcode9 and Arduino Nano (Atmega328)
But, whatever I type in the Overflow Period, the PWM frequency does not change (see picture).
Where is the problem?
I want a PWM frequency of 4.1KHz.
-
- Posts: 4
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 24, 2020 9:54 am
I want a PWM frequency of 4.1KHz.
- Attachments
-
- PWM_FC9_1.jpg (114.67 KiB) Viewed 6815 times
-
- PWM_FC9_0.jpg (119.14 KiB) Viewed 6815 times
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: I want a PWM frequency of 4.1KHz.
Hello,
When compiling to chip you likely are getting a warning that your target device doesn't have a period register, hence the value cannot be changed on your device from the default value of 256. I'll see if I can make this more obvious in the component as I'm sure it's very frustrating.
When compiling to chip you likely are getting a warning that your target device doesn't have a period register, hence the value cannot be changed on your device from the default value of 256. I'll see if I can make this more obvious in the component as I'm sure it's very frustrating.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: I want a PWM frequency of 4.1KHz.
Hello,
Thanks Ben for the answer.
I tried compiling again.
Really issue a warning "Period control register not available on target device, period will default to 255 + 1"
It would be good if the warning was written in red.
I would ask you if you can find a solution to this. The Atmega328 is a very popular processor.
Now I can only select 5 different PWM frequencies. This choice is too small. This is very disturbing.
Thank you and have a nice day.
Thanks Ben for the answer.
I tried compiling again.
Really issue a warning "Period control register not available on target device, period will default to 255 + 1"
It would be good if the warning was written in red.
I would ask you if you can find a solution to this. The Atmega328 is a very popular processor.
Now I can only select 5 different PWM frequencies. This choice is too small. This is very disturbing.
Thank you and have a nice day.
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: I want a PWM frequency of 4.1KHz.
Hello I'm afraid it's a limitation of the atmega328 hardware and not the software. You could maybe create software based pwm using a timer interrupt to give you more control over the output frequency.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: I want a PWM frequency of 4.1KHz.
All right, I understand.
I also tried PWM chanel 3. PWM chanel 3 uses timer1.
Timer1 has multiple registers to set up and is 16bit.
Unfortunately, timer1 does not work either.
Although the datasheet says "Timer1 Variable PWM period".
Why doesn't PWM work? There is no pwm signal on PORT B3.
Thank you and have a nice day.
I also tried PWM chanel 3. PWM chanel 3 uses timer1.
Timer1 has multiple registers to set up and is 16bit.
Unfortunately, timer1 does not work either.
Although the datasheet says "Timer1 Variable PWM period".
Why doesn't PWM work? There is no pwm signal on PORT B3.
Thank you and have a nice day.
- Attachments
-
- variable PWM period.JPG (83.2 KiB) Viewed 6763 times
Re: I want a PWM frequency of 4.1KHz.
I tried again.
If I select PWM Chanel3 there is no more warning "Period control register not available on target device, period will default to 255 + 1"
There is no PWM signal on port B1.
What is wrong?
I am also attaching a test program.
If I select PWM Chanel3 there is no more warning "Period control register not available on target device, period will default to 255 + 1"
There is no PWM signal on port B1.
What is wrong?
I am also attaching a test program.
- Attachments
-
- PWM_RR_9ka.fcfx
- (8.18 KiB) Downloaded 534 times
-
- opozorilo prevajalnika.jpg (32.16 KiB) Viewed 6749 times
Re: I want a PWM frequency of 4.1KHz.
PWM doesn't work at all for me either. Arduino Nano. Chanel1-6, nothing. Please help me.
-
- Matrix Staff
- Posts: 1923
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 623 times
- Been thanked: 645 times
Re: I want a PWM frequency of 4.1KHz.
Hello.
Unfortunately, a screenshot does not help.
For any issues, can you please attach your fcfx project.
For example, if the ADC component was set to AREF and you have not connected a jumper from AREF to 5V, then PWM will not work as expected.
Without a jumper, you will need to set AREF to AVCC.
I have done that in the attached project, which works on hardware.
If you want a wider frequency range, then you will need a timer-based interrupt PWM as Ben has suggested in an above post.
Unfortunately, a screenshot does not help.
For any issues, can you please attach your fcfx project.
For example, if the ADC component was set to AREF and you have not connected a jumper from AREF to 5V, then PWM will not work as expected.
Without a jumper, you will need to set AREF to AVCC.
I have done that in the attached project, which works on hardware.
If you want a wider frequency range, then you will need a timer-based interrupt PWM as Ben has suggested in an above post.
- Attachments
-
- Nano 328 PWM 1.fcfx
- (11.01 KiB) Downloaded 419 times
Martin
Re: I want a PWM frequency of 4.1KHz.
Hello.
After I switched the potentiometer to AVCC, it worked right away.
Thank you very much!
After I switched the potentiometer to AVCC, it worked right away.
