Page 1 of 1
About Dimmer Circuits...((Please Help))
Posted: Wed May 11, 2011 3:48 am
by hprane
I want to dim LEDs or other lights..I mean like the LED light going down & coming up again. But I don't know how to do that. Please help me for it..
Also I want to know how to turn on 2PORTs at one time. Like 16F877A PORT C0 & PORT D0..Please help me how to do it in FlowCode...
Thanks..
Re: About Dimmer Circuits...((Please Help))
Posted: Wed May 11, 2011 7:57 am
by medelec35
hprane wrote:I want to dim LEDs or other lights..I mean like the LED light going down & coming up again. But I don't know how to do that.
For Dimming LED's best way is using PWM (Pulse Width Modulation). Basically the frequency stays the same, but the on/off ratio is varied depending of brightness level required.
Take a look here:
http://www.matrixmultimedia.com/article.php?a=52
What version of Flowcode have you got, as the flowchart witin the link only loads with V4 and not with V3
There is plenty of information on creating PWM waveforms around this forum.
hprane wrote:Also I want to know how to turn on 2PORTs at one time. Like 16F877A PORT C0 & PORT D0..Please help me how to do it in FlowCode...
Thanks..
That's nice and simple. within Flowcode you have an output icon:

- output.jpg (1.46 KiB) Viewed 9841 times
Drag two of them to your flowchart.
Double click it, then select the port you want, and select single bit,then select the bit you want to control from the drop down box.
Like any other software, It does pay to learn how to use the product first. there are vast resources available.
Take a look in the learning centre here:
http://www.matrixmultimedia.com/lc_index.php?p=7
Finally you mush makesure your configuation settings are correct before sending to hex or target device
http://www.matrixmultimedia.com/mmforum ... =26&t=6936
Once you get the hang of it, you won't look back on programming chips any other way!
Good luck
Martin
Re: About Dimmer Circuits...((Please Help))
Posted: Wed May 11, 2011 5:11 pm
by hprane
First thank u Mr. Martin for reply me..
I'm new for FlowCode. Also I'm still learning about PICs. I'm using FlowCode v4..
I'm making a 14 way LED running program with 16F877A for Vesak festival in Sri Lanka..
I will send you my original program tomorrow. Now i have a little design of it.
If you can please edit it for fade a LED. Then i think i can study your program.
Thank you..
Re: About Dimmer Circuits...((Please Help))
Posted: Thu May 12, 2011 2:09 pm
by medelec35
Here is a light chaser that you can very brightness from dim to full brightness.
It will not look right when simulating because of the interrupt frequency rate can not be simulated correctly.
Martin
Re: About Dimmer Circuits...((Please Help))
Posted: Fri May 13, 2011 4:32 am
by hprane
Thanks again...
Now I'm trying to understand it..
Also can you help me in the future in my programming problems?
Thanks.
Harshana.
Re: About Dimmer Circuits...((Please Help))
Posted: Fri May 13, 2011 7:34 am
by medelec35
Re: Where you ask for help.
This thread is in the wrong section and any questions related to Flowcode 4 should be asked in the V4 section.
For how to do this please see:
http://www.matrixmultimedia.com/support ... =602#p1235
hprane wrote:
Now I'm trying to understand it.
To help you understand, search for the term
and then search for
Don't search for all five at the same time.
I plan on writing an article on how to produce correct duty, at desired frequency on bit bang PWM.
Until then with the flowchart I posted, the duty of PWM = double the Brightness value, after the calculation.
E.g if pot is set to 1/2 of it's full value. then Brightness = (48*127)/255+2 = 25
Since I said
duty of PWM = double the Brightness value, after the calculation.
That means the duty of PWM = 2*25 = 50%
so the average voltage is approx 1/2 of full voltage.
The frequency is always the same = interrupt frequency / max count value within interrupt macro
= 4800/50 = 96Hz
As for helping.
I will try and help when I can. That's what the forums are about
Martin
Re: About Dimmer Circuits...((Please Help))
Posted: Fri May 13, 2011 4:20 pm
by hprane
Thanks for your information.
I made a light running circuit using 16F877A, 4MHz crystal with 22pFs. Circuit works correctly. But lights running speed is very very high. I cant see my designs.
I took RB0-RB6 and RC0-RC6 as outputs for lights. I changed FlowCode program options > clock speed to 4000000Hz and simulation speed to 100 (Is this the correct speeds that PIC running. Or where is the speed settings to change?) . In the FlowCode it runs in correct speed. But in the circuit it not.
Please help me soon how to correct this problem.
Can i use a variable resistor to this....how...
Thank you..
Harshana.
Re: About Dimmer Circuits...((Please Help))
Posted: Fri May 13, 2011 4:44 pm
by Benj
Hello,
The Flowcode settings do the following.
Clock Speed - Defines what speed the hardware is running at so delays/baud rates etc are correct on the hardware.
Simulation Speed - Defines the speed of the simulation.
The actual hardware is clocked in a number of ways.
1) via a crystal or other external clock source.
2) via an internal oscillator
The Flowcode clock speed must match the frequency of your crystal or internal oscillator to allow delays to be correct on the hardware.
Internal oscillator speeds are usually 4MHz or 8MHz for the PIC16 devices.
Re: About Dimmer Circuits...((Please Help))
Posted: Fri May 13, 2011 4:46 pm
by Benj
To get your program to run correctly on the hardware you will either need to insert delays into your program or you will need to clock the microcontroller very slowly. You can do this by using a RC oscillator circuit as shown in the device datasheet in the oscillator section.
Re: About Dimmer Circuits...((Please Help))
Posted: Sat May 14, 2011 3:07 am
by hprane
Thanks Mr.Benj.
I will try to correct it....
Re: About Dimmer Circuits...((Please Help))
Posted: Sat May 14, 2011 11:36 am
by medelec35
Hi hprane,
I have edited my last post about you asking for help.
After reading it, I thought it came over a bit hash which was not my intention.
For that I apologise.
I may be able to help you further.
If you can let me know time delay between each LED lighting. E.g 80ms
Then I will used the patterns in your previous post controlling 14 LEDs
Do you still want to vary the brightness?
Martin.
Re: About Dimmer Circuits...((Please Help))
Posted: Sun May 15, 2011 1:25 am
by medelec35
I have created a Flowchart, that will give you the patterns you are after, and allow the brightness to be adjusted at the same time.
I have only included patterns 1 to 3, not got much time to finish with all patterns in, but hopefully you can see how patterns are created and add more patterns by editing Supplementary code window which can be found by 'view', 'project options'
Briefly how the flowchart works is:
Value of Pattern_Count starts at 0
So the 1st values of Look up tables LUT_PortB and LUT_PortC are assigned to Pattern_PortB and Pattern_PortC
= 1 & 0 respectively.
then Pattern_Count is incremented by 1 so is = 0+1=1
2nd values of Look up tables are assigned to Pattern_PortB and Pattern_PortC
= 3 & 0
Pattern_Count will continuously increase until Pattern_PortB = 255 (the very last number of LUT_PortB), then is reset back to 0 and whole process is started all over again.
Ports are also switch on and off at 96Hz, with a duty that is proportional to brightness, which has the effect of altering brightness LED's.
Note: Will not work within Flowcode simulator. You will not see any patterns if running on Flowcode simulator. This is because Look-Up Tables are using C and Flowcode does not simulate C.
If you get stuck just ask.
Re: About Dimmer Circuits...((Please Help))
Posted: Mon May 16, 2011 7:37 am
by medelec35
Here is an updated version with an added adjustable delay ranging from 50ms to 500ms per LED change.
If I get a bit more time will add some more patterns.
The first flowchart I posted was based on your first flowchart which has the osc set to 19.6 MHz.
So all flowcharts was based on that, and will not correctly run with a 4MHz osc.
After noticing in one of your posts you are using a 4MHz crystal I have changed prescaller and osc frequency.
This version should work OK.
Only tested with a simulator that runs in real time.
not tested on hardware.