Author Topic: i2c based timer  (Read 1875 times)

0 Members and 1 Guest are viewing this topic.

Offline whiskeyjack

  • Contributor
  • Posts: 8
  • Country: in
i2c based timer
« on: December 18, 2015, 10:07:20 am »
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.
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 9985
  • Country: 00
Re: i2c based timer
« Reply #1 on: December 18, 2015, 11:02:17 am »
Read this:

http://www.atmel.com/images/doc2508.pdf

Edit: It's actually related to today's blog video!  :-DD
« Last Edit: December 18, 2015, 11:57:32 am by Fungus »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 8017
Re: i2c based timer
« Reply #2 on: December 18, 2015, 11:43:37 am »
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).
 

Offline whiskeyjack

  • Contributor
  • Posts: 8
  • Country: in
Re: i2c based timer
« Reply #3 on: December 18, 2015, 12:04:05 pm »
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.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 8017
Re: i2c based timer
« Reply #4 on: December 18, 2015, 04:39:33 pm »
As I said, I don't know the Atmel ATmegas well enough.  I would suggest starting with the real complete ATMEL datasheet for the ATmega328 on 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.
« Last Edit: December 18, 2015, 09:07:37 pm by Ian.M »
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 9985
  • Country: 00
Re: i2c based timer
« Reply #5 on: December 18, 2015, 08:46:47 pm »
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.

You 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf