PDA

View Full Version : Synchronising HWPM to an external source



galliumman
- 6th December 2009, 00:57
Hello all,

This is my very first post on any forum, ever! Be gentle. :)

This is a Microcode Studio pbp question, not even sure if i'm on the right forum, but you seem a helpful lot!

I have a darlington pair hooked up to a recitifed (but not smoothed) 12v supply.
this gives me a beautiful pulse every 10ms or 100Hz (UK mains). i have this coming in via an adcin port.

I also have a PIC16F870configured with an RC network of 22KOhm and 45pF giving roughly a 1MHz clock - this is to get the HWPM down to 100Hz, i know it's not ideal and i have a 1Mhz crystal on order.

My question is, how do i synchronise the two? I'd like the HWPM to start the moment the darlington pair fire and then keep in sync with the pulses.

I'm using a 100k pot on an adcin to get 0 to 255 which is fed into the duty cycle of the hpwm command.

Any help appreciated.

galliumman
- 6th December 2009, 10:18
It was quite late when i posted, my eyelids were drooping! :o

Acetronics2
- 6th December 2009, 15:31
Hi,

Why not have a look to the CCP COMPARE section of your Datasheet ??? just reset TMR1 @ zero crossing and load Compare value as the delay for delaying your SCR firing ...

What about ???

Also have a look to MELABS site examples page , Steve Monfette has provided a good example ... for dimmer.

http://www.melabs.com/resources/samples/submitted/dimmer.zip

Alain

galliumman
- 6th December 2009, 18:03
Hi,

Thanks for responding with these suggestions Alain. I have tried resetting timer 2 - pic16f870 uses this for hardware pwm - t2con.2 = 0.
This did not seem to work, the output pwm drifts slowly away.

I will look through Steve Monfette's code to see if i can get some pointers.


The circuit is - as you correctly surmised - for firing four SCR's at Zero crossing ~ 8kw power load so i want to get the timing bang on, the SCR's are expensive!

I have been looking at the CCP Compare section of the datasheet and i'm still a little stumped?? How can i use this to synchronise the HPWM with an incoming zero crossing signal? I've been knee deep in datasheets and tutorials trying to get my head around this for days.

Many Thanks again for your time.

Gordon