CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Multiple TMR0 preseting

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Multiple TMR0 preseting
PostPosted: Tue Oct 19, 2004 12:43 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 19, 2004 1:29 pm     Reply with quote

This thread has a simple example that shows reloading Timer0 within
the int_rtcc isr. The code shown is for the 18F458, which has a 16-bit
Timer0. In your case, the 16F877 has an 8-bit timer, but the principle
is the same.
http://www.ccsinfo.com/forum/viewtopic.php?t=17859&highlight=settimer0
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Oct 19, 2004 1:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 19, 2004 3:32 pm     Reply with quote

Thanks!

I'll definately give these a try! :grin:
pop



Joined: 18 Sep 2004
Posts: 22

View user's profile Send private message

PostPosted: Wed Oct 20, 2004 1:18 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Oct 20, 2004 5:14 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Oct 20, 2004 7:35 pm     Reply with quote

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. Very Happy

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. Wink
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!

Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group