PWM using Flowcode V5

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
weatherman5
Posts: 7
Joined: Tue Jan 15, 2013 6:22 pm
Contact:

PWM using Flowcode V5

Post by weatherman5 »

Hi

I am running the free trial of Flowcode V5 and want to know if I can use it to bring an led from off to full brightness over say 0.5 second ?
I think this would be done using PWM which is built into the PIC I am using 16F628.
If I know it can be done I can purchase the full program.

Thanks, Dave

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: PWM using Flowcode V5

Post by Enamul »

Hi

It can be done in FCv5 very easily. If you want we can send you hex file so that you can test and decide to buy professional version.
Enamul
University of Nottingham
enamul4mm@gmail.com

weatherman5
Posts: 7
Joined: Tue Jan 15, 2013 6:22 pm
Contact:

Re: PWM using Flowcode V5

Post by weatherman5 »

If you could that would be very kind.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: PWM using Flowcode V5

Post by Enamul »

ok. No problem. I'll post to-night.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: PWM using Flowcode V5

Post by Enamul »

Hi

Here is the code promised. The LED need to be connected to RB3<PIN9 of PIC16f628> through 470 ohm resistor and crystal has to be external for this code which is 4MHz should be connected to 15 & 16 pin. But if you want I can tell you how to use internal clock if you need.
Attachments
PWM_LED.hex
(924 Bytes) Downloaded 417 times
PWM_LED.fcf
(8 KiB) Downloaded 843 times
Enamul
University of Nottingham
enamul4mm@gmail.com

weatherman5
Posts: 7
Joined: Tue Jan 15, 2013 6:22 pm
Contact:

Re: PWM using Flowcode V5

Post by weatherman5 »

Hi Enamul

It was very kind of you to send me the code, I will try it out.
The bit I wanted to see most was the Flowcode you also sent, but the free trial I am running is limited to just a few PIC devices, my PIC not being one of them. So it will not let me see your flow chart. Would it be possible to send me a screen shot image of the Flowcode flow chart ? That will tell me everything I need to know before purchasing the software.

Thanks, Dave

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: PWM using Flowcode V5

Post by Enamul »

Hi

Here is the screen shoots..
Attachments
config_628.PNG
(23.84 KiB) Downloaded 8267 times
pwm.PNG
(54.39 KiB) Downloaded 4444 times
Enamul
University of Nottingham
enamul4mm@gmail.com

weatherman5
Posts: 7
Joined: Tue Jan 15, 2013 6:22 pm
Contact:

Re: PWM using Flowcode V5

Post by weatherman5 »

Hi Enamul

I very much appreciate your help with this, thank you Dave.

weatherman5
Posts: 7
Joined: Tue Jan 15, 2013 6:22 pm
Contact:

Re: PWM using Flowcode V5

Post by weatherman5 »

Hi Enamul

Thanks to your help I have purchased Flowcode 5 (Home) and have successfully designed my PIC and circuit so the led dims up, holds 100% then dims down, look great.
I was wondering if it was possible to add a light level detector to an input of the PIC, 16F628, so as to run the LED only when it was dark.

Dave

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: PWM using Flowcode V5

Post by dazz »

Hi Dave
have a look at this link http://www.matrixmultimedia.com/mmforums/search.php

you should find something in there
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: PWM using Flowcode V5

Post by kersing »

There are several solutions for light level detection. One (simplest?) is to use a LDR connected to an analog input. Use the ADC component to read the input.

Wiring:

Code: Select all

5V ------------ LDR ----+------- Resistor ------------ GND
                        |
                   PIC analog in
Resistor value depends on LDR characteristics. Try different values or use a potentiometer.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

weatherman5
Posts: 7
Joined: Tue Jan 15, 2013 6:22 pm
Contact:

Re: PWM using Flowcode V5

Post by weatherman5 »

Hi kersing

I like your suggestion, very much what I had in mind.
So do you think I can connect this to PIC 16F628 ?
I guess if I can it would be to pin 17 or 18 AN0 / AN1.

Dave

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: PWM using Flowcode V5

Post by dazz »

Hi Dave
if you follow the link and type ldr in the box there are a few good posts with examples, if your feeling adventurous theres also some post on using an led to sample light got a few crude ones up and running

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
BChappy
Posts: 15
Joined: Fri Jun 19, 2009 11:03 pm
Location: Lincoln, UK.
Has thanked: 13 times
Been thanked: 7 times
Contact:

Re: PWM using Flowcode V5

Post by BChappy »

Hi Guys,

Be aware that the 16F628a does not have an ADC, only comparator inputs!
I'm sure they'll be a snippet of code somewhere on here to do the light level detection with the comparator.
See post regarding 16F628a: http://www.matrixmultimedia.com/mmforum ... 46&t=10681

...and...

Welcome to the forum Dave!

Regards

Brian
Is your Project Not Working? - Help and General Advice Click here!
Flowcode v8 forum topic - Click here!

weatherman5
Posts: 7
Joined: Tue Jan 15, 2013 6:22 pm
Contact:

Re: PWM using Flowcode V5

Post by weatherman5 »

Hi Brian

Thanks for the welcome. I am enjoying programming up my first PIC.
I think light level detection with the comparator is just what I am after.

Dave

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: PWM using Flowcode V5

Post by greentech »

Hello,
I can only see one pwm for 16f877a. I know there are two pwms for this chip. This has to be a bug or restriction in trial version?

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

Re: PWM using Flowcode V5

Post by medelec35 »

greentech wrote: I can only see one pwm for 16f877a. I know there are two pwms for this chip. This has to be a bug or restriction in trial version?
No restriction on PWM with Trial version.

Do you mean you have set flowchart up correctly but can only see PWM on one of the hardware channels only
Or
You can only see one channel within your flowchart?

If the latter, then I have posted information on how to create more than 1PWM channel with Flowcode V5 here:
http://www.matrixmultimedia.com/mmforum ... 26&t=11694

Posting your Flowchart could help us to solve your issue more quickly.

Martin
Martin

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: PWM using Flowcode V5

Post by greentech »

here is a screenshot. i cant c 2nd pwm in component macro and over panel.

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

Re: PWM using Flowcode V5

Post by medelec35 »

You need to add another PWM component, since you need to add an additional PWM component for each extra PWM channel your using.

E.g if your using 4 PWMs, you need to add 4 PWM components in total.

Martin
Martin

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

PWM using Flowcode V5

Post by greentech »

Aah! Silly me. i was used to fc4 :)
Sorry guyz, got it now.

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

Re: PWM using Flowcode V5

Post by medelec35 »

No worries greentech these things can catch you out if use to a different way.
Just remember to set both PWM components with the same settings:
http://www.matrixmultimedia.com/mmforum ... 570#p43570

I have altered the above post to mention about a requirement to add additional PWM pomonents, so you have helped other people out, by bringing it to my attention.

Thank you for that :)
Martin

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

PWM using Flowcode V5

Post by greentech »

Keep up the good work brainiacs.

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: PWM using Flowcode V5

Post by greentech »

i am trying to understand how to init 3 level pwm to obtain 50Hz sine output. I have to use pic16f877a. i also need to put some lcd functions voltage readings from mains and battery etc.

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: PWM using Flowcode V5

Post by greentech »

How can i invert the pwm for pushpull loads.

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: PWM using Flowcode V5

Post by Benj »


Post Reply