View previous topic :: View next topic |
Author |
Message |
Guest
|
Multiple TMR0 preseting |
Posted: Tue Oct 19, 2004 12:43 pm |
|
|
I can't seem to find this in ccs manual... :roll:
Once the timer0 value is set initially using set_timer(value), is it possible to change this "value" after a timer0 interrupt has been called?
I'm trying to control to 2 triacs using 16F877. My zero crossing circuit, triggers the RB0 interrupt every 8.33ms (using 60 Hz mains), and within this period I need to trigger the two triacs controlling two heaters. The control of 2 triacs must be independent of each other. (i.e. the two firing angles for 2 triacs are not necessarily the same). Supposedly that I need to fire triac A at 60° and triac B at 90° within the 8.33 msec period, I need to first load timer0 value with 60° and then reloaded with some offset value to get 90° firing angle.
Is it possible to reload timer0 with a new value (in this case 90°) once the current timer0 has caused an interrupt?
Here is another (probably stupid) question:
When PIC's PWM starts to run for the first time, does it start with low-to-high edge or logic low or logic high?
Thanks for any help |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Oct 19, 2004 1:31 pm |
|
|
Yes you can set timer0 again.
I would use the CCP module though. Just load the CCP value and you will get an int on compare (60) and then load the next CCP value (90) and the second int (have to set a flag to determine which one). Just restart the timer1 at your zero cross. I use this method to control 6 triacs for the purpose of dimming. |
|
|
pop
Joined: 18 Sep 2004 Posts: 22
|
|
Posted: Tue Oct 19, 2004 3:32 pm |
|
|
Thanks!
I'll definately give these a try! :grin: |
|
|
pop
Joined: 18 Sep 2004 Posts: 22
|
|
Posted: Wed Oct 20, 2004 1:18 pm |
|
|
After reading several pic CCP articles I can see the benefit of using CCP module instead of reloading the timer.
This question is for Mark or anybody else who has been playing with PIC-multiple triac control.
In your last post, you said that you control 6 triacs. I am wondering if you're using a multiplexer to control 6 triacs from a single CCP pin? In your case, is the triggering of 6 triacs hogging the PIC resources? And are you using pulse position modulation as triggering signal?
In short, I'm wondering if you could post pseudo or actual code (whichever is easier), for this triac operation triggering.
Thanks |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Oct 20, 2004 5:14 pm |
|
|
I am only using the CCP interrupt and not the pin. The pins are set in the interrupt routine. How much resources? Not really sure. Is it hogging it. Not not really. However, there is a lot more going on with the PIC so it still must remain responsive and never ever never ever miss one of the zero crosses. If it did, our customers wouldn't like their dimmers very much. There was a much of math involved. Lots of sorting of the CCP values and such. There is even a little "software magic" applied to the zero cross signal to keep it in check in noisey enviroments. Kind of a digital filter of sorts. I did a lot with asm to ensure a smooth system. I will take a look and see what I can post when I get a chance. |
|
|
pop
Joined: 18 Sep 2004 Posts: 22
|
|
Posted: Wed Oct 20, 2004 7:35 pm |
|
|
Quote: | I am only using the CCP interrupt and not the pin. The pins are set in the interrupt routine. |
This clarifies some of my important questions, so there is no need to post any code.
Unlike you application, with heater control I can afford to miss few zero crossings here and there, and still have a seemingly perfectly working heating controller.
Besides, if you can run 6 triacs and a digital filter then I don't think I'll have much problem with 2 triacs.
Thanks for the help!
|
|
|
|