i2c based timer - Page 1
Forum section: electronics / projects

author: whiskeyjack
author_rank: Contributor
timestamp: December 18, 2015, 10:07:20 am
content: I am using Arduino to dim an incandescent bulb by phase control, where I turn ON the triac after a measured delay once the zero cross is detected. Is there some i2c based chip available which can do that for me? Ideally the chip should detect zero cross (I have external circuit which gives a HIGH Pulse when zero cross is detected) and start timer for all the pins. Once the timeout condition is encountered, the pin goes HIGH.Is there such a device available in the market. The device should be cheap (as compared to Atmega328 IC) or it will defeat the purpose of using it.

author: Fungus
author_rank: Super Contributor
timestamp: December 18, 2015, 11:02:17 am
content: Read this:http://www.atmel.com/images/doc2508.pdfEdit: It's actually related to today's blog video!

author: Ian.M
author_rank: Super Contributor
timestamp: December 18, 2015, 11:43:37 am
content: Some of Microchip's enhanced midrange MCUs have a ZCD module that can synchronise the PWM timer to the mains zero crossing + up to eight PWM modules that could handle the TRIAC control in hardware + the facility to cascade timers via a CLC module to allow a high core clock speed while matching the PWM timebase closely to the mains half-cycle period. All that lot is 'set & forget' - i.e. the hardware will keep on producing the TRIAC firing pulses at the selected firing angles without intervention from the main program.Its then just a matter of writing code to update the duty cycle registers from serial input, though due to the cost of isolating I2C, I'd select logic level serial with RS232 framing or SPI, to be able to use cheap common optoisolators.I don't know if there are any Atmega chips that have comparable hardware synchronisation to an external signal for their PWM modules. That's something you should look into, however if it is possible you will have to leave the Arduino playground and read the real datasheets to write your own synchronous PWM driver.You can also do it in software given some timer support, but it gets really gnarly if you need a multi-channel implementation especially when two or more channels must switch in a very short time interval but not simultaneously (i.e. phase angles differing by one step).

author: whiskeyjack
author_rank: Contributor
timestamp: December 18, 2015, 12:04:05 pm
content: Thanks @Fungus and @Ian.M for your suggestions.@Fungus - I already have a working zero cross circuit which is based on optocoupler for galvanic isolation. I am using K814P optocoupler.@Ian.M - I was looking for some hardware solution which only requires updates when state of the bulb is changed. However it seems that I will have to use some sort of uC for the purpose. In that case, I think I will stick to arduino only because it takes around 2 USD to make one on my PCB. BTW, can you please give me a couple of part numbers that I should look into.

author: Ian.M
author_rank: Super Contributor
timestamp: December 18, 2015, 04:39:33 pm
content: As I said, I don't know the Atmel ATmegas well enough. I would suggest starting with the real complete ATMEL datasheet for theATmega328on your Arduino, and figuring out how to synchronise a hardware timer with the zero crossings, and then to output pulses at the desired firing angle using output compare modules and that timer.I agree that switching to Microchip, starting from scratch, would be expensive in both time and money - however if you already had the toolchain, it would have been an easy option you might have missed if you'd been away from PICs for a while.

author: Fungus
author_rank: Super Contributor
timestamp: December 18, 2015, 08:46:47 pm
content: Quote from: whiskeyjack on December 18, 2015, 12:04:05 pmYou don't really need more than a couple of pins so have a look at the Tiny85. It's an 8 pin chip and it can run with zero external components. You can set up the Arduino IDE to work with it.