Discussion forum for the BasicX family of microcontroller chips.
Faster PulseIn - Ed - Jun 16 5:36:00 2005
Hi
Is there anyway to speed up readings with PulseIn?
I'm using an ADXL202 from AnalogueDevices. T2 is set to 1kHz so in
theory I should get a reading every 1mS, is that right?
Basically I want to read axis X and Y and output it to the serial port
as fast as possible (using 115200bps). I only get about 40-50 samples
per second.
If I use the analogue version of the accelerometer (GetADC), then my
sample rate increases up to 150Hz.
I also tryed to encode the value in a byte value so I could double the
data sent to the serial port but I'm not good on encoding two values
on one. Also if I divide the Integer value read from ADC, then I loose
a lot of resolution.
My main interest is on speeding up the PulseIn method. Any ideas?
Thanks
Ed

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Faster PulseIn - Ed - Jun 19 13:28:00 2005
*Bump*
--- In basicx@basi..., "Ed" <esteyezz@y...> wrote:
> Hi
>
> Is there anyway to speed up readings with PulseIn?
>
> I'm using an ADXL202 from AnalogueDevices. T2 is set to 1kHz so in
> theory I should get a reading every 1mS, is that right?
>
> Basically I want to read axis X and Y and output it to the serial port
> as fast as possible (using 115200bps). I only get about 40-50 samples
> per second.
>
> If I use the analogue version of the accelerometer (GetADC), then my
> sample rate increases up to 150Hz.
>
> I also tryed to encode the value in a byte value so I could double the
> data sent to the serial port but I'm not good on encoding two values
> on one. Also if I divide the Integer value read from ADC, then I loose
> a lot of resolution.
>
> My main interest is on speeding up the PulseIn method. Any ideas?
>
> Thanks
>
> Ed

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Faster PulseIn - Don Kinzer - Jun 19 16:53:00 2005
--- In basicx@basi..., "Ed" <esteyezz@y...> wrote:
> Is there anyway to speed up readings with PulseIn?
Very likely not. Even if you could modify the BasicX firmware (you
can't) it's unlikely that you could improve the speed much. I
haven't seen the source code but I would guess that it only requires
a few assembly language instructions to examine the input line,
detect the state change, start the timer, wait for another state
change and read the timer value (checking for timer overflow during
the loop). Assuming that the typical pulse width is much longer
than the assembly language loop time, most of the time is spent
waiting for input line state changes.
Depending on the timing of the input pulses you may be able to
rearrange your BasicX code so as not to miss a pulse. I am
referring to the fact that if you call PulseIn when the input is
already in the middle of a pulse, that one will be missed and the
next pulse will be the one measured.
> I also tryed to encode the value in a byte value so I could
> double the data sent to the serial port but I'm not good
> on encoding two values on one. Also if I divide the Integer
> value read from ADC, then I loose a lot of resolution.
Depending on the range of expected values you may be able to devise
a scheme to compress the data stream without losing any resolution.
Don

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )