EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: ASHU on August 08, 2016, 01:23:56 pm

Title: I2C PWM Led Dimmers
Post by: ASHU on August 08, 2016, 01:23:56 pm
I am using NXP PCA9533 (http://www.nxp.com/documents/data_sheet/PCA9533.pdf (http://www.nxp.com/documents/data_sheet/PCA9533.pdf)) which has an adjustable frequency between 0.591 Hz and 152 Hz as per the datasheet. I am trying to attain a frequency of 100 Hz which is not going the way I expected.

As per datasheet :  page 5, section  6.3.2 defines how to set the frequency which is a 1 byte section. Setting it to 0 gives me the max frequency which is 152 Hz and setting it to 1  gives me the frequency of 76 Hz. Therefore, I am stuck between 76 Hz and 152 Hz, where as I want 100Hz. As per the formula in the datasheet, I need to set PCS0 to 0.52(decimal value) which can't be converted to binary. Is there any other kind of work around for this?

If not (which I think is gonna be the answer), can anyone suggest me a different IC  but with similar features of PCA9533 ( I2c, LED dimmer, GPIO) which can do the task for me?

I have found some LED driver IC's but they only have output options in them, no inputs.
Title: Re: I2C PWM Led Dimmers
Post by: Leopoldo on August 08, 2016, 10:51:43 pm
Do you actually need to set it at 100Hz? If you just need to dim LEDs, you probably want to stick with a higher frequecy, as you are less likely to see it blinking.
I didn't quite understand the table, I'm probably missing some sort of division; it might want to try to set that register at binary 0b10010111 (151 in dec); otherwise, just set it to 152Hz and you'll be fine as long as you use it for leds.
Title: Re: I2C PWM Led Dimmers
Post by: JPortici on August 09, 2016, 05:57:22 am
The period of BLINK1 = (PSC1 + 1) / 152

source: the datasheet you linked
Title: Re: I2C PWM Led Dimmers
Post by: ASHU on August 09, 2016, 07:03:34 am
@Leopoldo : I am trying to operate a optocoupler -moc3021(15mA) which is well with the specs of PCA9533. That optocoupler is then driving a 220V (50Hz) ac triac. I want to dim an ac lamp, hence I need 100Hz as I see flickering at 76 &152Hz. Yes, I have connected a Zero crossing detector to 1 of the pin in my micro-controller, which is working fine.
Other thing is that the frequency is in reverse order, meaning 0b00000000 [0x00 - HEX] gives the max frequency (152Hz) followed by 0b00000001 [0x01 - HEX] which gives 76Hz. It is also stated here http://www.nxp.com/documents/application_note/AN264.pdf (http://www.nxp.com/documents/application_note/AN264.pdf), table 8 - page 11

@JPortici : That formula needs some kind of conversion for blink rate, which I am still trying to figure out What/How and It's not stated in datasheet. If you see the calculations in the same datasheet Page 12 section 8.2, if you replace the blink rate in that to any number other than 1, you will get a number which is greater than 255(decimal) which needs more than 1 byte.

But the most important part is that 0x00(hex) gives me 152Hz and 0x01(hex) gives me 76Hz. There is no other HEX number in between which I can try.
Title: Re: I2C PWM Led Dimmers
Post by: JPortici on August 09, 2016, 07:44:17 am
yeah, because for 0 the period is 1/152 so 152 Hz
for 1 it is 2/152 so 1/76 so 76 Hz
for 2 it is 3/152 so 50,67 Hz
and so on
you can't set it at intermediate frequencies. if you absolutely need it you'll have to find a different solution

PSCx: Frequency prescaler: sets the PWM frequency
PWMx: Sets the PWM period. the pwm resolution is ALWAYS 8 bit
Title: Re: I2C PWM Led Dimmers
Post by: ASHU on August 09, 2016, 07:50:32 am
ooo..alright, do you know any alternative(s)?
Title: Re: I2C PWM Led Dimmers
Post by: JPortici on August 09, 2016, 08:42:15 am
I don't know. I don't know about these ICs
i personally would use a mcu, i'm sure this is a preprogrammed mcu anyway
Title: Re: I2C PWM Led Dimmers
Post by: ASHU on August 09, 2016, 10:38:17 am
Alright, thanks a lot for the support :)
Title: Re: I2C PWM Led Dimmers
Post by: Ian.M on August 09, 2016, 11:06:58 am
Your national electricity grid frequency is only NOMINALLY 50Hz (or 60Hz for Americans).  It is subject to short-term variations as the instantaneous national demand increases or decreases, and generating plant is spun up and put online, throttled, or taken offline to compensate.  When a sudden load increase occurs, the energy required comes from the rotational K.E. stored in the spinning turbines and generators and any flywheels.  This slows them down, lowering the frequency, until their governors can compensate by opening steam valves or increasing fuel flow.  If there isn't enough spinning reserve, it takes a significant amount of time to bring more generators online, so the grid frequency can drop for several minutes.   e.g The UK's Dinoweg hydro pumped storage plant takes 75 seconds for a cold start and 16 seconds from reserve spinning-in-air.  Its the fastest large scale 'peaking' plant in the country.  Gas Turbine peaking plants take more like 20 minutes to spin up to full load

Here's the UK grid current frequency response page: http://www2.nationalgrid.com/uk/services/balancing-services/frequency-response/ (http://www2.nationalgrid.com/uk/services/balancing-services/frequency-response/)

As such your design will have to cope gracefully with supply frequency variations of +/-0.1Hz in normal operation in a 1st world country - which would result in the brightness cycling between full and the desired level ith a period of as little as ten seconds if you used a simple crystal controlled 100Hz PWM to fire the TRIAC. A developing country is likely to have a less stable grid, and +/-1Hz would not be unusual.  As the PWM chip is unlikely to be crystal controlled, you also have the tolerance of its oscillator to contend with.  1% error would result in a 1Hz beat.   The *ONLY* way it could work is if the PWM timebase could be locked to the supply zero crossings. 

You wont find a singe chip solution for I2C controlled phase angle TRIAC firing.  A MCU would be the usual approach, but either you have to optoisolate the ZCD and triac gate circuits, or you need to use an I2C isolator and 'float' the whole MCU at mains potential, so at best you have two chips - MCU and $expensive$ I2C isolator, and at worst you have two or more optoisolators for ZCD and TRIAC gate + the MCU.
Title: Re: I2C PWM Led Dimmers
Post by: ASHU on August 09, 2016, 02:49:42 pm
Mannnnnn.....what are you?   :o

That was phenomenal piece of information. I'm coming across such kind of stuff for the very first time.

Thank you so much @Ian.M