PWM doesn't work right - Arduino NANO

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

Moderator: Benj

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

PWM doesn't work right - Arduino NANO

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

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

Re: PWM doesn't work right - Arduino NANO

Post 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.

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

Re: PWM doesn't work right - Arduino NANO

Post 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.

rradojko
Posts: 40
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

Post 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.

Post Reply