PWM Woes

For general Flowcode discussion that does not belong in the other sections.
alanwms
Posts: 144
http://meble-kuchenne.info.pl
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

PWM Woes

Post by alanwms »

Attempting to do a small test with PWM on FC10 with PIC12f1840. I can't get a scope signal on the PWM using simulator. Any ideas? See attached test

medelec35
Matrix Staff
Posts: 1950
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 624 times
Been thanked: 656 times

Re: PWM Woes

Post by medelec35 »

Hi Alan.
It looks like the attachment has not been added.
Martin

alanwms
Posts: 144
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: PWM Woes

Post by alanwms »

I don't know how to attach anymore?

alanwms
Posts: 144
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: PWM Woes

Post by alanwms »

Here it is
Attachments
PWM CODE.fcfx
(9.96 KiB) Downloaded 13 times

chipfryer27
Valued Contributor
Posts: 1543
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 352 times
Been thanked: 551 times

Re: PWM Woes

Post by chipfryer27 »

Hi

In your component properties you forgot to assign your PWM timer.

Once assigned (in this case timer 2) you can then base your duty cycle on your Period value. You have chosen 1000Hz which FC calculates out as Prescaler = 64 and Period = 77 for your oscillator values (external, 20MHz).

I usually set this in the chart too.

You can then figure out your values to give 0-100% cycles based on your PIC capabilities.

Regards

alanwms
Posts: 144
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: PWM Woes

Post by alanwms »

I tried that a few times. Currently I have tmr2 assigned. but the simulated scope shows a dead line. Pic chip is 12f1840
Last edited by alanwms on Mon May 12, 2025 10:09 pm, edited 1 time in total.

alanwms
Posts: 144
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: PWM Woes

Post by alanwms »

Scope meaning the simulated scope in FC

chipfryer27
Valued Contributor
Posts: 1543
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 352 times
Been thanked: 551 times

Re: PWM Woes

Post by chipfryer27 »

Hi

I have no access to hardware at present but the component gave the correct responses to my test values when simulating. If I get time later I'll look at "scope", but did you set it on the correct pin?

Regards

alanwms
Posts: 144
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: PWM Woes

Post by alanwms »

I have no hardware at this time. I'm simply attempting to assure operation using the scope component so I can verify theoretical output. I may hook up the chip for test if I can't get the simulation scope to play.
I assigned multiple pins to the scope thinking that the incorrect pin was allocated - no luck. All four traces dead. No pins worked for me. I am pretty sure I'm not setting something in FC?

medelec35
Matrix Staff
Posts: 1950
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 624 times
Been thanked: 656 times

Re: PWM Woes

Post by medelec35 »

Hello.
many thanks for letting us know.
I can replicate the issue.
I will look into this and see if I can set it sorted.
Martin

Post Reply