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

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

50Hz PWM

Postby saad.sharif » Sun Nov 17, 2013 9:56 pm

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: 14676
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4660 times
Been thanked: 4286 times
Contact:

Re: 50Hz PWM

Postby Benj » Mon Nov 18, 2013 5:24 pm

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

Postby saad.sharif » Mon Nov 18, 2013 6:32 pm

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

Postby brandonb » Mon Nov 18, 2013 9:27 pm

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 442 times

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

Re: 50Hz PWM

Postby saad.sharif » Mon Nov 18, 2013 10:05 pm

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

Postby saad.sharif » Mon Nov 18, 2013 10:52 pm

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

Postby brandonb » Tue Nov 19, 2013 3:05 am

here you are, this is a 50hz pwm 0-100% sweep program set up for your chip
YOUR PWM.fcf
(9.5 KiB) Downloaded 437 times
cheers
These users thanked the author brandonb for the post (total 3):
medelec35 (Tue Nov 19, 2013 7:59 am) • saad.sharif (Tue Nov 19, 2013 9:35 am) • Benj (Tue Nov 19, 2013 10:54 am)
Rating: 15%
 

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

Re: 50Hz PWM

Postby saad.sharif » Tue Nov 19, 2013 9:37 am

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

Postby saad.sharif » Tue Nov 19, 2013 4:16 pm

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

Postby brandonb » Tue Nov 19, 2013 8:14 pm

when i get off work will get that done for you
These users thanked the author brandonb for the post:
saad.sharif (Tue Nov 19, 2013 8:42 pm)
Rating: 5%
 

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

Re: 50Hz PWM

Postby saad.sharif » Wed Nov 20, 2013 9:01 pm

Hello brandonb,

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


saad sharif

have a nice day..!

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8615
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2480 times
Been thanked: 3564 times
Contact:

Re: 50Hz PWM

Postby medelec35 » Wed Nov 20, 2013 10:00 pm

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
These users thanked the author medelec35 for the post:
saad.sharif (Thu Nov 21, 2013 7:47 pm)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: 50Hz PWM

Postby saad.sharif » Thu Nov 21, 2013 7:47 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8615
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2480 times
Been thanked: 3564 times
Contact:

Re: 50Hz PWM

Postby medelec35 » Thu Nov 21, 2013 7:58 pm

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

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: 50Hz PWM

Postby saad.sharif » Thu Nov 21, 2013 8:18 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8615
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2480 times
Been thanked: 3564 times
Contact:

Re: 50Hz PWM

Postby medelec35 » Mon Nov 25, 2013 10:57 pm

Hi saad.sharif,
You can try this Flowchart

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.