You don't have to step through the lookup table to get the result do you? Just get the address of the start of the table, add in the offset and then read the result. Shouldn't take anything like 162 steps to do the lookup. Or am I missing something - I've been away from actual PIC programming for a long time. If you want to reduce the lookup to an even lower value at the expense of some additional calculation you need only store a 1/4 period of the sinewave since it is symmetrical about the 90degree point. RP On 14/03/06, David V. Fansler wrote: > I am working on a design for a two channel AC dimmer using a PIC (16F87x > series). Just wondering if anyone else has done it. I am running into a > timing issue =96 or rather a like of timing issue. Here are my thoughts: > > Input to the dimmer would be either a 0-5vdc voltage, or a command via the > RS232 input. The dimmer would have 256 steps between full on and off. > Also, I would like to linearize the output, rather than the common strong > start, linear in the middle and tapers off at the end. To do this, I tho= ugh > that I would have a circuit tied to the 60Hz line that would provide when= a > zero crossing takes place. This would start a counter based on T1 =96 th= is > counter would count up to 256 during =BD cycle of 60Hz wave. A look up = table > would be used to compare the current analog value (or command value) to t= he > linearized value at that slice of time (1 of the 256 slices in =BD of a 6= 0Hz > wave). When the current analog value exceeds the look up table value then > the AC output would be activated. At the end of the =BD cycle the process > would start over. > > Now for the problem =96 A 60Hz wave has a period of 16.66ms, so half a wa= ve > would be 8.33ms. If we divide this time into 256 slices that would give = us > 32.5 us per slice. A PIC16F87x running at 20MHz can perform an instructi= on > in 200ns. So at 200ns/per instruction we could perform 162 instructions = in > 32.5us. This is not enough time to go through all 255 steps in the look = up > table. I could reduce the steps to 7 bits (128 steps) and this would > possibly give me enough time for the look up table, but no much else. > > So as I said =96 anyone else already been through this that can possibly = guide > me in a better method? I am trying to hold external hardware down to a > minimum. > Thanks, > David > > David V. Fansler > S/V Annabelle > david@dv-fansler.com > www.dv-fansler.com > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist