PWM Flowcode v4

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
cobbp
Posts: 2
Joined: Thu Dec 02, 2010 7:35 pm
Contact:

PWM Flowcode v4

Post by cobbp »

Hello,
I was wondering if anyone could provide instructions for creating a flowcode program that will enable PWM and send this signal to an output pin. Is there any way to accomplish this using only the blocks in flowcode?

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8924
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: PWM Flowcode v4

Post by medelec35 »

Hello cobbp
First make sure you have Target Speed in project options correctly set .
Now go to Mechatronics menu and select PWM

It will then place an PWM component on to your panel
If You can't see your panel , then go to view menu and select panel.

If you have only 1 pwm on your target then you will see a single PWM component on your panel
If you have 2 pwm's or more on your target then you will see a dual PWM component on your panel

On the PWM on your Panel, Right click and select Ext properties. Change Clock source and period register to give desired PWM frequency.
Drag a component macro onto main of your flowchart.
Double click it and select PWM(0) Enable, then in ndlx(byte) place a number 1. This is for pwm channel1. If you have two pwm channels on your target device then ndlx(byte) could be 1 for CCP1 or 2 for CCP2.
This should be placed at the top of your Flowchart, so it is only accessed once.
Place a loop after the Enable.
Within this loop will be your main program
Drag another component macro, double click, then select either SetDutyCycle or SetDutyCycle 10bit.
Now you need to place the PWM channel number for ndlx(byte) and the duty value. e.g 1,50

Note the pwm o/p will be present at the CCP1 pin for PWM channel 1 and CCP2 for channel 2.
To take thing further, you can select an ADC component, read the value then place value into a variable, you can then use this ADC variable to directly alter PWM duty.
Have you followed the tutorials for flowcode?
Hope this gives you a starting point.
If you get stuck, post your flowchart, and state what frequency your osc is running at, and someone assist you further.
Good luck.
Martin

cobbp
Posts: 2
Joined: Thu Dec 02, 2010 7:35 pm
Contact:

Re: PWM Flowcode v4

Post by cobbp »

Thanks, I really appreciate the help. I'll try this out.

P.S. I don't think my copy of the software has a PWM tutorial... Is there any other place it could be found?

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8924
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: PWM Flowcode v4

Post by medelec35 »

Your welcome.
If you want a pwm example, then go to:
http://www.matrixmultimedia.com/Flowcode3a-X.php
Scroll down to
Flowcode V4:
Flowcode Examples

Within the zip file there is an example that show you how to control the duty of a PWM signal with a variable resistor.
Martin

Post Reply