From: owner-piclist To: Multiple recipients of list PICLIST Subject: 62.5 Hz sine wave Date: Wednesday, October 30, 1996 10:09AM Hey all, this will be the first real problem I have presented this list and I hope SOMEONE can come through for me. Buttering up aside, I have a 12-bit DAC (AD737) interfaced to a PIC16C74. I'm useing the PCW "C" compiler from CCS. I am trying to build a ultra-stable AC synchronious motor driver. So I have a sine wave represented as a 160-point data set that I generated with a basic program and imported into my code as an array. This data-set represents one half of one period of the sine wave. The PIC sends each value in the set out to the DAC and at the end of the set subtracts the numbers from half scale to produce the negative part of the period, then the whole thing loops. The PIC is looking at a 20Khz, 90% duty cycle ttl square wave that comes from the PWM module. This square wave also updates the DAC. The result should be a 62.5 Hz, +5VDC to -5VDC sine wave coming out of the DAC. The PIC loads the new DAC value only after seeing the DAC get updated by the 20 Khz pulse and then waits for the next DAC update before loading the next number. The DAC update is then fed into an APEX high voltage amp to produce a large sine wave. The problem is that the resulting sine wave is really 62.52 Hz (5 us too fast). I have used several different sources for the 20Khz update pulse with no change in performance so I don't think that could be the problem. The device this control is intended for needs stability better than +/- 1us. (Thats less than +/- 1us per revolution at 62.5 Hz) Right now we are running it with a 62.5 hz ttl square wave, being fed into an inverting amplifier, then a transformer to produce a +/- 60 V square wave. Anybody have any suggestions on: 1. What could this problem be? 2. Is there a better/easier way to achieve an ultra-stable sine wave? 3. Is there a ultra-stable motor-driver I can buy ready-made? 4. Is there another solution besides a synchronious motor that could provide a more stable rotation at these speeds? I hope there's someone out there smarter than me! Shawn ............................................................................ ......... The 62.5 hz wave is a 16 ms signal. With 160 points, this corresponds to 100us resolution. If you are interrupt driven this should not be a problem. I would wonder, however, that since you are only 5 us off, what about the time effect of the code that is executed after the interrupt is received. The delay in code, if equal for all points, would shift the waveform equally for the first and last point, resulting in no error. If you have a decision process in the code that is different netween the first and last point, then one or the other could be shifted. I'm new to the PIC arena so I don't know what timing is consumed for each instruction but 5 us doesnt sound like much - Perhaps only a few instructions could account for the error. Good luck