Page 1 of 1

PWM doesn't work right - Arduino NANO

Posted: Fri Nov 22, 2019 10:32 pm
by rradojko
I use an Arduino Nano.
I put together a PWM test program (Look at the picture).
On the PD6 pin I want a PWM 2kHz frequency.
I measured the frequency with a Seale Logic Logic Analyzer. The frequency on the PD6 pin is 490.3Hz.
PWM is not working properly.

What am I doing wrong?
How to adjust the 2kHz frequency with the Arduino Nano (Atmega328)?

Thanks for the reply.

Re: PWM doesn't work right - Arduino NANO

Posted: Mon Nov 25, 2019 12:10 pm
by Benj
Hello,

The ATMEGA328 used on the Nano does not have a period register and so it can only use the period overflow value 255. In later versions of Flowcode we generate a warning message to inform the user of the lack of hardware capability.

Re: PWM doesn't work right - Arduino NANO

Posted: Mon Nov 25, 2019 2:43 pm
by Docara
Hi rradojko,

In addition to what Ben posted, coincidentally, I have just watched a video by Eevblog (I think it was on the series he did about the 3 cent MCU) he programmed a blink LED function and showed the output on the same type of logic analyser you are using -Silae and it's clones, He said that there are often issues "A trap for young players" as he called it that the timing of the sample rate and the corresponding output display values are wrong, they are not part of the 'proper' signal being investigated.

From memory I think these were mainly extended pulses or wrong period reading that type of thing.

Re: PWM doesn't work right - Arduino NANO

Posted: Tue Nov 26, 2019 1:53 pm
by rradojko
Benj wrote:Hello,

The ATMEGA328 used on the Nano does not have a period register and so it can only use the period overflow value 255. In later versions of Flowcode we generate a warning message to inform the user of the lack of hardware capability.
Thanks for the reply.
Is it possible to use timer 2 on Arduino Nano?
Docara wrote:Hi rradojko,

In addition to what Ben posted, coincidentally, I have just watched a video by Eevblog (I think it was on the series he did about the 3 cent MCU) he programmed a blink LED function and showed the output on the same type of logic analyser you are using -Silae and it's clones, He said that there are often issues "A trap for young players" as he called it that the timing of the sample rate and the corresponding output display values are wrong, they are not part of the 'proper' signal being investigated.

From memory I think these were mainly extended pulses or wrong period reading that type of thing.
Thanks for the information. I'm using a Chinese clone logic analyzer. I'll look at EEVBlog.
I'll check the signal with an oscilloscope.