PWM doesn't work right - Arduino NANO

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

PWM doesn't work right - Arduino NANO

Postby rradojko » Fri Nov 22, 2019 10:32 pm

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.
Attachments
PWM arduino test.jpg
pwm
PWM arduino test.jpg (105.44 KiB) Viewed 178 times

User avatar
Benj
Matrix Staff
Posts: 14363
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4444 times
Been thanked: 4144 times
Contact:

Re: PWM doesn't work right - Arduino NANO

Postby Benj » Mon Nov 25, 2019 12:10 pm

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.
These users thanked the author Benj for the post:
rradojko (Tue Nov 26, 2019 1:38 pm)
Rating: 5.26%
 

Docara
Posts: 306
Joined: Sun Jun 23, 2013 1:29 pm
Has thanked: 28 times
Been thanked: 60 times
Contact:

Re: PWM doesn't work right - Arduino NANO

Postby Docara » Mon Nov 25, 2019 2:43 pm

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.
These users thanked the author Docara for the post (total 2):
rradojko (Tue Nov 26, 2019 1:48 pm) • chipfryer27 (Sun Dec 01, 2019 12:42 pm)
Rating: 10.53%
 

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: PWM doesn't work right - Arduino NANO

Postby rradojko » Tue Nov 26, 2019 1:53 pm

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.