Hi All
Working with a Memsic mx2125 accelerometer. Depending on tilt or g force, it puts out a pulse train with a varying pulse between 3.6 and 6.4 ms, 5ms being center(level) As a novice to the rabbits and C, this code gave me a value of 5. 5ms pulse using the MS_TIMER , its right. no resolution though.
unsigned long time, durX;
durX=0;
waitfor(BitRdPortI(PBDR,6));
waitfor(!BitRdPortI(PBDR,6));
time=MS_TIMER;
waitfor(BitRdPortI(PBDR,6));
durX = MS_TIMER - time;
so I changed it to this:
unsigned long time, durX;
durX=0;
waitfor(BitRdPortI(PBDR,6));
waitfor(!BitRdPortI(PBDR,6));
while(!BitRdPortI(PBDR,6))
{
durX++;
}
this gives me a range of about 500 to 850 with 675 being center(level)
There has to be a way to get a higher resolution (count) ? micro seconds would be great, then a 5 ms pulse would give me a value of 5000. even half of that(2500) would be good. As a learning curve, I would like to show the output of degrees, down to the 100th.