PDA

View Full Version : 40hz to 400hz PWM ?



bennettdan
05-26-2010, 11:49 PM
Hello Forum
··
··· I am new to Prop and i am trying to output a single 40hz to 400hz square wave with 1-99% duty cycle and i can not seem to find info on how to do this. I have looked through the OBEX and found that the code examples are hard for me to follow being new to the Prop. Thanks

Bobb Fwed
05-26-2010, 11:55 PM
Try this (attached). I use it all the time. It uses a cog, which is a bit of a waste (there may be ways to do it with the counters), but it does the job.

All you need to do is include the object in your project then call the start method with your pin, frequency, and duty (misspelled dudy).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!

Some of my objects:
MCP3X0X ADC Driver (http://obex.parallax.com/objects/488/) - Programmable Schmitt inputs, frequency reading, and more!
Simple Propeller-based Database (http://obex.parallax.com/objects/493/) - Making life easier and more readable for all your EEPROM storage needs.
String Manipulation Library (http://obex.parallax.com/objects/543/) - Don't allow strings to be the bane of the Propeller, bend them to your will!
Fast Inter-Propeller Comm (http://obex.parallax.com/objects/546/) - Fast communication between two propellers (1.37MB/s @100MHz)!

hover1
05-27-2010, 12:09 AM
If you want to explore PWM using counters, The Propeller Education Kit Labs has a good section on PWM, chapter 7:

·http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PELabsFunBook-v1.1.pdf

Also the Application note AN001 on this page:

·http://www.parallax.com/tabid/832/Default.aspx

is a good read.

Jim

bennettdan
05-27-2010, 01:01 AM
Thanks for the code.... Bobb

I will read the Propeller Education Kit Lab ...Jim

pjv
05-27-2010, 01:06 AM
bennettdan;

I believe Hanno's "12 Blocks" is a very good canidate for this. Download it and you'll be up and running in less than 5 minutes...... it's THAT intuitive!

Cheers,

Peter (pjv)

hover1
05-27-2010, 01:22 AM
Peter,

I was going to suggest 12Blocks also, but I didn't think there was a trial period, but there is! 30 days.

2nd the 12 Blocks!!

Jim


pjv said...
bennettdan;

I believe Hanno's "12 Blocks" is a very good canidate for this. Download it and you'll be up and running in less than 5 minutes...... it's THAT intuitive!

Cheers,

Peter (pjv)

bennettdan
05-27-2010, 08:33 AM
Bobb,

Start (1,50,400)

Would this be a 50% duty cycle 400 hz PWM signal on Pin 1 if I understand your obj.

Bobb Fwed
05-27-2010, 08:52 AM
The order is pin, frequency, then duty.

So what you want is

start(1, 400, 50)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!

Some of my objects:
MCP3X0X ADC Driver (http://obex.parallax.com/objects/488/) - Programmable Schmitt inputs, frequency reading, and more!
Simple Propeller-based Database (http://obex.parallax.com/objects/493/) - Making life easier and more readable for all your EEPROM storage needs.
String Manipulation Library (http://obex.parallax.com/objects/543/) - Don't allow strings to be the bane of the Propeller, bend them to your will!
Fast Inter-Propeller Comm (http://obex.parallax.com/objects/546/) - Fast communication between two propellers (1.37MB/s @100MHz)!