About Dimmer Circuits...((Please Help))
Moderator: Benj
About Dimmer Circuits...((Please Help))
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..
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..
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: About Dimmer Circuits...((Please Help))
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.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.
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.
That's nice and simple. within Flowcode you have an output icon: Drag two of them to your flowchart.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..
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
Martin
Re: About Dimmer Circuits...((Please Help))
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..
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..
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: About Dimmer Circuits...((Please Help))
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
It will not look right when simulating because of the interrupt frequency rate can not be simulated correctly.
Martin
- Attachments
-
- Fade2.fcf
- (8 KiB) Downloaded 464 times
Martin
Re: About Dimmer Circuits...((Please Help))
Thanks again...
Now I'm trying to understand it..
Also can you help me in the future in my programming problems?
Thanks.
Harshana.
Now I'm trying to understand it..
Also can you help me in the future in my programming problems?
Thanks.
Harshana.
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: About Dimmer Circuits...((Please Help))
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
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
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
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
To help you understand, search for the termhprane wrote: Now I'm trying to understand it.
Code: Select all
bit shiftingCode: Select all
bit bang pwmI 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
That means the duty of PWM = 2*25 = 50%duty of PWM = double the Brightness value, after the calculation.
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
Last edited by medelec35 on Sat May 14, 2011 11:16 am, edited 1 time in total.
Martin
Re: About Dimmer Circuits...((Please Help))
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.
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.
- Attachments
-
- Vesak 1.fcf
- This is my file.
- (21.86 KiB) Downloaded 385 times
- 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: About Dimmer Circuits...((Please Help))
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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: About Dimmer Circuits...((Please Help))
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: About Dimmer Circuits...((Please Help))
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.
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.
Martin
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: About Dimmer Circuits...((Please Help))
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.
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.
- Attachments
-
- Fade3.fcf
- Must be tested on hardware or a simulator that requires hex code to run.
- (10 KiB) Downloaded 397 times
Martin
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: About Dimmer Circuits...((Please Help))
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.
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.
- Attachments
-
- Fade4.fcf
- All LED patterns derived from look-up tables. Will not work within Flowcode simulator as that does not simulate C code.
- (14 KiB) Downloaded 377 times
Martin