The signals from the ADXL's are NOT synchronized wrt edges. They are synced in that they are the result of a compartor slicing a triangle wave so they will each change state once per overal period. Bascially the CENTER of each Pulse is synced, with the width extending in either direction as the sensor operates. The Microchip app note on using them with a PIC is quite thorough, complete with source code for measuring period and pulse width and temperature compensating the results. Basically one time stamps the rising and falling edges seen on CCPx and then does some simple math to get PW and Period for each cycle. The temperature effect IS significant but may be ignored if your application doesn't require high precision. Be sure to conformal coat the period setting resistor/cct since it is VERY sensitive to surface leakage. It is also possible to choose a series/parallel termistor/resistor combo the nicely compensates the temperature drift. Be sure to bypass the VCC on the ADXL close to the chip. It is VERY sensitive to supply voltage noise. I had to use an LC VCC circuit to get the jitter down to the levels we needed. Robert "M. Adam Davis" wrote: > > I just wanted to make sure that there wasn't an easier/better way to > measure a pwm signal. > > I have obtained some ADXL202E dual axis accellerometers from Analog > Devices, and want to hook one up to my IPaq. Rather than taking control > of the serial port, I'm going to make a simple interface with a 16f877 > (sort of a portable lab toy) and then interface that to the IPaq. > > The ADXL202 puts out two signals whose duty cycles vary with the > acceleration the device is under in the two axis'. Since the period of > he signal is controlled by a resistor (which can vary according to > temperature) then I need to occasionally (every few minutes) find the > total period, and when I need the data I need to find the width of the > pulse. > > My understanding is that the easiest way to do all this is: > > Measure total period: > > Set CCP to capture, positive going pulse > When a change is captured, reset timer one > When the next change is captured, the value captured is the period > > Measure Pulse Width: > > Set CCP to capture, positive going pulse > When change is captured, reset timer one and set capture to occur on > negative going pulse > When next change is captured the value captured is the pulse width > > The duty cycle can be found by dividing the pulse width by the total period. > > Assuming that's the best way, then I only have a few questions: > > If the two pulse trians (x axis, y axis) start at the same time, then I > won't have a problem measuring both simultaneously with the two ccp > pins. However, if they are not the same then I'd have to either measure > them seperately, or simply capture the readings for the start and stop > of each event, and use subtraction to determine the length without > reseting timer one. By doing so, though, I risk timer one overflowing > and having to deal with subtraction across the zero boundary, which > doesn't sound like fun to me. > > Is there a better way? Since my initial experiments are going to be > under 10 Hz sampling, then it's not an issue to measure them at > different time, and it will show me if they are synchronized, so I can > do it this way fine, but I'd still like to find out if there's something > better out there. > -Adam -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics