Page 1 of 1
Arduino PWM
Posted: Mon Jul 20, 2020 7:34 pm
by mnf
This might be me - PWM doesn't seem to work on Arduino (I tested Nano)
Using Channel 6 (Pin D3) - PWM::Enable() and PWM::SetdutyCycle(200) - just gives no output on pin.
Using Arduino IDE and pinMode(3, OUTPUT); analogWrite(3, 200); - gives a very nice square wave with 78.4% duty cycle as expected..
Am I doing something wrong - I tried various PWM channels / combinations of speeds.
Martin
How it should look:

- LabNation_Screenshot8.png (284.74 KiB) Viewed 2912 times
Re: Arduino PWM
Posted: Sat Aug 08, 2020 8:14 pm
by jgu1
Hi Martin!
You deserve an answer.

Maybe no help, but here my test.
When I test with your testprogram With cal., your rigth, no PWM out.
I made a test with the PWM component and it work. Maybe stupid question, why use the cal? I know it has something to do with creation component or simulation. I have no experience with this, probably a fault from me
Br Jorgen
Re: Arduino PWM
Posted: Sat Aug 08, 2020 9:27 pm
by mnf
Hi Jorgen,
Many thanks for that - works perfectly... Why did I use CAL - I searched for the PWM component - and it was the first I found.
Had never used PWM before.... Should have used search rather than looking through the component lists....
Martin
Re: Arduino PWM
Posted: Sun Aug 09, 2020 8:50 am
by jgu1
Hi Martin!
Glad I was able to help you and maybe a little repay with a fraction for your always helping.
Br. Jorgen.
Re: Arduino PWM
Posted: Tue Aug 11, 2020 4:12 pm
by Benj
Hello,
Glad you've got it working. Sorry for the lack of a reply.
The PWM component uses the CAL component behind the scenes but also calls the ChangePeriod function as part of the Enable macro which is probably the bit you were missing from your CAL program.