LED string with PWM
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi Enamul.
I did not have any decent Capacitors.
So I put 10uF on the outputs.
The flicker is gone.
The only other option is 100uF 16 volt.
Would there be a risk that they fail?
The LM317 gets quite warm, but I can still touch it fora few seconds.
Do they need a heat sink?
Best Regards:
Uli
I did not have any decent Capacitors.
So I put 10uF on the outputs.
The flicker is gone.
The only other option is 100uF 16 volt.
Would there be a risk that they fail?
The LM317 gets quite warm, but I can still touch it fora few seconds.
Do they need a heat sink?
Best Regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
It's nice to know that even 10uF worked....I did not have any decent Capacitors.
So I put 10uF on the outputs.
The flicker is gone.
16v capacitor is risky as if voltage exceed; though very little chance of exceeding for a nominal 12 v battery..By the way, when will you use the battery..is there any chance of using it when battery is in charging state? If yes, in that case it's better to not use 16V capacitor.The only other option is 100uF 16 volt.Would there be a risk that they fail?
In my terminology, I always says to my employees if you feel heat more than fever temp(99 deg F) then it will not going to survive without heatsink..The LM317 gets quite warm, but I can still touch it fora few seconds.
Do they need a heat sink?
But from your post it seems that they become quite hot and you should use heatsink...
Enamul
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi Enamul,
Thanks for the info.
Ok I understand what you say.
Heat sink is always better.
Then it gets a bit bulky.
From the output of the regulator it should not get that high because the forward voltage of two LED in series is about 7.5 volts.
Or will there be voltage spikes from the Regulator?
Best Regards:
Uli
Thanks for the info.
Ok I understand what you say.
Heat sink is always better.
Then it gets a bit bulky.
From the output of the regulator it should not get that high because the forward voltage of two LED in series is about 7.5 volts.
Or will there be voltage spikes from the Regulator?
Best Regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
In output side, you can easily use 100uF/16V, I don't think any spike possibilities..at least never faced..From the output of the regulator it should not get that high because the forward voltage of two LED in series is about 7.5 volts.
Or will there be voltage spikes from the Regulator?
I was talking about input of LM317...10uF/25V would work there..
Enamul
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi.
Things are working but now is the challenge of the heat sink for the LM317's
I want move them to point away as far as possible from the LEDs. I was thinking of using a flat piece of Aluminium to make a common heat sink.
I do not have any insulation material Is there a way to improvise make insulation with common materials.
Best Regards:
Uli
Things are working but now is the challenge of the heat sink for the LM317's
I want move them to point away as far as possible from the LEDs. I was thinking of using a flat piece of Aluminium to make a common heat sink.
I do not have any insulation material Is there a way to improvise make insulation with common materials.
Best Regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
Yes, flat piece of aluminium tied with the metal portion of LM3317 will work fine.I was thinking of using a flat piece of Aluminium to make a common heat sink.
Insulation fiber material normally used for insulation in transformer and electrical insulation where needed..you can manage similar kind of insulation material from hardware shops.I do not have any insulation material Is there a way to improvise make insulation with common materials.
I forget to mention you could use...un-used x-ray film which is quite thick and can work nice..
Enamul
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: LED string with PWM
or at a push you could use a colour copier transparency, these are heat stable up to about 225 degrees centigrade, do not use ohp ones as they will melt
regards
Dazz
regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi,
I found a Pic 12F617 that was lost.
I just wrote this program for the camping light and everything works fine.
Since I use a pull up resistor for the fet, which gets pulled down by a transistor.
Everything is the other way around.
I have attached the code.
I have a remote switch with 3 tactile buttons that work through the ADC
The middle one acts as an on off switch.
The top one acts as an increase switch.
And the bottom one acts as an decrease switch for the duty cycle.
Now I want to be able to save the Duty cycle in the EEPROM
However as soon as I use any EEPROM macro Flowcode gives an error message during compiling.
I am not sure If I do something wrong.
Could someone give an example how to use EEPROM on a Pic12F617
Best Regards:
Uli
I found a Pic 12F617 that was lost.
I just wrote this program for the camping light and everything works fine.
Since I use a pull up resistor for the fet, which gets pulled down by a transistor.
Everything is the other way around.
I have attached the code.
I have a remote switch with 3 tactile buttons that work through the ADC
The middle one acts as an on off switch.
The top one acts as an increase switch.
And the bottom one acts as an decrease switch for the duty cycle.
Now I want to be able to save the Duty cycle in the EEPROM
However as soon as I use any EEPROM macro Flowcode gives an error message during compiling.
I am not sure If I do something wrong.
Could someone give an example how to use EEPROM on a Pic12F617
Best Regards:
Uli
- Attachments
-
- Camping Light3.fcf
- (18.75 KiB) Downloaded 618 times
Last edited by Creative25 on Tue Aug 07, 2012 6:21 pm, edited 1 time in total.
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
Seems everything works fine..I just wrote this program for the camping light and everything works fine.
Since I use a pull up resistor for the fet, which gets pulled down by a transistor.
Everything is the other way around.
I have attached the code.
I have a remote switch with 3 tactile buttons that work through the ADC
The middle one acts as an on off switch.
The top one acts as an increase switch.
And the bottom one acts as an decrease switch for the duty cycle.
The compiler is giving error message because PIC 12f617 doesn't have any EEPROM...it's obvious when you try to compile something which is actually not in hardware. We can use external EEPROM but pin number in this chip(I guess you have used all) and price is an issue!Now I want to be able to save the Duty cycle in the EEPROM
However as soon as I use any EEPROM macro Flowcode gives an error message during compiling.
I am not sure If I do something wrong.
So it's not possible with PIC12f617..but easily possible with PIC12f675..as it has internal EEPROM.Could someone give an example how to use EEPROM on a Pic12F&17
Enamul
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Sorry the first
Code was not right.
Because a power failure I lost everything.
And what I posted was the Program at the beginning stage.
Now I uploaded the code I am using.
Do you mean Flowcode cannot use the EEPROM of a Pic12F617?
Best Regards:
Uli
Code was not right.
Because a power failure I lost everything.
And what I posted was the Program at the beginning stage.
Now I uploaded the code I am using.
Do you mean Flowcode cannot use the EEPROM of a Pic12F617?
Best Regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
No.. I didn't mean that..it's not a Flowcode issue..if you look at the datasheet of PIC12f617, you can see there is no EEPROM in this ic..Do you mean Flowcode cannot use the EEPROM of a Pic12F617?
That's why you can't use this IC for EEPROM...FC could be more intelligent by not giving you option to drag EEPROM IC if this chip is selected which I guess we will get soon.
Enamul
- Attachments
-
- 12f617.PNG
- (80.84 KiB) Downloaded 8242 times
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi Enamul,
Thanks for the Info.
I dont' know why I was thinking That the Pic 12F617 has EEPROM.
So if I need EEPROM the easiest way would be to get another chip.
I see the Pic12F1822 is a but cheaper than the 12F675, is there anyone who has experience with those chips?
I have a question about programming.
On PWM I would like to use a maximum dutycycle of 99% or so.
At the moment the LED's are off I would like to Measure the battery voltage.
I tried to do this by disabling the PWM measuring the voltage of the battery and then enabling it again.
But It gives a flicker. Is there a way to measure exactly at the moment the PWM is low.
Since I use a pull up resistor for the fet, it would actually be exactly when the PWM pin is high.
Best Regards:
Uli
Thanks for the Info.
I dont' know why I was thinking That the Pic 12F617 has EEPROM.
So if I need EEPROM the easiest way would be to get another chip.
I see the Pic12F1822 is a but cheaper than the 12F675, is there anyone who has experience with those chips?
I have a question about programming.
On PWM I would like to use a maximum dutycycle of 99% or so.
At the moment the LED's are off I would like to Measure the battery voltage.
I tried to do this by disabling the PWM measuring the voltage of the battery and then enabling it again.
But It gives a flicker. Is there a way to measure exactly at the moment the PWM is low.
Since I use a pull up resistor for the fet, it would actually be exactly when the PWM pin is high.
Best Regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
Yes..that's trueI dont' know why I was thinking That the Pic 12F617 has EEPROM.
So if I need EEPROM the easiest way would be to get another chip.
Yes. you can use this chip. I will post the last program in this chip with duty cycle saved in EEPROM.I see the Pic12F1822 is a but cheaper than the 12F675, is there anyone who has experience with those chips?
Your switch is controlling duty cycle it reaches to max 254 value which is 99%..On PWM I would like to use a maximum dutycycle of 99% or so.
what really you mean by that...in PWM with 99% duty cycle LED will be almost always on...did you mean when the PWM will not be enabled..At the moment the LED's are off I would like to Measure the battery voltage.
If you are using PWM to illuminate light..in that case it's not a good idea to do in between...I tried to do this by disabling the PWM measuring the voltage of the battery and then enabling it again.
That's why it gives flicker...But It gives a flicker.
It's a bit tough in 99% PWM and how will you synchoronise?Is there a way to measure exactly at the moment the PWM is low.
Enamul
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi
That was exactly my question.
Is It possible to synchronize with the PWM? I could reduce the duty cycle to maybe 90-95% if necessary.
I was also wondering if it is possible to make a software PWM. And simply turning the Pin on and off every minute or so just to measure battery voltage.
Would that give less flicker?
Best Regards:
Uli
That was exactly my question.
Is It possible to synchronize with the PWM? I could reduce the duty cycle to maybe 90-95% if necessary.
I was also wondering if it is possible to make a software PWM. And simply turning the Pin on and off every minute or so just to measure battery voltage.
Would that give less flicker?
Best Regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
Hi,
Enamul
One solution could be to use PWM output as input whenever it get low we can read adc for battery...other option is to check TMR2 interrupt which is used in PWM to identify status of PWM output internally...That was exactly my question.
Is It possible to synchronize with the PWM? I could reduce the duty cycle to maybe 90-95% if necessary.
Bit-bang software pwm can be used as well in that case you can identify off-time easily...Are you intended to control duty cycle of PWM still?I was also wondering if it is possible to make a software PWM. And simply turning the Pin on and off every minute or so just to measure battery voltage.
What do you think as source of flicker?Would that give less flicker?
Enamul
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi Enamul.
Maybe I used the wrong word.
I was wondering if it will be possible to read the ADC fast enough so that the LED will not be off for long enough to notice it.
Still want to control the duty cycle.
I guess to check the TMR2 interrupt would be the easiest way to determine. (I have no idea how to do this)
Since I use a pull up resistor for the fet the LED's are off when the PWM pin is high.
Therefore I would need to measure the Voltage while the PWM pin is high.
Best Regards:
Uli
Maybe I used the wrong word.
I was wondering if it will be possible to read the ADC fast enough so that the LED will not be off for long enough to notice it.
Still want to control the duty cycle.
I guess to check the TMR2 interrupt would be the easiest way to determine. (I have no idea how to do this)
Since I use a pull up resistor for the fet the LED's are off when the PWM pin is high.
Therefore I would need to measure the Voltage while the PWM pin is high.
Best Regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
In 4KHz PWM, with 90% duty cycle off -time will be (1/4000)*0.10us/2 = 12.5us which is not enough for ADC read.I was wondering if it will be possible to read the ADC fast enough so that the LED will not be off for long enough to notice it.
This will be bit more faster...I guess to check the TMR2 interrupt would be the easiest way to determine.
It that case hardware PWM is better...but ADC will be a problemStill want to control the duty cycle.
Ok...I got that point..in that case do you need 10%on and 90%off cycle in pwm output or reverse?Since I use a pull up resistor for the fet the LED's are off when the PWM pin is high.
Therefore I would need to measure the Voltage while the PWM pin is high.
ENAMUL
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
HI
I was thinking of setting the PWM to about 250 or 500Hz
And have minimum on time about 10% according to what is needed to read the ADC.
With the fet it will be inverted.
I always can put a few extra miliamps through the LED's to get the same average. As long as I don't go to the maximum.
Best regards:
Uli
I was thinking of setting the PWM to about 250 or 500Hz
And have minimum on time about 10% according to what is needed to read the ADC.
With the fet it will be inverted.
I always can put a few extra miliamps through the LED's to get the same average. As long as I don't go to the maximum.
Best regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
In hardware PWM that much low freq will be tough...but software PWM is fine..I was thinking of setting the PWM to about 250 or 500Hz
I understand what you mean..And have minimum on time about 10% according to what is needed to read the ADC.
Ok. I will post some flowcode...
Enamul
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi Enamul,
I meant PWM frequency of 250 With a clock speed of 4Khz
With software PWM does not have to be slow since one Could just turn the Pin high for the period until the ADC is read.
Also there would be no need for a minimum on time for the pin.
What delay is needed for the voltage on a 5 meter cable to rise to no load voltage?
Best Regards:
Uli
I meant PWM frequency of 250 With a clock speed of 4Khz
With software PWM does not have to be slow since one Could just turn the Pin high for the period until the ADC is read.
Also there would be no need for a minimum on time for the pin.
What delay is needed for the voltage on a 5 meter cable to rise to no load voltage?
Best Regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
I think you meant 4MHz not Khz for PIC clock...I meant PWM frequency of 250 With a clock speed of 4Khz
Yes we can use 250 Hz software PWM with duty cycle controlled...I have started to write FC for that..in off time we will read ADCWith software PWM does not have to be slow since one Could just turn the Pin high for the period until the ADC is read.
If it's 5V then should wait fraction of ms..its better in that case to raise the voltage to up to +12V to have better response...What delay is needed for the voltage on a 5 meter cable to rise to no load voltage?
Enamul
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi Enamul
It actually should read during on time.
Else I have to wait till I get an PNP transistor.
Of course the battery voltage will be +12volt.
Best regards:
Uli
YesI think you meant 4MHz not Khz for PIC clock...
It actually should read during on time.
Else I have to wait till I get an PNP transistor.
Of course the battery voltage will be +12volt.
Best regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
Hi Uli,
No problem, I mean light off time which means PWM pin output ON time..
Enamul
No problem, I mean light off time which means PWM pin output ON time..
Enamul
-
- Posts: 323
- Joined: Tue Sep 06, 2011 2:54 am
- Has thanked: 166 times
- Been thanked: 26 times
- Contact:
Re: LED string with PWM
Hi
I just wonder if it is easier to just use the Comparator
Since I just need to be able to read about three different threshold voltages.
Would that be faster and easier?
Best Regards:
Uli
I just wonder if it is easier to just use the Comparator
Since I just need to be able to read about three different threshold voltages.
Would that be faster and easier?
Best Regards:
Uli
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: LED string with PWM
Hi Uli,
Sorry for late response..
I have managed to make one simple software PWM with 250 frequency...with normally high output at RB5 which will decrease duty cycle with increment in UP switch..decrement with down sw..
I know you want to do both using one sw..I will post that soon..
Enamul
Sorry for late response..
Which comparator you are thinking to use? The comparator that is built-in PIC or any external comparator IC like LM324 or LM358?I just wonder if it is easier to just use the Comparator
If you use any external comparator, in that case you just need to check an input in light off duration which will take couple us only..so definitely much faster than adc read.Since I just need to be able to read about three different threshold voltages.
Would that be faster and easier?
I have managed to make one simple software PWM with 250 frequency...with normally high output at RB5 which will decrease duty cycle with increment in UP switch..decrement with down sw..
I know you want to do both using one sw..I will post that soon..
Enamul
- Attachments
-
- LOW_FREQ_PWM_I.fcf
- 250 Hz using PIC16f877a for test
- (18.18 KiB) Downloaded 525 times