50Hz PWM

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
saad.sharif
Posts: 16
Joined: Sun Nov 10, 2013 12:35 pm
Has thanked: 4 times
Been thanked: 1 time

50Hz PWM

Post by saad.sharif »

please any one can tell me how to make 50 Hz with pwm in flowcode.... i am using 4MHZ crystal please kindly tell... i shall be very thankful to you.....

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: 50Hz PWM

Post by Benj »

Hello,

I moved the post as it seems to be relating to a new topic.

Which version of Flowcode are you using? I think the Hardware PWM will not run this slow but it should be possible using a timer based software driven PWM.

saad.sharif
Posts: 16
Joined: Sun Nov 10, 2013 12:35 pm
Has thanked: 4 times
Been thanked: 1 time

Re: 50Hz PWM

Post by saad.sharif »

HELLO

i am using flowcode version 5.1...

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: 50Hz PWM

Post by brandonb »

you'll have to set if up for your chip, and change c code to

Code: Select all

t2con=4; pr2=199;
YOUR PWM.fcf
(13.23 KiB) Downloaded 713 times

saad.sharif
Posts: 16
Joined: Sun Nov 10, 2013 12:35 pm
Has thanked: 4 times
Been thanked: 1 time

Re: 50Hz PWM

Post by saad.sharif »

HELLO

sir i am having 4 MHZ crystal and 16f887 pic micro controller... plz can u draw it with my requirements please...
i shall b thank full to you..

saad.sharif
Posts: 16
Joined: Sun Nov 10, 2013 12:35 pm
Has thanked: 4 times
Been thanked: 1 time

Re: 50Hz PWM

Post by saad.sharif »

hello brandonb


it is not working ....

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: 50Hz PWM

Post by brandonb »

here you are, this is a 50hz pwm 0-100% sweep program set up for your chip
YOUR PWM.fcf
(9.5 KiB) Downloaded 726 times
cheers

saad.sharif
Posts: 16
Joined: Sun Nov 10, 2013 12:35 pm
Has thanked: 4 times
Been thanked: 1 time

Re: 50Hz PWM

Post by saad.sharif »

hello

sir if i want to add adc with 0-100% sweep .... please can you do it for me....
and thanks for the 50 hz...
saad shaarif

saad.sharif
Posts: 16
Joined: Sun Nov 10, 2013 12:35 pm
Has thanked: 4 times
Been thanked: 1 time

Re: 50Hz PWM

Post by saad.sharif »

hello mr brandonb,

sorry for disturbing you again again... sir i want to to out puts.. which work one by one for example if port A5 is 1 then port A2 is 0 and when port A5 is 0 then port A2 is 1... in this way i want 50 hz... and duty cycle must same on both ports...

please can u draw it for me....

and i have added adc to your pwm that you uploaded it i just want to see how you add adc with it...

saad sharif..
have a nice day sir..!

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: 50Hz PWM

Post by brandonb »

when i get off work will get that done for you

saad.sharif
Posts: 16
Joined: Sun Nov 10, 2013 12:35 pm
Has thanked: 4 times
Been thanked: 1 time

Re: 50Hz PWM

Post by saad.sharif »

Hello brandonb,

please kindly help me i am waiting...... is there any problem for you to do....


saad sharif

have a nice day..!

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 50Hz PWM

Post by medelec35 »

Hi saad ,
All you will need to do is use an ADC component (ReadAsByte)
use a formula to convert from 0 - 255 to 0 - 100
assigned the result to a variable called pwm.
Finally delete

Code: Select all

pwm = pwm + 1
calculation box.
Then you will have a pwm duty thats will be controlled by ADC pot.

Can you please give it a go, then if your stuck, you can post flowchart for further assistance.

Martin
Martin

saad.sharif
Posts: 16
Joined: Sun Nov 10, 2013 12:35 pm
Has thanked: 4 times
Been thanked: 1 time

Re: 50Hz PWM

Post by saad.sharif »

HI MARTIN

i have done it as you told.. but i want two outputs of 50 hz pwm with the same duty cycle on both ports..
can you help me for that.


saad sharif
have a nice day.!

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 50Hz PWM

Post by medelec35 »

If you post a flowchart, with your modifications, what you want can be easily modified for you.

Martin
Martin

saad.sharif
Posts: 16
Joined: Sun Nov 10, 2013 12:35 pm
Has thanked: 4 times
Been thanked: 1 time

Re: 50Hz PWM

Post by saad.sharif »

Here is it...
Attachments
50 Hz PWM with ADC.fcf
(16 KiB) Downloaded 476 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 50Hz PWM

Post by medelec35 »

Hi saad.sharif,
You can try this Flowchart

Martin
Attachments
50 Hz PWM with ADC V2.fcf
(12 KiB) Downloaded 527 times
Martin

Post Reply