Pulsin and the Memsic 2125
Archiver
Posts: 46,084
Hi all,
I am working on a project using the Memsic 2125 to measure velocity. In
order to do this, I need to know how much time ellapses between each
measurement and calculations.
Anyways, I have a question on the Pulsin command
For example Pulsin 0,1,pulse ' measure a high pulse on pin 0 and store
result in pulse.
This function is looking for a trigger edge going from 0 to 1 to start the
measuring.
Now what happens when the pin is already in a high state when the Pulsin
command is being executed?
A. Does it immediately return a zero?
B. Would it stay in an infinite loop waiting for the pin to go low before
starting the measurement when it goes high again, or
C. Start measuring until the 1-0 transition occurs and report that as the
pulse width even though it never saw the 0 - 1 rise trigger.
The documentation, talks about a timeout that would occur when measuring the
pulse at 64k periods, but will it have a timeout if it never sees a pulse,
or will there be a time out if the measurement pin is high all the time.
Anyone have any info on this?
Pete Miles
I am working on a project using the Memsic 2125 to measure velocity. In
order to do this, I need to know how much time ellapses between each
measurement and calculations.
Anyways, I have a question on the Pulsin command
For example Pulsin 0,1,pulse ' measure a high pulse on pin 0 and store
result in pulse.
This function is looking for a trigger edge going from 0 to 1 to start the
measuring.
Now what happens when the pin is already in a high state when the Pulsin
command is being executed?
A. Does it immediately return a zero?
B. Would it stay in an infinite loop waiting for the pin to go low before
starting the measurement when it goes high again, or
C. Start measuring until the 1-0 transition occurs and report that as the
pulse width even though it never saw the 0 - 1 rise trigger.
The documentation, talks about a timeout that would occur when measuring the
pulse at 64k periods, but will it have a timeout if it never sees a pulse,
or will there be a time out if the measurement pin is high all the time.
Anyone have any info on this?
Pete Miles
Comments
There was a thread on www.piclist.com several months back about this.
To keep a set period between measurements, say 1 ms, use the Pause command.
You won't be able to do anything else during this period, but you don't want
to 'cause it'll further screw up your accuracy.
- Robert
Original Message
From: "Pete Miles" <petem@o...>
To: <basicstamps@yahoogroups.com>
Sent: Thursday, August 14, 2003 2:06 PM
Subject: [noparse][[/noparse]basicstamps] Pulsin and the Memsic 2125
> Hi all,
>
> I am working on a project using the Memsic 2125 to measure velocity. In
> order to do this, I need to know how much time ellapses between each
> measurement and calculations.
>
> Anyways, I have a question on the Pulsin command
>
> For example Pulsin 0,1,pulse ' measure a high pulse on pin 0 and store
> result in pulse.
>
> This function is looking for a trigger edge going from 0 to 1 to start the
> measuring.
>
> Now what happens when the pin is already in a high state when the Pulsin
> command is being executed?
> A. Does it immediately return a zero?
> B. Would it stay in an infinite loop waiting for the pin to go low before
> starting the measurement when it goes high again, or
> C. Start measuring until the 1-0 transition occurs and report that as the
> pulse width even though it never saw the 0 - 1 rise trigger.
>
> The documentation, talks about a timeout that would occur when measuring
the
> pulse at 64k periods, but will it have a timeout if it never sees a pulse,
> or will there be a time out if the measurement pin is high all the time.
>
> Anyone have any info on this?
>
> Pete Miles
>
>
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>For example Pulsin 0,1,pulse ' measure a high pulse on pin 0 and store
>result in pulse.
>...
>Now what happens when the pin is already in a high state when the Pulsin
>command is being executed?
>A. Does it immediately return a zero?
>B. Would it stay in an infinite loop waiting for the pin to go low before
>starting the measurement when it goes high again, or
>C. Start measuring until the 1-0 transition occurs and report that as the
>pulse width even though it never saw the 0 - 1 rise trigger.
It waits for the 0->1 transition, even if the pin is already high
when the command starts. A BS2 waits up to 131.07 milliseconds for
the 0->1 transition, and if it does not arrive, it gives up and
returns a value of zero. If the 0-1 transition does occur within
that time frame, then the BS2 times the pulse, up to 131.07
milliseconds (1 count=2 microseconds). If the 1->0 transition does
not occur within 131.07 milliseconds, then it returns a value of
zero. This is explained in the manual. The times for the 'sx, 'p,
and 'pe are different.
>
>The documentation, talks about a timeout that would occur when measuring the
>pulse at 64k periods, but will it have a timeout if it never sees a pulse,
Yes.
>or will there be a time out if the measurement pin is high all the time.
Yes. The manual does talk about this. pg 241 of the v2.0 manual.
>
>Anyone have any info on this?
>
>Pete Miles
I am using the BS-2p, running the PBasic 2.5
When I read the manual, it was not very clear on this, and I get an odd
result with my o-scope that leds me to a different conclusion.
The Memsic 2125 outputs both the a_x and a_y pulses at the same time, and
updates the results every 10 ms. So if both pulses are 5 ms long, it will
take a minimum of 15 ms to read both pulses, plus some overhead.
My program goes like this
Do
Call Read_Acceleration
display acceleration results to LCD
convert to velocity
display velocity results to LCD
TOGGLE pin0
Loop
I am using an o-scope to monitor the TOGGLE times to determine the velocity
time constants I will need. With the accelerometer not moving, you would
expect that you would get an nice 50% duty cycle square wave right? Well
that is not what happens. I get a very consistant square wave with a 30 ms
period, but the high side is 22 ms long, and the low side is 8ms long. It
acts like it is reading the acceleration values every other time the
read_acceleration subroutine is called.
Then when I change the program to look like this
Do
Call Read_a_x_acceleration
convert velocity
display a_x and velocity results to LCD
Call Read_a_y_acceleration
convert velocity
display a_y and velocity results to LCD
TOGGLE pin0
Loop
When I do this, I get the 50% duty cycle square wave with the same 30 ms
period with the above program. This is what was originally expected.
The only real difference between the two programs is when the Pulsin
commands are executed relative to the accelerometer, so that is why I asked
the question, about what happens if the signal is high when the pulsin
command is executed.
I think tonight I will put in an error trap to see if I can catch this.
Pete Miles
Original Message
From: "Tracy Allen" <tracy@e...>
To: <basicstamps@yahoogroups.com>
Sent: Thursday, August 14, 2003 2:09 PM
Subject: Re: [noparse][[/noparse]basicstamps] Pulsin and the Memsic 2125
> >...
> >For example Pulsin 0,1,pulse ' measure a high pulse on pin 0 and store
> >result in pulse.
> >...
> >Now what happens when the pin is already in a high state when the Pulsin
> >command is being executed?
> >A. Does it immediately return a zero?
> >B. Would it stay in an infinite loop waiting for the pin to go low before
> >starting the measurement when it goes high again, or
> >C. Start measuring until the 1-0 transition occurs and report that as the
> >pulse width even though it never saw the 0 - 1 rise trigger.
>
> It waits for the 0->1 transition, even if the pin is already high
> when the command starts. A BS2 waits up to 131.07 milliseconds for
> the 0->1 transition, and if it does not arrive, it gives up and
> returns a value of zero. If the 0-1 transition does occur within
> that time frame, then the BS2 times the pulse, up to 131.07
> milliseconds (1 count=2 microseconds). If the 1->0 transition does
> not occur within 131.07 milliseconds, then it returns a value of
> zero. This is explained in the manual. The times for the 'sx, 'p,
> and 'pe are different.
>
> >
> >The documentation, talks about a timeout that would occur when measuring
the
> >pulse at 64k periods, but will it have a timeout if it never sees a
pulse,
>
> Yes.
>
> >or will there be a time out if the measurement pin is high all the time.
>
> Yes. The manual does talk about this. pg 241 of the v2.0 manual.
>
> >
> >Anyone have any info on this?
> >
> >Pete Miles
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>