PDA

View Full Version : Managing multiple channels driving triacs



RussMartin
- 4th February 2010, 02:08
Using: 16F88 at 8 MHz and Darrel's interrupts (INT_INT).

Overview: I'm reading 5 different analog values and attempting to drive 5 corresponding triacs with outputs proportional to the analog voltages (forward phase-cutting). INT_INT provides the AC zero-crossing signal.

Successes so far: All blinkies have worked. I can get any one channel to do what I want, but I can't manage all five.

What I've been doing: I read the analog channel(s) in MAIN (looped), then let the interrupt handler turn on the channel(s).

One problem seems to be manipulating the analog values. If I do this in MAIN, even for a single channel, the output result is screwy, so I do it in the handler, which begins to bog it down time-wise. In the handler, I've tried loops counting up, loops counting down, and in either case it seems the killer is the conditional testing to determine when to fire the triac(s).

I'm not asking anyone to write the code for me; I've got working fragments from here to hell and back.

I'm looking for a strategy. Suggestions, please?

Charles Linquis
- 4th February 2010, 03:48
Russ,

I don't know how you are doing things, but a couple come to mind:

#1. Use an 18F chip. They are generally more efficient, and their A/Ds are faster.

#2. Don't use ADCIN - You can "interleave" the converter. Write the
A/D registers directly.

A. Change to a channel
B. Go off and do something for 10uSecs or so (acquisition time)
C. Start the converter
D. Go off and do something else for 15uSecs or so (conversion time)
E. Read the converter (test the ADC DONE bit).
F.Go back to step "A"

By doing things this way, your A/D conversion time is close to zero, and you have plenty time to do whatever else you need. I did 4 simultaneous channels of 60Hz RMS conversion this way. The square root routine takes a lot of time, so I had to make every uSec count. I was using an '8723 at 40Mhz, though.

RussMartin
- 4th February 2010, 04:49
Thanks, Charles.

But for the nonce, I'm stuck with the 16F88.

The A/D conversion time isn't hurting me (at least I don't think so); that's in the MAIN loop.

The difficulty is manipulating five outputs in the interrupt handler during the 8.33 ms AC phase.

Charles Linquis
- 4th February 2010, 15:24
The only problem I see is the number of bits of resolution you need. I assume you are doing lights, so the phase-angle vs. brightness is not linear. I also assume you have a zero-crossing detector somewhere. If you can deal with 20 "steps" or so, I would:

Sit in a loop until you get a zero cross
Start a 410uSec interrupt
In the ISR decide which of the 5 channels you want to turn on
After 20 interrupts, go back to the main loop and wait until you get another
zero cross.