Doubts Abt PULSIN and PULSOUT
Archiver
Posts: 46,084
Hi Everyone,
Wish u a Happy New Year.
I'm using BS2 and I'm testing the PULSIN and PULSOUT commands using a
same BS2.
My objective is to make BS2 to produce a positive pulse(Using
PULSOUT) of 50 microsec at pin 6. The duration of this pulse should
be read and displayed (Using DEBUG) by the same BS2.
Therefore, I connect pin 6 and pin 7 together. I did not use any
resistors between this connection nor connect them to gnd. Just a
loop between pin 6 and Pin 7.
The BS2 should read the duration of pulse from Pin 7 (Using PULSIN).
My Code is as follows :
'{$STAMP BS2}
'Program TO Read Waveform
A CON 6
B CON 7
reps VAR Nib
time VAR Word
main:
LOW A 'A LOW level at first
PULSIN B,1,time 'Waits And Measure For The High pulse
PAUSE 10 'A delay of 10 msec
PULSOUT A,25 'Produce Pulse For 50 usec
LOW A
DEBUG CR,"Duration Of Pulse: ", DEC time,CR
GOTO main
RETURN
Here's where the problem arises :
I don't get to see the correct value (that is 25) of the pulse
duration. The values I get is either 0 or other numbers.
Is this because that I need to place a resistor between Pin 6 and Pin
7 or conncet to a ground? Is it because of the code?
I just loop a wire between pin 6 and Pin 7. No resistors or gnd is
connected.
Pls Help,
Vinod
Wish u a Happy New Year.
I'm using BS2 and I'm testing the PULSIN and PULSOUT commands using a
same BS2.
My objective is to make BS2 to produce a positive pulse(Using
PULSOUT) of 50 microsec at pin 6. The duration of this pulse should
be read and displayed (Using DEBUG) by the same BS2.
Therefore, I connect pin 6 and pin 7 together. I did not use any
resistors between this connection nor connect them to gnd. Just a
loop between pin 6 and Pin 7.
The BS2 should read the duration of pulse from Pin 7 (Using PULSIN).
My Code is as follows :
'{$STAMP BS2}
'Program TO Read Waveform
A CON 6
B CON 7
reps VAR Nib
time VAR Word
main:
LOW A 'A LOW level at first
PULSIN B,1,time 'Waits And Measure For The High pulse
PAUSE 10 'A delay of 10 msec
PULSOUT A,25 'Produce Pulse For 50 usec
LOW A
DEBUG CR,"Duration Of Pulse: ", DEC time,CR
GOTO main
RETURN
Here's where the problem arises :
I don't get to see the correct value (that is 25) of the pulse
duration. The values I get is either 0 or other numbers.
Is this because that I need to place a resistor between Pin 6 and Pin
7 or conncet to a ground? Is it because of the code?
I just loop a wire between pin 6 and Pin 7. No resistors or gnd is
connected.
Pls Help,
Vinod
Comments
writes:
> I just loop a wire between pin 6 and Pin 7. No resistors or gnd is
> connected.
>
> Pls Help,
> Vinod
>
>
That pulse is long gone before you can measure it. Stamp does not store
pulses - it pulses and that's it. To do what you want to do you have to use
two Stamps.
Sid Weaver
W4EKQ
Port Richey, FL
[noparse][[/noparse]Non-text portions of this message have been removed]
> In a message dated 01/01/2003 12:35:44 Eastern Standard Time,
pctsp@y...
> writes:
>
>
> > I just loop a wire between pin 6 and Pin 7. No resistors or gnd
is
> > connected.
> >
> > Pls Help,
> > Vinod
> >
> >
>
> That pulse is long gone before you can measure it. Stamp does not
store
> pulses - it pulses and that's it. To do what you want to do you
have to use
> two Stamps.
> Sid Weaver
> W4EKQ
> Port Richey, FL
>
>
In my code, i placed PULSIN first and then PULSOUT. Does that mean
that my PULSIN is not waiting for the high pulse.
Here's how i code it :
PULSIN B,1,time 'Waits And Measure For The High pulse
PAUSE 10 'A delay of 10 msec
PULSOUT A,25 'Produce Pulse For 50 usec
vinod
writes:
> In my code, i placed PULSIN first and then PULSOUT. Does that mean
> that my PULSIN is not waiting for the high pulse.
>
Stamp pulses out. End of instruction.
Stamp waits for pulsin. From where? The pulse from pulsout is gone - gone
-gone.
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
writes:
> >I just loop a wire between pin 6 and Pin 7. No resistors or gnd is
> >connected.
> >
> >Pls Help,
> >Vinod
> >
> >
>
> That pulse is long gone before you can measure it. Stamp does not store
> pulses - it pulses and that's it. To do what you want to do you have to
> use
> two Stamps.
> Sid Weaver
> W4EKQ
> Port Richey, FL
Not my posting, but a question to your reply...
Would it be correct to say that basically, the Stamp can do only one thing at
a time in a somewhat serial fashion. In this case, when it sends out the
pulse on one of the pins it is busy doing that, and in this instance, cannot
do to things at once?
[noparse][[/noparse]Non-text portions of this message have been removed]
> Would it be correct to say that basically, the Stamp can do only one
thing at
> a time in a somewhat serial fashion. In this case, when it sends out
the
> pulse on one of the pins it is busy doing that, and in this
instance, cannot
> do to things at once?
Correct.
> In a message dated 01/01/2003 12:51:54 Eastern Standard Time,
pctsp@y...
> writes:
>
>
> > In my code, i placed PULSIN first and then PULSOUT. Does that
mean
> > that my PULSIN is not waiting for the high pulse.
> >
>
> Stamp pulses out. End of instruction.
> Stamp waits for pulsin. From where? The pulse from pulsout is
gone - gone
> -gone.
>
> Sid
>
>
I wrote my code in this step...
Firstly, STAMPS waits for the pulse.
Secondly, STAMP pulses out.
Here's my doubt,
At the third step, is the STAMP still waiting for the pulse or the
1st instruction just dies out at the first place.
Pls clarify this matter.
Thx.
Vinod
smartdim@a... writes:
> Not my posting, but a question to your reply...
> Would it be correct to say that basically, the Stamp can do only one thing
> at
> a time in a somewhat serial fashion. In this case, when it sends out the
> pulse on one of the pins it is busy doing that, and in this instance,
> cannot
> do to things at once?
>
Your are correct, sir.
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
writes:
> At the third step, is the STAMP still waiting for the pulse or the
> 1st instruction just dies out at the first place.
>
Pulsout puts out a 50us pulse. When the 50us is up, the Stamp quits pusling.
Ergo, no more pulse for anything. It's like hitting a nail with a hammer,
laying down the hammer then turn on a mike to record the hit.
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
it. If this is critical to your application, look at
http://www.al-williams.com/pak8.htm.
Al Williams
AWC
* Easy RS-232 Prototyping
http://www.al-williams.com/awce/rs1.htm
> >
> My objective is to make BS2 to produce a positive pulse(Using
> PULSOUT) of 50 microsec at pin 6. The duration of this pulse should
> be read and displayed (Using DEBUG) by the same BS2.
>
arrives or it times out. By the time your PAUSE 10 is executed, PULSIN has
returned 0 because there was no pulse present when it was running.
You'll need two Stamp for your experiment.
-- Jon Williams
-- Parallax
In a message dated 1/1/2003 11:51:55 AM Central Standard Time,
pctsp@y... writes:
> In my code, i placed PULSIN first and then PULSOUT. Does that mean
> that my PULSIN is not waiting for the high pulse.
>
[noparse][[/noparse]Non-text portions of this message have been removed]
First t will generate a timed pulse out, then it will try measururing
a pulse in! It will only start measuring the pulse in after the pulse
out has finished so no wonder it will never measure 25. It may will
read 65584 or whatever (2^16 is!) because thats the timeout value
for measuring a pulse in. If the stamp did not time out then the
program could get stuck in a loop waiting for ever for a pulse that
never comes!
Its one of the limitations of a stamp that it doesnt have useful
things like interrupts and timer that the programmer can use directly.
Often careful program design can get you around these problems.
Dominic
time. And before you go off and say, "But such-and-such competitor has
interrupts!" you'd better read the fine print. Those [noparse][[/noparse]clone] micros that
program in BASIC [noparse][[/noparse]or PBASIC] that claim to have interrupts are not reentrant
-- they are not true interrupts. Their "interrupts" work pretty much like
our pin polling in the BS2p family; that is, they are processed between BASIC
commands.
If your project does in fact require true interrupts, we sell Ubicom SX
micros, tools to program them and books on SX programming.
-- Jon Williams
-- Parallax
In a message dated 1/30/2003 2:53:37 PM Central Standard Time,
dosser32@y... writes:
> The stamp will only do one thing at a time!
>
> First t will generate a timed pulse out, then it will try measururing
> a pulse in! It will only start measuring the pulse in after the pulse
> out has finished so no wonder it will never measure 25. It may will
> read 65584 or whatever (2^16 is!) because thats the timeout value
> for measuring a pulse in. If the stamp did not time out then the
> program could get stuck in a loop waiting for ever for a pulse that
> never comes!
>
> Its one of the limitations of a stamp that it doesnt have useful
> things like interrupts and timer that the programmer can use directly.
> Often careful program design can get you around these problems.
>
> Dominic
[noparse][[/noparse]Non-text portions of this message have been removed]
writes:
> Yes, it is very well-known that the BASIC Stamp does only one thing at a
> time. And before you go off and say, "But such-and-such competitor has
> interrupts!" you'd better read the fine print. Those [noparse][[/noparse]clone] micros that
> program in BASIC [noparse][[/noparse]or PBASIC] that claim to have interrupts are not
> reentrant
> -- they are not true interrupts. Their "interrupts" work pretty much like
> our pin polling in the BS2p family; that is, they are processed between
> BASIC
> commands.
>
> If your project does in fact require true interrupts, we sell Ubicom SX
> micros, tools to program them and books on SX programming.
>
> -- Jon Williams
> -- Parallax
>
Although the SX is not as user friendly as the Basic Stamp, it is far more
powerful (if you are a dummy like me and enjoy the challenge of writing a
program to achieve your task.)
The SX will save you lots of cash, not counting your labor. However, there is
not nearly as much support from this forum for th SX. I suspect there aren't
that many Jon Williams, Pearlsixtytwo's, James@SXlist, and others who reallly
know the SX (I apologize for any names I left out that have previously bailed
me out or answered my questions).
[noparse][[/noparse]Non-text portions of this message have been removed]